F_RPT_040105.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040105.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_040105 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_040105 _instance;
  28. //默认清空生产线,重置回用户当前权限生产线
  29. private string _currentUserLinePuview = null;
  30. #endregion
  31. #region 构造函数
  32. public F_RPT_040105()
  33. {
  34. InitializeComponent();
  35. // 窗体显示的Title
  36. this.Text = FormTitles.F_RPT_040105;
  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_040105 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null || _instance.IsDisposed)
  53. {
  54. _instance = new F_RPT_040105();
  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).AddMinutes(-1);
  82. this.chkTestMouldFlag.AllItemCheck();
  83. this.RecyclingflagCheckBox1.FalseItemCheck();
  84. getPurviewLine();
  85. }
  86. catch (Exception ex)
  87. {
  88. // 对异常进行共通处理
  89. ExceptionManager.HandleEventException(this.ToString(),
  90. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  91. }
  92. }
  93. /// <summary>
  94. /// 自动适应列宽
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  99. {
  100. this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  101. }
  102. /// <summary>
  103. /// 窗体关闭事件
  104. /// </summary>
  105. /// <param name="sender"></param>
  106. /// <param name="e"></param>
  107. private void F_RPT_040104_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. this.dgvRptProcedure.DataSource = null;
  130. this.dgvRptProcedure.DataSource = this.GetSearchData();
  131. }
  132. catch (Exception ex)
  133. {
  134. this.btnSearch.Enabled = true;
  135. this.btnClearCondition.Enabled = true;
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 清空条件按钮事件
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void btnClearCondition_Click(object sender, EventArgs e)
  147. {
  148. //this.dropKilnCode.Text = string.Empty;
  149. this.dropKilnCode.SelectedIndex = 0;
  150. //this.dkGoodsSearchBox.ClearControl();
  151. //this.dkGoodsTypeSearchBox.ClearControl();
  152. this.dkproductionLineSearchBox.ClearControl();
  153. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  154. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1);
  155. this.RecyclingflagCheckBox1.FalseItemCheck();
  156. //this.dkGroutingLineSearchBox.ClearControl();
  157. //this.dkUserInfoSearchBox.ClearControl();
  158. this.chkAll.Checked = false;
  159. //this.dkProcedureSearchBox2.ClearControl();
  160. this.chkTestMouldFlag.AllItemCheck();
  161. this.scbGoodsType.ClearValue();
  162. }
  163. #endregion
  164. #region 私有方法
  165. /// <summary>
  166. /// 根据界面查询条件获取数据集
  167. /// </summary>
  168. private DataTable GetSearchData()
  169. {
  170. try
  171. {
  172. RPT040105_SE se = new RPT040105_SE();
  173. if (this.chkAll.Checked)
  174. {
  175. //if (string.IsNullOrEmpty(dkProcedureSearchBox2.ProcedureIDS))
  176. //{
  177. // MessageBox.Show("请选择出窑数统计工序", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  178. // this.dkProcedureSearchBox2.Focus();
  179. // return null;
  180. //}
  181. //se.OutProcedureIDS = dkProcedureSearchBox2.ProcedureIDS;
  182. }
  183. else
  184. {
  185. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  186. {
  187. this.dropRptProcedure.Focus();
  188. return null;
  189. }
  190. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  191. //获取数据来源工序Id
  192. ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  193. {
  194. return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  195. }
  196. );
  197. if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  198. {
  199. se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  200. }
  201. }
  202. //获取数据来源工序Id
  203. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  204. //se.GoodsIDS = this.dkGoodsSearchBox.GoodsIDS;
  205. //se.GoodsTypeIDS = this.dkGoodsTypeSearchBox.GoodsTypeIDS;
  206. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  207. {
  208. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  209. }
  210. //se.CreateTimeStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  211. //se.CreateTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  212. se.CreateTimeStart = this.dtpAccountDateStart.Value;
  213. //se.CreateTimeEnd = this.dtpAccountDateEnd.Value.AddMinutes(1).AddSeconds(-1);
  214. se.CreateTimeEnd = this.dtpAccountDateEnd.Value.AddSeconds(59);
  215. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  216. object[] testRecyclingflag = this.RecyclingflagCheckBox1.SelectedValues;
  217. if (testMouldFlags.Length == 1)
  218. {
  219. se.TestMouldFlag = testMouldFlags[0].ToString();
  220. }
  221. if (testRecyclingflag.Length == 1)
  222. {
  223. se.TestRecyclingflag = testRecyclingflag[0].ToString();
  224. }
  225. se.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  226. //se.GroutingUserIDS = this.dkUserInfoSearchBox.UserIDS;
  227. //se.GroutingLineIDS = this.dkGroutingLineSearchBox.GroutingLineIDS;
  228. // 调用服务器端获取数据集
  229. ServiceResultEntity sre = DoAsync(() =>
  230. {
  231. return ReportModuleProxy.Service.GetRPT040105SData(se);
  232. }
  233. );
  234. if (sre.Status == Constant.ServiceResultStatus.Success)
  235. {
  236. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  237. {
  238. // 提示未查找到数据
  239. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  240. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  241. //清空数据
  242. return null;
  243. }
  244. return sre.Data.Tables[0];
  245. }
  246. return null;
  247. }
  248. catch (Exception ex)
  249. {
  250. throw ex;
  251. }
  252. }
  253. /// <summary>
  254. /// 绑定下拉列表值
  255. /// </summary>
  256. /// <returns></returns>
  257. private void BindPage()
  258. {
  259. //绑定数据来源下拉列表
  260. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  261. {
  262. return ReportModuleProxy.Service.GetRptProcedureModule();
  263. }
  264. );
  265. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  266. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  267. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  268. //绑定窑炉下来列表
  269. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  270. {
  271. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  272. return ReportModuleProxy.Service.GetKilnData(byFlage);
  273. }
  274. );
  275. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  276. DataRow newRowDic = dtKilnInfo.NewRow();
  277. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  278. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  279. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  280. this.dropKilnCode.DataSource = dtKilnInfo;
  281. this.dropKilnCode.ValueMember = "KilnID";
  282. this.dropKilnCode.DisplayMember = "KilnCode";
  283. }
  284. /// <summary>
  285. /// 获取权限(生产线)
  286. /// </summary>
  287. protected void getPurviewLine()
  288. {
  289. try
  290. {
  291. StringBuilder sbProcedurePurview = new StringBuilder();
  292. //得到工序查看权限
  293. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  294. {
  295. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  296. }));
  297. if (dsProcedurePurview != null)
  298. {
  299. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  300. if (drPurview.Length == 0)
  301. {
  302. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  303. {
  304. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  305. }
  306. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  307. {
  308. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  309. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  311. }
  312. }
  313. else
  314. {
  315. ProductionLineEntity line = new ProductionLineEntity();
  316. line.ValueFlags = new object[] { 1 };
  317. dsProcedurePurview = (DataSet)DoAsync(() =>
  318. {
  319. return PCModuleProxy.Service.SearchProductionLine(line);
  320. });
  321. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  322. {
  323. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  324. }
  325. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  326. {
  327. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  328. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  329. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  330. }
  331. }
  332. }
  333. }
  334. catch (Exception ex)
  335. {
  336. throw ex;
  337. }
  338. }
  339. #endregion
  340. private void chkAll_CheckedChanged(object sender, EventArgs e)
  341. {
  342. if (this.chkAll.Checked)
  343. {
  344. dropRptProcedure.Enabled = false;
  345. //dkProcedureSearchBox2.Enabled = true;
  346. }
  347. else
  348. {
  349. dropRptProcedure.Enabled = true;
  350. //dkProcedureSearchBox2.Enabled = false;
  351. }
  352. }
  353. }
  354. }