F_RPT_030105.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030105.cs
  5. * 2.功能描述:在产产品汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/06/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. public partial class F_RPT_030105 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_030105 _instance;
  28. //实体类
  29. private RPT030105_SE rptse = new RPT030105_SE();
  30. //默认清空工序,重置回用户当前权限工序
  31. private string _currentUserPurview = null;
  32. //默认清空生产线,重置回用户当前权限生产线
  33. private string _currentUserLinePurview = null;
  34. #endregion
  35. #region 构造函数
  36. public F_RPT_030105()
  37. {
  38. InitializeComponent();
  39. // 窗体显示的Title
  40. this.Text = FormTitles.F_RPT_030105;
  41. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  42. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  43. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  44. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  45. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  46. }
  47. #endregion
  48. #region 单例模式
  49. /// <summary>
  50. /// 单例模式,防止重复创建窗体
  51. /// </summary>
  52. public static F_RPT_030105 Instance
  53. {
  54. get
  55. {
  56. if (_instance == null || _instance.IsDisposed)
  57. {
  58. _instance = new F_RPT_030105();
  59. }
  60. return _instance;
  61. }
  62. }
  63. #endregion
  64. #region 事件处理
  65. /// <summary>
  66. /// 窗体加载事件
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. private void F_RPT_030101_1_Load(object sender, EventArgs e)
  71. {
  72. try
  73. {
  74. // 加载权限
  75. FormPermissionManager.FormPermissionControl(this.Name, this,
  76. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  77. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  78. // 设置表格不自动创建列
  79. this.dgvReportModule.AutoGenerateColumns = false;
  80. this.dkproductionLineSearchBox.IsEnablePurview = true;
  81. this.dkProcedureSearchBox.IsEnablePurview = true;
  82. getPurview();
  83. getPurviewLine();//生产线
  84. }
  85. catch (Exception ex)
  86. {
  87. // 对异常进行共通处理
  88. ExceptionManager.HandleEventException(this.ToString(),
  89. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  90. }
  91. }
  92. /// <summary>
  93. /// 自动适应列宽
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  98. {
  99. this.dgvReportModule.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  100. this.dgvDetailReportModule.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  101. }
  102. /// <summary>
  103. /// 窗体关闭事件
  104. /// </summary>
  105. /// <param name="sender"></param>
  106. /// <param name="e"></param>
  107. private void F_RPT_030101_1_FormClosed(object sender, FormClosedEventArgs e)
  108. {
  109. _instance = null;
  110. }
  111. /// <summary>
  112. /// 关闭按钮
  113. /// </summary>
  114. /// <param name="sender"></param>
  115. /// <param name="e"></param>
  116. private void tsbtnClose_Click(object sender, EventArgs e)
  117. {
  118. this.Close();
  119. }
  120. /// <summary>
  121. /// 查询按钮事件
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void btnSearch_Click(object sender, EventArgs e)
  126. {
  127. try
  128. {
  129. if (string.IsNullOrEmpty(this._currentUserPurview))
  130. {
  131. // 提示未查找到数据
  132. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  133. MessageBoxButtons.OK, MessageBoxIcon.Information);
  134. return;
  135. }
  136. if (string.IsNullOrEmpty(this._currentUserLinePurview))
  137. {
  138. // 提示未查找到数据
  139. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  140. MessageBoxButtons.OK, MessageBoxIcon.Information);
  141. return;
  142. }
  143. this.dgvReportModule.DataSource = null;
  144. this.dgvDetailReportModule.DataSource = null;
  145. CreateSearchCondition();
  146. if (this.tblReportModule.SelectedIndex == Constant.INT_IS_ZERO)
  147. {
  148. this.dgvReportModule.DataSource = null;
  149. this.dgvReportModule.DataSource = GetSearchDetailData();
  150. }
  151. else
  152. {
  153. this.dgvDetailReportModule.DataSource = null;
  154. this.dgvDetailReportModule.DataSource = GetSearchDetailIData();
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. this.btnSearch.Enabled = true;
  160. this.btnClearCondition.Enabled = true;
  161. // 对异常进行共通处理
  162. ExceptionManager.HandleEventException(this.ToString(),
  163. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  164. }
  165. }
  166. /// <summary>
  167. /// 清空条件按钮事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void btnClearCondition_Click(object sender, EventArgs e)
  172. {
  173. this.scbGoodsType.ClearValue();
  174. this.dkProcedureSearchBox.ClearControl();
  175. this.dkproductionLineSearchBox.ClearControl();
  176. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  177. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePurview;
  178. this.txtGoodsCode.Text = string.Empty;
  179. }
  180. private void dgvReportModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  181. {
  182. try
  183. {
  184. //判断是否为空
  185. if (this.dgvReportModule.CurrentRow == null)
  186. {
  187. return;
  188. }
  189. //获取数据信息
  190. DataGridViewRow dgvr = dgvReportModule.CurrentRow;
  191. //string goodsCode = dgvr.Cells["GoodsCode"].Value.ToString();
  192. string procedureId = dgvr.Cells["ProcedureId"].Value + "";
  193. string GoodsTypeIDS = dgvr.Cells["colGoodsTypeCode2"].Value + "";
  194. string goodsid = dgvr.Cells["colgoodsid"].Value + "";
  195. string userid = dgvr.Cells["coluserid"].Value + "";
  196. //判断是否选择统计行
  197. //if (!goodsCode.Equals("--"))
  198. {
  199. this.tblReportModule.SelectTab(1);
  200. rptse = new RPT030105_SE();
  201. rptse.ProcedureIDS = procedureId;
  202. //rptse.GoodsCode = goodsCode;
  203. if (!string.IsNullOrEmpty(goodsid))
  204. {
  205. rptse.GoodsID = Convert.ToInt32(goodsid);
  206. }
  207. if (!string.IsNullOrEmpty(userid))
  208. {
  209. rptse.UserID = Convert.ToInt32(userid);
  210. }
  211. rptse.GoodsTypeIDS = GoodsTypeIDS;
  212. this.dgvDetailReportModule.DataSource = null;
  213. this.dgvDetailReportModule.DataSource = GetSearchDetailIData();
  214. }
  215. }
  216. catch (Exception ex)
  217. {
  218. this.btnSearch.Enabled = true;
  219. this.btnClearCondition.Enabled = true;
  220. // 对异常进行共通处理
  221. ExceptionManager.HandleEventException(this.ToString(),
  222. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  223. }
  224. }
  225. #endregion
  226. #region 私有方法
  227. /// <summary>
  228. /// 搜索条件
  229. /// </summary>
  230. /// <returns></returns>
  231. private void CreateSearchCondition()
  232. {
  233. rptse = new RPT030105_SE();
  234. rptse.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  235. rptse.LineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  236. rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  237. rptse.GoodsCode = this.txtGoodsCode.Text.Trim();
  238. }
  239. /// <summary>
  240. /// 查询表
  241. /// </summary>
  242. private DataTable GetSearchDetailData()
  243. {
  244. try
  245. {
  246. //调用服务器端获取数据集
  247. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  248. {
  249. return ReportModuleProxy.Service.GetRPT030105Data(rptse);
  250. }
  251. );
  252. if (sre.Status == Constant.ServiceResultStatus.Success)
  253. {
  254. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  255. {
  256. // 提示未查找到数据
  257. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  258. MessageBoxButtons.OK, MessageBoxIcon.Information);
  259. //清空数据
  260. return null;
  261. }
  262. return sre.Data.Tables[0];
  263. }
  264. return null;
  265. }
  266. catch (Exception ex)
  267. {
  268. throw ex;
  269. }
  270. }
  271. /// <summary>
  272. /// 查询表
  273. /// </summary>
  274. private DataTable GetSearchDetailIData()
  275. {
  276. try
  277. {
  278. //调用服务器端获取数据集
  279. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  280. {
  281. return ReportModuleProxy.Service.GetRPT030105IData(rptse);
  282. }
  283. );
  284. if (sre.Status == Constant.ServiceResultStatus.Success)
  285. {
  286. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  287. {
  288. // 提示未查找到数据
  289. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  290. MessageBoxButtons.OK, MessageBoxIcon.Information);
  291. //清空数据
  292. return null;
  293. }
  294. return sre.Data.Tables[0];
  295. }
  296. return null;
  297. }
  298. catch (Exception ex)
  299. {
  300. throw ex;
  301. }
  302. }
  303. /// <summary>
  304. /// 获取权限(生产线)
  305. /// </summary>
  306. protected void getPurviewLine()
  307. {
  308. try
  309. {
  310. StringBuilder sbProcedurePurview = new StringBuilder();
  311. //得到工序查看权限
  312. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  313. {
  314. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  315. }));
  316. if (dsProcedurePurview != null)
  317. {
  318. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  319. if (drPurview.Length == 0)
  320. {
  321. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  322. {
  323. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  324. }
  325. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  326. {
  327. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  328. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  329. this._currentUserLinePurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  330. }
  331. }
  332. else
  333. {
  334. ProductionLineEntity line = new ProductionLineEntity();
  335. line.ValueFlags = new object[] { 1 };
  336. dsProcedurePurview = (DataSet)DoAsync(() =>
  337. {
  338. return PCModuleProxy.Service.SearchProductionLine(line);
  339. });
  340. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  341. {
  342. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  343. }
  344. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  345. {
  346. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  347. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  348. this._currentUserLinePurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  349. }
  350. }
  351. }
  352. }
  353. catch (Exception ex)
  354. {
  355. throw ex;
  356. }
  357. }
  358. /// <summary>
  359. /// 获取权限
  360. /// </summary>
  361. protected void getPurview()
  362. {
  363. try
  364. {
  365. StringBuilder sbProcedurePurview = new StringBuilder();
  366. //得到工序查看权限
  367. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  368. {
  369. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  370. }));
  371. if (dsProcedurePurview != null)
  372. {
  373. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  374. if (drPurview.Length == 0)
  375. {
  376. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  377. {
  378. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  379. }
  380. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  381. {
  382. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  383. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  384. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  385. }
  386. }
  387. else
  388. {
  389. SearchProductionLineEntity line = new SearchProductionLineEntity();
  390. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  391. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  392. {
  393. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  394. }
  395. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  396. {
  397. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  398. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  399. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  400. }
  401. }
  402. }
  403. }
  404. catch (Exception ex)
  405. {
  406. throw ex;
  407. }
  408. }
  409. #endregion
  410. }
  411. }