BaseMandrelSpec.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  11. using Core.Mes.Client.Comm.Control;
  12. using Core.StlMes.Client.PlnSaleOrd.工序排产.entity;
  13. using Core.Mes.Client.Comm.Format;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Core.Mes.Client.Comm.Server;
  16. using Infragistics.Win.UltraWinGrid;
  17. namespace Core.StlMes.Client.PlnSaleOrd.工序排产.control
  18. {
  19. public partial class BaseMandrelSpec : UserControl
  20. {
  21. private string id = "";
  22. private OpeBase ob = null;
  23. public OpeBase Ob
  24. {
  25. get { return ob; }
  26. set { ob = value; }
  27. }
  28. private string creName = "";
  29. /// <summary>
  30. /// 创建人
  31. /// </summary>
  32. public string CreName
  33. {
  34. get { return creName; }
  35. set { creName = value; }
  36. }
  37. /// <summary>
  38. /// 芯棒编码
  39. /// </summary>
  40. private string mandrelId = "";
  41. /// <summary>
  42. /// 芯棒编码
  43. /// </summary>
  44. public string MandrelId
  45. {
  46. get { return mandrelId; }
  47. set { mandrelId = value; }
  48. }
  49. /// <summary>
  50. /// 芯棒直径
  51. /// </summary>
  52. private string mandDimater = "";
  53. /// <summary>
  54. /// 芯棒直径
  55. /// </summary>
  56. public string MandDimater
  57. {
  58. get { return mandDimater; }
  59. set { mandDimater = value;}
  60. }
  61. public BaseMandrelSpec(System.Windows.Forms.Control container, OpeBase ob)
  62. {
  63. InitializeComponent();
  64. this.ob = ob;
  65. container.Controls.Add(this);
  66. this.Dock = DockStyle.Fill;
  67. }
  68. /// <summary>
  69. /// 初始化
  70. /// </summary>
  71. public void Init()
  72. {
  73. //BaseHelper.NitializeDropDownBox(txtDimater, "com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.initDimater", new Object[] { }, "DIAMETER_MANDREL", "MANDREL_ID", false, ob);
  74. PlanHelper.InitDropPline("D", "", txtPline1, this.ob);
  75. PlanHelper.InitDropPline("D", "", txtPline2, this.ob);
  76. PlanHelper.InitDropGroup("4047", txtPassModel, this.ob);
  77. BaseHelper.setOtherColumnReadOnly(entityGridMandrel, null);
  78. BaseHelper.InitCellPosition(entityGridMandrel, new string[] { "MinD", "MaxD", "MinH", "MaxH", "DiameterMandrel", "PassName", "LenSingerBill" });
  79. ClsBaseInfo.SetComboItemHeight(txtDimater);
  80. ClsBaseInfo.SetComboItemHeight(txtPassModel);
  81. ClsBaseInfo.SetComboItemHeight(txtPline2);
  82. ClsBaseInfo.SetComboItemHeight(txtPline1);
  83. Query();
  84. }
  85. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  86. {
  87. switch (e.Tool.Key)
  88. {
  89. //case "Query"://查询
  90. // Query();
  91. // break;
  92. case "Add"://新增
  93. Add();
  94. break;
  95. case "Update"://修改 q
  96. DoUpdate();
  97. break;
  98. case "Delete"://删除
  99. Delete();
  100. break;
  101. case "Export": //导出
  102. GridHelper.ulGridToExcel(entityGridMandrel, "芯棒产线适用规格信息");
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. public void Query()
  109. {
  110. txtDimater.Text = MandDimater.ToString();
  111. //string plineCode = "";
  112. //if (chcPline.Checked && txtPline1.Value != null)
  113. //{ plineCode = txtPline1.Value.ToString(); }
  114. List<ComBaseMandrelSpecEntity> listSource = EntityHelper.GetData<ComBaseMandrelSpecEntity>
  115. ("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.query1", new object[] { mandrelId }, ob);
  116. comBaseMandrelSpecEntityBindingSource.DataSource = listSource;
  117. if (!id.Equals("") && entityGridMandrel.Rows.Count > 0)
  118. {
  119. foreach (UltraGridRow ugr in entityGridMandrel.Rows)
  120. {
  121. if (ugr.Cells["RelationId"].Text.Equals(id))
  122. {
  123. ugr.Activate();
  124. break;
  125. }
  126. }
  127. }
  128. id = "";
  129. }
  130. private bool CheckParams()
  131. {
  132. if (txtPline2.Value == null)
  133. {
  134. MessageUtil.ShowWarning("请选择产线!", txtPline2);
  135. return false;
  136. }
  137. if (txtPassModel.Value == null)
  138. {
  139. MessageUtil.ShowWarning("请选择孔型!", txtPassModel);
  140. return false;
  141. }
  142. if (txtDimater.Value == null)
  143. {
  144. MessageUtil.ShowWarning("请选择芯棒直径!", txtDimater);
  145. return false;
  146. }
  147. if (txtMinD == null || txtMinD.Value.ToString().Length == 0)
  148. {
  149. MessageUtil.ShowWarning("请输入外径最小值!", txtMinD);
  150. return false;
  151. }
  152. if (txtMaxD == null || txtMaxD.Value.ToString().Length == 0)
  153. {
  154. MessageUtil.ShowWarning("请输入外径最大值!", txtMaxD);
  155. return false;
  156. }
  157. if (txtMinH == null || txtMinH.Value.ToString().Length == 0)
  158. {
  159. MessageUtil.ShowWarning("请输入壁厚最小值!", txtMinH);
  160. return false;
  161. }
  162. if (txtMaxH == null || txtMaxH.Value.ToString().Length == 0)
  163. {
  164. MessageUtil.ShowWarning("请输入壁厚最大值!", txtMaxH);
  165. return false;
  166. }
  167. //if (numLenSinger == null || numLenSinger.Value.ToString().Length == 0)
  168. //{
  169. // MessageUtil.ShowWarning("请输入单倍坯最长!", txtMaxH);
  170. // return false;
  171. //}
  172. double minD = Convert.ToDouble(txtMinD.Value.ToString());
  173. double maxD = Convert.ToDouble(txtMaxD.Value.ToString());
  174. if (minD > maxD)
  175. {
  176. MessageUtil.ShowWarning("外径最小值不能大于外径最大值!", txtMinD);
  177. return false;
  178. }
  179. double minH = Convert.ToDouble(txtMinH.Value.ToString());
  180. double maxH = Convert.ToDouble(txtMaxH.Value.ToString());
  181. if (minH > maxH)
  182. {
  183. MessageUtil.ShowWarning("壁厚最小值不能大于壁厚最大值!", txtMinH);
  184. return false;
  185. }
  186. return true;
  187. }
  188. private void Add()
  189. {
  190. if (!CheckParams())
  191. {
  192. return;
  193. }
  194. ComBaseMandrelSpecEntity entity = new ComBaseMandrelSpecEntity();
  195. string plineCode = txtPline2.Value.ToString();
  196. string plineName = txtPline2.Text.Trim();
  197. string passCode = txtPassModel.Value.ToString();
  198. string passName = txtPassModel.Text.Trim();
  199. string dimaterId = MandrelId.ToString();
  200. string dimater = txtDimater.Text;
  201. string memo = txtMemo.Text.Trim();
  202. string minD = txtMinD.Value.ToString();
  203. string maxD = txtMaxD.Value.ToString();
  204. string minH = txtMinH.Value.ToString();
  205. string maxH = txtMaxH.Value.ToString();
  206. string lenSinger = numLenSinger.Value.ToString();
  207. entity.CreateName = creName;
  208. entity.DiameterMandrel = (decimal?)Convert.ToDouble(dimater);
  209. entity.MandrelId = dimaterId;
  210. entity.MaxD = (decimal?)Convert.ToDouble(maxD);
  211. entity.MinD = (decimal?)Convert.ToDouble(minD);
  212. entity.MaxH = (decimal?)Convert.ToDouble(maxH);
  213. entity.MinH = (decimal?)Convert.ToDouble(minH);
  214. entity.PlineCode = plineCode;
  215. entity.PlineName = plineName;
  216. entity.PassCode = passCode;
  217. entity.PassName = passName;
  218. entity.Memo = memo;
  219. entity.LenSingerBill = lenSinger;
  220. //if (double.Parse(passName)<=double.Parse(dimater)){
  221. // MessageUtil.ShowTips("孔型不能小于等于芯棒直径!");
  222. // return;
  223. //}
  224. if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No)
  225. {
  226. return;
  227. }
  228. string jsonStr = JSONFormat.Format(entity);
  229. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.add", new object[] { jsonStr }, ob);
  230. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  231. else
  232. {
  233. MessageUtil.ShowWarning("新增成功!", entityGridMandrel);
  234. Query();
  235. }
  236. }
  237. private void DoUpdate()
  238. {
  239. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  240. if (ugr == null)
  241. {
  242. MessageUtil.ShowWarning("请选择要修改的记录!", entityGridMandrel);
  243. return;
  244. }
  245. if (!CheckParams())
  246. {
  247. return;
  248. }
  249. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  250. string plineCode = txtPline2.Value.ToString();
  251. string plineName = txtPline2.Text.Trim();
  252. string passCode = txtPassModel.Value.ToString();
  253. string passName = txtPassModel.Text.Trim();
  254. string dimaterId = MandrelId.ToString();
  255. string dimater = txtDimater.Text;
  256. string memo = txtMemo.Text.Trim();
  257. string minD = txtMinD.Value.ToString();
  258. string maxD = txtMaxD.Value.ToString();
  259. string minH = txtMinH.Value.ToString();
  260. string maxH = txtMaxH.Value.ToString();
  261. string lenSinger = numLenSinger.Value.ToString();
  262. entity.UpdateName = creName;
  263. entity.DiameterMandrel = (decimal?)Convert.ToDouble(dimater);
  264. entity.MandrelId = dimaterId;
  265. entity.MaxD = (decimal?)Convert.ToDouble(maxD);
  266. entity.MinD = (decimal?)Convert.ToDouble(minD);
  267. entity.MaxH = (decimal?)Convert.ToDouble(maxH);
  268. entity.MinH = (decimal?)Convert.ToDouble(minH);
  269. entity.PlineCode = plineCode;
  270. entity.PlineName = plineName;
  271. entity.PassCode = passCode;
  272. entity.PassName = passName;
  273. entity.Memo = memo;
  274. entity.LenSingerBill = lenSinger;
  275. //if (double.Parse(passName) <= double.Parse(dimater))
  276. //{
  277. // MessageUtil.ShowTips("孔型不能小于等于芯棒直径!");
  278. // return;
  279. //}
  280. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No)
  281. {
  282. return;
  283. }
  284. id = entity.MandrelId;
  285. string jsonStr = JSONFormat.Format(entity);
  286. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.update", new object[] { jsonStr }, ob);
  287. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  288. else
  289. {
  290. MessageUtil.ShowWarning("修改成功!", entityGridMandrel);
  291. Query();
  292. }
  293. }
  294. private void Delete()
  295. {
  296. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  297. if (ugr == null)
  298. {
  299. MessageUtil.ShowWarning("请选择要删除的记录!", entityGridMandrel);
  300. return;
  301. }
  302. if (!CheckParams()) { return; }
  303. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  304. string jsonStr = JSONFormat.Format(entity);
  305. if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No)
  306. {
  307. return;
  308. }
  309. int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.delete", new object[] { jsonStr }, ob);
  310. if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; }
  311. else
  312. {
  313. MessageUtil.ShowWarning("删除成功!", entityGridMandrel);
  314. Query();
  315. }
  316. }
  317. private void txtPline2_ValueChanged(object sender, EventArgs e)
  318. {
  319. if (txtPline2.Value == null)
  320. {
  321. txtPassModel.Clear();
  322. return;
  323. }
  324. BaseHelper.NitializeDropDownBox(txtPassModel, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPassModel", new Object[] { txtPline2.Value.ToString() }, "PASS_NAME", "PASS_CODE", false, ob);
  325. }
  326. private void chcPline_CheckedChanged(object sender, EventArgs e)
  327. {
  328. if (chcPline.Checked) { txtPline1.ReadOnly = false; } else { txtPline1.ReadOnly = true; }
  329. }
  330. private void entityGridMandrel_AfterRowActivate(object sender, EventArgs e)
  331. {
  332. UltraGridRow ugr = entityGridMandrel.ActiveRow;
  333. if (ugr == null)
  334. {
  335. txtPline2.Value = "";
  336. txtPassModel.Value = "";
  337. //txtDimater.Value = entity.MandrelId;
  338. txtMemo.Value = "";
  339. txtMinD.Value = 0.00;
  340. txtMinH.Value = 0.00;
  341. txtMaxD.Value = 0.00;
  342. txtMaxH.Value = 0.00;
  343. numLenSinger.Value = 0.00;
  344. return;
  345. }
  346. ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject;
  347. txtPline2.Value = entity.PlineCode;
  348. txtPassModel.Value = entity.PassCode;
  349. //txtDimater.Value = entity.MandrelId;
  350. txtMemo.Value = entity.Memo;
  351. txtMinD.Value = entity.MinD;
  352. txtMinH.Value = entity.MinH;
  353. txtMaxD.Value = entity.MaxD;
  354. txtMaxH.Value = entity.MaxH;
  355. if (entity.LenSingerBill.Equals(""))
  356. {
  357. numLenSinger.Value = 0;
  358. }
  359. else
  360. {
  361. numLenSinger.Value = entity.LenSingerBill;
  362. }
  363. }
  364. private void BaseMandrelSpec_Load(object sender, EventArgs e)
  365. {
  366. Init();
  367. }
  368. }
  369. }