FrmRunTimeReport.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.YdmStuffReport
  16. {
  17. public partial class FrmRunTimeReport : FrmBase
  18. {
  19. public FrmRunTimeReport()
  20. {
  21. InitializeComponent();
  22. }
  23. private string[] belongArr = null;//所属权
  24. private void FrmRunTimeReport_Load(object sender, EventArgs e)
  25. {
  26. this.dataYearMoth.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  27. belongArr = this.ValidDataPurviewIds;
  28. }
  29. public override void ToolBar_Click(object sender, string ToolbarKey)
  30. {
  31. switch (ToolbarKey)
  32. {
  33. case "Query":
  34. queryData();
  35. break;
  36. case "Export":
  37. exportData();
  38. break;
  39. case "InsertInital":
  40. insertInital();
  41. break;
  42. case "Close":
  43. this.Close();
  44. break;
  45. }
  46. }
  47. private void queryData()
  48. {
  49. string bathYearMoth = this.dataYearMoth.Value.ToString("yyyyMM");
  50. try
  51. {
  52. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  53. if (Constant.WaitingForm == null)
  54. {
  55. Constant.WaitingForm = new WaitingForm();
  56. }
  57. Constant.WaitingForm.ShowToUser = true;
  58. Constant.WaitingForm.Show();
  59. Constant.WaitingForm.Update();
  60. DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.Report.FrmRunTimeReport.queryDataRun", new object[] { bathYearMoth, belongArr,this.CustomInfo }, ob);
  61. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  62. this.SetStaticsInfo();
  63. CommonMethod.SetGridSumArea(this.ultraGrid1);
  64. this.Cursor = Cursors.Default;
  65. Constant.WaitingForm.ShowToUser = false;
  66. Constant.WaitingForm.Close();
  67. Constant.WaitingForm = null;
  68. }
  69. catch (Exception e)
  70. {
  71. this.Cursor = Cursors.Default;
  72. Constant.WaitingForm.ShowToUser = false;
  73. Constant.WaitingForm.Close();
  74. Constant.WaitingForm = null;
  75. }
  76. }
  77. private void SetStaticsInfo()
  78. {
  79. try
  80. {
  81. if (this.ultraGrid1.Rows.Count == 0)
  82. {
  83. this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
  84. }
  85. else
  86. {
  87. ArrayList alist = new ArrayList();
  88. alist.Add("ORIGINAL_AMOUNT");
  89. alist.Add("ORIGINAL_COUNT");
  90. alist.Add("MONTH_1");
  91. alist.Add("MONTH_1COUNT");
  92. alist.Add("MONTH_2");
  93. alist.Add("MONTH_2COUNT");
  94. alist.Add("END_AMOUNT");
  95. alist.Add("END_COUNT");
  96. CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  97. }
  98. }
  99. catch { }
  100. }
  101. private void insertInital()
  102. {
  103. this.ultraGrid1.UpdateData();
  104. string nowTim = this.dataYearMoth.Value.ToString("yyyyMM");
  105. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  106. if (uRow == null)
  107. {
  108. MessageUtil.ShowTips("无期末数据,无法结转!");
  109. return;
  110. }
  111. DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.Report.FrmRunTimeReport.doQueryInialData", new object[] { nowTim,CustomInfo }, ob);
  112. if (int.Parse(ds.Rows[0][0].ToString()) > 0)
  113. {
  114. MessageUtil.ShowTips("已存在下月结转数据,不允许重复结转!");
  115. return;
  116. }
  117. ArrayList parm = new ArrayList();
  118. if (MessageUtil.ShowYesNoAndQuestion("是否结转期初数据?") == DialogResult.No) return;
  119. try
  120. {
  121. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  122. if (Constant.WaitingForm == null)
  123. {
  124. Constant.WaitingForm = new WaitingForm();
  125. }
  126. Constant.WaitingForm.ShowToUser = true;
  127. Constant.WaitingForm.Show();
  128. Constant.WaitingForm.Update();
  129. foreach (UltraGridRow row in ultraGrid1.Rows)
  130. {
  131. ArrayList list = new ArrayList();
  132. if (int.Parse(row.Cells["END_COUNT"].Value.ToString()) > 0)
  133. {
  134. //row.Cells["STOVE_NO"].Text.ToString()
  135. //row.Cells["JUDGE_STOVE_NO"].Value.ToString()
  136. list.Add(row.Cells["STOVE_NO"].Text.ToString());
  137. list.Add(row.Cells["JUDGE_STOVE_NO"].Value.ToString());
  138. list.Add(row.Cells["END_COUNT"].Value.ToString());
  139. list.Add(row.Cells["END_AMOUNT"].Value.ToString());
  140. list.Add(row.Cells["MATERIAL_NAME"].Text);
  141. list.Add(row.Cells["BACK_FLAG"].Text);
  142. list.Add(row.Cells["IS_DEALER"].Text);
  143. parm.Add(list);
  144. }
  145. }
  146. CoreClientParam ccp = new CoreClientParam();
  147. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.Report.FrmRunTimeReport";
  148. ccp.MethodName = "insertInital";
  149. ccp.ServerParams = new object[] { parm, nowTim,this.UserInfo.GetUserName(),this.CustomInfo };
  150. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  151. if (ccp.ReturnCode != -1)
  152. {
  153. if (ccp.ReturnInfo.Equals("期初数据结转成功!"))
  154. {
  155. MessageUtil.ShowTips(ccp.ReturnInfo);
  156. }
  157. else
  158. {
  159. MessageUtil.ShowTips(ccp.ReturnInfo);
  160. }
  161. }
  162. this.Cursor = Cursors.Default;
  163. Constant.WaitingForm.ShowToUser = false;
  164. Constant.WaitingForm.Close();
  165. Constant.WaitingForm = null;
  166. }
  167. catch (Exception e)
  168. {
  169. this.Cursor = Cursors.Default;
  170. Constant.WaitingForm.ShowToUser = false;
  171. Constant.WaitingForm.Close();
  172. Constant.WaitingForm = null;
  173. }
  174. }
  175. private void exportData()
  176. {
  177. GridHelper.ulGridToExcel(ultraGrid1, "管坯运行年月收发存汇总");
  178. }
  179. }
  180. }