FrmBaseMandrelSpec.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  6. using Core.StlMes.Client.PlnSaleOrd.工序排产;
  7. using Core.StlMes.Client.PlnSaleOrd.工序排产.entity;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinGrid;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.PlnSaleOrd
  20. {
  21. public partial class FrmBaseMandrelSpec : FrmBase
  22. {
  23. private string id = "";
  24. public FrmBaseMandrelSpec()
  25. {
  26. InitializeComponent();
  27. }
  28. private void FrmBaseMandrelSpec_Load(object sender, EventArgs e)
  29. {
  30. BaseHelper.NitializeDropDownBox(txtDimater, "com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.initDimater",new Object[]{}, "DIAMETER_MANDREL", "MANDREL_ID", false, ob);
  31. PlanHelper.InitDropPline("D", "", txtPline1, this.ob);
  32. PlanHelper.InitDropPline("D", "", txtPline2, this.ob);
  33. BaseHelper.setOtherColumnReadOnly(entityGridMandrel, null);
  34. BaseHelper.InitCellPosition(entityGridMandrel, new string[] { "MinD", "MaxD", "MinH", "MaxH", "DiameterMandrel", "PassName" });
  35. }
  36. public override void ToolBar_Click(object sender, string ToolbarKey)
  37. {
  38. base.ToolBar_Click(sender, ToolbarKey);
  39. switch (ToolbarKey)
  40. {
  41. case "Query"://查询
  42. Query();
  43. break;
  44. case "Add"://新增
  45. Add();
  46. break;
  47. case "Update"://修改 q
  48. Update();
  49. break;
  50. case "Delete"://删除
  51. Delete();
  52. break;
  53. case "Close"://关闭
  54. this.Close();
  55. break;
  56. case "Export": //导出
  57. GridHelper.ulGridToExcel(entityGridMandrel, "芯棒产线适用规格信息");
  58. break;
  59. default:
  60. break;
  61. }
  62. }
  63. private void Query()
  64. {
  65. string plineCode = "";
  66. if (chcPline.Checked && txtPline1.Value != null)
  67. { plineCode = txtPline1.Value.ToString(); }
  68. List<ComBaseMandrelSpecEntity> listSource = EntityHelper.GetData<ComBaseMandrelSpecEntity>
  69. ("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.query", new object[] { plineCode }, ob);
  70. comBaseMandrelSpecEntityBindingSource.DataSource = listSource;
  71. if (!id.Equals("") && entityGridMandrel.Rows.Count > 0)
  72. {
  73. foreach (UltraGridRow ugr in entityGridMandrel.Rows)
  74. {
  75. if (ugr.Cells["RelationId"].Text.Equals(id))
  76. {
  77. ugr.Activate();
  78. break;
  79. }
  80. }
  81. }
  82. id = "";
  83. }
  84. private bool CheckParams()
  85. {
  86. if (txtPline2.Value == null)
  87. {
  88. MessageUtil.ShowWarning("请选择产线!",txtPline2);
  89. return false;
  90. }
  91. if (txtPassModel.Value == null)
  92. {
  93. MessageUtil.ShowWarning("请选择孔型!", txtPassModel);
  94. return false;
  95. }
  96. if (txtDimater.Value == null)
  97. {
  98. MessageUtil.ShowWarning("请选择芯棒直径!", txtDimater);
  99. return false;
  100. }
  101. if (txtMinD == null || txtMinD.Value.ToString().Length == 0)
  102. {
  103. MessageUtil.ShowWarning("请输入外径最小值!", txtMinD);
  104. return false;
  105. }
  106. if (txtMaxD == null || txtMaxD.Value.ToString().Length == 0)
  107. {
  108. MessageUtil.ShowWarning("请输入外径最大值!", txtMaxD);
  109. return false;
  110. }
  111. if (txtMinH == null || txtMinH.Value.ToString().Length == 0)
  112. {
  113. MessageUtil.ShowWarning("请输入壁厚最小值!", txtMinH);
  114. return false;
  115. }
  116. if (txtMaxH == null || txtMaxH.Value.ToString().Length == 0)
  117. {
  118. MessageUtil.ShowWarning("请输入壁厚最大值!", txtMaxH);
  119. return false;
  120. }
  121. double minD = Convert.ToDouble(txtMinD.Value.ToString());
  122. double maxD = Convert.ToDouble(txtMaxD.Value.ToString());
  123. if (minD > maxD)
  124. {
  125. MessageUtil.ShowWarning("外径最小值不能大于外径最大值!", txtMinD);
  126. return false;
  127. }
  128. double minH = Convert.ToDouble(txtMinH.Value.ToString());
  129. double maxH = Convert.ToDouble(txtMaxH.Value.ToString());
  130. if (minH > maxH)
  131. {
  132. MessageUtil.ShowWarning("壁厚最小值不能大于壁厚最大值!", txtMinH);
  133. return false;
  134. }
  135. return true;
  136. }
  137. private void Add()
  138. {
  139. if (!CheckParams())
  140. {
  141. return;
  142. }
  143. ComBaseMandrelSpecEntity entity = new ComBaseMandrelSpecEntity();
  144. string plineCode = txtPline2.Value.ToString();
  145. string plineName = txtPline2.Text.Trim();
  146. string passCode = txtPassModel.Value.ToString();
  147. string passName = txtPassModel.Text.Trim();
  148. string dimaterId = txtDimater.Value.ToString();
  149. string dimater = txtDimater.Text;
  150. string memo = txtMemo.Text.Trim();
  151. string minD = txtMinD.Value.ToString();
  152. string maxD = txtMaxD.Value.ToString();
  153. string minH = txtMinH.Value.ToString();
  154. string maxH = txtMaxH.Value.ToString();
  155. entity.CreateName = UserInfo.GetUserName();
  156. entity.DiameterMandrel =(decimal?)Convert.ToDouble( dimater);
  157. entity.MandrelId = dimaterId;
  158. entity.MaxD = (decimal?)Convert.ToDouble(maxD);
  159. entity.MinD = (decimal?)Convert.ToDouble(minD);
  160. entity.MaxH = (decimal?)Convert.ToDouble(maxH);
  161. entity.MinH = (decimal?)Convert.ToDouble(minH);
  162. entity.PlineCode = plineCode;
  163. entity.PlineName = plineName;
  164. entity.PassCode = passCode;
  165. entity.PassName = passName;
  166. entity.Memo = memo;
  167. if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  168. {
  169. return;
  170. }
  171. string jsonStr = JSONFormat.Format(entity);
  172. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.add", new object[] { jsonStr }, ob);
  173. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  174. else
  175. {
  176. MessageUtil.ShowWarning("新增成功!", entityGridMandrel);
  177. Query();
  178. }
  179. }
  180. private void Update()
  181. {
  182. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  183. if (ugr == null)
  184. {
  185. MessageUtil.ShowWarning("请选择要修改的记录!", entityGridMandrel);
  186. return;
  187. }
  188. if (!CheckParams())
  189. {
  190. return;
  191. }
  192. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  193. string plineCode = txtPline2.Value.ToString();
  194. string plineName = txtPline2.Text.Trim();
  195. string passCode = txtPassModel.Value.ToString();
  196. string passName = txtPassModel.Text.Trim();
  197. string dimaterId = txtDimater.Value.ToString();
  198. string dimater = txtDimater.Text;
  199. string memo = txtMemo.Text.Trim();
  200. string minD = txtMinD.Value.ToString();
  201. string maxD = txtMaxD.Value.ToString();
  202. string minH = txtMinH.Value.ToString();
  203. string maxH = txtMaxH.Value.ToString();
  204. entity.UpdateName = UserInfo.GetUserName();
  205. entity.DiameterMandrel = (decimal?)Convert.ToDouble(dimater);
  206. entity.MandrelId = dimaterId;
  207. entity.MaxD = (decimal?)Convert.ToDouble(maxD);
  208. entity.MinD = (decimal?)Convert.ToDouble(minD);
  209. entity.MaxH = (decimal?)Convert.ToDouble(maxH);
  210. entity.MinH = (decimal?)Convert.ToDouble(minH);
  211. entity.PlineCode = plineCode;
  212. entity.PlineName = plineName;
  213. entity.PassCode = passCode;
  214. entity.PassName = passName;
  215. entity.Memo = memo;
  216. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  217. {
  218. return;
  219. }
  220. id = entity.MandrelId;
  221. string jsonStr = JSONFormat.Format(entity);
  222. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.update", new object[] { jsonStr }, ob);
  223. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  224. else
  225. {
  226. MessageUtil.ShowWarning("修改成功!", entityGridMandrel);
  227. Query();
  228. }
  229. }
  230. private void Delete()
  231. {
  232. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  233. if (ugr == null)
  234. {
  235. MessageUtil.ShowWarning("请选择要删除的记录!", entityGridMandrel);
  236. return;
  237. }
  238. if (!CheckParams()) { return; }
  239. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  240. string jsonStr = JSONFormat.Format(entity);
  241. if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No)
  242. {
  243. return;
  244. }
  245. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.delete", new object[] { jsonStr }, ob);
  246. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  247. else
  248. {
  249. MessageUtil.ShowWarning("删除成功!", entityGridMandrel);
  250. Query();
  251. }
  252. }
  253. private void txtPline2_ValueChanged(object sender, EventArgs e)
  254. {
  255. if (txtPline2.Value == null)
  256. {
  257. txtPassModel.Clear();
  258. return;
  259. }
  260. BaseHelper.NitializeDropDownBox(txtPassModel, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPassModel", new Object[] { txtPline2.Value.ToString() }, "PASS_NAME", "PASS_CODE", false, ob);
  261. }
  262. private void chcPline_CheckedChanged(object sender, EventArgs e)
  263. {
  264. if (chcPline.Checked) { txtPline1.ReadOnly = false; } else { txtPline1.ReadOnly = true; }
  265. }
  266. private void entityGridMandrel_AfterRowActivate(object sender, EventArgs e)
  267. {
  268. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  269. if (ugr == null)
  270. {
  271. return;
  272. }
  273. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  274. txtPline2.Value = entity.PlineCode;
  275. txtPassModel.Value = entity.PassCode;
  276. txtDimater.Value = entity.MandrelId;
  277. txtMemo.Value = entity.Memo;
  278. txtMinD.Value = entity.MinD;
  279. txtMinH.Value = entity.MinH;
  280. txtMaxD.Value = entity.MaxD;
  281. txtMaxH.Value = entity.MaxH;
  282. }
  283. }
  284. }