FrmUpdateBalYearMonth.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.ZGMil.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.ZGMil.Report
  17. {
  18. public partial class FrmUpdateBalYearMonth : FrmBase
  19. {
  20. private string departm = "";
  21. private string plineCode = "";
  22. public FrmUpdateBalYearMonth()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. private void FrmUpdateBalYearMonth_Load(object sender, EventArgs e)
  28. {
  29. NativeMethodNew na = new NativeMethodNew(this.ob);
  30. departm = UserInfo.GetDepartment();
  31. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  32. }
  33. /// <summary>
  34. /// 重写基类方法
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="ToolbarKey"></param>
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. doQuery();
  44. break;
  45. case "Update":
  46. doUpdate();
  47. break;
  48. case "Export":
  49. ExportData();
  50. break;
  51. case "Close":
  52. this.Close();
  53. break;
  54. }
  55. }
  56. /// <summary>
  57. /// 查询
  58. /// </summary>
  59. private void doQuery()
  60. {
  61. //string date = "";
  62. //string endDate = "";
  63. string JudgeStoveNo = "";
  64. //string LotNo = "";
  65. string barYearMonth = "";
  66. //string ContractNo = "";
  67. if (chkJudgeStoveNo.Checked)
  68. {
  69. if (uteJudgeStoveNo.Text.Trim() == "")
  70. {
  71. JudgeStoveNo = "";
  72. }
  73. else
  74. {
  75. JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
  76. }
  77. }
  78. //if (chkLotNo.Checked)
  79. //{
  80. // if (uteLotNo.Text.Trim() == "")
  81. // {
  82. // LotNo = "";
  83. // }
  84. // else
  85. // {
  86. // LotNo = uteLotNo.Value.ToString();
  87. // }
  88. //}
  89. if (chkBalYearMonth.Checked)
  90. {
  91. if (BAL_YEAR_MONTH.Text.Trim() == "")
  92. {
  93. barYearMonth = "";
  94. }
  95. else
  96. {
  97. barYearMonth = BAL_YEAR_MONTH.Value.ToString("yyyyMM");
  98. }
  99. }
  100. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  101. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getBalYearMonth", new Object[] { barYearMonth, JudgeStoveNo, getPlineCode() }, this.ob);
  102. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  103. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  104. wf.Close();
  105. }
  106. /// <summary>
  107. /// 调整结转年月
  108. /// </summary>
  109. private void doUpdate()
  110. {
  111. ultraGrid1.UpdateData();
  112. UltraGridRow row = ultraGrid1.ActiveRow;
  113. if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  114. int count = 0;
  115. ArrayList list = new ArrayList();
  116. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  117. {
  118. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  119. {
  120. count += 1;
  121. //int actCount = 0;
  122. if (!ugr.Cells["ACT_COUNT"].Text.ToString().Equals(""))
  123. {
  124. if (!StringUtil.IsInteger(ugr.Cells["ACT_COUNT"].Text.ToString()) || ugr.Cells["ACT_COUNT"].Text.ToString() == "0")
  125. {
  126. MessageUtil.ShowTips("请输入正确的数字!");
  127. return;
  128. }
  129. if (Int32.Parse(ugr.Cells["ACT_COUNT"].Value.ToString2()) > Int32.Parse(ugr.Cells["ACT_COUNT1"].Value.ToString2()))
  130. {
  131. MessageUtil.ShowTips("输入的支数不能大于实际的支数!");
  132. return;
  133. }
  134. //actCount = Int32.Parse(ugr.Cells["ACT_COUNT"].Value.ToString());
  135. }
  136. if (ugr.Cells["BAL_YEAR_MONTH"].Text.ToString().Equals(""))
  137. {
  138. MessageUtil.ShowTips("请输入正确的时间!");
  139. return;
  140. }
  141. else
  142. {
  143. if (!StringUtil.IsNumber(ugr.Cells["BAL_YEAR_MONTH"].Text.ToString()))
  144. {
  145. MessageUtil.ShowTips("请输入正确的时间!");
  146. return;
  147. }
  148. }
  149. ArrayList pram = new ArrayList();
  150. pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString());
  151. pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
  152. pram.Add(ugr.Cells["ACT_COUNT"].Value.ToString());
  153. pram.Add(ugr.Cells["BAL_YEAR_MONTH"].Value.ToString());
  154. list.Add(pram);
  155. }
  156. }
  157. if (count == 0 || count > 1)
  158. {
  159. MessageUtil.ShowTips("请选择一条需要修改的数据!");
  160. return;
  161. }
  162. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  163. {
  164. return;
  165. }
  166. CoreClientParam ccp = new CoreClientParam();
  167. ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth";
  168. ccp.MethodName = "doUpdate";
  169. ccp.ServerParams = new object[] { list };
  170. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  171. if (ccp.ReturnCode != -1)
  172. {
  173. MessageUtil.ShowTips(ccp.ReturnInfo);
  174. if (ccp.ReturnInfo.Equals("修改成功!"))
  175. {
  176. doQuery();
  177. }
  178. }
  179. }
  180. /// <summary>
  181. /// 导出
  182. /// </summary>
  183. private void ExportData()
  184. {
  185. GridHelper.ulGridToExcel(ultraGrid1, "轧管投入产出报表");
  186. }
  187. /// <summary>
  188. /// 非250、258、168、460的产线代码都为空
  189. /// </summary>
  190. /// <returns></returns>
  191. private string getPlineCode()
  192. {
  193. if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017"))
  194. {
  195. return plineCode;
  196. }
  197. else
  198. {
  199. return "";
  200. }
  201. }
  202. /// <summary>
  203. /// 查询条件
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void chkDate_CheckedChanged(object sender, EventArgs e)
  208. {
  209. if (chkBalYearMonth.Checked) { BAL_YEAR_MONTH.Enabled = true; } else { BAL_YEAR_MONTH.Enabled = false; }
  210. //if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
  211. if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
  212. }
  213. }
  214. }