F_RPT_030105.cs 13 KB

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