F_PC_1002.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1002.cs
  5. * 2.功能描述:新建、编辑模具档案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 新建、编辑模具档案
  25. /// </summary>
  26. public partial class F_PC_1002 : DKFormBase
  27. {
  28. #region 成员变量
  29. /// <summary>
  30. /// 模具ID
  31. /// </summary>
  32. private int _mouldID = 0;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PC_1002(int mouldID)
  39. {
  40. InitializeComponent();
  41. //this.txtWeight.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
  42. //this.txtCost.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
  43. //this.txtStandardGroutingNum.Number = new Dongke.WinForm.Controls.DNumber(6, 0);
  44. //txtOutputCount.Number = new Dongke.WinForm.Controls.DNumber(3, 0);
  45. this.txtWeight.Number = new Point(5, 2);
  46. this.txtCost.Number = new Point(5, 2);
  47. this.txtStandardGroutingNum.Number = new Point(6, 0);
  48. txtOutputCount.Number = new Point(3, 0);
  49. this._mouldID = mouldID;
  50. if (this._mouldID > 0)
  51. {
  52. this.Text = "编辑模具档案";
  53. this.txtBarcode.ReadOnly = true;
  54. this.scbGoods.EditReadOnly = true;
  55. this.scbGoods.Enabled = false;
  56. }
  57. else
  58. {
  59. this.Text = "新建模具档案";
  60. }
  61. }
  62. #endregion
  63. #region 事件处理
  64. /// <summary>
  65. /// 画面加载
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void F_PC_1002_Load(object sender, System.EventArgs e)
  70. {
  71. try
  72. {
  73. if (this._mouldID > 0)
  74. {
  75. chkAutoPrint.Checked = false;
  76. chkAutoPrint.Visible = false;
  77. txtMCount.Visible = false;
  78. lblMCount.Visible = false;
  79. }
  80. this.dtpPDate.Value = DateTime.Now;
  81. ClientRequestEntity cre = new ClientRequestEntity();
  82. cre.NameSpace = "FPC1002";
  83. cre.Name = "GetFPC1002LoadData";
  84. cre.Properties["MouldID"] = this._mouldID;
  85. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  86. if (sre == null)
  87. {
  88. this.Close();
  89. return;
  90. }
  91. this.ftcMouldType.DataSource = sre.Data.Tables["MouldType"];
  92. this.ftcSuppliers.DataSource = sre.Data.Tables["Suppliers"];
  93. this.CBMouldPlan.DataSource = sre.Data.Tables["Mouldplan"];
  94. if (this._mouldID > 0)
  95. {
  96. DataRow item = sre.Data.Tables["InfoData"].Rows[0];
  97. // 编辑
  98. this.txtBarcode.Text = item["MouldBarcode"].ToString();
  99. this.scbGoods.CheckedData = sre.Data.Tables["InfoData"];
  100. this.scbGoods.Text = item["GoodsCode"].ToString();
  101. this.ftcMouldType.InitValue(item["MouldTypeName"].ToString(), item["MouldType"]);
  102. this.ftcSuppliers.InitValue(item["SupplierName"].ToString(), item["materialsupplier"]);
  103. this.dtpPDate.Value = Convert.ToDateTime(item["ProductionDate"]);
  104. this.txtWeight.DataValue = Convert.ToDecimal(item["Weight"]);
  105. this.txtCost.DataValue = Convert.ToDecimal(item["Cost"]);
  106. this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
  107. this.txtOutputCount.DataValue = Convert.ToDecimal(item["OutputCount"]);
  108. this.txtRemarks.Text = item["Remarks"].ToString();
  109. this.dkUserInfo.Text = item["UserCode"].ToString();
  110. this.dkUserInfo.UserCode = item["UserCode"].ToString();
  111. this.dkUserInfo.UserID = Convert.ToInt32(item["UserID"]);
  112. this.txtStandardGroutingNum.ReadOnly = true;
  113. this.txtOutputCount.ReadOnly = true;
  114. this.CBMouldPlan.SelectedValue = item["MOULD_PLAN_ID"];
  115. this.CBMouldPlan.Enabled = false;
  116. if (!string.IsNullOrEmpty(item["MOULD_PLAN_ID"] + ""))
  117. {
  118. this.ftcSuppliers.ReadOnly = true;
  119. }
  120. }
  121. else
  122. {
  123. //this.txtBarcode.Text = DateTime.Now.ToString("yyMMdd") + "XXXXXX";
  124. this.dkUserInfo.Text = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  125. this.dkUserInfo.UserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  126. this.dkUserInfo.UserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. // 对异常进行共通处理
  132. ExceptionManager.HandleEventException(this.ToString(),
  133. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  134. }
  135. }
  136. /// <summary>
  137. /// 关闭画面
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. private void btnCancel_Click(object sender, System.EventArgs e)
  142. {
  143. if (this._mouldID < 0)
  144. {
  145. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  146. }
  147. else
  148. {
  149. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  150. }
  151. this.Close();
  152. }
  153. /// <summary>
  154. /// 保存
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. private void btnSave_Click(object sender, EventArgs e)
  159. {
  160. try
  161. {
  162. if (!this.CheckInput())
  163. {
  164. return;
  165. }
  166. ClientRequestEntity cre = new ClientRequestEntity();
  167. cre.NameSpace = "FPC1002";
  168. cre.Name = "SetFPC1002Data";
  169. cre.Properties["MouldID"] = (this._mouldID > 0 ? this._mouldID : 0);
  170. //cre.Properties["MouldBarcode"] = this.txtBarcode.Text.Trim();
  171. cre.Properties["GoodsID"] = scbGoods.SearchedPKMember;
  172. cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  173. cre.Properties["MouldType"] = this.ftcMouldType.SelectedValue;
  174. cre.Properties["MaterialSupplier"] = this.ftcSuppliers.SelectedValue;
  175. cre.Properties["ProductionDate"] = this.dtpPDate.Value;
  176. cre.Properties["UserID"] = this.dkUserInfo.UserID;
  177. cre.Properties["UserCode"] = this.dkUserInfo.UserCode;
  178. cre.Properties["Weight"] = this.txtWeight.DataValue;
  179. cre.Properties["Cost"] = this.txtCost.DataValue;
  180. cre.Properties["StandardGroutingNum"] = this.txtStandardGroutingNum.DataValue;
  181. cre.Properties["OutputCount"] = this.txtOutputCount.DataValue;
  182. cre.Properties["Remarks"] = this.txtRemarks.Text;
  183. cre.Properties["MCount"] = this.txtMCount.DataValue;
  184. cre.Properties["MOULD_PLAN_ID"] = this.CBMouldPlan.SelectedValue;// 模具生产计划id add 夏常明 2023-6-25
  185. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  186. {
  187. return PCModuleProxyNew.Service.HandleRequest(cre);
  188. });
  189. if (sre != null)
  190. {
  191. if (sre.Status == Constant.ServiceResultStatus.Success)
  192. {
  193. if (this.chkAutoPrint.Checked && sre.Result != null)
  194. {
  195. string[] barcodes = (sre.Result as string).Split(',');
  196. foreach (string item in barcodes)
  197. {
  198. F_MST_013006.PrintBarcode(item, 1, this);
  199. }
  200. }
  201. // 提示信息
  202. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  203. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  204. if (this._mouldID > 0)
  205. {
  206. this.DialogResult = DialogResult.OK;
  207. this.Close();
  208. }
  209. else
  210. {
  211. this._mouldID = -1;
  212. this.ClearData();
  213. this.txtBarcode.Focus();
  214. }
  215. }
  216. else if (!string.IsNullOrWhiteSpace(sre.Message))
  217. {
  218. MessageBox.Show(sre.Message,
  219. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  220. }
  221. }
  222. else
  223. {
  224. // 提示信息
  225. MessageBox.Show("保存失败",
  226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  227. }
  228. }
  229. catch (Exception ex)
  230. {
  231. // 对异常进行共通处理
  232. ExceptionManager.HandleEventException(this.ToString(),
  233. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  234. }
  235. }
  236. /// <summary>
  237. /// 选择产品型号
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void scbGoods_SearchedItemChanged(object sender, EventArgs e)
  242. {
  243. if (string.IsNullOrEmpty(this.scbGoods.Text))
  244. {
  245. return;
  246. }
  247. try
  248. {
  249. ClientRequestEntity cre = new ClientRequestEntity();
  250. cre.NameSpace = "FPC1002";
  251. cre.Name = "GetFPC1002GoodsData";
  252. cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  253. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  254. if (sre == null)
  255. {
  256. return;
  257. }
  258. DataRow item = sre.Data.Tables[0].Rows[0];
  259. if (item["MouldWeight"] != DBNull.Value)
  260. {
  261. this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
  262. }
  263. if (item["MouldCost"] != DBNull.Value)
  264. {
  265. this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
  266. }
  267. if (item["StandardGroutingNum"] != DBNull.Value)
  268. {
  269. this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
  270. }
  271. if (item["MouldOutputCount"] != DBNull.Value)
  272. {
  273. this.txtOutputCount.DataValue = Convert.ToDecimal(item["MouldOutputCount"]);
  274. }
  275. //模具生产计划
  276. //if(sre.Data.Tables[1].Rows.Count>0)
  277. // {
  278. this.CBMouldPlan.DataSource = sre.Data.Tables[1];
  279. this.CBMouldPlan.SelectedValue = 0;
  280. this.CBMouldPlan.Text = "";
  281. //}
  282. }
  283. catch (Exception ex)
  284. {
  285. // 对异常进行共通处理
  286. ExceptionManager.HandleEventException(this.ToString(),
  287. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  288. }
  289. }
  290. ///// <summary>
  291. ///// 选择产品型号
  292. ///// </summary>
  293. ///// <param name="sender"></param>
  294. ///// <param name="e"></param>
  295. //private void dkGoodsCode_GoodsValueChanged(object sender, Controls.SearchTextBox.dkGoodsCodeSearchBox.TextChangeEventArgs e)
  296. //{
  297. // if (string.IsNullOrEmpty(this.scbGoods.Text))
  298. // {
  299. // return;
  300. // }
  301. // try
  302. // {
  303. // ClientRequestEntity cre = new ClientRequestEntity();
  304. // cre.NameSpace = "FPC1002";
  305. // cre.Name = "GetFPC1002GoodsData";
  306. // cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  307. // ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  308. // if (sre == null)
  309. // {
  310. // return;
  311. // }
  312. // DataRow item = sre.Data.Tables[0].Rows[0];
  313. // if (item["MouldWeight"] != DBNull.Value)
  314. // {
  315. // this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
  316. // }
  317. // if (item["MouldCost"] != DBNull.Value)
  318. // {
  319. // this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
  320. // }
  321. // }
  322. // catch (Exception ex)
  323. // {
  324. // // 对异常进行共通处理
  325. // ExceptionManager.HandleEventException(this.ToString(),
  326. // MethodBase.GetCurrentMethod().Name, this.Text, ex);
  327. // }
  328. //}
  329. #endregion
  330. #region 私有方法
  331. /// <summary>
  332. /// 清除画面数据
  333. /// </summary>
  334. private void ClearData()
  335. {
  336. this.txtBarcode.Clear();
  337. //this.dkGoodsCode.Text = null;
  338. //this.dkGoodsCode.GoodsID = null;
  339. //this.dkGoodsCode.GoodsCode = null;
  340. //this.ftcMouldType.ClearValue();
  341. //this.ftcSuppliers.ClearValue();
  342. //this.dtpPDate.ClearValue();
  343. //this.txtWeight.Clear();
  344. //this.txtCost.Clear();
  345. //this.txtStandardGroutingNum.Clear();
  346. //this.txtRemarks.Clear();
  347. //this.dkUserInfo.Text = null;
  348. //this.dkUserInfo.UserCode = null;
  349. //this.dkUserInfo.UserID = null;
  350. }
  351. /// <summary>
  352. /// 保存前画面数据验证
  353. /// </summary>
  354. /// <returns></returns>
  355. private bool CheckInput()
  356. {
  357. if (this._mouldID <= 0)
  358. {
  359. //if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
  360. //{
  361. // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具条码"),
  362. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  363. // MessageBoxDefaultButton.Button1);
  364. // this.txtBarcode.Focus();
  365. // return false;
  366. //}
  367. if (this.scbGoods.SearchedPKMember == 0)
  368. {
  369. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
  370. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  371. MessageBoxDefaultButton.Button1);
  372. this.scbGoods.Focus();
  373. return false;
  374. }
  375. }
  376. if (this.ftcMouldType.SelectedValue == null)
  377. {
  378. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具类型"),
  379. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  380. MessageBoxDefaultButton.Button1);
  381. this.ftcMouldType.Focus();
  382. return false;
  383. }
  384. if (this.ftcSuppliers.SelectedValue == null)
  385. {
  386. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "材料供应商"),
  387. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  388. MessageBoxDefaultButton.Button1);
  389. this.ftcSuppliers.Focus();
  390. return false;
  391. }
  392. if (this.txtWeight.DataValue == null)
  393. {
  394. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具重量"),
  395. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  396. MessageBoxDefaultButton.Button1);
  397. this.txtWeight.Focus();
  398. return false;
  399. }
  400. if (this.txtCost.DataValue == null)
  401. {
  402. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具成本"),
  403. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  404. MessageBoxDefaultButton.Button1);
  405. this.txtCost.Focus();
  406. return false;
  407. }
  408. if (this.dkUserInfo.UserID == null)
  409. {
  410. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "生产工号"),
  411. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  412. MessageBoxDefaultButton.Button1);
  413. this.dkUserInfo.Focus();
  414. return false;
  415. }
  416. if (this.txtStandardGroutingNum.DataValue == null)
  417. {
  418. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "标准注浆次数"),
  419. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  420. MessageBoxDefaultButton.Button1);
  421. this.txtStandardGroutingNum.Focus();
  422. return false;
  423. }
  424. if (this.txtOutputCount.DataValue == null)
  425. {
  426. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产出数量"),
  427. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  428. MessageBoxDefaultButton.Button1);
  429. this.txtOutputCount.Focus();
  430. return false;
  431. }
  432. if (this.ftcMouldType.Text == "石膏" && this.CBMouldPlan.SelectedValue == null)
  433. {
  434. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "生产计划"),
  435. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  436. MessageBoxDefaultButton.Button1);
  437. this.CBMouldPlan.Focus();
  438. return false;
  439. }
  440. return true;
  441. }
  442. #endregion
  443. private void txtOutputCount_TextChanged(object sender, EventArgs e)
  444. {
  445. try
  446. {
  447. int mouldOutputCount = (this.txtOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtOutputCount.DataValue) : 1);
  448. int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
  449. this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum;
  450. }
  451. catch (Exception ex)
  452. {
  453. // 对异常进行共通处理
  454. ExceptionManager.HandleEventException(this.ToString(),
  455. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  456. }
  457. }
  458. /// <summary>
  459. /// 模具类型改变事件
  460. /// </summary>
  461. /// <param name="sender"></param>
  462. /// <param name="e"></param>
  463. private void ftcMouldType_SelectedIndexChanged(object sender, EventArgs e)
  464. {
  465. try
  466. {
  467. if (this.ftcMouldType.Text.ToString() == "石膏")
  468. {
  469. this.lblLabel10.MustInput = true;
  470. this.CBMouldPlan.MustInput = true;
  471. }
  472. else
  473. {
  474. this.lblLabel10.MustInput = false;
  475. this.CBMouldPlan.MustInput = false;
  476. }
  477. }
  478. catch (Exception ex)
  479. {
  480. // 对异常进行共通处理
  481. ExceptionManager.HandleEventException(this.ToString(),
  482. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  483. }
  484. }
  485. }
  486. }