F_RPT_040104.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040104.cs
  5. * 2.功能描述:产成品质量分析表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/05/11 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_040104 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_040104 _instance;
  28. //默认清空生产线,重置回用户当前权限生产线
  29. private string _currentUserLinePuview = null;
  30. #endregion
  31. #region 构造函数
  32. public F_RPT_040104()
  33. {
  34. InitializeComponent();
  35. // 窗体显示的Title
  36. this.Text = FormTitles.F_RPT_040104;
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  39. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  40. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  41. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  42. }
  43. #endregion
  44. #region 单例模式
  45. /// <summary>
  46. /// 单例模式,防止重复创建窗体
  47. /// </summary>
  48. public static F_RPT_040104 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null || _instance.IsDisposed)
  53. {
  54. _instance = new F_RPT_040104();
  55. }
  56. return _instance;
  57. }
  58. }
  59. #endregion
  60. #region 事件处理
  61. /// <summary>
  62. /// 窗体加载事件
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void F_RPT_040104_Load(object sender, EventArgs e)
  67. {
  68. try
  69. {
  70. // 加载权限
  71. FormPermissionManager.FormPermissionControl(this.Name, this,
  72. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  73. //绑定下了列表
  74. BindPage();
  75. // 设置表格不自动创建列
  76. this.dgvRptProcedure.AutoGenerateColumns = false;
  77. this.dropRptProcedure.Focus();
  78. this.dkproductionLineSearchBox.IsEnablePurview = true;
  79. // 初始化时间控件为当前日期
  80. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  81. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  82. this.chkTestMouldFlag.AllItemCheck();
  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.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  100. }
  101. /// <summary>
  102. /// 窗体关闭事件
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void F_RPT_040104_FormClosed(object sender, FormClosedEventArgs e)
  107. {
  108. _instance = null;
  109. }
  110. /// <summary>
  111. /// 关闭按钮
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void tsbtnClose_Click(object sender, EventArgs e)
  116. {
  117. this.Close();
  118. }
  119. /// <summary>
  120. /// 查询按钮事件
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void btnSearch_Click(object sender, EventArgs e)
  125. {
  126. try
  127. {
  128. this.dgvRptProcedure.DataSource = null;
  129. this.dgvRptProcedure.DataSource = this.GetSearchData();
  130. }
  131. catch (Exception ex)
  132. {
  133. this.btnSearch.Enabled = true;
  134. this.btnClearCondition.Enabled = true;
  135. // 对异常进行共通处理
  136. ExceptionManager.HandleEventException(this.ToString(),
  137. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  138. }
  139. }
  140. /// <summary>
  141. /// 清空条件按钮事件
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void btnClearCondition_Click(object sender, EventArgs e)
  146. {
  147. //this.dropKilnCode.Text = string.Empty;
  148. this.dropKilnCode.SelectedIndex = 0;
  149. this.scbGoods.ClearValue();
  150. this.scbGoodsType.ClearValue();
  151. this.dkproductionLineSearchBox.ClearControl();
  152. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  153. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  154. this.GroutingLineLh.Clear();
  155. this.GroutingLineLc.Clear();
  156. this.GroutingLineMh.Clear();
  157. this.GroutingLineXh.Clear();
  158. this.dkUserInfoSearchBox.ClearControl();
  159. this.chkTestMouldFlag.AllItemCheck();
  160. }
  161. #endregion
  162. #region 私有方法
  163. /// <summary>
  164. /// 根据界面查询条件获取数据集
  165. /// </summary>
  166. private DataTable GetSearchData()
  167. {
  168. try
  169. {
  170. RPT040104_SE se = new RPT040104_SE();
  171. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  172. {
  173. this.dropRptProcedure.Focus();
  174. return null;
  175. }
  176. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  177. //获取数据来源工序Id
  178. ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  179. {
  180. return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  181. }
  182. );
  183. if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  184. {
  185. se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  186. }
  187. //获取数据来源工序Id
  188. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  189. se.GoodsIDS = scbGoods.CheckedPKMember;
  190. se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  191. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  192. {
  193. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  194. }
  195. se.CreateTimeStart = this.dtpAccountDateStart.Value;
  196. //se.CreateTimeEnd = this.dtpAccountDateEnd.Value;
  197. se.CreateTimeEnd = this.dtpAccountDateEnd.Value.AddSeconds(1);
  198. se.GroutingUserIDS = this.dkUserInfoSearchBox.UserIDS;
  199. se.GroutingLineLh = this.GroutingLineLh.Text.Trim();
  200. se.GroutingLineLc = this.GroutingLineLc.Text.Trim();
  201. se.GroutingLineMh = this.GroutingLineMh.Text.Trim();
  202. se.GroutingLineXh = this.GroutingLineXh.Text.Trim();
  203. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  204. if (testMouldFlags.Length == 1)
  205. {
  206. se.TestMouldFlag = testMouldFlags[0].ToString();
  207. }
  208. // 调用服务器端获取数据集
  209. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  210. {
  211. return ReportModuleProxy.Service.GetRPT040104SData(se);
  212. }
  213. );
  214. if (sre.Status == Constant.ServiceResultStatus.Success)
  215. {
  216. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  217. {
  218. // 提示未查找到数据
  219. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  220. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  221. //清空数据
  222. return null;
  223. }
  224. return sre.Data.Tables[0];
  225. }
  226. return null;
  227. }
  228. catch (Exception ex)
  229. {
  230. throw ex;
  231. }
  232. }
  233. /// <summary>
  234. /// 绑定下拉列表值
  235. /// </summary>
  236. /// <returns></returns>
  237. private void BindPage()
  238. {
  239. //绑定数据来源下拉列表
  240. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  241. {
  242. return ReportModuleProxy.Service.GetRptProcedureModule();
  243. }
  244. );
  245. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  246. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  247. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  248. //绑定窑炉下来列表
  249. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  250. {
  251. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  252. return ReportModuleProxy.Service.GetKilnData(byFlage);
  253. }
  254. );
  255. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  256. DataRow newRowDic = dtKilnInfo.NewRow();
  257. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  258. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  259. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  260. this.dropKilnCode.DataSource = dtKilnInfo;
  261. this.dropKilnCode.ValueMember = "KilnID";
  262. this.dropKilnCode.DisplayMember = "KilnCode";
  263. }
  264. /// <summary>
  265. /// 获取权限(生产线)
  266. /// </summary>
  267. protected void getPurviewLine()
  268. {
  269. try
  270. {
  271. StringBuilder sbProcedurePurview = new StringBuilder();
  272. //得到工序查看权限
  273. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  274. {
  275. return SystemModuleProxy.Service.GetUserPurview(7, 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.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  289. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  290. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  291. }
  292. }
  293. else
  294. {
  295. ProductionLineEntity line = new ProductionLineEntity();
  296. line.ValueFlags = new object[] { 1 };
  297. dsProcedurePurview = (DataSet)DoAsync(() =>
  298. {
  299. return PCModuleProxy.Service.SearchProductionLine(line);
  300. });
  301. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  302. {
  303. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  304. }
  305. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  306. {
  307. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  308. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  309. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. }
  311. }
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. throw ex;
  317. }
  318. }
  319. #endregion
  320. }
  321. }