FrmUpdateYearMonthAndBelongNameGX.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.Common;
  5. using Core.StlMes.Client.ZGMil.Entity;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Core.StlMes.Client.ZGMil.Report
  18. {
  19. public partial class FrmUpdateYearMonthAndBelongNameGX : FrmBase
  20. {
  21. private string departm = "";
  22. private string[] plineCode = null;
  23. private string[] arr = null;
  24. private string[] arrId;//数据权限
  25. public FrmUpdateYearMonthAndBelongNameGX()
  26. {
  27. InitializeComponent();
  28. this.IsLoadUserView = true;
  29. }
  30. private void FrmUpdateYearMonthAndBelongNameGX_Load(object sender, EventArgs e)
  31. {
  32. NativeMethodNew na = new NativeMethodNew(this.ob);
  33. departm = UserInfo.GetDepartment();
  34. plineCode = BaseMethod.GetPlineCode(this.ValidDataPurviewIds,this.ob);//获取 用户 对应的产线
  35. arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,ob);
  36. arrId = this.ValidDataPurviewIds;//获取数据权限
  37. }
  38. /// <summary>
  39. /// 重写基类方法
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="ToolbarKey"></param>
  43. public override void ToolBar_Click(object sender, string ToolbarKey)
  44. {
  45. switch (ToolbarKey)
  46. {
  47. case "Query":
  48. doQuery();
  49. break;
  50. case "UpdateYearMonth":
  51. doUpdateYearMonth();
  52. break;
  53. case "UpdateBelongName":
  54. doUpdateBelongName();
  55. break;
  56. case "Export":
  57. ExportData();
  58. break;
  59. case "Close":
  60. this.Close();
  61. break;
  62. }
  63. }
  64. /// <summary>
  65. /// 调整所属权
  66. /// </summary>
  67. private void doUpdateBelongName()
  68. {
  69. ultraGrid1.UpdateData();
  70. UltraGridRow row = ultraGrid1.ActiveRow;
  71. if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  72. int count = 0;
  73. ArrayList list = new ArrayList();
  74. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  75. {
  76. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  77. {
  78. count += 1;
  79. if (ugr.Cells["TARGET"].Value.ToString().Equals("A"))
  80. {
  81. MessageUtil.ShowTips("产品标识为【A】的不可调整所属权!");
  82. return;
  83. }
  84. ArrayList pram = new ArrayList();
  85. pram.Add(ugr.Cells["BELONG_NAME_JUGDE"].Value.ToString());
  86. pram.Add(ugr.Cells["JUGDE_APPLY_CODE"].Value.ToString());
  87. pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString());
  88. pram.Add(ugr.Cells["BATCH_NO"].Value.ToString());
  89. pram.Add(ugr.Cells["BATCH_GROUD_NO"].Value.ToString());
  90. pram.Add(ugr.Cells["QUALITY_GROUP"].Value.ToString());
  91. pram.Add(ugr.Cells["MAT_GOWHERE_NAME"].Value.ToString());
  92. pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
  93. list.Add(pram);
  94. }
  95. }
  96. if (count == 0 || count > 1)
  97. {
  98. MessageUtil.ShowTips("请选择一条需要修改的数据!");
  99. return;
  100. }
  101. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  102. {
  103. return;
  104. }
  105. CoreClientParam ccp = new CoreClientParam();
  106. ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth";
  107. ccp.MethodName = "doUpdateBelongName";
  108. ccp.ServerParams = new object[] { list };
  109. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  110. if (ccp.ReturnCode != -1)
  111. {
  112. MessageUtil.ShowTips(ccp.ReturnInfo);
  113. if (ccp.ReturnInfo.Equals("修改成功!"))
  114. {
  115. doQuery();
  116. }
  117. }
  118. }
  119. /// <summary>
  120. /// 查询
  121. /// </summary>
  122. private void doQuery()
  123. {
  124. string JudgeStoveNo = "";
  125. string barYearMonth = "";
  126. if (chkJudgeStoveNo.Checked)
  127. {
  128. if (uteJudgeStoveNo.Text.Trim() == "")
  129. {
  130. JudgeStoveNo = "";
  131. }
  132. else
  133. {
  134. JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
  135. }
  136. }
  137. if (chkBalYearMonth.Checked)
  138. {
  139. if (BAL_YEAR_MONTH.Text.Trim() == "")
  140. {
  141. barYearMonth = "";
  142. }
  143. else
  144. {
  145. barYearMonth = BAL_YEAR_MONTH.Value.ToString("yyyyMM");
  146. }
  147. }
  148. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  149. DataTable dt = new DataTable();
  150. dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmUpdateBalYearMonth.getApplyBalYearMonthGX", new Object[] { barYearMonth, JudgeStoveNo, this.CustomInfo.ToString(), plineCode }, this.ob);
  151. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  152. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  153. wf.Close();
  154. }
  155. /// <summary>
  156. /// 调整结转年月
  157. /// </summary>
  158. private void doUpdateYearMonth()
  159. {
  160. ultraGrid1.UpdateData();
  161. UltraGridRow row = ultraGrid1.ActiveRow;
  162. if (row == null) { MessageUtil.ShowTips("无数据!"); return; }
  163. int count = 0;
  164. ArrayList list = new ArrayList();
  165. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  166. {
  167. if (Convert.ToBoolean(ugr.Cells["CHK"].Text) == true)
  168. {
  169. count += 1;
  170. //if (ugr.Cells["INSTOCK_FLAG"].Text.ToString().Equals("未确认"))
  171. //{
  172. // MessageUtil.ShowTips("缴库标志未确认,不允许调整结转年月!");
  173. // return;
  174. //}
  175. //if (ugr.Cells["TARGET"].Value.ToString().Equals("A") && ugr.Cells["INSTOCK_FLAG"].Text.ToString().Equals("已确认"))
  176. //{
  177. // MessageUtil.ShowTips("缴库标志已确认,不允许调整结转年月!");
  178. // return;
  179. //}
  180. ArrayList pram = new ArrayList();
  181. string bal = DateTime.Parse(ugr.Cells["BAL_YEAR_MONTH"].Text).ToString("yyyyMM");
  182. pram.Add(bal);
  183. pram.Add(ugr.Cells["JUGDE_APPLY_CODE"].Value.ToString());
  184. pram.Add(ugr.Cells["JUDGE_STOVE_NO"].Value.ToString());
  185. pram.Add(ugr.Cells["BATCH_NO"].Value.ToString());
  186. pram.Add(ugr.Cells["BATCH_GROUD_NO"].Value.ToString());
  187. pram.Add(ugr.Cells["QUALITY_GROUP"].Value.ToString());
  188. pram.Add(ugr.Cells["MAT_GOWHERE_NAME"].Value.ToString());
  189. pram.Add(ugr.Cells["TARGET"].Value.ToString());
  190. pram.Add(ugr.Cells["PLINE_CODE"].Value.ToString());
  191. pram.Add(DateTime.Parse(ugr.Cells["BAL_YEAR_MONTH"].Text).ToString("yyyy-MM"));
  192. pram.Add(ugr.Cells["INSTOCK_FLAG"].Text.ToString());
  193. list.Add(pram);
  194. }
  195. }
  196. if (count == 0 )
  197. {
  198. MessageUtil.ShowTips("请选择需要修改的数据!");
  199. return;
  200. }
  201. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  202. {
  203. return;
  204. }
  205. CoreClientParam ccp = new CoreClientParam();
  206. ccp.ServerName = "com.steering.mes.zgmil.report.FrmUpdateBalYearMonth";
  207. ccp.MethodName = "doUpdateYearMonth";
  208. ccp.ServerParams = new object[] { list };
  209. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  210. if (ccp.ReturnCode != -1)
  211. {
  212. MessageUtil.ShowTips(ccp.ReturnInfo);
  213. if (ccp.ReturnInfo.Equals("修改成功!"))
  214. {
  215. doQuery();
  216. }
  217. }
  218. }
  219. /// <summary>
  220. /// 查询条件
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void chkDate_CheckedChanged(object sender, EventArgs e)
  225. {
  226. if (chkBalYearMonth.Checked) { BAL_YEAR_MONTH.Enabled = true; } else { BAL_YEAR_MONTH.Enabled = false; }
  227. //if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
  228. if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
  229. }
  230. /// <summary>
  231. /// 导出
  232. /// </summary>
  233. private void ExportData()
  234. {
  235. GridHelper.ulGridToExcel(ultraGrid1, "轧管投入产出报表");
  236. }
  237. private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  238. {
  239. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  240. {
  241. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  242. {
  243. uRow.Cells["CHK"].Value = true;
  244. }
  245. }
  246. }
  247. private void ultraGrid1_KeyUp(object sender, KeyEventArgs e)
  248. {
  249. BaseMethod.setGridCopyActColumn(ultraGrid1, e, "BAL_YEAR_MONTH");
  250. }
  251. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  252. {
  253. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  254. {
  255. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  256. {
  257. uRow.Cells["CHK"].Value = true;
  258. }
  259. }
  260. }
  261. }
  262. }