FrmPlnBasePlineLg.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Format;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  14. using Core.StlMes.Client.PlnSaleOrd.炼钢计划;
  15. using Core.StlMes.Client.PlnSaleOrd.炼钢计划.entity;
  16. using CoreFS.CA06;
  17. using Infragistics.Win;
  18. using Infragistics.Win.UltraWinEditors;
  19. using Infragistics.Win.UltraWinGrid;
  20. namespace Core.StlMes.Client.PlnSaleOrd
  21. {
  22. public partial class FrmPlnBasePlineLg : FrmBase
  23. {
  24. public FrmPlnBasePlineLg()
  25. {
  26. InitializeComponent();
  27. }
  28. private void FrmPlnBasePlineLg_Load(object sender, EventArgs e)
  29. {
  30. EntityHelper.ShowGridCaption<PlnBasePlineLgEntity>(ultraGridBaseLg.DisplayLayout.Bands[0]);
  31. BaseHelper.setOtherColumnReadOnly(ultraGridBaseLg, new string[] { "" });
  32. BaseHelper.InitCellPosition(ultraGridBaseLg, new string[] { "EfMaxLife", "StdOutWt", "EfWtLeft", "StdWtEnd", "OutWtMax", "OutWtMin", "EfAgeNow" });
  33. SteelHelper.InitPline(comPlineA, "A", this.ob);
  34. SteelHelper.InitProcess(comProcess, "A", this.ob);
  35. }
  36. public override void ToolBar_Click(object sender, string ToolbarKey)
  37. {
  38. switch (ToolbarKey.Trim())
  39. {
  40. case "Query":
  41. Query();
  42. break;
  43. case "Add":
  44. Add();
  45. break;
  46. case "Update":
  47. Update();
  48. break;
  49. case "Delete":
  50. Delete();
  51. break;
  52. case "Close":
  53. this.Close();
  54. break;
  55. default:
  56. break;
  57. }
  58. }
  59. private void Query()
  60. {
  61. List<PlnBasePlineLgEntity> listSource = EntityHelper.GetData<PlnBasePlineLgEntity>
  62. ("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.query", new object[] { }, ob);
  63. plnBasePlineLgEntityBindingSource.DataSource = listSource;
  64. }
  65. private void Add()
  66. {
  67. string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString();
  68. if (plineCode.Equals(""))
  69. {
  70. MessageUtil.ShowWarning("请选择电炉产线!");
  71. return;
  72. }
  73. string plineName = comPlineA.Text;
  74. bool flag = ChcSpec(plineCode);
  75. if (flag)
  76. {
  77. MessageUtil.ShowWarning("电炉产线:" + plineName + "已经存在,不能新增!");
  78. return;
  79. }
  80. string proceeCode = comProcess.Value == null ? "" : comProcess.Value.ToString();
  81. string processDesc = comProcess.Text;
  82. string schedulecode = txtCode.Text.Trim();
  83. string efMaxLife = txtMaxLife.Value == null ? "0" : txtMaxLife.Value.ToString();
  84. string efAgeNow = txtNowage.Value == null ? "0" : txtNowage.Value.ToString();
  85. string efWtLeft = txtLeft.Value == null ? "0" : txtLeft.Value.ToString();
  86. string stdOutWt = txtStandSteel.Value == null ? "0" : txtStandSteel.Value.ToString();
  87. string outWtMax = txtSteelMax.Value == null ? "0" : txtSteelMax.Value.ToString();
  88. string outWtMin = txtMinSteel.Value == null ? "0" : txtMinSteel.Value.ToString();
  89. if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  90. {
  91. return;
  92. }
  93. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.add", new string[] { plineCode, plineName,
  94. proceeCode, processDesc, efMaxLife,
  95. stdOutWt, efWtLeft, outWtMax, outWtMin,
  96. efAgeNow, UserInfo.GetUserName(), schedulecode}, this.ob);
  97. MessageUtil.ShowTips("新增成功!");
  98. Query();
  99. if (ultraGridBaseLg.Rows.Count > 0)
  100. foreach (UltraGridRow ugr in ultraGridBaseLg.Rows)
  101. {
  102. if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode))
  103. {
  104. ugr.Activate();
  105. }
  106. }
  107. }
  108. private void Delete()
  109. {
  110. UltraGridRow ugr = ultraGridBaseLg.ActiveRow;
  111. if (ugr == null)
  112. {
  113. MessageUtil.ShowWarning("请选择要删除的记录!");
  114. return;
  115. }
  116. string PlineCodeB = ugr.Cells["PlineCode"].Text.Trim();
  117. string PlineNameB = ugr.Cells["PlineName"].Text.Trim();
  118. if (MessageUtil.ShowYesNoAndQuestion("是否删除电炉:" + PlineNameB + "基础数据?(此删除不可恢复)") == DialogResult.No)
  119. {
  120. return;
  121. }
  122. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.delete", new string[] { PlineCodeB }, this.ob);
  123. MessageUtil.ShowTips("删除成功!");
  124. Query();
  125. }
  126. private void Update()
  127. {
  128. string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString();
  129. if (plineCode.Equals(""))
  130. {
  131. MessageUtil.ShowWarning("请选择电炉产线!");
  132. return;
  133. }
  134. string plineName = comPlineA.Text;
  135. bool flag = ChcSpec(plineCode);
  136. if (!flag)
  137. {
  138. MessageUtil.ShowWarning("电炉产线:" + plineName + "不存在,不能修改!");
  139. return;
  140. }
  141. string proceeCode = comProcess.Value == null ? "" : comProcess.Value.ToString();
  142. string processDesc = comProcess.Text;
  143. string schedulecode = txtCode.Text.Trim();
  144. string efMaxLife = txtMaxLife.Value == null ? "0" : txtMaxLife.Value.ToString();
  145. string efAgeNow = txtNowage.Value == null ? "0" : txtNowage.Value.ToString();
  146. string efWtLeft = txtLeft.Value == null ? "0" : txtLeft.Value.ToString();
  147. string stdOutWt = txtStandSteel.Value == null ? "0" : txtStandSteel.Value.ToString();
  148. string outWtMax = txtSteelMax.Value == null ? "0" : txtSteelMax.Value.ToString();
  149. string outWtMin = txtMinSteel.Value == null ? "0" : txtMinSteel.Value.ToString();
  150. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  151. {
  152. return;
  153. }
  154. ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.update", new string[] { plineCode, plineName,
  155. proceeCode, processDesc, efMaxLife,
  156. stdOutWt, efWtLeft, outWtMax, outWtMin,
  157. efAgeNow, UserInfo.GetUserName(), schedulecode }, this.ob);
  158. MessageUtil.ShowTips("修改成功!");
  159. Query();
  160. if (ultraGridBaseLg.Rows.Count > 0)
  161. foreach (UltraGridRow ugr in ultraGridBaseLg.Rows)
  162. {
  163. if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode))
  164. {
  165. ugr.Activate();
  166. }
  167. }
  168. }
  169. bool ChcSpec(string plineCode)
  170. {
  171. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.checkPline", new string[] { plineCode }, this.ob);
  172. if (dt == null || dt.Rows.Count == 0)
  173. {
  174. return false;
  175. }
  176. else
  177. {
  178. if (dt.Rows[0][0].ToString().Equals("1"))
  179. {
  180. return true;
  181. }
  182. else
  183. {
  184. return false;
  185. }
  186. }
  187. }
  188. private void ultraGridBaseLg_AfterRowActivate(object sender, EventArgs e)
  189. {
  190. UltraGridRow ugr = ultraGridBaseLg.ActiveRow;
  191. if (ugr == null)
  192. {
  193. return;
  194. }
  195. PlnBasePlineLgEntity entity = (PlnBasePlineLgEntity)ugr.ListObject;
  196. comPlineA.Value = entity.PlineCode;
  197. comProcess.Value = entity.ProcessCode;
  198. txtCode.Value = entity.ScheduleCode;
  199. txtMaxLife.Value = entity.EfMaxLife;
  200. txtNowage.Value = entity.EfAgeNow;
  201. txtLeft.Value = entity.EfWtLeft;
  202. txtStandSteel.Value = entity.StdOutWt;
  203. txtSteelMax.Value = entity.OutWtMax;
  204. txtMinSteel.Value = entity.OutWtMin;
  205. }
  206. }
  207. }