F_RPT_030105.cs 14 KB

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