F_RPT_040110.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040110.cs
  5. * 2.功能描述:产成品逐日出窑数值分析表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2016/11/09 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. public partial class F_RPT_040110 : DKDockPanelBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_RPT_040110 _instance;
  29. //private TreeNode tnGUsercode = new TreeNode("成型工号");
  30. //private TreeNode tnGLType = new TreeNode("成型线类型");
  31. #endregion
  32. #region 构造函数
  33. public F_RPT_040110()
  34. {
  35. InitializeComponent();
  36. // 窗体显示的Title
  37. //this.Text = FormTitles.F_RPT_040105;
  38. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  39. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  40. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  41. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  42. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  43. //tnGUsercode.Name = "成型工号";
  44. //tnGUsercode.Text = "成型工号";
  45. //tnGLType.Name = "成型线类型";
  46. //tnGLType.Text = "成型线类型";
  47. //this.treeView1.Nodes.Insert(1, tnGUsercode);
  48. //this.treeView1.Nodes.Insert(2, tnGLType);
  49. this.gusercode.Visible = false;
  50. this.gltype.Visible = false;
  51. }
  52. #endregion
  53. #region 单例模式
  54. /// <summary>
  55. /// 单例模式,防止重复创建窗体
  56. /// </summary>
  57. public static F_RPT_040110 Instance
  58. {
  59. get
  60. {
  61. if (_instance == null || _instance.IsDisposed)
  62. {
  63. _instance = new F_RPT_040110();
  64. }
  65. return _instance;
  66. }
  67. }
  68. #endregion
  69. #region 事件处理
  70. /// <summary>
  71. /// 窗体加载事件
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void F_RPT_040104_Load(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. // 加载权限
  80. FormPermissionManager.FormPermissionControl(this.Name, this,
  81. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  83. //绑定下了列表
  84. BindPage();
  85. // 设置表格不自动创建列
  86. this.dgvTQ.AutoGenerateColumns = false;
  87. this.dropRptProcedure.Focus();
  88. // 初始化时间控件为当前日期
  89. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  90. this.dtpAccountDateEnd.Value = this.dtpAccountDateStart.Value.AddDays(1).AddSeconds(-1);
  91. }
  92. catch (Exception ex)
  93. {
  94. // 对异常进行共通处理
  95. ExceptionManager.HandleEventException(this.ToString(),
  96. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  97. }
  98. }
  99. /// <summary>
  100. /// 自动适应列宽
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  105. {
  106. this.dgvTQ.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void F_RPT_040104_FormClosed(object sender, FormClosedEventArgs e)
  114. {
  115. _instance = null;
  116. }
  117. /// <summary>
  118. /// 关闭按钮
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. }
  126. /// <summary>
  127. /// 查询按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnSearch_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. this.dgvTQ.DataSource = null;
  136. if (this.chkG.Checked)
  137. {
  138. this.gusercode.Visible = true;
  139. this.gltype.Visible = true;
  140. //if (!this.treeView1.Nodes.Contains(tnGUsercode))
  141. //{
  142. // this.treeView1.Nodes.Insert(1, tnGUsercode);
  143. //}
  144. //if (!this.treeView1.Nodes.Contains(tnGLType))
  145. //{
  146. // this.treeView1.Nodes.Insert(2, tnGLType);
  147. //}
  148. }
  149. else
  150. {
  151. this.gusercode.Visible = false;
  152. this.gltype.Visible = false;
  153. //if (this.treeView1.Nodes.Contains(tnGUsercode))
  154. //{
  155. // this.treeView1.Nodes.Remove(tnGUsercode);
  156. //}
  157. //if (this.treeView1.Nodes.Contains(tnGLType))
  158. //{
  159. // this.treeView1.Nodes.Remove(tnGLType);
  160. //}
  161. }
  162. DataSet dataSet = this.GetSearchData();
  163. if (dataSet == null)
  164. {
  165. return;
  166. }
  167. this.dgvTQ.DataSource = dataSet.Tables[0];
  168. }
  169. catch (Exception ex)
  170. {
  171. this.btnSearch.Enabled = true;
  172. this.btnClearCondition.Enabled = true;
  173. this.dgvTQ.Enabled = true;
  174. // 对异常进行共通处理
  175. ExceptionManager.HandleEventException(this.ToString(),
  176. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  177. }
  178. finally
  179. {
  180. this.btnSearch.Enabled = true;
  181. this.btnClearCondition.Enabled = true;
  182. this.dgvTQ.Enabled = true;
  183. }
  184. }
  185. /// <summary>
  186. /// 清空条件按钮事件
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. private void btnClearCondition_Click(object sender, EventArgs e)
  191. {
  192. this.dropKilnCode.SelectedIndex = 0;
  193. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  194. this.dtpAccountDateEnd.Value = this.dtpAccountDateStart.Value.AddDays(1).AddSeconds(-1);
  195. }
  196. #endregion
  197. #region 私有方法
  198. /// <summary>
  199. /// 根据界面查询条件获取数据集
  200. /// </summary>
  201. private DataSet GetSearchData()
  202. {
  203. try
  204. {
  205. RPT040110_SE se = new RPT040110_SE();
  206. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  207. {
  208. this.dropRptProcedure.Focus();
  209. return null;
  210. }
  211. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  212. //获取数据来源工序Id
  213. ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  214. {
  215. return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  216. }
  217. );
  218. if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  219. {
  220. se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  221. }
  222. //获取数据来源工序Id
  223. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  224. {
  225. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  226. }
  227. se.CreateTimeStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  228. se.CreateTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  229. se.IsShowG = this.chkG.Checked;
  230. // 调用服务器端获取数据集
  231. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  232. {
  233. return ReportModuleProxy.Service.GetRPT040110SData(se);
  234. }
  235. );
  236. if (sre.Status == Constant.ServiceResultStatus.Success)
  237. {
  238. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  239. {
  240. // 提示未查找到数据
  241. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  242. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  243. //清空数据
  244. return null;
  245. }
  246. return sre.Data;
  247. }
  248. return null;
  249. }
  250. catch (Exception ex)
  251. {
  252. throw ex;
  253. }
  254. }
  255. /// <summary>
  256. /// 绑定下拉列表值
  257. /// </summary>
  258. /// <returns></returns>
  259. private void BindPage()
  260. {
  261. //绑定数据来源下拉列表
  262. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  263. {
  264. return ReportModuleProxy.Service.GetRptProcedureModule();
  265. }
  266. );
  267. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  268. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  269. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  270. //绑定窑炉下来列表
  271. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  272. {
  273. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  274. return ReportModuleProxy.Service.GetKilnData(byFlage);
  275. }
  276. );
  277. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  278. DataRow newRowDic = dtKilnInfo.NewRow();
  279. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  280. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  281. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  282. this.dropKilnCode.DataSource = dtKilnInfo;
  283. this.dropKilnCode.ValueMember = "KilnID";
  284. this.dropKilnCode.DisplayMember = "KilnCode";
  285. }
  286. #endregion
  287. }
  288. }