F_PM_1102.cs 52 KB

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