F_RPT_040110.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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.chkRecyclingFlag.FalseItemCheck();
  90. // 初始化时间控件为当前日期
  91. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  92. this.dtpAccountDateEnd.Value = this.dtpAccountDateStart.Value.AddDays(1).AddSeconds(-1);
  93. }
  94. catch (Exception ex)
  95. {
  96. // 对异常进行共通处理
  97. ExceptionManager.HandleEventException(this.ToString(),
  98. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  99. }
  100. }
  101. /// <summary>
  102. /// 自动适应列宽
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  107. {
  108. this.dgvTQ.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  109. }
  110. /// <summary>
  111. /// 窗体关闭事件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void F_RPT_040104_FormClosed(object sender, FormClosedEventArgs e)
  116. {
  117. _instance = null;
  118. }
  119. /// <summary>
  120. /// 关闭按钮
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void tsbtnClose_Click(object sender, EventArgs e)
  125. {
  126. this.Close();
  127. }
  128. /// <summary>
  129. /// 查询按钮事件
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. private void btnSearch_Click(object sender, EventArgs e)
  134. {
  135. try
  136. {
  137. this.dgvTQ.DataSource = null;
  138. if (this.chkG.Checked)
  139. {
  140. this.gusercode.Visible = true;
  141. this.gltype.Visible = true;
  142. //if (!this.treeView1.Nodes.Contains(tnGUsercode))
  143. //{
  144. // this.treeView1.Nodes.Insert(1, tnGUsercode);
  145. //}
  146. //if (!this.treeView1.Nodes.Contains(tnGLType))
  147. //{
  148. // this.treeView1.Nodes.Insert(2, tnGLType);
  149. //}
  150. }
  151. else
  152. {
  153. this.gusercode.Visible = false;
  154. this.gltype.Visible = false;
  155. //if (this.treeView1.Nodes.Contains(tnGUsercode))
  156. //{
  157. // this.treeView1.Nodes.Remove(tnGUsercode);
  158. //}
  159. //if (this.treeView1.Nodes.Contains(tnGLType))
  160. //{
  161. // this.treeView1.Nodes.Remove(tnGLType);
  162. //}
  163. }
  164. DataSet dataSet = this.GetSearchData();
  165. if (dataSet == null)
  166. {
  167. return;
  168. }
  169. this.dgvTQ.DataSource = dataSet.Tables[0];
  170. }
  171. catch (Exception ex)
  172. {
  173. this.btnSearch.Enabled = true;
  174. this.btnClearCondition.Enabled = true;
  175. this.dgvTQ.Enabled = true;
  176. // 对异常进行共通处理
  177. ExceptionManager.HandleEventException(this.ToString(),
  178. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  179. }
  180. finally
  181. {
  182. this.btnSearch.Enabled = true;
  183. this.btnClearCondition.Enabled = true;
  184. this.dgvTQ.Enabled = true;
  185. }
  186. }
  187. /// <summary>
  188. /// 清空条件按钮事件
  189. /// </summary>
  190. /// <param name="sender"></param>
  191. /// <param name="e"></param>
  192. private void btnClearCondition_Click(object sender, EventArgs e)
  193. {
  194. this.dropKilnCode.SelectedIndex = 0;
  195. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  196. this.dtpAccountDateEnd.Value = this.dtpAccountDateStart.Value.AddDays(1).AddSeconds(-1);
  197. }
  198. #endregion
  199. #region 私有方法
  200. /// <summary>
  201. /// 根据界面查询条件获取数据集
  202. /// </summary>
  203. private DataSet GetSearchData()
  204. {
  205. try
  206. {
  207. RPT040110_SE se = new RPT040110_SE();
  208. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  209. {
  210. this.dropRptProcedure.Focus();
  211. return null;
  212. }
  213. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  214. //获取数据来源工序Id
  215. ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  216. {
  217. return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  218. }
  219. );
  220. if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  221. {
  222. se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  223. }
  224. //获取数据来源工序Id
  225. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  226. {
  227. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  228. }
  229. object[] testRecyclingFlags = this.chkRecyclingFlag.SelectedValues;
  230. if (testRecyclingFlags.Length == 1)
  231. {
  232. se.RECYCLINGFLAG = Convert.ToInt32(testRecyclingFlags[0]);
  233. }
  234. se.CreateTimeStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  235. se.CreateTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  236. se.IsShowG = this.chkG.Checked;
  237. // 调用服务器端获取数据集
  238. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  239. {
  240. return ReportModuleProxy.Service.GetRPT040110SData(se);
  241. }
  242. );
  243. if (sre.Status == Constant.ServiceResultStatus.Success)
  244. {
  245. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  246. {
  247. // 提示未查找到数据
  248. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  249. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  250. //清空数据
  251. return null;
  252. }
  253. return sre.Data;
  254. }
  255. return null;
  256. }
  257. catch (Exception ex)
  258. {
  259. throw ex;
  260. }
  261. }
  262. /// <summary>
  263. /// 绑定下拉列表值
  264. /// </summary>
  265. /// <returns></returns>
  266. private void BindPage()
  267. {
  268. //绑定数据来源下拉列表
  269. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  270. {
  271. return ReportModuleProxy.Service.GetRptProcedureModule();
  272. }
  273. );
  274. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  275. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  276. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  277. //绑定窑炉下来列表
  278. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  279. {
  280. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  281. return ReportModuleProxy.Service.GetKilnData(byFlage);
  282. }
  283. );
  284. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  285. DataRow newRowDic = dtKilnInfo.NewRow();
  286. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  287. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  288. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  289. this.dropKilnCode.DataSource = dtKilnInfo;
  290. this.dropKilnCode.ValueMember = "KilnID";
  291. this.dropKilnCode.DisplayMember = "KilnCode";
  292. }
  293. #endregion
  294. }
  295. }