F_RPT_040102_1.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040102_1.cs
  5. * 2.功能描述:工序产量分析表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/13 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. /// <summary>
  24. /// 工序产量分析表
  25. /// </summary>
  26. public partial class F_RPT_040102_1 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_RPT_040102_1 _instance;
  31. //默认清空工序,重置回用户当前权限工序
  32. private string _currentUserPurview = null;
  33. //默认清空生产线,重置回用户当前权限生产线
  34. private string _currentUserLinePuview = null;
  35. #endregion
  36. #region 构造函数
  37. public F_RPT_040102_1()
  38. {
  39. InitializeComponent();
  40. // 窗体显示的Title
  41. this.Text = FormTitles.F_RPT_040102;
  42. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  43. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  44. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  45. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  46. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  47. }
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 单例模式,防止重复创建窗体
  52. /// </summary>
  53. public static F_RPT_040102_1 Instance
  54. {
  55. get
  56. {
  57. if (_instance == null || _instance.IsDisposed)
  58. {
  59. _instance = new F_RPT_040102_1();
  60. }
  61. return _instance;
  62. }
  63. }
  64. #endregion
  65. #region 事件处理
  66. /// <summary>
  67. /// 窗体加载事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void F_RPT_040102_1_Load(object sender, EventArgs e)
  72. {
  73. try
  74. {
  75. // 加载权限
  76. FormPermissionManager.FormPermissionControl(this.Name, this,
  77. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  79. // 设置表格不自动创建列
  80. //this.dgvLineProcessTotal.AutoGenerateColumns = false;
  81. this.dkproductionLineSearchBox.Focus();
  82. this.dkproductionLineSearchBox.IsEnablePurview = true;
  83. this.dkProcedureSearchBox.IsEnablePurview = true;
  84. // 初始化时间控件为当前日期
  85. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  86. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  87. getPurview();
  88. getPurviewLine();
  89. }
  90. catch (Exception ex)
  91. {
  92. // 对异常进行共通处理
  93. ExceptionManager.HandleEventException(this.ToString(),
  94. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  95. }
  96. }
  97. /// <summary>
  98. /// 窗体关闭事件
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void F_RPT_040102_1_FormClosed(object sender, FormClosedEventArgs e)
  103. {
  104. _instance = null;
  105. }
  106. /// <summary>
  107. /// 关闭按钮
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void tsbtnClose_Click(object sender, EventArgs e)
  112. {
  113. this.Close();
  114. }
  115. /// <summary>
  116. /// 自动适应列宽
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  121. {
  122. this.dgvLineProcessTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  123. }
  124. /// <summary>
  125. /// 查询按钮事件
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void btnSearch_Click(object sender, EventArgs e)
  130. {
  131. try
  132. {
  133. //判断生产线不能为空和权限不能为空
  134. if (!this.dkproductionLineSearchBox.ProductionLineID.HasValue)
  135. {
  136. // 提示选择生产线数据
  137. MessageBox.Show("生产线是必选项,请选择生产线!", this.Text,
  138. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  139. this.dkproductionLineSearchBox.Focus();
  140. return;
  141. }
  142. this.dgvLineProcessTotal.AutoGenerateColumns = true;
  143. this.dgvLineProcessTotal.DataSource = null;
  144. this.dgvLineProcessTotal.Columns.Clear();
  145. this.dgvLineProcessTotal.DataSource = this.GetSearchData();
  146. foreach (DataGridViewColumn dc in this.dgvLineProcessTotal.Columns)
  147. {
  148. dc.SortMode = DataGridViewColumnSortMode.NotSortable;
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. this.btnSearch.Enabled = true;
  154. // 对异常进行共通处理
  155. ExceptionManager.HandleEventException(this.ToString(),
  156. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  157. }
  158. }
  159. /// <summary>
  160. /// 清空条件按钮事件
  161. /// </summary>
  162. /// <param name="sender"></param>
  163. /// <param name="e"></param>
  164. private void btnClearCondition_Click(object sender, EventArgs e)
  165. {
  166. this.scbGoods.ClearValue();
  167. this.scbGoodsType.ClearValue();
  168. this.dkproductionLineSearchBox.ClearControl();
  169. this.chkTestRefireFlag.AllItemCheck();
  170. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  171. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  172. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  173. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  174. this.chkFlag.Checked = false;
  175. }
  176. #endregion
  177. #region 私有方法
  178. /// <summary>
  179. /// 根据界面查询条件获取数据集
  180. /// </summary>
  181. private DataTable GetSearchData()
  182. {
  183. try
  184. {
  185. RPT040102_SE se = new RPT040102_SE();
  186. se.GoodsIDS = scbGoods.CheckedPKMember;
  187. se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  188. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  189. se.AccountDateStart = this.dtpAccountDateStart.Value;
  190. se.AccountDateEnd = this.dtpAccountDateEnd.Value;
  191. se.ProcedureIDs = this.dkProcedureSearchBox.ProcedureIDS;
  192. se.ProductionFlag = this.chkFlag.Checked ? "1" : "0";
  193. object[] testRefireFlags = this.chkTestRefireFlag.SelectedValues;
  194. if (testRefireFlags.Length == 1)
  195. {
  196. se.TestRefireFlag = testRefireFlags[0].ToString();
  197. }
  198. // 调用服务器端获取数据集
  199. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  200. {
  201. return ReportModuleProxy.Service.GetRPT040102SData(se);
  202. }
  203. );
  204. if (sre.Status == Constant.ServiceResultStatus.Success)
  205. {
  206. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  207. {
  208. // 提示未查找到数据
  209. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  210. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  211. //清空数据
  212. return null;
  213. }
  214. ////清空集合
  215. //this.dgvLineProcessTotal.Columns.Clear();
  216. ////绑定值
  217. //DataTable dt_ProductionData = sre.Data.Tables[0];
  218. //foreach (DataColumn dc in dt_ProductionData.Columns)
  219. //{
  220. // this.dgvLineProcessTotal.Columns.Add(dc.ColumnName, dc.ColumnName);
  221. // this.dgvLineProcessTotal.Columns[dc.ColumnName].DataPropertyName = dc.ColumnName;
  222. // //不允许排序
  223. // this.dgvLineProcessTotal.Columns[dc.ColumnName].SortMode = DataGridViewColumnSortMode.NotSortable;
  224. //}
  225. return sre.Data.Tables[0];
  226. }
  227. return null;
  228. }
  229. catch (Exception ex)
  230. {
  231. throw ex;
  232. }
  233. }
  234. private void BindDisplayItem()
  235. {
  236. //清空集合
  237. this.dgvLineProcessTotal.Columns.Clear();
  238. //增加固定项
  239. this.dgvLineProcessTotal.Columns.Add("GoodsTypeName", "产品类别");
  240. this.dgvLineProcessTotal.Columns["GoodsTypeName"].DataPropertyName = "产品类别";
  241. this.dgvLineProcessTotal.Columns.Add("GoodsCode", "产品编号");
  242. this.dgvLineProcessTotal.Columns["GoodsCode"].DataPropertyName = "产品编号";
  243. this.dgvLineProcessTotal.Columns.Add("GOODSSPECIFICATION", "规格");
  244. this.dgvLineProcessTotal.Columns["GOODSSPECIFICATION"].DataPropertyName = "规格";
  245. this.dgvLineProcessTotal.Columns.Add("DICTIONARYVALUE", "釉色类别");
  246. this.dgvLineProcessTotal.Columns["DICTIONARYVALUE"].DataPropertyName = "釉色类别";
  247. if (this.dkproductionLineSearchBox.ProductionLineID != null)
  248. {
  249. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  250. {
  251. return ReportModuleProxy.Service.GetRptProductionLineProcedures(this.dkproductionLineSearchBox.ProductionLineID);
  252. }
  253. );
  254. if (sre.Status == Constant.ServiceResultStatus.Success)
  255. {
  256. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  257. {
  258. return;
  259. }
  260. //绑定值
  261. DataTable dt_ProductionData = sre.Data.Tables[0];
  262. foreach (DataRow dr in dt_ProductionData.Rows)
  263. {
  264. this.dgvLineProcessTotal.Columns.Add(dr["Procedurename"].ToString(), dr["Procedurename"].ToString());
  265. this.dgvLineProcessTotal.Columns[dr["Procedurename"].ToString()].DataPropertyName = dr["Procedurename"].ToString();
  266. }
  267. }
  268. }
  269. }
  270. /// <summary>
  271. /// 获取权限
  272. /// </summary>
  273. protected void getPurview()
  274. {
  275. try
  276. {
  277. StringBuilder sbProcedurePurview = new StringBuilder();
  278. //得到工序查看权限
  279. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  280. {
  281. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  282. }));
  283. if (dsProcedurePurview != null)
  284. {
  285. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  286. if (drPurview.Length == 0)
  287. {
  288. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  289. {
  290. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  291. }
  292. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  293. {
  294. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  296. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  297. }
  298. }
  299. else
  300. {
  301. SearchProductionLineEntity line = new SearchProductionLineEntity();
  302. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  303. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  304. {
  305. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  306. }
  307. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  308. {
  309. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  311. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  312. }
  313. }
  314. }
  315. }
  316. catch (Exception ex)
  317. {
  318. throw ex;
  319. }
  320. }
  321. /// <summary>
  322. /// 获取权限(生产线)
  323. /// </summary>
  324. protected void getPurviewLine()
  325. {
  326. try
  327. {
  328. StringBuilder sbProcedurePurview = new StringBuilder();
  329. //得到工序查看权限
  330. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  331. {
  332. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  333. }));
  334. if (dsProcedurePurview != null)
  335. {
  336. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  337. if (drPurview.Length == 0)
  338. {
  339. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  340. {
  341. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  342. }
  343. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  344. {
  345. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  346. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  347. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  348. }
  349. if (dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows.Count == 1)
  350. {
  351. this.dkproductionLineSearchBox.ProductionLineID = Convert.ToInt32(dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows[0][0]);
  352. }
  353. }
  354. else
  355. {
  356. ProductionLineEntity line = new ProductionLineEntity();
  357. line.ValueFlags = new object[] { 1 };
  358. dsProcedurePurview = (DataSet)DoAsync(() =>
  359. {
  360. return PCModuleProxy.Service.SearchProductionLine(line);
  361. });
  362. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  363. {
  364. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  365. }
  366. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  367. {
  368. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  369. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  370. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  371. }
  372. if (dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows.Count == 1)
  373. {
  374. this.dkproductionLineSearchBox.ProductionLineID = Convert.ToInt32(dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows[0][0]);
  375. }
  376. }
  377. }
  378. }
  379. catch (Exception ex)
  380. {
  381. throw ex;
  382. }
  383. }
  384. #endregion
  385. }
  386. }