FrmScrapStoveApplyDescion.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. 
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Server;
  5. using Core.Mes.Client.Comm.Tool;
  6. using Core.StlMes.Client.ZGMil.Entity;
  7. using CoreFS.CA06;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Text.RegularExpressions;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.ZGMil.Signature
  20. {
  21. public partial class FrmScrapStoveApplyDescion : FrmBase
  22. {
  23. public FrmScrapStoveApplyDescion()
  24. {
  25. InitializeComponent();
  26. }
  27. private string departCode = "";//所属权
  28. private void FrmScrapStoveApplyDescion_Load(object sender, EventArgs e)
  29. {
  30. dtBathYear.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  31. EntityHelper.ShowGridCaption<MilPlanEntity3>(ultraGrid1.DisplayLayout.Bands[0]);
  32. EntityHelper.ShowGridCaption<QcmZgJugdeApplyEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  33. EntityHelper.ShowGridCaption<MilPlanEntity3>(ultraGrid3.DisplayLayout.Bands[0]);
  34. }
  35. /// <summary>
  36. /// 基类方法
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="ToolbarKey"></param>
  40. public override void ToolBar_Click(object sender, string ToolbarKey)
  41. {
  42. switch (ToolbarKey)
  43. {
  44. case "Query":
  45. queryData();
  46. break;
  47. case"QueryScrap":
  48. queryScrapData();
  49. break;
  50. case "insertScrapMata":
  51. insertScrapMata();
  52. break;
  53. case "insertWhiteBank":
  54. insertWhiteBank();
  55. break;
  56. case"cancelScrapMata":
  57. cancelScrapMata();
  58. break;
  59. case "Export":
  60. ExportData();
  61. break;
  62. case "Close":
  63. this.Close();
  64. break;
  65. }
  66. }
  67. /// <summary>
  68. /// 查询整炉废
  69. /// </summary>
  70. private void queryScrapData()
  71. {
  72. string jugeNo = "";
  73. string bathYear = this.dtBathYear.Value.ToString("yyyyMM");
  74. string plineCode = this.ultraComboEditor1.Value.ToString();
  75. if (this.ultraComboEditor1.Text.ToString() == "")
  76. {
  77. MessageUtil.ShowTips("请选择产线!");
  78. return;
  79. }
  80. //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  81. if (this.chkHeatNo2.Checked)
  82. {
  83. if (this.txtHeatNo2.Text.Trim() == "")
  84. {
  85. MessageUtil.ShowTips("请输入炉号!");
  86. }
  87. else
  88. {
  89. jugeNo = this.txtHeatNo2.Text.Trim();
  90. }
  91. }
  92. ArrayList parmList = new ArrayList();
  93. parmList.Add(jugeNo);
  94. parmList.Add(bathYear);
  95. parmList.Add(plineCode);
  96. List<MilPlanEntity3> listSource = EntityHelper.GetData<MilPlanEntity3>(
  97. "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryMata", new object[] { parmList }, this.ob);
  98. PortMilBatchSampleResultEntity1bindingSource.DataSource = listSource;
  99. queryQcm();
  100. }
  101. /// <summary>
  102. /// 查询白条信息
  103. /// </summary>
  104. private void queryData()
  105. {
  106. string jugeNo = "";
  107. string bathYear = this.dtBathYear.Value.ToString("yyyyMM");
  108. string plineCode = this.ultraComboEditor1.Value.ToString();
  109. if (this.ultraComboEditor1.Text.ToString() == "")
  110. {
  111. MessageUtil.ShowTips("请选择产线!");
  112. return;
  113. }
  114. //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  115. if(this.chkHeatNo2.Checked)
  116. {
  117. if (this.txtHeatNo2.Text.Trim() == "")
  118. {
  119. MessageUtil.ShowTips("请输入炉号!");
  120. }
  121. else
  122. {
  123. jugeNo = this.txtHeatNo2.Text.Trim();
  124. }
  125. }
  126. ArrayList parmList = new ArrayList();
  127. parmList.Add(jugeNo);
  128. parmList.Add(bathYear);
  129. parmList.Add(plineCode);
  130. List<MilPlanEntity3> listSourceS = EntityHelper.GetData<MilPlanEntity3>(
  131. "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryBTMata", new object[] { parmList }, this.ob);
  132. PortMilBatchSampleResultEntitybindingSource.DataSource = listSourceS;
  133. queryQcm();
  134. }
  135. /// <summary>
  136. /// 查询当月所有白条\ 整炉废判定数据
  137. /// </summary>
  138. public void queryQcm()
  139. {
  140. string jugeNo = "";
  141. string bathYear = this.dtBathYear.Value.ToString("yyyyMM");
  142. string plineCode = this.ultraComboEditor1.Value.ToString();
  143. if (this.ultraComboEditor1.Text.ToString() == "")
  144. {
  145. MessageUtil.ShowTips("请选择产线!");
  146. return;
  147. }
  148. //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
  149. if (this.chkHeatNo2.Checked)
  150. {
  151. if (this.txtHeatNo2.Text.Trim() == "")
  152. {
  153. MessageUtil.ShowTips("请输入炉号!");
  154. }
  155. else
  156. {
  157. jugeNo = this.txtHeatNo2.Text.Trim();
  158. }
  159. }
  160. ArrayList parmList = new ArrayList();
  161. parmList.Add(jugeNo);
  162. parmList.Add(bathYear);
  163. parmList.Add(plineCode);
  164. List<QcmZgJugdeApplyEntity> listSource = EntityHelper.GetData<QcmZgJugdeApplyEntity>(
  165. "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryQcmMata", new object[] { parmList }, this.ob);
  166. QcmZgJugdeApplyEntitybindingSource.DataSource = listSource;
  167. }
  168. /// <summary>
  169. /// 增加整炉判废判定记录
  170. /// </summary>
  171. private void insertScrapMata()
  172. {
  173. this.ultraGrid3.UpdateData();
  174. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
  175. if (checkMagRows.Count()==0)
  176. {
  177. MessageUtil.ShowTips("请选择需要整炉废信息");
  178. return;
  179. }
  180. ArrayList parmList = new ArrayList();
  181. foreach (UltraGridRow uRow in checkMagRows)
  182. {
  183. MilPlanEntity3 milPlanEntity = (MilPlanEntity3)uRow.ListObject;
  184. string mPlanTity = JSONFormat.Format(milPlanEntity);
  185. parmList.Add(mPlanTity);
  186. }
  187. CoreClientParam ccp = new CoreClientParam();
  188. ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion";
  189. ccp.MethodName = "doDecisionScrap";
  190. ccp.ServerParams = new object[] { parmList, this.UserInfo.GetUserName() };
  191. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  192. if (ccp.ReturnCode != -1)
  193. {
  194. if (ccp.ReturnInfo.Equals("送判成功!"))
  195. {
  196. queryScrapData();
  197. MessageUtil.ShowTips(ccp.ReturnInfo);
  198. }
  199. else
  200. {
  201. MessageUtil.ShowTips(ccp.ReturnInfo);
  202. }
  203. }
  204. }
  205. /// <summary>
  206. /// 增加白条判定记录
  207. /// </summary>
  208. private void insertWhiteBank()
  209. {
  210. this.ultraGrid1.UpdateData();
  211. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  212. if (checkMagRows.Count() == 0)
  213. {
  214. MessageUtil.ShowTips("请选择需要打白条的信息");
  215. return;
  216. }
  217. ArrayList parmList = new ArrayList();
  218. foreach(UltraGridRow uRow in checkMagRows)
  219. {
  220. MilPlanEntity3 milPlanEntity = (MilPlanEntity3)uRow.ListObject;
  221. //if (!IsInt(milPlanEntity.ActCount.ToString()))
  222. //{
  223. // MessageUtil.ShowTips("支数请输入整数!");
  224. // return;
  225. //}
  226. //if (!IsNumber(milPlanEntity.ActWeight.ToString()))
  227. //{
  228. // MessageUtil.ShowTips("重量请输入数字!");
  229. // return;
  230. //}
  231. string mPlanTity = JSONFormat.Format(milPlanEntity);
  232. parmList.Add(mPlanTity);
  233. }
  234. CoreClientParam ccp = new CoreClientParam();
  235. ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion";
  236. ccp.MethodName = "insertWhiteBank";
  237. ccp.ServerParams = new object[] { parmList, this.UserInfo.GetUserName() };
  238. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  239. if (ccp.ReturnCode != -1)
  240. {
  241. if (ccp.ReturnInfo.Equals("送判成功!"))
  242. {
  243. queryData();
  244. MessageUtil.ShowTips(ccp.ReturnInfo);
  245. }
  246. else
  247. {
  248. MessageUtil.ShowTips(ccp.ReturnInfo);
  249. }
  250. }
  251. }
  252. /// <summary>
  253. /// 检验是否为数字
  254. /// </summary>
  255. /// <param name="str">需要检验的字符串</param>
  256. /// <returns>是否为数字:true代表是,false代表否</returns>
  257. public static bool IsNumber(string str)
  258. {
  259. Regex rx = new Regex(@"^[+-]?[0123456789]*[.]?[0123456789]*$");
  260. return rx.IsMatch(str);
  261. }
  262. /// <summary>
  263. /// 检验是否是整数
  264. /// </summary>
  265. /// <param name="str">需要检验的字符串</param>
  266. /// <returns>是否为整数:true是整数,false非整数</returns>
  267. public static bool IsInt(string str)
  268. {
  269. Regex rx = new Regex(@"^[0123456789]+$");
  270. return rx.IsMatch(str);
  271. }
  272. /// <summary>
  273. /// 撤销整炉废
  274. /// </summary>
  275. private void cancelScrapMata()
  276. {
  277. this.ultraGrid2.UpdateData();
  278. UltraGridRow uRow = this.ultraGrid2.ActiveRow;
  279. if (uRow == null)
  280. {
  281. MessageUtil.ShowTips("请选择需要撤销的信息");
  282. return;
  283. }
  284. QcmZgJugdeApplyEntity qcmEntity = (QcmZgJugdeApplyEntity)uRow.ListObject;
  285. string qcmZcTity = JSONFormat.Format(qcmEntity);
  286. CoreClientParam ccp = new CoreClientParam();
  287. ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion";
  288. ccp.MethodName = "cancelScrapMata";
  289. ccp.ServerParams = new object[] { qcmZcTity};
  290. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  291. if (ccp.ReturnCode != -1)
  292. {
  293. if (ccp.ReturnInfo.Equals("撤销成功!"))
  294. {
  295. queryData();
  296. queryScrapData();
  297. MessageUtil.ShowTips(ccp.ReturnInfo);
  298. }
  299. else
  300. {
  301. MessageUtil.ShowTips(ccp.ReturnInfo);
  302. }
  303. }
  304. }
  305. private void chkHeatNo2_CheckedChanged(object sender, EventArgs e)
  306. {
  307. txtHeatNo2.Enabled = this.chkHeatNo2.Checked;
  308. }
  309. /// <summary>
  310. /// 导出
  311. /// </summary>
  312. private void ExportData()
  313. {
  314. GridHelper.ulGridToExcel(ultraGrid2, "虚数申请判定->整炉废(白条信息)");
  315. }
  316. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  317. {
  318. this.ultraGrid1.UpdateData();
  319. int strCountTex = 0;
  320. double strWgtTex = 0.000;
  321. if (e.Cell.Column.Key == "CHK")
  322. {
  323. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  324. foreach (UltraGridRow uRow in checkMagRows)
  325. {
  326. strCountTex = strCountTex + int.Parse(uRow.Cells["ActCount"].Value.ToString3());
  327. strWgtTex = strWgtTex + double.Parse(uRow.Cells["ActWeight"].Value.ToString3());
  328. }
  329. this.ultraGroupBox1.Text = "可打白条信息" + " " + "已选支:" + strCountTex.ToString() + " " + "已选产量: " + strWgtTex.ToString();
  330. }
  331. }
  332. }
  333. }