F_RPT_040102_1.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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.dtpAccountDateStart.Value = DateTime.Now.Date;
  170. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  171. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  172. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  173. this.chkFlag.Checked = false;
  174. }
  175. #endregion
  176. #region 私有方法
  177. /// <summary>
  178. /// 根据界面查询条件获取数据集
  179. /// </summary>
  180. private DataTable GetSearchData()
  181. {
  182. try
  183. {
  184. RPT040102_SE se = new RPT040102_SE();
  185. se.GoodsIDS = scbGoods.CheckedPKMember;
  186. se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  187. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  188. se.AccountDateStart = this.dtpAccountDateStart.Value;
  189. se.AccountDateEnd = this.dtpAccountDateEnd.Value;
  190. se.ProcedureIDs = this.dkProcedureSearchBox.ProcedureIDS;
  191. se.ProductionFlag = this.chkFlag.Checked ? "1" : "0";
  192. // 调用服务器端获取数据集
  193. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  194. {
  195. return ReportModuleProxy.Service.GetRPT040102SData(se);
  196. }
  197. );
  198. if (sre.Status == Constant.ServiceResultStatus.Success)
  199. {
  200. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  201. {
  202. // 提示未查找到数据
  203. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  204. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  205. //清空数据
  206. return null;
  207. }
  208. ////清空集合
  209. //this.dgvLineProcessTotal.Columns.Clear();
  210. ////绑定值
  211. //DataTable dt_ProductionData = sre.Data.Tables[0];
  212. //foreach (DataColumn dc in dt_ProductionData.Columns)
  213. //{
  214. // this.dgvLineProcessTotal.Columns.Add(dc.ColumnName, dc.ColumnName);
  215. // this.dgvLineProcessTotal.Columns[dc.ColumnName].DataPropertyName = dc.ColumnName;
  216. // //不允许排序
  217. // this.dgvLineProcessTotal.Columns[dc.ColumnName].SortMode = DataGridViewColumnSortMode.NotSortable;
  218. //}
  219. return sre.Data.Tables[0];
  220. }
  221. return null;
  222. }
  223. catch (Exception ex)
  224. {
  225. throw ex;
  226. }
  227. }
  228. private void BindDisplayItem()
  229. {
  230. //清空集合
  231. this.dgvLineProcessTotal.Columns.Clear();
  232. //增加固定项
  233. this.dgvLineProcessTotal.Columns.Add("GoodsTypeName", "产品类别");
  234. this.dgvLineProcessTotal.Columns["GoodsTypeName"].DataPropertyName = "产品类别";
  235. this.dgvLineProcessTotal.Columns.Add("GoodsCode", "产品编号");
  236. this.dgvLineProcessTotal.Columns["GoodsCode"].DataPropertyName = "产品编号";
  237. this.dgvLineProcessTotal.Columns.Add("GOODSSPECIFICATION", "规格");
  238. this.dgvLineProcessTotal.Columns["GOODSSPECIFICATION"].DataPropertyName = "规格";
  239. this.dgvLineProcessTotal.Columns.Add("DICTIONARYVALUE", "釉色类别");
  240. this.dgvLineProcessTotal.Columns["DICTIONARYVALUE"].DataPropertyName = "釉色类别";
  241. if (this.dkproductionLineSearchBox.ProductionLineID != null)
  242. {
  243. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  244. {
  245. return ReportModuleProxy.Service.GetRptProductionLineProcedures(this.dkproductionLineSearchBox.ProductionLineID);
  246. }
  247. );
  248. if (sre.Status == Constant.ServiceResultStatus.Success)
  249. {
  250. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  251. {
  252. return;
  253. }
  254. //绑定值
  255. DataTable dt_ProductionData = sre.Data.Tables[0];
  256. foreach (DataRow dr in dt_ProductionData.Rows)
  257. {
  258. this.dgvLineProcessTotal.Columns.Add(dr["Procedurename"].ToString(), dr["Procedurename"].ToString());
  259. this.dgvLineProcessTotal.Columns[dr["Procedurename"].ToString()].DataPropertyName = dr["Procedurename"].ToString();
  260. }
  261. }
  262. }
  263. }
  264. /// <summary>
  265. /// 获取权限
  266. /// </summary>
  267. protected void getPurview()
  268. {
  269. try
  270. {
  271. StringBuilder sbProcedurePurview = new StringBuilder();
  272. //得到工序查看权限
  273. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  274. {
  275. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  276. }));
  277. if (dsProcedurePurview != null)
  278. {
  279. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  280. if (drPurview.Length == 0)
  281. {
  282. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  283. {
  284. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  285. }
  286. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  287. {
  288. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  289. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  290. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  291. }
  292. }
  293. else
  294. {
  295. SearchProductionLineEntity line = new SearchProductionLineEntity();
  296. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  297. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  298. {
  299. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  300. }
  301. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  302. {
  303. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  304. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  305. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  306. }
  307. }
  308. }
  309. }
  310. catch (Exception ex)
  311. {
  312. throw ex;
  313. }
  314. }
  315. /// <summary>
  316. /// 获取权限(生产线)
  317. /// </summary>
  318. protected void getPurviewLine()
  319. {
  320. try
  321. {
  322. StringBuilder sbProcedurePurview = new StringBuilder();
  323. //得到工序查看权限
  324. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  325. {
  326. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  327. }));
  328. if (dsProcedurePurview != null)
  329. {
  330. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  331. if (drPurview.Length == 0)
  332. {
  333. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  334. {
  335. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  336. }
  337. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  338. {
  339. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  340. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  341. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  342. }
  343. if (dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows.Count == 1)
  344. {
  345. this.dkproductionLineSearchBox.ProductionLineID = Convert.ToInt32(dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows[0][0]);
  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._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  365. }
  366. if (dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows.Count == 1)
  367. {
  368. this.dkproductionLineSearchBox.ProductionLineID = Convert.ToInt32(dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows[0][0]);
  369. }
  370. }
  371. }
  372. }
  373. catch (Exception ex)
  374. {
  375. throw ex;
  376. }
  377. }
  378. #endregion
  379. }
  380. }