FrmPlnBasePlineLz.cs 8.3 KB

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