FrmBcRunTimeReport.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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.YdmBcPipeManage
  16. {
  17. public partial class FrmBcRunTimeReport : FrmBase
  18. {
  19. public FrmBcRunTimeReport()
  20. {
  21. InitializeComponent();
  22. }
  23. private string[] belongArr = null;//所属权
  24. private void FrmBcRunTimeReport_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("com.steering.ydm.bc.report.FrmBcRunTimeReport.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. alist.Add("HC_COUNT");
  97. alist.Add("HC_WGT");
  98. alist.Add("GP_COUNT");
  99. alist.Add("GP_WGT");
  100. alist.Add("GPC_COUNT");
  101. alist.Add("GPC_WGT");
  102. CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  103. }
  104. }
  105. catch { }
  106. }
  107. private void insertInital()
  108. {
  109. this.ultraGrid1.UpdateData();
  110. string nowTim = this.dataYearMoth.Value.ToString("yyyyMM");
  111. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  112. if (uRow == null)
  113. {
  114. MessageUtil.ShowTips("无期末数据,无法结转!");
  115. return;
  116. }
  117. DataTable ds = ServerHelper.GetData("com.steering.ydm.bc.report.FrmBcRunTimeReport.doQueryInialData", new object[] { nowTim,this.CustomInfo }, ob);
  118. if (int.Parse(ds.Rows[0][0].ToString()) > 0)
  119. {
  120. MessageUtil.ShowTips("已存在下月结转数据,不允许重复结转!");
  121. return;
  122. }
  123. ArrayList parm = new ArrayList();
  124. if (MessageUtil.ShowYesNoAndQuestion("是否结转期初数据?") == DialogResult.No) return;
  125. try
  126. {
  127. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  128. if (Constant.WaitingForm == null)
  129. {
  130. Constant.WaitingForm = new WaitingForm();
  131. }
  132. Constant.WaitingForm.ShowToUser = true;
  133. Constant.WaitingForm.Show();
  134. Constant.WaitingForm.Update();
  135. foreach (UltraGridRow row in ultraGrid1.Rows)
  136. {
  137. ArrayList list = new ArrayList();
  138. if (int.Parse(row.Cells["END_COUNT"].Value.ToString()) != 0)
  139. {
  140. //row.Cells["STOVE_NO"].Text.ToString()
  141. //row.Cells["JUDGE_STOVE_NO"].Value.ToString()
  142. list.Add(row.Cells["JUDGE_STOVE_NO"].Text.ToString());
  143. list.Add(row.Cells["BATCH_NO"].Value.ToString());
  144. list.Add(row.Cells["END_COUNT"].Value.ToString());
  145. list.Add(row.Cells["END_AMOUNT"].Value.ToString());
  146. list.Add(row.Cells["PROCESS_CDOE"].Value.ToString());
  147. list.Add(row.Cells["PLINE_CODE"].Value.ToString());
  148. list.Add(row.Cells["MATERIAL_NAME"].Value.ToString());
  149. parm.Add(list);
  150. }
  151. }
  152. CoreClientParam ccp = new CoreClientParam();
  153. ccp.ServerName = "com.steering.ydm.bc.report.FrmBcRunTimeReport";
  154. ccp.MethodName = "insertInital";
  155. ccp.ServerParams = new object[] { parm, nowTim,this.UserInfo.GetUserName(),this.CustomInfo };
  156. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  157. if (ccp.ReturnCode != -1)
  158. {
  159. if (ccp.ReturnInfo.Equals("期初数据结转成功!"))
  160. {
  161. MessageUtil.ShowTips(ccp.ReturnInfo);
  162. }
  163. else
  164. {
  165. MessageUtil.ShowTips(ccp.ReturnInfo);
  166. }
  167. }
  168. this.Cursor = Cursors.Default;
  169. Constant.WaitingForm.ShowToUser = false;
  170. Constant.WaitingForm.Close();
  171. Constant.WaitingForm = null;
  172. }
  173. catch (Exception e)
  174. {
  175. this.Cursor = Cursors.Default;
  176. Constant.WaitingForm.ShowToUser = false;
  177. Constant.WaitingForm.Close();
  178. Constant.WaitingForm = null;
  179. }
  180. }
  181. private void exportData()
  182. {
  183. GridHelper.ulGridToExcel(ultraGrid1, "半成品运行年月收发存汇总");
  184. }
  185. }
  186. }