F_PM_1102.cs 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1102.cs
  5. * 2.功能描述:新建/编辑产品废弃信息窗体
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/24 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.Library;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 编辑产品废弃信息窗体
  25. /// </summary>
  26. public partial class F_PM_1102 : FormBase
  27. {
  28. #region 成员变量
  29. //窗体模式ID
  30. private Constant.FormMode _formType;
  31. //修改产品报损信息ID
  32. private string _barCode;
  33. //页面报损工序的数据源
  34. private List<ProductionDataEntity> _productionDataList = new List<ProductionDataEntity>();
  35. //该产品在产信息实体
  36. private InProductionEntity _isScrapProductEntity;
  37. //用户选择报损工序实体
  38. private ProductionDataEntity _scrapProductResponProcedure;
  39. //当前责任人集合
  40. private List<ScrapResponsibleEntity> _scrapResponsibleList = new List<ScrapResponsibleEntity>();
  41. //修改用废弃产品实体
  42. private ScrapProductEntity _updateEntity;
  43. //修改用废弃责任工序实体
  44. private ResponProcedureEntity _updateProcedureEntity;
  45. //修改用责任人集合
  46. private List<ScrapResponsibleEntity> _updateScrapResponsibleList;
  47. //有效条码标示
  48. private bool _yxBarCode = false;
  49. //产品分级类别ID
  50. private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
  51. //产品分级ID
  52. private int _goodsLevelId;
  53. //报损信息ID
  54. private int _editSPId;
  55. //是否允许审批
  56. private bool _isScrap = false;
  57. //未干补
  58. int SpecialRepairFlag = 0;
  59. //完成工序
  60. int? _CompleteProcdureID = null;
  61. //完成工序编码
  62. string _CompleteProcdureCode = "";
  63. //完成工序名称
  64. string _CompleteProcdureName = "";
  65. // 商标ID
  66. int? _LogoID = null;
  67. #endregion
  68. #region 构造函数
  69. /// <summary>
  70. /// 窗体构造
  71. /// </summary>
  72. public F_PM_1102(Constant.FormMode formType, string BarCode, int EditSPId, bool isScrap)
  73. {
  74. InitializeComponent();
  75. this._formType = formType;
  76. this._barCode = BarCode;
  77. this._editSPId = EditSPId;
  78. this._isScrap = isScrap;
  79. if (formType == Constant.FormMode.Add)
  80. {
  81. this.Text = FormTitles.F_PM_1102_ADD;
  82. }
  83. else
  84. {
  85. this.Text = FormTitles.F_PM_1102_EDIT;
  86. }
  87. this.btnViewApprover.Text = ButtonText.BTN_VIEWAPPROVER;
  88. this.btnSave.Text = ButtonText.BTN_SAVE;
  89. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  90. }
  91. #endregion
  92. #region 事件
  93. /// <summary>
  94. /// 窗体加载
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void F_PM_1102_Load(object sender, EventArgs e)
  99. {
  100. try
  101. {
  102. //获取当前产品分级ID
  103. this._goodsLevelId = Convert.ToInt32(SystemModuleProxy.Service.GetGoodsLevelDataById(_goodsLevelTypeID, null)
  104. .Tables[0].Rows[0]["GoodsLevelID"]);
  105. // 损坯原因
  106. DataSet dsRreason = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  107. {
  108. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC008");
  109. }));
  110. this.cmbRreason.DisplayMember = "DictionaryValue";
  111. this.cmbRreason.ValueMember = "DictionaryID";
  112. this.cmbRreason.DataSource = dsRreason.Tables[0];
  113. //绑定损坯状态
  114. DataTable dtAuditStatus = new DataTable();
  115. dtAuditStatus.Columns.Add("AuditStatusID");
  116. dtAuditStatus.Columns.Add("AuditStatusValue");
  117. DataRow dr = dtAuditStatus.NewRow();
  118. dr["AuditStatusID"] = 0;
  119. dr["AuditStatusValue"] = "待审核";
  120. dtAuditStatus.Rows.Add(dr);
  121. if (this._isScrap)
  122. {
  123. dr = dtAuditStatus.NewRow();
  124. dr["AuditStatusID"] = 1;
  125. dr["AuditStatusValue"] = "损坯通过";
  126. dtAuditStatus.Rows.Add(dr);
  127. dr = dtAuditStatus.NewRow();
  128. dr["AuditStatusID"] = 2;
  129. dr["AuditStatusValue"] = "损坯驳回";
  130. dtAuditStatus.Rows.Add(dr);
  131. }
  132. this.cmbAuditStatus.DisplayMember = "AuditStatusValue";
  133. this.cmbAuditStatus.ValueMember = "AuditStatusID";
  134. this.cmbAuditStatus.DataSource = dtAuditStatus;
  135. if (this._formType == Constant.FormMode.Edit)
  136. {
  137. BindEntity();
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(this.ToString(),
  144. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 提交操作
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void btnSave_Click(object sender, EventArgs e)
  153. {
  154. try
  155. {
  156. if (this.txtBarCode.Text == string.Empty)
  157. {
  158. this.txtBarCode.Focus();
  159. return;
  160. }
  161. if (this.cmbRreason.Text == string.Empty)
  162. {
  163. MessageBox.Show("损坯原因必须填写!",
  164. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  165. return;
  166. }
  167. this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  168. if (this._formType == Constant.FormMode.Add)
  169. {
  170. if (this._yxBarCode != true)
  171. {
  172. MessageBox.Show("请先输入一个有效条码!!",
  173. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  174. this.txtBarCode.Focus();
  175. return;
  176. }
  177. ScrapProductEntity addScrapProduct = null;
  178. ResponProcedureEntity addRProcedure = null;
  179. //获取责任人集合
  180. List<ScrapResponsibleEntity> addResponsibleList = new List<ScrapResponsibleEntity>();
  181. foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
  182. {
  183. int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
  184. if (isSelected == Constant.INT_IS_ONE)
  185. {
  186. ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
  187. selectResponsible.BarCode = this.txtBarCode.Text;
  188. selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
  189. selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
  190. selectResponsible.UserID = scbUser.SearchedPKMember;
  191. selectResponsible.UserCode = scbUser.SearchedValue + "";
  192. selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
  193. selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
  194. addResponsibleList.Add(selectResponsible);
  195. }
  196. }
  197. //如果选择了责任工序就一定要选择责任人
  198. //if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
  199. if (addResponsibleList.Count == Constant.INT_IS_ZERO)
  200. {
  201. MessageBox.Show("请选择责任人!",
  202. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  203. return;
  204. }
  205. //首先判断责任类型
  206. int thisResponType = 0;
  207. if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
  208. {
  209. thisResponType = 1;
  210. }
  211. else if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
  212. {
  213. thisResponType = 3;
  214. }
  215. else if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
  216. {
  217. thisResponType = 2;
  218. }
  219. if (thisResponType == Constant.INT_IS_ZERO)
  220. {
  221. MessageBox.Show("责任类别不正确!",
  222. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  223. return;
  224. }
  225. //新建报损产品实体
  226. addScrapProduct = new ScrapProductEntity();
  227. addScrapProduct.BarCode = this.txtBarCode.Text;
  228. addScrapProduct.ProductionLineID = _isScrapProductEntity.ProductionLineID;
  229. addScrapProduct.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
  230. addScrapProduct.ProductionLineName = _isScrapProductEntity.ProductionLineName;
  231. addScrapProduct.GoodsID = _isScrapProductEntity.GoodsID;
  232. addScrapProduct.GoodsCode = _isScrapProductEntity.GoodsCode;
  233. addScrapProduct.GoodsName = _isScrapProductEntity.GoodsName;
  234. addScrapProduct.GroutingDailyID = _isScrapProductEntity.GroutingDailyID;
  235. addScrapProduct.GroutingDailyDetailID = _isScrapProductEntity.GroutingDailyDetailID;
  236. addScrapProduct.GroutingDate = Convert.ToDateTime(_isScrapProductEntity.GroutingDate);
  237. addScrapProduct.GroutingLineID = _isScrapProductEntity.GroutingLineID;
  238. addScrapProduct.GroutingLineCode = _isScrapProductEntity.GroutingLineCode;
  239. addScrapProduct.GroutingLineName = _isScrapProductEntity.GroutingLineName;
  240. addScrapProduct.GMouldTypeID = _isScrapProductEntity.GMouldTypeID;
  241. addScrapProduct.GroutingLineDetailID = _isScrapProductEntity.GroutingLineDetailID;
  242. addScrapProduct.GroutingMouldCode = _isScrapProductEntity.GroutingMouldCode;
  243. addScrapProduct.MouldCode = _isScrapProductEntity.MouldCode;
  244. addScrapProduct.GoodsLevelTypeID = _goodsLevelTypeID;
  245. addScrapProduct.GoodsLevelID = _goodsLevelId;
  246. addScrapProduct.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
  247. addScrapProduct.Rreason = this.cmbRreason.Text;
  248. addScrapProduct.ResponUserID = scbUser.SearchedPKMember;
  249. addScrapProduct.ResponUserCode = scbUser.SearchedValue + "";
  250. addScrapProduct.ResponUserName = scbUser.Text;
  251. addScrapProduct.Remarks = this.txtRemarks.Text;
  252. addScrapProduct.AuditStatus = 0;
  253. addScrapProduct.SettlementFlag = 0;
  254. addScrapProduct.ResponType = thisResponType;
  255. addScrapProduct.GroutingUserID = Convert.ToInt32(_isScrapProductEntity.GroutingUserID);
  256. addScrapProduct.GroutingUserCode = _isScrapProductEntity.GroutingUserCode;
  257. addScrapProduct.GroutingNum = _isScrapProductEntity.GroutingNum;
  258. addScrapProduct.IsPublicBody = Convert.ToInt32(_isScrapProductEntity.IsPublicBody);
  259. addScrapProduct.IsReFire = Convert.ToInt32(_isScrapProductEntity.IsReFire);
  260. addScrapProduct.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
  261. addScrapProduct.SpecialRepairflag = this.SpecialRepairFlag;
  262. addScrapProduct.LogoID = this._LogoID;
  263. addScrapProduct.DiscovererStaffCode = this.dkStaffName.Text;
  264. if (this._CompleteProcdureID != null)
  265. {
  266. addScrapProduct.ProcedureID = this._CompleteProcdureID;
  267. //addScrapProduct.ProcedureName = this.txtCompleteProcdure.Text;
  268. addScrapProduct.ProcedureName = this._CompleteProcdureName;
  269. addScrapProduct.ProcedureCode = this._CompleteProcdureCode;
  270. }
  271. if (txtScrapFine.Text != string.Empty)
  272. {
  273. addScrapProduct.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
  274. }
  275. //如果存在责任工序的话,也要添加责任工序
  276. if (thisResponType == Constant.INT_IS_THREE)
  277. {
  278. addRProcedure = new ResponProcedureEntity();
  279. addRProcedure.BarCode = this.txtBarCode.Text;
  280. addRProcedure.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
  281. addRProcedure.ProductionLineID = _isScrapProductEntity.ProductionLineID;
  282. addRProcedure.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
  283. addRProcedure.ProductionLineName = _isScrapProductEntity.ProductionLineName;
  284. addRProcedure.ProcedureID = _scrapProductResponProcedure.ProcedureID;
  285. addRProcedure.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
  286. addRProcedure.ProcedureName = _scrapProductResponProcedure.ProcedureName;
  287. addRProcedure.UserID = scbUser.SearchedPKMember;
  288. addRProcedure.UserCode = scbUser.SearchedValue + "";
  289. addRProcedure.UserName = scbUser.Text;
  290. addRProcedure.Remarks = "";
  291. }
  292. int addReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  293. {
  294. return PMModuleProxy.Service.AddScrapProduct(addScrapProduct, addRProcedure, addResponsibleList);
  295. }));
  296. if (addReturn > Constant.INT_IS_ZERO)
  297. {
  298. //成功
  299. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
  300. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  301. this.DialogResult = DialogResult.OK;
  302. }
  303. else if (addReturn == Constant.RETURN_IS_DATACHANGED)
  304. {
  305. //成功
  306. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化"),
  307. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  308. this.DialogResult = DialogResult.OK;
  309. }
  310. else
  311. {
  312. //失败
  313. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
  314. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  315. }
  316. }
  317. else
  318. {
  319. //获取修改后的责任人集合
  320. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  321. foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
  322. {
  323. int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
  324. if (isSelected == Constant.INT_IS_ONE)
  325. {
  326. ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
  327. selectResponsible.BarCode = this.txtBarCode.Text;
  328. selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
  329. selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
  330. selectResponsible.UserID = scbUser.SearchedPKMember;
  331. selectResponsible.UserCode = scbUser.SearchedValue + "";
  332. selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
  333. selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
  334. this._updateScrapResponsibleList.Add(selectResponsible);
  335. }
  336. }
  337. //如果选择了责任工序就一定要选择责任人
  338. //if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  339. if (_updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  340. {
  341. MessageBox.Show("请选择责任人!",
  342. this.Text,
  343. MessageBoxButtons.OK,
  344. MessageBoxIcon.Warning,
  345. MessageBoxDefaultButton.Button1);
  346. return;
  347. }
  348. //根据修改信息判断新的责任类型
  349. int thisResponType = 0;
  350. if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  351. {
  352. thisResponType = 1;
  353. }
  354. else if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
  355. {
  356. thisResponType = 3;
  357. }
  358. else if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
  359. {
  360. thisResponType = 2;
  361. }
  362. if (thisResponType == Constant.INT_IS_ZERO)
  363. {
  364. MessageBox.Show("责任类别不正确!",
  365. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  366. return;
  367. }
  368. //为修改实体赋值(可修改的只有备注,原因,责任工序,以及责任人)
  369. this._updateEntity.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
  370. this._updateEntity.Rreason = this.cmbRreason.Text;
  371. this._updateEntity.Remarks = this.txtRemarks.Text;
  372. this._updateEntity.ResponType = thisResponType;
  373. this._updateEntity.LogoID = this._LogoID;
  374. if (txtScrapFine.Text != string.Empty)
  375. {
  376. this._updateEntity.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
  377. }
  378. //新添审批状态判断,如果审批状态为未通过审批,要修改为未审批
  379. //if (this._updateEntity.AuditStatus != null)
  380. //{
  381. // if (this._updateEntity.AuditStatus == Constant.INT_IS_TWO)
  382. // {
  383. // this._updateEntity.AuditStatus = 0;
  384. // }
  385. //}
  386. this._updateEntity.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
  387. //如果存在责任工序的话,也要添加责任工序
  388. if (thisResponType == Constant.INT_IS_THREE)
  389. {
  390. if (this._updateProcedureEntity == null)
  391. {
  392. this._updateProcedureEntity = new ResponProcedureEntity();
  393. }
  394. this._updateProcedureEntity.BarCode = this.txtBarCode.Text;
  395. this._updateProcedureEntity.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
  396. this._updateProcedureEntity.ProductionLineID = _updateEntity.ProductionLineID;
  397. this._updateProcedureEntity.ProductionLineCode = _updateEntity.ProductionLineCode;
  398. this._updateProcedureEntity.ProductionLineName = _updateEntity.ProductionLineName;
  399. this._updateProcedureEntity.ProcedureID = _scrapProductResponProcedure.ProcedureID;
  400. this._updateProcedureEntity.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
  401. this._updateProcedureEntity.ProcedureName = _scrapProductResponProcedure.ProcedureName;
  402. this._updateProcedureEntity.UserID = scbUser.SearchedPKMember;
  403. this._updateProcedureEntity.UserCode = scbUser.SearchedValue + "";
  404. this._updateProcedureEntity.UserName = scbUser.Text;
  405. }
  406. else //不存在了直接把原来的删掉
  407. {
  408. if (this._updateProcedureEntity != null)
  409. {
  410. this._updateProcedureEntity.ValueFlag = 0;
  411. }
  412. }
  413. int updateReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  414. {
  415. return PMModuleProxy.Service.UpdateScrapProduct(_updateEntity, _updateProcedureEntity, _updateScrapResponsibleList, _scrapResponsibleList);
  416. }));
  417. if (updateReturn > Constant.INT_IS_ZERO)
  418. {
  419. //成功
  420. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
  421. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  422. this.DialogResult = DialogResult.OK;
  423. }
  424. else
  425. {
  426. //失败
  427. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
  428. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  429. }
  430. }
  431. }
  432. catch (Exception ex)
  433. {
  434. // 对异常进行共通处理
  435. ExceptionManager.HandleEventException(this.ToString(),
  436. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  437. }
  438. }
  439. /// <summary>
  440. /// 察看审批意见
  441. /// </summary>
  442. /// <param name="sender"></param>
  443. /// <param name="e"></param>
  444. private void btnViewApprover_Click(object sender, EventArgs e)
  445. {
  446. try
  447. {
  448. string barCode = this.txtBarCode.Text;
  449. F_PM_1103 frmFPM1103 = new F_PM_1103(barCode, 1, _editSPId);
  450. DialogResult dialogresult = frmFPM1103.ShowDialog();
  451. }
  452. catch (Exception ex)
  453. {
  454. // 对异常进行共通处理
  455. ExceptionManager.HandleEventException(this.ToString(),
  456. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  457. }
  458. }
  459. /// <summary>
  460. /// 选择工号改变
  461. /// </summary>
  462. /// <param name="sender"></param>
  463. /// <param name="e"></param>
  464. private void scbUser_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
  465. {
  466. try
  467. {
  468. if (this.scbUser.SearchedPKMember != 0)
  469. {
  470. if (this.scbUser.Text != "")
  471. {
  472. this.dgvResponsible.AutoGenerateColumns = false;
  473. DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  474. {
  475. return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
  476. }));
  477. this.dgvResponsible.DataSource = dsUser.Tables[0];
  478. }
  479. else
  480. {
  481. this.dgvResponsible.DataSource = null;
  482. this.scbUser.ClearValue();
  483. }
  484. }
  485. else
  486. {
  487. this.dgvResponsible.DataSource = null;
  488. }
  489. if (this._formType == Constant.FormMode.Edit)
  490. {
  491. if (this.dgvResponsible.DataSource != null)
  492. {
  493. if (_scrapResponsibleList.Count != 0)
  494. {
  495. foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
  496. {
  497. string sourseNow = drNow.Cells["StaffID"].Value.ToString();
  498. foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
  499. {
  500. if (srFor.StaffID.ToString() == sourseNow)
  501. {
  502. drNow.Cells["UserSelected"].Value = "1";
  503. break;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. // 对异常进行共通处理
  514. ExceptionManager.HandleEventException(this.ToString(),
  515. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  516. }
  517. }
  518. /// <summary>
  519. /// 选择工号改变
  520. /// </summary>
  521. /// <param name="sender"></param>
  522. /// <param name="e"></param>
  523. private void dkUser_UserValueChanged(object sender, Controls.SearchTextBox.dkUserInfoSearchBox.TextChangeEventArgs e)
  524. {
  525. // try
  526. // {
  527. // if (this.scbUser.SearchedPKMember != 0)
  528. // {
  529. // if (this.scbUser.Text != "")
  530. // {
  531. // this.dgvResponsible.AutoGenerateColumns = false;
  532. // DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  533. // {
  534. // return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
  535. // }));
  536. // this.dgvResponsible.DataSource = dsUser.Tables[0];
  537. // }
  538. // else
  539. // {
  540. // this.dgvResponsible.DataSource = null;
  541. // this.scbUser.ClearValue();
  542. //}
  543. // }
  544. // else
  545. // {
  546. // this.dgvResponsible.DataSource = null;
  547. // }
  548. // if (this._formType == Constant.FormMode.Edit)
  549. // {
  550. // if (this.dgvResponsible.DataSource != null)
  551. // {
  552. // if (_scrapResponsibleList.Count != 0)
  553. // {
  554. // foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
  555. // {
  556. // string sourseNow = drNow.Cells["StaffID"].Value.ToString();
  557. // foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
  558. // {
  559. // if (srFor.StaffID.ToString() == sourseNow)
  560. // {
  561. // drNow.Cells["UserSelected"].Value = "1";
  562. // break;
  563. // }
  564. // }
  565. // }
  566. // }
  567. // }
  568. // }
  569. // }
  570. // catch (Exception ex)
  571. // {
  572. // // 对异常进行共通处理
  573. // ExceptionManager.HandleEventException(this.ToString(),
  574. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  575. // }
  576. }
  577. /// <summary>
  578. /// 窗体关闭
  579. /// </summary>
  580. /// <param name="sender"></param>
  581. /// <param name="e"></param>
  582. private void btnCancel_Click(object sender, EventArgs e)
  583. {
  584. this.Close();
  585. }
  586. /// <summary>
  587. /// 条码输入完毕后
  588. /// </summary>
  589. /// <param name="sender"></param>
  590. /// <param name="e"></param>
  591. private void txtBarCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  592. {
  593. try
  594. {
  595. string BarCode = this.txtBarCode.Text.Trim();
  596. if (BarCode != string.Empty)
  597. {
  598. string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
  599. {
  600. return PMModuleProxy.Service.ScrapProductChack(BarCode);
  601. }));
  602. string[] doRuselts = doRuselt.Split(':');
  603. int isHave = Convert.ToInt32(doRuselts[0]);
  604. if (isHave == 2)
  605. {
  606. MessageBox.Show("不是在产产品不能报损!",
  607. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  608. this.txtBarCode.Text = "";
  609. this.txtBarCode.Focus();
  610. return;
  611. }
  612. if (isHave == 3)
  613. {
  614. MessageBox.Show(string.Format("当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
  615. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  616. this.txtBarCode.Text = "";
  617. this.txtBarCode.Focus();
  618. return;
  619. }
  620. if (isHave == 4)
  621. {
  622. MessageBox.Show(doRuselts[1],
  623. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  624. this.txtBarCode.Text = "";
  625. this.txtBarCode.Focus();
  626. return;
  627. }
  628. if (isHave == Constant.INT_IS_ZERO)
  629. {
  630. MessageBox.Show("该产品已经存在报损记录!",
  631. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  632. this.txtBarCode.Text = "";
  633. this.txtBarCode.Focus();
  634. return;
  635. }
  636. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  637. {
  638. return PMModuleProxy.Service.GetInProductionAndProductionData(BarCode);
  639. }));
  640. if (dsReturn != null)
  641. {
  642. if (dsReturn.Tables.Count == 4)
  643. {
  644. //判断在产表以及报损表中是否存在条码数据
  645. if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO && dsReturn.Tables[2].Rows.Count== Constant.INT_IS_ZERO) //在产表中没有数据
  646. {
  647. //目前不在生产线上也只报损 2015/07/14 modify wangx
  648. DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  649. {
  650. return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(BarCode);
  651. }));
  652. if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
  653. {
  654. MessageBox.Show("该产品条码无效,无法报损!",
  655. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  656. this.txtBarCode.Text = "";
  657. this.txtBarCode.Focus();
  658. return;
  659. }
  660. //SpecialRepairFlag = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["SpecialRepairFlag"]);
  661. //this.txtProductionLineName.Text = "";
  662. //this.txtGoodsCode.Text = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
  663. //this.txtGroutingLine.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  664. //this.txtMouldCode.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  665. //this.txtGroutingUser.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  666. //this.cbResponProcedure.Enabled = false;
  667. ////this._isScrapProductEntity.ProductionLineID = 0;//放null
  668. ////this._isScrapProductEntity.ProductionLineCode = null;
  669. ////this._isScrapProductEntity.ProductionLineName = null;
  670. //this._isScrapProductEntity = new InProductionEntity();
  671. //this._isScrapProductEntity.GoodsID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GoodsID"]);
  672. //this._isScrapProductEntity.GoodsCode = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
  673. //this._isScrapProductEntity.GoodsName = dsDailyDetail.Tables[0].Rows[0]["GoodsName"].ToString();
  674. //this._isScrapProductEntity.GroutingDailyID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyID"]);
  675. //this._isScrapProductEntity.GroutingDailyDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  676. //this._isScrapProductEntity.GroutingDate = Convert.ToDateTime(dsDailyDetail.Tables[0].Rows[0]["GroutingDate"]);
  677. //this._isScrapProductEntity.GroutingLineID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineID"]);
  678. //this._isScrapProductEntity.GroutingLineCode = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  679. //this._isScrapProductEntity.GroutingLineName = dsDailyDetail.Tables[0].Rows[0]["GroutingLineName"].ToString();
  680. //this._isScrapProductEntity.GMouldTypeID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GMouldTypeID"]);
  681. //this._isScrapProductEntity.GroutingLineDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineDetailID"]);
  682. //this._isScrapProductEntity.GroutingMouldCode = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  683. //this._isScrapProductEntity.MouldCode = dsDailyDetail.Tables[0].Rows[0]["MouldCode"].ToString();
  684. //this._isScrapProductEntity.GroutingUserID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingUserID"]);
  685. //this._isScrapProductEntity.GroutingUserCode = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  686. //this._isScrapProductEntity.GroutingNum = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingNum"]);
  687. //this._isScrapProductEntity.IsPublicBody = 0;
  688. //this._isScrapProductEntity.IsReFire = 0;
  689. //this._yxBarCode = true;
  690. //this.txtBarCode.Enabled = false;
  691. // 2015/07/14 modify wangx end
  692. ////产品不在生产线上
  693. MessageBox.Show("不是在产产品不能报损!",
  694. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  695. this.txtBarCode.Text = "";
  696. this.txtBarCode.Focus();
  697. ////判断条码是否有效
  698. return; //加这个返回代码为了如果在注浆登记中,赋完值后直接返回,为了保存时候取值
  699. }
  700. DataTable dtInProduction = null;
  701. //获取产品情况以及经过工序情况
  702. if (dsReturn.Tables[0] == null ||dsReturn.Tables[0].Rows.Count==0)
  703. {
  704. dtInProduction = dsReturn.Tables[2];
  705. }
  706. else {
  707. //如果为第一次报损
  708. dtInProduction = dsReturn.Tables[0];
  709. //2015-05-26 begin modify by wangx
  710. if (dtInProduction != null && dtInProduction.Rows.Count > 0)
  711. {
  712. if (dtInProduction.Rows[0]["endmode"].ToString() == "2")//代表已经产成品
  713. {
  714. MessageBox.Show("该产品条码已经生产完成,无法报损!",
  715. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  716. this.txtBarCode.Text = "";
  717. this.txtBarCode.Focus();
  718. return;
  719. }
  720. if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
  721. {
  722. MessageBox.Show("该产品条码已经是返工状态,无法报损!",
  723. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  724. this.txtBarCode.Text = "";
  725. this.txtBarCode.Focus();
  726. return;
  727. }
  728. }
  729. }
  730. //2015-05-26 end
  731. //获取节点类型
  732. //如果存在该类型的字段的话,判断一下
  733. // string a = dtInProduction.Columns[dtInProduction.Columns.Count - 1].ColumnName;
  734. foreach (DataColumn dcFor in dtInProduction.Columns)
  735. {
  736. if (dcFor.ColumnName.ToLower() == "proceduremodeltypeid")
  737. {
  738. int modelType = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureModelTypeID"]);
  739. // 装车,入窑,出窑,窑车补件不能报损
  740. }
  741. }
  742. DataTable dtProductionData = null;
  743. //过滤查询已经报损过的工序
  744. if (dsReturn.Tables[1].Rows.Count == 0) {
  745. dtProductionData = dsReturn.Tables[2];
  746. }
  747. else {
  748. dtProductionData = dsReturn.Tables[1];
  749. this.cbResponProcedure.DataSource = dtProductionData;
  750. this.cbResponProcedure.ValueMember = "ProcedureID";
  751. this.cbResponProcedure.DisplayMember = "ProcedureName";
  752. this.cbResponProcedure.Text = "";
  753. }
  754. foreach (DataRow drFor in dtInProduction.Rows)
  755. {
  756. SpecialRepairFlag = Convert.ToInt32(drFor["SpecialRepairFlag"]);
  757. this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  758. this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  759. this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  760. this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  761. this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  762. if (drFor["logoID"].ToString() != "")
  763. {
  764. this._LogoID = Convert.ToInt32(drFor["logoID"]);
  765. }
  766. }
  767. List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
  768. if (inProductionList.Count != Constant.INT_IS_ZERO)
  769. {
  770. this._isScrapProductEntity = inProductionList[0];
  771. }
  772. else
  773. {
  774. if (this._updateEntity == null)
  775. {
  776. return;
  777. }
  778. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  779. {
  780. return;
  781. }
  782. //失败,条码不存在数据或无法转换
  783. MessageBox.Show(Messages.MSG_PM_W007,
  784. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  785. return;
  786. }
  787. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  788. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  789. {
  790. this._scrapProductResponProcedure = this._productionDataList[0];
  791. }
  792. this._yxBarCode = true;
  793. this.txtBarCode.Enabled = false;
  794. if (dtProductionData != null && dtProductionData.Rows.Count > 0)
  795. {
  796. this.cbResponProcedure.SelectedValue = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"];
  797. //赋值第三个table值
  798. dtProductionData = dsReturn.Tables[3];
  799. //this.cbResponProcedure.Enabled = false;
  800. // modify wangx 2015/06/06 begin
  801. this._CompleteProcdureID = Convert.ToInt32(dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"]);
  802. this.txtCompleteProcdure.Text = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
  803. _CompleteProcdureName = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
  804. this._CompleteProcdureCode = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureCode"].ToString();
  805. // modify wangx 2015/06/06 end
  806. cbResponProcedure_SelectedIndexChanged(sender, e);
  807. }
  808. else
  809. {
  810. this._CompleteProcdureID = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureID"]);
  811. _CompleteProcdureName = dtInProduction.Rows[0]["ProcedureName"].ToString();
  812. this._CompleteProcdureCode = dtInProduction.Rows[0]["ProcedureCode"].ToString();
  813. }
  814. if (this.cbResponProcedure.Text == "" || this.cbResponProcedure.Text == null)
  815. {
  816. MessageBox.Show("该产品目前无可选损坯工序!",
  817. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  818. this.txtBarCode.Focus();
  819. return;
  820. }
  821. }
  822. }
  823. else
  824. {
  825. if (this._updateEntity == null)
  826. {
  827. return;
  828. }
  829. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  830. {
  831. return;
  832. }
  833. //失败
  834. MessageBox.Show(Messages.MSG_PM_W007,
  835. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  836. }
  837. }
  838. }
  839. catch (Exception ex)
  840. {
  841. // 对异常进行共通处理
  842. ExceptionManager.HandleEventException(this.ToString(),
  843. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  844. }
  845. }
  846. /// <summary>
  847. /// 将用户选择的工序实体赋值
  848. /// </summary>
  849. /// <param name="sender"></param>
  850. /// <param name="e"></param>
  851. private void cbResponProcedure_SelectedIndexChanged(object sender, EventArgs e)
  852. {
  853. try
  854. {
  855. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  856. {
  857. if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
  858. {
  859. this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
  860. DataTable dt = this.cbResponProcedure.DataSource as DataTable;
  861. int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
  862. DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  863. {
  864. return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
  865. }));
  866. if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
  867. && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  868. {
  869. this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  870. scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
  871. //this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
  872. //this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
  873. this.cbResponProcedure.DataSource = dt;
  874. this.cbResponProcedure.Enabled = true;
  875. //this.dkUser.ReadOnly = true;
  876. this.scbUser.Enabled = false;
  877. }
  878. else
  879. {
  880. this.scbUser.Enabled = true;
  881. this.scbUser.SearchedPKMember = 0;
  882. this.scbUser.ClearValue();
  883. }
  884. }
  885. else
  886. {
  887. this._scrapProductResponProcedure = null;
  888. }
  889. }
  890. }
  891. catch (Exception ex)
  892. {
  893. // 对异常进行共通处理
  894. ExceptionManager.HandleEventException(this.ToString(),
  895. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  896. }
  897. }
  898. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  899. {
  900. try
  901. {
  902. if ((int)e.KeyChar == 13) // 按了回车键
  903. {
  904. this.cbResponProcedure.Focus();
  905. }
  906. }
  907. catch (Exception ex)
  908. {
  909. // 对异常进行共通处理
  910. ExceptionManager.HandleEventException(this.ToString(),
  911. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  912. }
  913. }
  914. #endregion
  915. #region 私有方法
  916. /// <summary>
  917. /// 加载数据
  918. /// </summary>
  919. private void BindEntity()
  920. {
  921. try
  922. {
  923. //条码控件不可用
  924. this.txtBarCode.Enabled = false;
  925. this._updateEntity = new ScrapProductEntity();
  926. this._updateEntity.BarCode = _barCode;
  927. this._updateEntity.ScrapProductID = _editSPId;
  928. //绑定生产工序集合
  929. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  930. {
  931. return PMModuleProxy.Service.GetInProductionAndProductionData (_barCode);
  932. }));
  933. if (dsReturn != null)
  934. {
  935. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  936. {
  937. //获取产品情况以及经过工序情况
  938. DataTable dtInProduction = dsReturn.Tables[0];
  939. DataTable dtProductionData = dsReturn.Tables[1];
  940. foreach (DataRow drFor in dtInProduction.Rows)
  941. {
  942. this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  943. this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  944. this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  945. this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  946. this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  947. }
  948. this.cbResponProcedure.DataSource = dtProductionData;
  949. this.cbResponProcedure.DisplayMember = "ProcedureName";
  950. this.cbResponProcedure.ValueMember = "ProcedureID";
  951. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  952. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  953. {
  954. this._scrapProductResponProcedure = this._productionDataList[0];
  955. }
  956. if (dtInProduction.Rows.Count == 0)
  957. {
  958. this.cbResponProcedure.Enabled = false;
  959. }
  960. }
  961. }
  962. //获取报废产品实体
  963. DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  964. {
  965. return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
  966. }));
  967. if (dsScrap != null)
  968. {
  969. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  970. {
  971. DataRow drScrap = dsScrap.Tables[0].Rows[0];
  972. this._updateEntity.BarCode = drScrap["BarCode"].ToString();
  973. if (drScrap["ProductionLineID"].ToString() != "")
  974. {
  975. this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
  976. this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
  977. this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
  978. this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  979. this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  980. this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  981. this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  982. this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
  983. this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
  984. this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
  985. }
  986. else //等于空时,取模具信息
  987. {
  988. this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  989. this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  990. this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  991. this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  992. }
  993. if (drScrap["logoid"].ToString() != "")
  994. {
  995. this._LogoID = Convert.ToInt32(drScrap["logoid"]);
  996. }
  997. this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
  998. this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
  999. this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
  1000. this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
  1001. this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
  1002. this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
  1003. this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
  1004. this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
  1005. this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
  1006. this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
  1007. this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
  1008. this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
  1009. this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
  1010. this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
  1011. this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
  1012. this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
  1013. this._updateEntity.Rreason = drScrap["Rreason"].ToString();
  1014. this._updateEntity.Remarks = drScrap["Remarks"].ToString();
  1015. this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
  1016. this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
  1017. this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  1018. this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  1019. if (drScrap["Auditor"] != DBNull.Value)
  1020. {
  1021. this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
  1022. }
  1023. if (drScrap["AuditDate"] != DBNull.Value)
  1024. {
  1025. this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
  1026. }
  1027. this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
  1028. if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
  1029. {
  1030. this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
  1031. }
  1032. if (drScrap["UserID"] != DBNull.Value)
  1033. {
  1034. this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
  1035. }
  1036. if (drScrap["UserCode"] != DBNull.Value)
  1037. {
  1038. this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
  1039. }
  1040. if (drScrap["UserName"] != DBNull.Value)
  1041. {
  1042. this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
  1043. }
  1044. if (drScrap["ScrapFine"] != DBNull.Value)
  1045. {
  1046. this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
  1047. }
  1048. this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
  1049. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
  1050. (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
  1051. {
  1052. this.txtBarCode.Enabled = false;
  1053. this.txtGoodsCode.Enabled = false;
  1054. this.txtProductionLineName.Enabled = false;
  1055. this.cbResponProcedure.Enabled = false;
  1056. // 报损日期不能修改
  1057. //this.txtScrapDate.Enabled = false;
  1058. this.cmbRreason.Enabled = false;
  1059. this.txtRemarks.Enabled = false;
  1060. this.scbUser.Enabled = false;
  1061. this.dgvResponsible.Enabled = false;
  1062. this.btnSave.Enabled = false;
  1063. this.btnViewApprover.Visible = false;
  1064. this.cmbAuditStatus.Enabled = false;
  1065. }
  1066. if (this._updateEntity.Auditor != null && this._updateEntity.GoodsLevelTypeID == this._goodsLevelTypeID)
  1067. {
  1068. this.btnViewApprover.Visible = true;
  1069. }
  1070. }
  1071. }
  1072. else
  1073. {
  1074. this.Close();
  1075. return;
  1076. }
  1077. //获取报废责任工序实体
  1078. if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
  1079. {
  1080. DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1081. {
  1082. return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1083. }));
  1084. this._updateProcedureEntity = new ResponProcedureEntity();
  1085. if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
  1086. {
  1087. DataRow drResPro = dsResPro.Tables[0].Rows[0];
  1088. this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
  1089. this.scbUser.Enabled = false;
  1090. }
  1091. this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
  1092. }
  1093. //获取报废责任人实体集合
  1094. if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
  1095. {
  1096. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  1097. DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1098. {
  1099. return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1100. }));
  1101. DataTableToListByScrapResponsible(dsResponsible);
  1102. }
  1103. //控件赋值
  1104. this.txtBarCode.Text = _updateEntity.BarCode;
  1105. this.txtGoodsCode.Text = _updateEntity.GoodsCode;
  1106. this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
  1107. this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
  1108. this.txtScrapDate.Text = _updateEntity.ScrapDate.ToString();
  1109. try
  1110. {
  1111. this.cmbRreason.Text = _updateEntity.Rreason;
  1112. }
  1113. catch
  1114. {
  1115. this.cmbRreason.Text = "";
  1116. }
  1117. this.txtRemarks.Text = _updateEntity.Remarks;
  1118. this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
  1119. //this._updateEntity.ScrapFine
  1120. if (this._updateEntity.ResponUserID != null)
  1121. {
  1122. scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
  1123. scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
  1124. //this.dkUser.UserID = _updateEntity.ResponUserID;
  1125. // this.dkUser.UserCode = _updateEntity.ResponUserCode;
  1126. // this.dkUser.UserName = _updateEntity.ResponUserName;
  1127. }
  1128. else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
  1129. {
  1130. scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
  1131. scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
  1132. //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
  1133. // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
  1134. // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
  1135. }
  1136. }
  1137. catch (Exception ex)
  1138. {
  1139. throw ex;
  1140. }
  1141. }
  1142. /// <summary>
  1143. /// 数据表到实体转换
  1144. /// </summary>
  1145. /// <param name="dsScrapResponsible"></param>
  1146. private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
  1147. {
  1148. foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
  1149. {
  1150. ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
  1151. srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
  1152. srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
  1153. srEntity.BarCode = drFor["BarCode"].ToString();
  1154. srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
  1155. if (drFor["ResponProcedureID"] != DBNull.Value)
  1156. {
  1157. srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
  1158. }
  1159. srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
  1160. srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
  1161. srEntity.UserCode = drFor["UserCode"].ToString();
  1162. srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
  1163. srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
  1164. srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
  1165. srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
  1166. srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
  1167. srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
  1168. srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
  1169. srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
  1170. srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
  1171. srEntity.UserName = drFor["userName"].ToString();
  1172. this._scrapResponsibleList.Add(srEntity);
  1173. }
  1174. }
  1175. /// <summary>
  1176. /// 数据表到实体转换
  1177. /// </summary>
  1178. /// <param name="dtProductionData"></param>
  1179. /// <returns></returns>
  1180. private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
  1181. {
  1182. List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
  1183. foreach (DataRow drFor in dtProductionData.Rows)
  1184. {
  1185. ProductionDataEntity pdEntity = new ProductionDataEntity();
  1186. pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
  1187. pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
  1188. pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
  1189. pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
  1190. pdList.Add(pdEntity);
  1191. }
  1192. return pdList;
  1193. }
  1194. #endregion
  1195. private void cbResponProcedure_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1196. {
  1197. try
  1198. {
  1199. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  1200. {
  1201. if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
  1202. {
  1203. this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
  1204. DataTable dt = this.cbResponProcedure.DataSource as DataTable;
  1205. int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
  1206. DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1207. {
  1208. return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
  1209. }));
  1210. if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
  1211. && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1212. {
  1213. this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  1214. scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
  1215. //this.dkUser.UserID = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  1216. // this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
  1217. // this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
  1218. this.cbResponProcedure.DataSource = dt;
  1219. this.cbResponProcedure.Enabled = true;
  1220. this.scbUser.Enabled = false; ;
  1221. }
  1222. else
  1223. {
  1224. this.scbUser.Enabled = true;
  1225. this.scbUser.SearchedPKMember = 0;
  1226. this.scbUser.ClearValue();
  1227. }
  1228. }
  1229. else
  1230. {
  1231. this._scrapProductResponProcedure = null;
  1232. this.scbUser.Enabled = true;
  1233. }
  1234. }
  1235. }
  1236. catch (Exception ex)
  1237. {
  1238. // 对异常进行共通处理
  1239. ExceptionManager.HandleEventException(this.ToString(),
  1240. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1241. }
  1242. }
  1243. }
  1244. }