F_RPT_030105.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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(rptse);
  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. this.txtSTAFFNAME.Text = string.Empty;
  180. }
  181. private void dgvReportModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  182. {
  183. try
  184. {
  185. //判断是否为空
  186. if (this.dgvReportModule.CurrentRow == null)
  187. {
  188. return;
  189. }
  190. //获取数据信息
  191. DataGridViewRow dgvr = dgvReportModule.CurrentRow;
  192. //string goodsCode = dgvr.Cells["GoodsCode"].Value.ToString();
  193. string procedureId = dgvr.Cells["ProcedureId"].Value + "";
  194. string GoodsTypeIDS = dgvr.Cells["colGoodsTypeCode2"].Value + "";
  195. string goodsid = dgvr.Cells["colgoodsid"].Value + "";
  196. string userid = dgvr.Cells["coluserid"].Value + "";
  197. //判断是否选择统计行
  198. //if (!goodsCode.Equals("--"))
  199. {
  200. this.tblReportModule.SelectTab(1);
  201. RPT030105_SE rptse_d = new RPT030105_SE();
  202. rptse_d.GoodsCode = rptse.GoodsCode;
  203. if (string.IsNullOrWhiteSpace(procedureId))
  204. {
  205. rptse_d.ProcedureIDS = rptse.ProcedureIDS;
  206. }
  207. else
  208. {
  209. rptse_d.ProcedureIDS = procedureId;
  210. }
  211. if (string.IsNullOrWhiteSpace(GoodsTypeIDS))
  212. {
  213. rptse_d.GoodsTypeIDS = rptse.GoodsTypeIDS;
  214. }
  215. else
  216. {
  217. rptse_d.GoodsTypeIDS = GoodsTypeIDS;
  218. }
  219. if (!string.IsNullOrEmpty(goodsid))
  220. {
  221. rptse_d.GoodsID = Convert.ToInt32(goodsid);
  222. }
  223. if (!string.IsNullOrEmpty(userid))
  224. {
  225. rptse_d.UserID = Convert.ToInt32(userid);
  226. }
  227. this.dgvDetailReportModule.DataSource = null;
  228. this.dgvDetailReportModule.DataSource = GetSearchDetailIData(rptse_d);
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. this.btnSearch.Enabled = true;
  234. this.btnClearCondition.Enabled = true;
  235. // 对异常进行共通处理
  236. ExceptionManager.HandleEventException(this.ToString(),
  237. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  238. }
  239. }
  240. #endregion
  241. #region 私有方法
  242. /// <summary>
  243. /// 搜索条件
  244. /// </summary>
  245. /// <returns></returns>
  246. private void CreateSearchCondition()
  247. {
  248. rptse = new RPT030105_SE();
  249. rptse.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  250. rptse.LineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  251. rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  252. rptse.GoodsCode = this.txtGoodsCode.Text.Trim();
  253. rptse.StaffName = this.txtSTAFFNAME.Text.Trim();
  254. }
  255. /// <summary>
  256. /// 查询表
  257. /// </summary>
  258. private DataTable GetSearchDetailData()
  259. {
  260. try
  261. {
  262. //调用服务器端获取数据集
  263. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  264. {
  265. return ReportModuleProxy.Service.GetRPT030105Data(rptse);
  266. }
  267. );
  268. if (sre.Status == Constant.ServiceResultStatus.Success)
  269. {
  270. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  271. {
  272. // 提示未查找到数据
  273. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  274. MessageBoxButtons.OK, MessageBoxIcon.Information);
  275. //清空数据
  276. return null;
  277. }
  278. return sre.Data.Tables[0];
  279. }
  280. return null;
  281. }
  282. catch (Exception ex)
  283. {
  284. throw ex;
  285. }
  286. }
  287. /// <summary>
  288. /// 查询表
  289. /// </summary>
  290. private DataTable GetSearchDetailIData(RPT030105_SE rptse_d)
  291. {
  292. try
  293. {
  294. //调用服务器端获取数据集
  295. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  296. {
  297. return ReportModuleProxy.Service.GetRPT030105IData(rptse_d);
  298. }
  299. );
  300. if (sre.Status == Constant.ServiceResultStatus.Success)
  301. {
  302. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  303. {
  304. // 提示未查找到数据
  305. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  306. MessageBoxButtons.OK, MessageBoxIcon.Information);
  307. //清空数据
  308. return null;
  309. }
  310. return sre.Data.Tables[0];
  311. }
  312. return null;
  313. }
  314. catch (Exception ex)
  315. {
  316. throw ex;
  317. }
  318. }
  319. /// <summary>
  320. /// 获取权限(生产线)
  321. /// </summary>
  322. protected void getPurviewLine()
  323. {
  324. try
  325. {
  326. StringBuilder sbProcedurePurview = new StringBuilder();
  327. //得到工序查看权限
  328. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  329. {
  330. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  331. }));
  332. if (dsProcedurePurview != null)
  333. {
  334. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  335. if (drPurview.Length == 0)
  336. {
  337. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  338. {
  339. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  340. }
  341. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  342. {
  343. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  344. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  345. this._currentUserLinePurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  346. }
  347. }
  348. else
  349. {
  350. ProductionLineEntity line = new ProductionLineEntity();
  351. line.ValueFlags = new object[] { 1 };
  352. dsProcedurePurview = (DataSet)DoAsync(() =>
  353. {
  354. return PCModuleProxy.Service.SearchProductionLine(line);
  355. });
  356. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  357. {
  358. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  359. }
  360. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  361. {
  362. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  363. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  364. this._currentUserLinePurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  365. }
  366. }
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. throw ex;
  372. }
  373. }
  374. /// <summary>
  375. /// 获取权限
  376. /// </summary>
  377. protected void getPurview()
  378. {
  379. try
  380. {
  381. StringBuilder sbProcedurePurview = new StringBuilder();
  382. //得到工序查看权限
  383. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  384. {
  385. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  386. }));
  387. if (dsProcedurePurview != null)
  388. {
  389. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  390. if (drPurview.Length == 0)
  391. {
  392. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  393. {
  394. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  395. }
  396. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  397. {
  398. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  399. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  400. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  401. }
  402. }
  403. else
  404. {
  405. SearchProductionLineEntity line = new SearchProductionLineEntity();
  406. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  407. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  408. {
  409. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  410. }
  411. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  412. {
  413. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  414. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  415. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  416. }
  417. }
  418. }
  419. }
  420. catch (Exception ex)
  421. {
  422. throw ex;
  423. }
  424. }
  425. #endregion
  426. }
  427. }