F_PC_1002.cs 16 KB

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