FrmBaseDeviation.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. namespace Core.StlMes.Client.PlnSaleOrd.炼钢计划
  15. {
  16. public partial class FrmBaseDeviation : FrmBase
  17. {
  18. public FrmBaseDeviation()
  19. {
  20. InitializeComponent();
  21. }
  22. private void FrmBaseDeviation_Load(object sender, EventArgs e)
  23. {
  24. SteelHelper.InitPline(comPlineA, "A", this.ob);
  25. }
  26. public override void ToolBar_Click(object sender, string ToolbarKey)
  27. {
  28. switch (ToolbarKey.Trim())
  29. {
  30. case "Query":
  31. Query();
  32. break;
  33. case "Add":
  34. Add();
  35. break;
  36. case "Update":
  37. Update();
  38. break;
  39. case "Delete":
  40. Delete();
  41. break;
  42. case "Close":
  43. this.Close();
  44. break;
  45. default:
  46. break;
  47. }
  48. }
  49. /// <summary>
  50. /// 查询
  51. /// </summary>
  52. private void Query()
  53. {
  54. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseDeviation.query", new object[] { }, ob);
  55. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  56. GridHelper.RefreshAndAutoSize(ultraGrid1);
  57. }
  58. private void Add()
  59. {
  60. string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString();
  61. if (plineCode.Equals(""))
  62. {
  63. MessageUtil.ShowWarning("请选择电炉产线!");
  64. return;
  65. }
  66. string plineName = comPlineA.Text;
  67. string planRoute = ComplanRoute.Text;
  68. if (planRoute.Equals(""))
  69. {
  70. MessageUtil.ShowWarning("请选择工艺路径!");
  71. return;
  72. }
  73. string proPoint = comProPoint.Text;
  74. if (proPoint.Equals(""))
  75. {
  76. MessageUtil.ShowWarning("请选择工序点!");
  77. return;
  78. }
  79. bool flag = ChcSpec(plineCode, planRoute, proPoint);
  80. if (flag)
  81. {
  82. MessageUtil.ShowWarning("电炉产线:" + plineName + "在工艺路径:" + planRoute + "下已经存在工序点:" + proPoint + ",不能新增!");
  83. return;
  84. }
  85. string txtdeviNo1 = txtDeviNo1.Value == null ? "0" : txtDeviNo1.Value.ToString();
  86. string txtdeviUn1 = txtDeviUn1.Value == null ? "0" : txtDeviUn1.Value.ToString();
  87. string txtdeviNo2 = txtDeviNo2.Value == null ? "0" : txtDeviNo2.Value.ToString();
  88. string txtdeviUn2 = txtDeviUn2.Value == null ? "0" : txtDeviUn2.Value.ToString();
  89. if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  90. {
  91. return;
  92. }
  93. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseDeviation.add", new string[] { plineCode, plineName,
  94. planRoute, proPoint, txtdeviNo1,
  95. txtdeviUn1, txtdeviNo2, txtdeviUn2, UserInfo.GetUserName()}, this.ob);
  96. MessageUtil.ShowTips("新增成功!");
  97. Query();
  98. if (ultraGrid1.Rows.Count > 0)
  99. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  100. {
  101. if (ugr.Cells["PLINE_CODE"].Value.ToString().Equals(plineCode) && ugr.Cells["PLAN_ROUTE"].Value.ToString().Equals(planRoute) && ugr.Cells["PRO_POINT"].Value.ToString().Equals(proPoint))
  102. {
  103. ugr.Activate();
  104. }
  105. }
  106. }
  107. private void Delete()
  108. {
  109. UltraGridRow ugr = ultraGrid1.ActiveRow;
  110. if (ugr == null)
  111. {
  112. MessageUtil.ShowWarning("请选择要删除的记录!");
  113. return;
  114. }
  115. string PlineCodeB = ugr.Cells["PLINE_CODE"].Text.Trim();
  116. string PlineNameB = ugr.Cells["PLINE_NAME"].Text.Trim();
  117. string planRoute = ugr.Cells["PLAN_ROUTE"].Text.Trim();
  118. string proPoint = ugr.Cells["PRO_POINT"].Text.Trim();
  119. if (MessageUtil.ShowYesNoAndQuestion("是否删除电炉:" + PlineNameB + "工艺路径:" + planRoute + "下的工序点:" + proPoint + "基础数据?(此删除不可恢复)") == DialogResult.No)
  120. {
  121. return;
  122. }
  123. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseDeviation.delete", new string[] { PlineCodeB, planRoute, proPoint }, this.ob);
  124. MessageUtil.ShowTips("删除成功!");
  125. Query();
  126. }
  127. private void Update()
  128. {
  129. string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString();
  130. if (plineCode.Equals(""))
  131. {
  132. MessageUtil.ShowWarning("请选择电炉产线!");
  133. return;
  134. }
  135. string plineName = comPlineA.Text;
  136. string planRoute = ComplanRoute.Text;
  137. if (planRoute.Equals(""))
  138. {
  139. MessageUtil.ShowWarning("请选择工艺路径!");
  140. return;
  141. }
  142. string proPoint = comProPoint.Text;
  143. if (proPoint.Equals(""))
  144. {
  145. MessageUtil.ShowWarning("请选择工序点!");
  146. return;
  147. }
  148. bool flag = ChcSpec(plineCode, planRoute, proPoint);
  149. if (!flag)
  150. {
  151. MessageUtil.ShowWarning("电炉产线:" + plineName + "在工艺路径:" + planRoute + "下已经存在工序点:" + proPoint + ",不能修改!");
  152. return;
  153. }
  154. string txtdeviNo1 = txtDeviNo1.Value == null ? "0" : txtDeviNo1.Value.ToString();
  155. string txtdeviUn1 = txtDeviUn1.Value == null ? "0" : txtDeviUn1.Value.ToString();
  156. string txtdeviNo2 = txtDeviNo2.Value == null ? "0" : txtDeviNo2.Value.ToString();
  157. string txtdeviUn2 = txtDeviUn2.Value == null ? "0" : txtDeviUn2.Value.ToString();
  158. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  159. {
  160. return;
  161. }
  162. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseDeviation.update", new string[] { plineCode, planRoute, proPoint, txtdeviNo1,
  163. txtdeviUn1, txtdeviNo2, txtdeviUn2, UserInfo.GetUserName()}, this.ob);
  164. MessageUtil.ShowTips("修改成功!");
  165. Query();
  166. if (ultraGrid1.Rows.Count > 0)
  167. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  168. {
  169. if (ugr.Cells["PLINE_CODE"].Value.ToString().Equals(plineCode) && ugr.Cells["PLAN_ROUTE"].Value.ToString().Equals(planRoute) && ugr.Cells["PRO_POINT"].Value.ToString().Equals(proPoint))
  170. {
  171. ugr.Activate();
  172. }
  173. }
  174. }
  175. bool ChcSpec(string plineCode, string planRoute, string comProPoint)
  176. {
  177. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseDeviation.checkPline", new string[] { plineCode, planRoute, comProPoint }, this.ob);
  178. if (dt == null || dt.Rows.Count == 0)
  179. {
  180. return false;
  181. }
  182. else
  183. {
  184. if (dt.Rows[0][0].ToString().Equals("1"))
  185. {
  186. return true;
  187. }
  188. else
  189. {
  190. return false;
  191. }
  192. }
  193. }
  194. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  195. {
  196. UltraGridRow ugr = ultraGrid1.ActiveRow;
  197. if (ugr == null) return;
  198. comPlineA.Value = ugr.Cells["PLINE_CODE"].Value.ToString();
  199. ComplanRoute.Text = ugr.Cells["PLAN_ROUTE"].Value.ToString();
  200. comProPoint.Text = ugr.Cells["PRO_POINT"].Value.ToString();
  201. txtDeviNo1.Value = ugr.Cells["DEVIATION_NO1"].Value.ToString();
  202. txtDeviUn1.Value = ugr.Cells["DEVIATION_UN1"].Value.ToString();
  203. txtDeviNo2.Value = ugr.Cells["DEVIATION_NO2"].Value.ToString();
  204. txtDeviUn2.Value = ugr.Cells["DEVIATION_NU2"].Value.ToString();
  205. }
  206. private void comProPoint_ValueChanged(object sender, EventArgs e)
  207. {
  208. //string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString();
  209. //string plineName = comPlineA.Text;
  210. //string planRoute = ComplanRoute.Text;
  211. //string proPoint = comProPoint.Text;
  212. //if (plineName.Equals("一炼钢电炉"))
  213. //{
  214. // if (planRoute.Equals("ELC"))
  215. // {
  216. // if (proPoint.Equals("LF"))
  217. // {
  218. // txtDeviNo1.Enabled = true;
  219. // txtDeviUn1.Enabled = true;
  220. // txtDeviNo2.Enabled = true;
  221. // txtDeviUn2.Enabled = true;
  222. // }
  223. // else
  224. // {
  225. // txtDeviNo1.Enabled = false;
  226. // txtDeviUn1.Enabled = false;
  227. // txtDeviNo2.Enabled = false;
  228. // txtDeviUn2.Enabled = false;
  229. // }
  230. // }
  231. // else
  232. // {
  233. // txtDeviNo1.Enabled = true;
  234. // txtDeviUn1.Enabled = true;
  235. // txtDeviNo2.Enabled = true;
  236. // txtDeviUn2.Enabled = true;
  237. // }
  238. //}
  239. //else if (plineName.Equals("二炼钢电炉"))
  240. //{
  241. // if (planRoute.Equals("ELC"))
  242. // {
  243. // if (proPoint.Equals("LF"))
  244. // {
  245. // txtDeviNo1.Enabled = true;
  246. // txtDeviUn1.Enabled = true;
  247. // txtDeviNo2.Enabled = true;
  248. // txtDeviUn2.Enabled = true;
  249. // }
  250. // else
  251. // {
  252. // txtDeviNo1.Enabled = false;
  253. // txtDeviUn1.Enabled = false;
  254. // txtDeviNo2.Enabled = false;
  255. // txtDeviUn2.Enabled = false;
  256. // }
  257. // }
  258. // else
  259. // {
  260. // txtDeviNo1.Enabled = true;
  261. // txtDeviUn1.Enabled = true;
  262. // txtDeviNo2.Enabled = true;
  263. // txtDeviUn2.Enabled = true;
  264. // }
  265. //}
  266. //else if (plineName.Equals("三炼钢电炉"))
  267. //{
  268. // if (planRoute.Equals("ELC"))
  269. // {
  270. // if (proPoint.Equals("LF"))
  271. // {
  272. // txtDeviNo1.Enabled = true;
  273. // txtDeviUn1.Enabled = true;
  274. // txtDeviNo2.Enabled = true;
  275. // txtDeviUn2.Enabled = true;
  276. // }
  277. // else
  278. // {
  279. // txtDeviNo1.Enabled = false;
  280. // txtDeviUn1.Enabled = false;
  281. // txtDeviNo2.Enabled = false;
  282. // txtDeviUn2.Enabled = false;
  283. // }
  284. // }
  285. // else
  286. // {
  287. // txtDeviNo1.Enabled = true;
  288. // txtDeviUn1.Enabled = true;
  289. // txtDeviNo2.Enabled = true;
  290. // txtDeviUn2.Enabled = true;
  291. // }
  292. //}
  293. }
  294. }
  295. }