F_PM_1102.cs 52 KB

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