FrmStraighteningOffLine.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. using com.steering.mes.zgmil.entity;
  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.Windows.Forms;
  18. namespace Core.StlMes.Client.ZGMil.NodeResultQuery
  19. {
  20. public partial class FrmStraighteningOffLine : FrmBase
  21. {
  22. private OpeBase ob;
  23. public OpeBase Ob
  24. {
  25. get { return ob; }
  26. set { ob = value; }
  27. }
  28. //工序状态:01-矫直1#,02-矫直2#,03-矫直3#,11-ET探伤,12-MT探伤,13-UT探伤
  29. private string node="";
  30. private string test = "";
  31. private string colno = "0";//探伤台号
  32. //可下线支数
  33. private int ScrapNumBefore = 0;
  34. //剔除支数
  35. private int DelNum = 0;
  36. //产线代码
  37. string PlineCod = "";
  38. //点击主计划的炉号
  39. private string heatno = "";
  40. private string stoveno = "";
  41. private string lotno = "";
  42. private string proPlanId = "";//轧管订单编号
  43. private string gxPlanNo = "";//工序排产序号
  44. //工序
  45. private string process = "";
  46. private string labtext = "";
  47. private string qualifiedNum = "";//上倒工序合格支数
  48. //下线实绩表实体类
  49. MilOfflineReslutEntity2 milofflineresult = new MilOfflineReslutEntity2();
  50. /// <summary>
  51. /// 构造函数
  52. /// </summary>
  53. public FrmStraighteningOffLine()
  54. {
  55. }
  56. public FrmStraighteningOffLine(string node, OpeBase _ob, string PlineCode, string stoveno, string lotno, string qualifiedNumS, string proPlanId, string gxPlanNo)
  57. {
  58. InitializeComponent();
  59. EntityHelper.ShowGridCaption<MilPlanEntity>(this.ultraRack.DisplayLayout.Bands[0]);
  60. process = node;
  61. this.Ob = _ob;
  62. this.PlineCod = PlineCode;
  63. this.stoveno = stoveno;
  64. this.lotno = lotno;
  65. this.proPlanId = gxPlanNo;
  66. this.gxPlanNo = gxPlanNo;
  67. qualifiedNum = qualifiedNumS;
  68. Query();
  69. }
  70. private void Query()
  71. {
  72. string jugeNo = this.TxtHeatNo.Text.Trim();
  73. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.GetMILPlan", new object[] { PlineCod,process }, this.ob);
  74. List<MilPlanEntity> listSource = EntityHelper.GetData<MilPlanEntity>(
  75. "com.steering.mes.zgmil.coup.FrmOffLine.GetMILPlan", new object[] { PlineCod, process, jugeNo, proPlanId, gxPlanNo }, this.ob);
  76. MilPlanEntity3bindingSource.DataSource = listSource;
  77. if (listSource ==null)
  78. {
  79. dtPlan.Rows.Clear();
  80. MessageBox.Show("未查询到可下线计划", "提示:", MessageBoxButtons.OK);
  81. this.TxtHeatNo.Text = "";
  82. //this.TxtHeatNo.Enabled = false;
  83. this.TxtTotalNum.Text = "0";
  84. this.TxtTotalNum.Enabled = false;
  85. this.TxtOfflineNumhas.Text = "0";
  86. this.TxtOfflineNumhas.Enabled = false;
  87. this.TxtOfflinNum.Text = "0";
  88. this.Dispose();
  89. this.Close();
  90. }
  91. }
  92. /// <summary>
  93. /// 表格单击事件
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void ultraRack_AfterRowActivate(object sender, EventArgs e)
  98. {
  99. UltraGridRow ugr = this.ultraRack.ActiveRow;
  100. this.TxtTotalNum.Text = "0";
  101. this.TxtOfflinNumBack.Text = "0";
  102. heatno = ugr.Cells["JudgeStoveNo"].Value.ToString();
  103. this.TxtHeatNo.Text = heatno;
  104. //this.TxtHeatNo.Enabled = false;
  105. //可下线支数
  106. string s = "";
  107. DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.getStraighteningCount", new object[] { heatno, PlineCod }, ob);
  108. if (ds.Rows.Count > 0)
  109. {
  110. s = ds.Rows[0]["OFFLINE_COUNT"].ToString();
  111. }
  112. this.TxtTotalNum.Text = s;
  113. this.TxtTotalNum.Enabled = false;
  114. //已下线支数
  115. DataTable dthas = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.GetStraighteningCountHAS", new object[] { heatno, process }, this.ob);
  116. if (dthas.Rows.Count > 0)
  117. {
  118. this.TxtOfflineNumhas.Text = dthas.Rows[0]["OFFLINE_NUM"].ToString();
  119. this.TxtOfflineNumhas.Enabled = false;
  120. }
  121. else
  122. {
  123. this.TxtOfflineNumhas.Text = "0";
  124. this.TxtOfflineNumhas.Enabled = false;
  125. }
  126. }
  127. /// <summary>
  128. /// 下线操作
  129. /// </summary>
  130. public void Offline()
  131. {
  132. string strInbound = "800707";//入库类型
  133. string strInMemo = "";
  134. NativeMethodNew na = new NativeMethodNew(this.ob);
  135. string plinCode = na.GetPCode(this.UserInfo.GetDepartment());
  136. UltraGridRow ugr1 = this.ultraRack.ActiveRow;
  137. heatno = ugr1.Cells["JudgeStoveNo"].Value.ToString();
  138. int xxOfflineNum = 0; //交库点离线的支数
  139. if (string.IsNullOrEmpty(heatno)||ultraRack.ActiveRow==null)
  140. {
  141. MessageBox.Show("未选择计划行,不允许进行下线操作","提示:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
  142. return;
  143. }
  144. if (!string.IsNullOrEmpty(TxtOfflinNum.Text.ToString().Replace("_","")))
  145. {
  146. if (int.Parse(this.TxtOfflinNum.Text.ToString().Replace("_", "")) - int.Parse(this.TxtTotalNum.Text.Trim()) > 0)
  147. {
  148. MessageBox.Show("输入的下线支数超过了可下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  149. return;
  150. }
  151. if (int.Parse(TxtOfflinNum.Text.ToString3().Replace("_", "")) <= 0)
  152. {
  153. MessageBox.Show("下线支数不能为零支,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  154. return;
  155. }
  156. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryXxOfflinNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob);
  157. if (dt.Rows.Count > 0)
  158. {
  159. xxOfflineNum = int.Parse(dt.Rows[0]["OFFLINE_NUM"].ToString3());
  160. if (xxOfflineNum + int.Parse(this.TxtOfflinNum.Text.ToString().Replace("_", "")) - int.Parse(this.TxtTotalNum.Text.Trim()) > 0)
  161. {
  162. MessageBox.Show("交库点离线了" +xxOfflineNum+"支,请确认数据再做离线!" , "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  163. return;
  164. }
  165. }
  166. }
  167. else
  168. {
  169. MessageBox.Show("未输入下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  170. return;
  171. }
  172. DataTable dtMemo = PipeManageClass.getComTypeInfo(strInbound, ob);
  173. if (dtMemo.Rows.Count >= 1)
  174. {
  175. strInMemo = dtMemo.Rows[0]["MEMO"].ToString();
  176. }
  177. ArrayList list = new ArrayList();
  178. DataTable ds = getStoreNo(plinCode);
  179. if (ds == null)
  180. {
  181. MessageUtil.ShowTips("无轧管在线库基础信息,请维护!");
  182. return;
  183. }
  184. list.Add(ds.Rows[0]["STORAGE_NO"].ToString());
  185. list.Add(ds.Rows[0]["STORAGE_NO"].ToString() + "10101");
  186. list.Add(ds.Rows[0]["STORAGE_TYPE_NO"].ToString());
  187. list.Add(ds.Rows[0]["STORAGE_TYPE_NAME"].ToString());
  188. list.Add(this.UserInfo.GetUserName());
  189. list.Add(this.UserInfo.GetDeptid());
  190. list.Add(this.UserInfo.GetDepartment());
  191. list.Add(this.UserInfo.GetDeptid());
  192. list.Add(this.UserInfo.GetDepartment());
  193. //list.Add(PipeManageClass.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
  194. //list.Add(PipeManageClass.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
  195. list.Add(UserInfo.GetUserOrder());
  196. list.Add(UserInfo.GetUserGroup());
  197. UltraGridRow uRow = this.ultraRack.ActiveRow;
  198. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryResult", new object[] { uRow.Cells["JudgeStoveNo"].Value.ToString2() }, this.ob);
  199. //if (int.Parse(dt.Rows[0]["ACOUNT"].ToString2()) < 1)
  200. //{
  201. // MessageUtil.ShowTips("部分下线之前,请先录入实绩!");
  202. // return;
  203. //}
  204. MilPlanEntity milPlan = (MilPlanEntity)uRow.ListObject;
  205. String milPlanTity = JSONFormat.Format(milPlan);
  206. CoreClientParam ccp = new CoreClientParam();
  207. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  208. ccp.MethodName = "offLineJZ";
  209. ccp.ServerParams = new object[] { milPlanTity, TxtOfflinNum.Text.ToString().Replace("_", ""), this.UserInfo.GetUserName(), this.UserInfo.GetUserGroup(), this.UserInfo.GetUserOrder(), "0", list, strInbound, strInMemo, plinCode };
  210. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  211. if (ccp.ReturnCode != -1)
  212. {
  213. if (ccp.ReturnInfo.Equals("离线成功!"))
  214. {
  215. Query();
  216. MessageUtil.ShowTips(ccp.ReturnInfo);
  217. }
  218. else
  219. {
  220. MessageUtil.ShowTips(ccp.ReturnInfo);
  221. }
  222. }
  223. foreach (UltraGridRow ugr in ultraRack.Rows)
  224. {
  225. if (ugr.Cells["JudgeStoveNo"].Value.ToString().Equals(heatno))
  226. {
  227. ultraRack.ActiveRow = ugr;
  228. }
  229. }
  230. }
  231. /// <summary>
  232. /// 查询仓库信息
  233. /// </summary>
  234. /// <param name="plineCode"></param>
  235. /// <returns></returns>
  236. private DataTable getStoreNo(string plineCode)
  237. {
  238. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  239. if (ds.Rows.Count > 0)
  240. {
  241. return ds;
  242. }
  243. else
  244. {
  245. return null;
  246. }
  247. }
  248. public void offlineAll()
  249. {
  250. string strInbound = "800707";//入库类型
  251. string strInMemo = "";
  252. int xxOfflineNum = 0; //交库点离线的支数
  253. NativeMethodNew na = new NativeMethodNew(this.ob);
  254. string plinCode = na.GetPCode(this.UserInfo.GetDepartment());
  255. if (string.IsNullOrEmpty(heatno) || ultraRack.ActiveRow == null)
  256. {
  257. MessageBox.Show("未选择计划行,不允许进行下线操作。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  258. return;
  259. }
  260. UltraGridRow uRow = this.ultraRack.ActiveRow;
  261. //heatno = uRow.Cells["JudgeStoveNo"].Value.ToString();
  262. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryResult", new object[] { uRow.Cells["JudgeStoveNo"].Value.ToString2() }, this.ob);
  263. //if (int.Parse(dt.Rows[0]["ACOUNT"].ToString2()) < 1)
  264. //{
  265. // MessageUtil.ShowTips("部分下线之前,请先录入实绩!");
  266. // return;
  267. //}
  268. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryXxOfflinNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob);
  269. if (dt.Rows.Count > 0)
  270. {
  271. xxOfflineNum = int.Parse(dt.Rows[0]["OFFLINE_NUM"].ToString3());
  272. MessageBox.Show("交库点离线了" + xxOfflineNum + "支,不允许使用整台离线功能!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  273. return;
  274. }
  275. DataTable dtMemo = PipeManageClass.getComTypeInfo(strInbound, ob);
  276. if (dtMemo.Rows.Count >= 1)
  277. {
  278. strInMemo = dtMemo.Rows[0]["MEMO"].ToString();
  279. }
  280. ArrayList list = new ArrayList();
  281. DataTable ds = getStoreNo(plinCode);
  282. if (ds == null)
  283. {
  284. MessageUtil.ShowTips("无轧管在线库基础信息,请维护!");
  285. return;
  286. }
  287. list.Add(ds.Rows[0]["STORAGE_NO"].ToString());
  288. list.Add(ds.Rows[0]["STORAGE_NO"].ToString() + "10101");
  289. list.Add(ds.Rows[0]["STORAGE_TYPE_NO"].ToString());
  290. list.Add(ds.Rows[0]["STORAGE_TYPE_NAME"].ToString());
  291. list.Add(this.UserInfo.GetUserName());
  292. list.Add(this.UserInfo.GetDeptid());
  293. list.Add(this.UserInfo.GetDepartment());
  294. list.Add(PipeManageClass.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
  295. list.Add(PipeManageClass.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
  296. list.Add(UserInfo.GetUserOrder());
  297. list.Add(UserInfo.GetUserGroup());
  298. MilPlanEntity milPlan = (MilPlanEntity)uRow.ListObject;
  299. String milPlanTity = JSONFormat.Format(milPlan);
  300. CoreClientParam ccp = new CoreClientParam();
  301. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  302. ccp.MethodName = "offLineJZ";
  303. ccp.ServerParams = new object[] { milPlanTity, TxtTotalNum.Text.ToString().Replace("_", ""), this.UserInfo.GetUserName(), this.UserInfo.GetUserGroup(), this.UserInfo.GetUserOrder(), "1", list, strInbound, strInMemo, plinCode };
  304. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  305. if (ccp.ReturnCode != -1)
  306. {
  307. if (ccp.ReturnInfo.Equals("离线成功!"))
  308. {
  309. Query();
  310. MessageUtil.ShowTips(ccp.ReturnInfo);
  311. }
  312. else
  313. {
  314. MessageUtil.ShowTips(ccp.ReturnInfo);
  315. }
  316. }
  317. }
  318. public void offlineBack()
  319. {
  320. if (string.IsNullOrEmpty(heatno) || ultraRack.ActiveRow == null)
  321. {
  322. MessageBox.Show("未选择计划行,不允许进行下线回退操作", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  323. return;
  324. }
  325. if (!string.IsNullOrEmpty(this.TxtOfflineNumhas.Text.ToString().Replace("_", "")))
  326. {
  327. if (int.Parse(this.TxtOfflineNumhas.Text.ToString().Replace("_","")) == 0)
  328. {
  329. MessageBox.Show("已下线支数为0,不允许进行下线回退操作", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  330. return;
  331. }
  332. }
  333. else
  334. {
  335. MessageBox.Show("未进行下线操作,不允许进行下线回退", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  336. return;
  337. }
  338. int offlinehas=int.Parse(this.TxtOfflineNumhas.Text.ToString().Replace("_",""));
  339. if (!string.IsNullOrEmpty(this.TxtOfflinNumBack.Text.ToString().Replace("_", "")))
  340. {
  341. if (int.Parse(this.TxtOfflinNumBack.Text.ToString().Replace("_", "")) - offlinehas > 0)
  342. {
  343. MessageBox.Show("输入的下线回退支数超过了已下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  344. return;
  345. }
  346. }
  347. else
  348. {
  349. MessageBox.Show("未输入下线回退支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  350. return;
  351. }
  352. UltraGridRow uRow = this.ultraRack.ActiveRow;
  353. MilPlanEntity milPlan = (MilPlanEntity)uRow.ListObject;
  354. String milPlanTity = JSONFormat.Format(milPlan);
  355. CoreClientParam ccp = new CoreClientParam();
  356. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  357. ccp.MethodName = "newStaOfflineBack";
  358. ccp.ServerParams = new object[] { milPlanTity,this.TxtOfflinNumBack.Text.ToString().Replace("_", ""),"JZ" };
  359. ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
  360. if (ccp.ReturnCode != -1)
  361. {
  362. if (ccp.ReturnInfo.Equals("回退成功!"))
  363. {
  364. Query();
  365. MessageUtil.ShowTips(ccp.ReturnInfo);
  366. }
  367. else
  368. {
  369. MessageUtil.ShowTips(ccp.ReturnInfo);
  370. }
  371. }
  372. }
  373. /// <summary>
  374. /// 是否要插入下线实绩表
  375. /// </summary>
  376. /// <returns></returns>
  377. public bool isInsert()
  378. {
  379. bool result = true;
  380. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.isInsertOfflineResult", new object[] { heatno, process, proPlanId, gxPlanNo }, this.ob);
  381. if (dt.Rows.Count > 0)
  382. {
  383. result = false;
  384. }
  385. return result;
  386. }
  387. //查询
  388. private void FrmStraighteningOffLine_Load(object sender, EventArgs e)
  389. {
  390. Query();
  391. }
  392. private void FrmStraighteningOffLine_FormClosed(object sender, FormClosedEventArgs e)
  393. {
  394. this.DialogResult = DialogResult.OK;
  395. }
  396. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  397. {
  398. switch (e.Tool.Key)
  399. {
  400. case "doquery":
  401. Query();
  402. break;
  403. case "offline":
  404. Offline();
  405. break;
  406. case "offlineall":
  407. offlineAll();
  408. break;
  409. case "OfflineBack":
  410. offlineBack();
  411. break;
  412. case "Close":
  413. this.Close();
  414. break;
  415. }
  416. }
  417. private void TxtOfflineNumhas_TextChanged(object sender, EventArgs e)
  418. {
  419. if (int.Parse(TxtOfflineNumhas.Text.ToString()) > 0)
  420. {
  421. this.TxtOfflinNumBack.Enabled = true;
  422. }
  423. else
  424. {
  425. this.TxtOfflinNumBack.Enabled = false;
  426. }
  427. }
  428. }
  429. }