F_PM_2204.cs 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2204.cs
  5. * 2.功能描述:复检检验
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2016/07/01 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Drawing.Drawing2D;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Windows.Forms;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.BaseResources;
  20. using Dongke.IBOSS.PRD.Client.CommonModule;
  21. using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
  22. using Dongke.IBOSS.PRD.WCF.DataModels;
  23. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  24. using Dongke.IBOSS.PRD.WCF.Proxys;
  25. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  26. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  27. namespace Dongke.IBOSS.PRD.Client.PMModule
  28. {
  29. public partial class F_PM_2204 : FormBase
  30. {
  31. #region 成员变量
  32. // 新建,编辑返工,编辑不合格
  33. private int _semiCheckEditType;
  34. // 工序ID
  35. private int _procedureID;
  36. // 生产工号
  37. private int _userID = -1;
  38. // 生产编号
  39. private string _userCode;
  40. // 生产名称
  41. private string _userName;
  42. // 工序实体类
  43. ProcedureEntity _procedureDataEntity;
  44. // 产品数据表
  45. DataTable _dtProductionData = null;
  46. // 产品缺陷数据表
  47. DataTable _dtProductionDefectData = null;
  48. // 当前选择的行
  49. private int _selectedRowIndex;
  50. // ComBoxEditingControl
  51. private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
  52. // 当前产品条码的产品ID,用来查询缺陷位置
  53. private int _currentGoodsID = 0;
  54. // 当前产品条码,用来切换筛选列表数据
  55. private string _currentBarCode = "";
  56. // 当前产品缺陷
  57. private int _currentDefectFlag = 0;
  58. // 返工工序搜索列表对象
  59. C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
  60. // 过滤结果集
  61. private DataSet _ds = null;
  62. // 过滤员工结果集
  63. private DataSet _dsStaff = null;
  64. // 过滤缺陷图片
  65. private DataSet _dsImage = null;
  66. // 过滤漏检员工结果集
  67. private DataSet _dsMissdeStaff = null;
  68. // 临时数,用来过滤责任员工数据源标识
  69. private int _tempCount = 0;
  70. // 当前临时标记
  71. private string _currentTempSign = "";
  72. // 图片字节集
  73. private List<byte[]> _PicByte = new List<byte[]>();
  74. // 缩略图片字节集
  75. private List<byte[]> _smallByte = new List<byte[]>();
  76. // 当前产品缺陷
  77. private int _currentDefaultDefectFlag = 0;
  78. // 当前默认产品分级ID
  79. private int _currentGoodsLevelTypeID = 0;
  80. // 返工工序数据源
  81. private DataSet _dsRework = null;
  82. // 产品等级数据源
  83. private DataSet _dsGoodsLevel = null;
  84. //编辑生产数据ID
  85. private int _productiondataid = 0;
  86. //编辑半成品数据ID
  87. private int _semicheckid = 0;
  88. // 是否查看
  89. private bool _isView = false;
  90. // 允许编辑
  91. private int _AllowEdit = 0;
  92. // 是否只读
  93. private int _ReadOnly = 0;// 1为只读
  94. // 时间戳
  95. private DateTime _optimestamp;
  96. // 默认责任工号数据源
  97. private DataTable _dtDutyProcedureUser = null;
  98. #endregion
  99. #region 属性
  100. /// <summary>
  101. /// 条码返工工序数据源
  102. /// </summary>
  103. public DataSet DSREWORK
  104. {
  105. set
  106. {
  107. _dsRework = value;
  108. }
  109. get
  110. {
  111. if (_dsRework == null)
  112. {
  113. return _dsRework = new DataSet();
  114. }
  115. return _dsRework;
  116. }
  117. }
  118. /// <summary>
  119. /// 生产工号
  120. /// </summary>
  121. public int UserID
  122. {
  123. set
  124. {
  125. _userID = value;
  126. }
  127. get
  128. {
  129. return _userID;
  130. }
  131. }
  132. /// <summary>
  133. /// 生产编号
  134. /// </summary>
  135. public string UserCode
  136. {
  137. set
  138. {
  139. _userCode = value;
  140. }
  141. get
  142. {
  143. return _userCode;
  144. }
  145. }
  146. /// <summary>
  147. /// 用户名称
  148. /// </summary>
  149. public string UserName
  150. {
  151. set
  152. {
  153. _userName = value;
  154. }
  155. get
  156. {
  157. return _userName;
  158. }
  159. }
  160. /// <summary>
  161. /// 时间戳
  162. /// </summary>
  163. public DateTime PTimeStamp
  164. {
  165. get
  166. {
  167. return _optimestamp;
  168. }
  169. set
  170. {
  171. _optimestamp = value;
  172. }
  173. }
  174. /// <summary>
  175. /// 产品数据表
  176. /// </summary>
  177. public DataTable TableProductionData
  178. {
  179. set
  180. {
  181. _dtProductionData = value;
  182. }
  183. get
  184. {
  185. if (_dtProductionData == null)
  186. {
  187. _dtProductionData = new DataTable("ProductionData");
  188. _dtProductionData.Columns.Add("ProductionDataID");
  189. _dtProductionData.Columns.Add("BarCode");
  190. _dtProductionData.Columns.Add("GoodsID");
  191. _dtProductionData.Columns.Add("GoodsCode");
  192. _dtProductionData.Columns.Add("GoodsName");
  193. _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
  194. _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
  195. _dtProductionData.Columns.Add("Remarks");
  196. _dtProductionData.Columns.Add("UserID");
  197. _dtProductionData.Columns.Add("UserCode");
  198. _dtProductionData.Columns.Add("UserName");
  199. _dtProductionData.Columns.Add("GoodsLevelTypeID");
  200. _dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
  201. _dtProductionData.Columns.Add("ReFine");//重烧标识
  202. _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
  203. _dtProductionData.Columns.Add("ReadOnly");//1 为 只读
  204. _dtProductionData.Columns.Add("KilnCarCode");
  205. _dtProductionData.Columns.Add("KilnCode");
  206. _dtProductionData.Columns.Add("Dictionaryvalue");
  207. _dtProductionData.Columns.Add("MouldCode");//模具编号
  208. _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
  209. _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
  210. _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
  211. _dtProductionData.Columns.Add("GroutingNum");//注浆次数
  212. _dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
  213. _dtProductionData.Columns.Add("LogoCodeName");//
  214. _dtProductionData.Columns.Add("LogoID");//
  215. return _dtProductionData;
  216. }
  217. else
  218. {
  219. return _dtProductionData;
  220. }
  221. }
  222. }
  223. /// <summary>
  224. /// 产品缺陷表
  225. /// </summary>
  226. public DataTable TableProductionDefectData
  227. {
  228. set
  229. {
  230. _dtProductionDefectData = value;
  231. }
  232. get
  233. {
  234. if (_dtProductionDefectData == null)
  235. {
  236. _dtProductionDefectData = new DataTable("ProductionDefectData");
  237. _dtProductionDefectData.Columns.Add("ProductionBarCode");
  238. _dtProductionDefectData.Columns.Add("discarde");
  239. _dtProductionDefectData.Columns.Add("DefectFlag", typeof(decimal));
  240. _dtProductionDefectData.Columns.Add("DefectLocation", typeof(decimal));
  241. _dtProductionDefectData.Columns.Add("DutyProcedureUserID", typeof(decimal));
  242. _dtProductionDefectData.Columns.Add("DutyUserCode");
  243. _dtProductionDefectData.Columns.Add("DefectRemarks");
  244. return _dtProductionDefectData;
  245. }
  246. else
  247. {
  248. return _dtProductionDefectData;
  249. }
  250. }
  251. }
  252. /// <summary>
  253. /// 缺陷数据集
  254. /// </summary>
  255. public DataSet DSTable
  256. {
  257. set
  258. {
  259. _ds = value;
  260. }
  261. get
  262. {
  263. if (_ds == null)
  264. {
  265. _ds = new DataSet();
  266. return _ds;
  267. }
  268. else
  269. {
  270. return _ds;
  271. }
  272. }
  273. }
  274. /// <summary>
  275. /// 员工数据集
  276. /// </summary>
  277. public DataSet DSTableStaff
  278. {
  279. set
  280. {
  281. _dsStaff = value;
  282. }
  283. get
  284. {
  285. if (_dsStaff == null)
  286. {
  287. _dsStaff = new DataSet();
  288. return _dsStaff;
  289. }
  290. else
  291. {
  292. return _dsStaff;
  293. }
  294. }
  295. }
  296. //// <summary>
  297. //// 漏检员工数据集
  298. //// </summary>
  299. ////public DataSet DSTableMissedStaff
  300. ////{
  301. //// set
  302. //// {
  303. //// _dsMissdeStaff = value;
  304. //// }
  305. //// get
  306. //// {
  307. //// if (_dsMissdeStaff == null)
  308. //// {
  309. //// _dsMissdeStaff = new DataSet();
  310. //// return _dsMissdeStaff;
  311. //// }
  312. //// else
  313. //// {
  314. //// return _dsMissdeStaff;
  315. //// }
  316. //// }
  317. ////}
  318. //// <summary>
  319. //// 缺陷图片
  320. //// </summary>
  321. ////public DataSet DSTableImage
  322. ////{
  323. //// set
  324. //// {
  325. //// _dsImage = value;
  326. //// }
  327. //// get
  328. //// {
  329. //// if (_dsImage == null)
  330. //// {
  331. //// _dsImage = new DataSet();
  332. //// return _dsImage;
  333. //// }
  334. //// else
  335. //// {
  336. //// return _dsImage;
  337. //// }
  338. //// }
  339. ////}
  340. #endregion
  341. #region 构造函数
  342. public F_PM_2204()
  343. {
  344. InitializeComponent();
  345. }
  346. public F_PM_2204(int procedureID, string fromTitle)
  347. {
  348. InitializeComponent();
  349. this._procedureID = procedureID;
  350. this.Text = fromTitle;
  351. //this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  352. //this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  353. this.btnSave.Text = ButtonText.BTN_SAVE;
  354. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  355. //this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  356. }
  357. public F_PM_2204(int procedureID, string fromTitle, int productiondataID, bool isView)
  358. {
  359. InitializeComponent();
  360. this._AllowEdit = 1;//允许编辑
  361. this._productiondataid = productiondataID;
  362. this._procedureID = procedureID;
  363. this.Text = fromTitle;
  364. this._isView = isView;
  365. //this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  366. //this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  367. this.btnSave.Text = ButtonText.BTN_SAVE;
  368. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  369. //this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  370. }
  371. #endregion
  372. #region 事件
  373. /// <summary>
  374. /// 窗体加载事件
  375. /// </summary>
  376. /// <param name="sender"></param>
  377. /// <param name="e"></param>
  378. private void F_PM_1202_Load(object sender, System.EventArgs e)
  379. {
  380. try
  381. {
  382. this.dgvProductionData.AutoGenerateColumns = false;
  383. this.dgvProductionData.DataSource = null;
  384. this.dgvProductionData.DataSource = TableProductionData;
  385. this.dgvDefect.AutoGenerateColumns = false;
  386. this.dgvDefectStaff.AutoGenerateColumns = false;
  387. this.txtReworkProcedure.ReadOnly = true;
  388. this.txtReworkUserCode.ReadOnly = true;
  389. this.dkReSemiCheckType.Enabled = false;
  390. // 加载权限
  391. FormPermissionManager.FormPermissionControl(this.Name, this,
  392. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  393. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  394. // 加载半检,复检状态数据源
  395. DataSet dsGetSemiCheckType = SystemModuleProxy.Service.GetSemiCheckType();
  396. if (dsGetSemiCheckType != null && dsGetSemiCheckType.Tables[0].Rows.Count > 0)
  397. {
  398. DataRow drNew = dsGetSemiCheckType.Tables[0].NewRow();
  399. drNew["Semichecktypeid"] = "-1";
  400. drNew["Semichecktypename"] = "";
  401. drNew["Semichecktype"] = 2;
  402. dsGetSemiCheckType.Tables[0].Rows.InsertAt(drNew,0);
  403. DataRow[] drSemiCheckType = dsGetSemiCheckType.Tables[0].Select("Semichecktype=2 and Semichecktypeid<>0");
  404. if (drSemiCheckType.Length > 0)
  405. {
  406. this.dkReSemiCheckType.ValueMember = "Semichecktypeid";
  407. this.dkReSemiCheckType.DisplayMember = "Semichecktypename";
  408. this.dkReSemiCheckType.DataSource = drSemiCheckType.CopyToDataTable();
  409. }
  410. }
  411. }
  412. catch (Exception ex)
  413. {
  414. // 对异常进行共通处理
  415. ExceptionManager.HandleEventException(this.ToString(),
  416. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  417. }
  418. }
  419. /// <summary>
  420. /// 责任工号数据表 责任工序不选择时,默认数据源
  421. /// </summary>
  422. /// <returns></returns>
  423. private DataTable GetDutyProcedureUser()
  424. {
  425. SUserEntity userEntity = new SUserEntity();
  426. userEntity.IsWorker = 1;//生产工号
  427. DataSet dsDutyProcedureUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  428. {
  429. return SystemModuleProxy.Service.SearchUserData(userEntity);
  430. }));
  431. DataRow dr = dsDutyProcedureUser.Tables[0].NewRow();
  432. dr["UserID"] = -1;
  433. dr["UserCode"] = "";
  434. dr["UserName"] = "";
  435. dsDutyProcedureUser.Tables[0].Rows.InsertAt(dr, 0);
  436. dsDutyProcedureUser.Tables[0].AcceptChanges();
  437. this._dtDutyProcedureUser = dsDutyProcedureUser.Tables[0];
  438. return dsDutyProcedureUser.Tables[0];
  439. }
  440. /// <summary>
  441. /// 条形码按键事件
  442. /// </summary>
  443. /// <param name="sender"></param>
  444. /// <param name="e"></param>
  445. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  446. {
  447. try
  448. {
  449. this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
  450. if (this.txtBarCode.ReadOnly)
  451. {
  452. return;
  453. }
  454. if ((int)e.KeyChar == 13) // 按了回车键
  455. {
  456. if (this.txtBarCode.Text.Trim() == string.Empty)
  457. {
  458. this.txtBarCode.Focus();
  459. return;
  460. }
  461. // 校验条码
  462. ServiceResultEntity resultEntity = PMModuleProxy.Service.ReSemiCheckBarcode(this.txtBarCode.Text.Trim());
  463. this._currentBarCode = this.txtBarCode.Text.Trim();
  464. if (Convert.ToInt32(resultEntity.Result) < 0)
  465. {
  466. // 有错误
  467. // 表示有错误
  468. MessageBox.Show(resultEntity.Message,
  469. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  470. this._currentBarCode = string.Empty;
  471. return;
  472. }
  473. else
  474. {
  475. this._semicheckid = Convert.ToInt32(resultEntity.Result);
  476. SetEditDataSource_Edit();//显示数据
  477. }
  478. this.txtBarCode.Text = string.Empty;
  479. this.dkReSemiCheckType.Enabled = true;
  480. this.dkReSemiCheckType.Focus();
  481. }
  482. }
  483. catch (Exception ex)
  484. {
  485. // 对异常进行共通处理
  486. ExceptionManager.HandleEventException(this.ToString(),
  487. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  488. }
  489. }
  490. /// <summary>
  491. /// 生产数据编辑控件显示事件
  492. /// </summary>
  493. /// <param name="sender"></param>
  494. /// <param name="e"></param>
  495. private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  496. {
  497. if (e.Control is DataGridViewComboBoxEditingControl
  498. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
  499. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  500. {
  501. this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
  502. //增加委托处理
  503. this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
  504. }
  505. if (e.Control is DKListBoxComboBox
  506. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
  507. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  508. {
  509. _selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  510. DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
  511. _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  512. _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  513. dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
  514. dkListBoxComboBox.ValueMember = "ReworkProcedureID";
  515. dkListBoxComboBox.DataSource = DSREWORK.Tables[0];// DSREWORK.Tables[_currentBarCode];
  516. }
  517. }
  518. /// <summary>
  519. /// 生产数据下拉列表改变事件
  520. /// </summary>
  521. /// <param name="sender"></param>
  522. /// <param name="e"></param>
  523. private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
  524. {
  525. this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
  526. SetGridView(this._currentDefectFlag);
  527. }
  528. /// <summary>
  529. /// 产品数据单元格进入事件
  530. /// </summary>
  531. /// <param name="sender"></param>
  532. /// <param name="e"></param>
  533. private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
  534. {
  535. try
  536. {
  537. if (this.dgvProductionData.CurrentCell != null)
  538. {
  539. // 记录最后选择行
  540. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  541. {
  542. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  543. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  544. this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  545. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  546. {
  547. return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  548. }));
  549. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  550. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  551. this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  552. this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  553. this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  554. }
  555. }
  556. }
  557. catch (Exception ex)
  558. {
  559. // 对异常进行共通处理
  560. ExceptionManager.HandleEventException(this.ToString(),
  561. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  562. }
  563. }
  564. /// <summary>
  565. /// 产品数据选定项改变事件
  566. /// </summary>
  567. /// <param name="sender"></param>
  568. /// <param name="e"></param>
  569. private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
  570. {
  571. try
  572. {
  573. if (this.dgvProductionData.CurrentCell != null)
  574. {
  575. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  576. // 有无缺陷 0无缺陷 1有缺陷
  577. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  578. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  579. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  580. this.dgvDefectStaff.CurrentCell = null;
  581. this.dgvDefectStaff.DataSource = null;
  582. }
  583. }
  584. catch (Exception ex)
  585. {
  586. // 对异常进行共通处理
  587. ExceptionManager.HandleEventException(this.ToString(),
  588. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  589. }
  590. }
  591. /// <summary>
  592. /// 缺陷数据源选定项改变事件
  593. /// </summary>
  594. /// <param name="sender"></param>
  595. /// <param name="e"></param>
  596. private void dgvDefect_SelectionChanged(object sender, EventArgs e)
  597. {
  598. try
  599. {
  600. if (this.dgvDefect.CurrentCell != null)
  601. {
  602. if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
  603. {
  604. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  605. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  606. this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
  607. }
  608. else
  609. {
  610. this.dgvDefectStaff.DataSource = null;
  611. }
  612. }
  613. }
  614. catch (Exception ex)
  615. {
  616. // 对异常进行共通处理
  617. ExceptionManager.HandleEventException(this.ToString(),
  618. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  619. }
  620. }
  621. /// <summary>
  622. /// 单元格CheckBox事件
  623. /// </summary>
  624. /// <param name="sender"></param>
  625. /// <param name="e"></param>
  626. private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
  627. {
  628. if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
  629. {
  630. int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
  631. if (checkValue == Constant.INT_IS_ZERO)
  632. {
  633. SetCheckBoxSelected(checkValue, e.RowIndex);
  634. }
  635. else
  636. {
  637. this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
  638. }
  639. }
  640. }
  641. /// <summary>
  642. /// 关闭按钮事件
  643. /// </summary>
  644. /// <param name="sender"></param>
  645. /// <param name="e"></param>
  646. private void tsbtnClose_Click(object sender, EventArgs e)
  647. {
  648. this.Close();
  649. }
  650. /// <summary>
  651. /// 产品条码列表删除事件
  652. /// </summary>
  653. /// <param name="sender"></param>
  654. /// <param name="e"></param>
  655. private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  656. {
  657. try
  658. {
  659. string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
  660. DSTable.Tables[BarCode].Rows.Clear();//清空行
  661. this.dgvDefectStaff.DataSource = null;//责任员工数据源
  662. }
  663. catch (Exception ex)
  664. {
  665. throw ex;
  666. }
  667. }
  668. /// <summary>
  669. /// 产品缺陷删除行事件
  670. /// </summary>
  671. /// <param name="sender"></param>
  672. /// <param name="e"></param>
  673. private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  674. {
  675. try
  676. {
  677. if (e.Row.Index != -1)
  678. {
  679. int selectedRow = 0;
  680. if (this.dgvDefect.CurrentCell != null)
  681. {
  682. if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) ==0) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
  683. {
  684. e.Cancel = true;
  685. return;
  686. }
  687. string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
  688. DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  689. if (TempCount == "0")
  690. {
  691. selectedRow = this.dgvDefect.Rows.Count - 1;
  692. }
  693. this.dgvDefectStaff.DataSource = null;
  694. }
  695. if (this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString() != string.Empty)
  696. {
  697. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString());
  698. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  699. this._currentTempSign = this.dgvDefect.Rows[selectedRow].Cells["TempCount"].Value.ToString(); //当前临时标记
  700. }
  701. else
  702. {
  703. this.dgvDefectStaff.DataSource = null;
  704. }
  705. }
  706. }
  707. catch (Exception ex)
  708. {
  709. throw ex;
  710. }
  711. }
  712. /// <summary>
  713. /// 产品数据源值改变后
  714. /// </summary>
  715. /// <param name="sender"></param>
  716. /// <param name="e"></param>
  717. private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  718. {
  719. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  720. {
  721. }
  722. }
  723. /// <summary>
  724. /// 保存按钮事件
  725. /// </summary>
  726. /// <param name="sender"></param>
  727. /// <param name="e"></param>
  728. private void btnSave_Click(object sender, EventArgs e)
  729. {
  730. try
  731. {
  732. #region 保存画面验证 2016-06-29
  733. if (this.dkReSemiCheckType.SelectedValue==null || this.dkReSemiCheckType.SelectedValue.ToString()=="-1")
  734. {
  735. // 提示信息
  736. MessageBox.Show("复检状态必须填写",
  737. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  738. this.dkReSemiCheckType.Focus();
  739. return;
  740. }
  741. #endregion 保存画面验证
  742. SemiCheckEntity[] productionDataEntitys = new SemiCheckEntity[this.TableProductionData.Rows.Count];
  743. bool isError = false; // 是否存在缺陷员工
  744. int ErrorCount = -1;
  745. for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
  746. {
  747. SemiCheckEntity productionDataEntity = new SemiCheckEntity();
  748. productionDataEntity.SemiCheckCategory = 2; //复检
  749. productionDataEntity.ReSemiCheckType = this.dkReSemiCheckType.SelectedValue.ToString();
  750. if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
  751. {
  752. productionDataEntity.SemiCheckID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
  753. }
  754. productionDataEntity.BarCode = this.TableProductionData.Rows[i]["BarCode"].ToString();
  755. productionDataEntity.SemiCheckUserID = UserID;
  756. productionDataEntity.SemiCheckUserCode = UserCode;
  757. productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
  758. productionDataEntitys[i] = productionDataEntity;
  759. List<SemiCheckDefectEntity> productionDefectEntitys = new List<SemiCheckDefectEntity>();
  760. SemiCheckDefectEntity productionDefectEntity = null;
  761. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.BarCode].Rows.Count; j++) //缺陷列表
  762. {
  763. productionDefectEntity = new SemiCheckDefectEntity();
  764. productionDefectEntity.ScrapResponFlag = "0";
  765. productionDefectEntity.DefectID =
  766. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectID"]);
  767. productionDefectEntity.DefectCode =
  768. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectCode"].ToString();
  769. productionDefectEntity.DefectName =
  770. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  771. productionDefectEntity.DefectPositionID =
  772. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionID"]);
  773. productionDefectEntity.DefectPositionCode =
  774. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionCode"].ToString();
  775. productionDefectEntity.DefectPositionName =
  776. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  777. productionDefectEntity.DefectProductionDataID =
  778. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["ProductionDataID"].ToString()==""?"0":
  779. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["ProductionDataID"].ToString());
  780. if (productionDefectEntity.DefectProductionDataID == 0)
  781. {
  782. productionDefectEntity.DefectProductionDataID = null;
  783. }
  784. if (this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
  785. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
  786. {
  787. productionDefectEntity.DefectProcedureID =
  788. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureID"]);
  789. }
  790. productionDefectEntity.DefectProcedureCode =
  791. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureCode"].ToString();
  792. productionDefectEntity.DefectProcedureName =
  793. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectProcedureName"].ToString();
  794. productionDefectEntity.DefectUserID =
  795. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserID"]);
  796. productionDefectEntity.DefectUserCode =
  797. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserCode"].ToString();
  798. productionDefectEntity.DefectUserName =
  799. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectUserName"].ToString();
  800. //productionDefectEntity.DefectJobs =
  801. // Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  802. productionDefectEntity.Remarks =
  803. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["DefectRemarks"].ToString();
  804. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  805. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  806. //{
  807. // productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  808. //}
  809. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
  810. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
  811. //{
  812. // productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
  813. // productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
  814. // productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
  815. //}
  816. // 遍历责任员工
  817. List<SemiCheckResponsibleEntity> DefectResponsibles = new List<SemiCheckResponsibleEntity>();
  818. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  819. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())))
  820. {
  821. SemiCheckResponsibleEntity defectResponsibleEntity = null;
  822. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  823. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())];
  824. foreach (DataRow drStaff in dtTemp.Rows)
  825. {
  826. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  827. {
  828. defectResponsibleEntity = new SemiCheckResponsibleEntity();
  829. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  830. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  831. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  832. defectResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
  833. defectResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
  834. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  835. DefectResponsibles.Add(defectResponsibleEntity);
  836. }
  837. }
  838. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  839. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  840. }
  841. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  842. {
  843. isError = true;
  844. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.BarCode];
  845. this.dgvDefect.CurrentCell = null;
  846. this.dgvDefect.Rows[j].Selected = true;
  847. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  848. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())))
  849. {
  850. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  851. this.DSTable.Tables[productionDataEntity.BarCode].Rows[j]["TempCount"].ToString())];
  852. }
  853. else
  854. {
  855. this.dgvDefectStaff.DataSource = null;
  856. }
  857. break;
  858. }
  859. productionDefectEntitys.Add(productionDefectEntity);
  860. }
  861. if (isError)
  862. {
  863. break;
  864. }
  865. productionDataEntitys[i].SemiCheckDefects = productionDefectEntitys;
  866. }
  867. // 有错误
  868. if (isError)
  869. {
  870. if (ErrorCount == -Constant.INT_IS_ONE)
  871. {
  872. // 提示信息
  873. MessageBox.Show(Messages.MSG_PM_W002,
  874. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  875. return;
  876. }
  877. else if (ErrorCount == -Constant.INT_IS_TWO)
  878. {
  879. // 提示信息
  880. MessageBox.Show(Messages.MSG_PM_W004,
  881. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  882. return;
  883. }
  884. else
  885. {
  886. this.dgvProductionData.DataSource = TableProductionData;
  887. // 提示信息
  888. MessageBox.Show(Messages.MSG_PM_W003,
  889. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);;
  890. return;
  891. }
  892. }
  893. // 最外层For循环结束
  894. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  895. {
  896. string returnValue = "";
  897. ServiceResultEntity entity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  898. {
  899. return PMModuleProxy.Service.AddSemiCheck(productionDataEntitys);
  900. }));
  901. returnValue = entity.Message;
  902. if (string.IsNullOrEmpty(returnValue))//成功
  903. {
  904. // 提示信息
  905. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  906. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  907. this.TableProductionData.Rows.Clear();
  908. this.dgvProductionData.DataSource = TableProductionData;
  909. this.DSTable.Tables.Clear();
  910. this.dgvDefect.DataSource = null;
  911. this.DSTableStaff.Tables.Clear();
  912. this.dgvDefectStaff.DataSource = null;
  913. this.txtBarCode.Text = string.Empty;
  914. this.txtUserCode.Text = string.Empty;
  915. // this.txtUserCode.ReadOnly = false;
  916. this.dkReSemiCheckType.SelectedValue = -1;
  917. this.dkReSemiCheckType.Enabled = false;
  918. this.txtReworkProcedure.Text = string.Empty;
  919. this.txtReworkUserCode.Text = string.Empty;
  920. this.txtUserCode.Text = string.Empty;
  921. this.txtBarCode.ReadOnly = false;
  922. this.txtBarCode.Focus();
  923. }
  924. else
  925. {
  926. // 提示信息
  927. MessageBox.Show(returnValue,
  928. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  929. }
  930. }
  931. }
  932. catch (Exception ex)
  933. {
  934. // 对异常进行共通处理
  935. ExceptionManager.HandleEventException(this.ToString(),
  936. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  937. }
  938. }
  939. /// <summary>
  940. /// 关闭按钮事件
  941. /// </summary>
  942. /// <param name="sender"></param>
  943. /// <param name="e"></param>
  944. private void tsbCloseTop_Click(object sender, EventArgs e)
  945. {
  946. this.Close();
  947. }
  948. /// <summary>
  949. /// 单元格编辑开始时事件
  950. /// </summary>
  951. /// <param name="sender"></param>
  952. /// <param name="e"></param>
  953. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  954. {
  955. //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  956. //{
  957. // DataGridView dgv = (DataGridView)sender;
  958. // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  959. // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  960. // {
  961. // e.Cancel = true;
  962. // }
  963. //}
  964. //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  965. //{
  966. // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  967. // {
  968. // e.Cancel = true;
  969. // }
  970. //}
  971. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  972. {
  973. DataGridView dgv = (DataGridView)sender;
  974. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  975. if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  976. {
  977. e.Cancel = true;
  978. }
  979. }
  980. if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  981. {
  982. if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  983. {
  984. e.Cancel = true;
  985. }
  986. }
  987. }
  988. /// <summary>
  989. /// 用户编码验证事件
  990. /// </summary>
  991. /// <param name="sender"></param>
  992. /// <param name="e"></param>
  993. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  994. {
  995. }
  996. #endregion
  997. #region 私有方法
  998. /// <summary>
  999. /// 设置数据源
  1000. /// </summary>
  1001. /// <param name="tempCount"></param>
  1002. public void SetDataSource(int tempCount)
  1003. {
  1004. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1005. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1006. this._tempCount = tempCount;
  1007. }
  1008. /// <summary>
  1009. /// 通过是否有缺陷来启用或禁用
  1010. /// </summary>
  1011. /// <param name="DefectFlag"></param>
  1012. private void SetGridView(int GoodsLevelID)
  1013. {
  1014. }
  1015. /// <summary>
  1016. /// 清空以前所选中的缺陷
  1017. /// </summary>
  1018. /// <param name="checkValue"></param>
  1019. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  1020. {
  1021. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  1022. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  1023. {
  1024. if (i == rowIndex)
  1025. {
  1026. dtOrgDataSource.Rows[i]["discarde"] = 1;
  1027. }
  1028. else
  1029. {
  1030. dtOrgDataSource.Rows[i]["discarde"] = 0;
  1031. }
  1032. }
  1033. }
  1034. #endregion
  1035. /// <summary>
  1036. /// 责任员工
  1037. /// </summary>
  1038. /// <param name="sender"></param>
  1039. /// <param name="e"></param>
  1040. private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1041. {
  1042. try
  1043. {
  1044. if (e.Row.Index != -1)
  1045. {
  1046. if (this.dgvDefect.CurrentCell != null)
  1047. {
  1048. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1049. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1050. {
  1051. e.Cancel = true;
  1052. return;
  1053. }
  1054. }
  1055. }
  1056. }
  1057. catch (Exception ex)
  1058. {
  1059. throw ex;
  1060. }
  1061. }
  1062. /// <summary>
  1063. /// 漏扫责任员工
  1064. /// </summary>
  1065. /// <param name="sender"></param>
  1066. /// <param name="e"></param>
  1067. private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1068. {
  1069. try
  1070. {
  1071. if (e.Row.Index != -1)
  1072. {
  1073. if (this.dgvDefect.CurrentCell != null)
  1074. {
  1075. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1076. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1077. {
  1078. e.Cancel = true;
  1079. return;
  1080. }
  1081. }
  1082. }
  1083. }
  1084. catch (Exception ex)
  1085. {
  1086. throw ex;
  1087. }
  1088. }
  1089. /// <summary>
  1090. /// 绑定到第一个DataGriwView数据源
  1091. /// </summary>
  1092. private void BindProductionData_New()
  1093. {
  1094. try
  1095. {
  1096. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  1097. if (dr.Length > Constant.INT_IS_ZERO)
  1098. {
  1099. // 不允许重复添加
  1100. return;
  1101. }
  1102. // 目前只能添加一个条码
  1103. this.TableProductionData.Rows.Clear();
  1104. this.dgvProductionData.DataSource = TableProductionData;
  1105. this.DSTable.Tables.Clear();
  1106. this.dgvDefect.DataSource = null;
  1107. this.DSTableStaff.Tables.Clear();
  1108. this.dgvDefectStaff.DataSource = null;
  1109. //this.txtBarCode.Text = string.Empty;
  1110. //this.dropReworkProcedure.DataSource = null;
  1111. //this.dropDutyUser.DisplayMember = "UserCode";
  1112. //this.dropDutyUser.ValueMember = "UserID";
  1113. //this.dropDutyUser.DataSource = this._dtDutyProcedureUser;
  1114. // 目前只能添加一个条码
  1115. int SpecialRepairflag = 0;
  1116. string KilnCarCode = string.Empty;
  1117. string KilnCode = string.Empty;
  1118. string Dictionaryvalue = string.Empty;
  1119. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1120. {
  1121. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  1122. }));
  1123. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1124. {
  1125. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  1126. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  1127. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  1128. }
  1129. DataRow drNew = TableProductionData.NewRow();
  1130. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  1131. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1132. {
  1133. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  1134. }));
  1135. if (ds != null && ds.Tables[0].Rows.Count > 0)
  1136. {
  1137. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  1138. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  1139. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  1140. SpecialRepairflag = Convert.ToInt32(ds.Tables[0].Rows[0]["SpecialRepairFlag"]);
  1141. }
  1142. drNew["UserID"] = UserID;
  1143. drNew["KilnCarCode"] = KilnCarCode;
  1144. drNew["KilnCode"] = KilnCode;
  1145. drNew["Dictionaryvalue"] = Dictionaryvalue;
  1146. // drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  1147. //drNew["ReworkProcedureID"] = DBNull.Value;
  1148. drNew["Remarks"] = "";
  1149. drNew["UserID"] = UserID;
  1150. drNew["UserCode"] = UserCode;
  1151. drNew["UserName"] = UserName;
  1152. //drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1153. //drNew["OrgGoodsLevelTypeID"] = -1;
  1154. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  1155. drNew["LogoCodeName"] = ds.Tables[0].Rows[0]["logoname"]
  1156. + "[" + ds.Tables[0].Rows[0]["logocode"] + "]";
  1157. drNew["LogoID"] = ds.Tables[0].Rows[0]["LogoID"];
  1158. // 校验条码是否重烧过
  1159. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1160. {
  1161. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  1162. }));
  1163. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  1164. {
  1165. drNew["ReFine"] = 1;
  1166. }
  1167. else
  1168. {
  1169. drNew["ReFine"] = 0;
  1170. }
  1171. // 由产品条码获取注浆信息
  1172. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1173. {
  1174. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  1175. }));
  1176. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  1177. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  1178. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  1179. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  1180. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  1181. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  1182. TableProductionData.Rows.Add(drNew);
  1183. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  1184. {
  1185. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  1186. dtProductionDefectData.Columns.Add("BarCode");
  1187. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1188. dtProductionDefectData.Columns.Add("DefectName");
  1189. dtProductionDefectData.Columns.Add("DefectCode");
  1190. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1191. dtProductionDefectData.Columns.Add("DefectPositionName");
  1192. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1193. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1194. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1195. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1196. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1197. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1198. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1199. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1200. dtProductionDefectData.Columns.Add("JobsText");//工种
  1201. dtProductionDefectData.Columns.Add("DefectRemarks");
  1202. dtProductionDefectData.Columns.Add("TempCount");
  1203. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1204. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1205. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  1206. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1207. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1208. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1209. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  1210. //新添加的 wangx 2016/1/6
  1211. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1212. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1213. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1214. DSTable.Tables.Add(dtProductionDefectData);
  1215. }
  1216. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  1217. //this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1218. this.dgvDefect.DataSource = null;
  1219. this.dgvDefectStaff.DataSource = null;
  1220. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1221. }
  1222. catch (Exception ex)
  1223. {
  1224. throw ex;
  1225. }
  1226. }
  1227. /// <summary>
  1228. /// 编辑后设置数据源
  1229. /// </summary>
  1230. private void SetEditDataSource_Edit()
  1231. {
  1232. try
  1233. {
  1234. this.txtUserCode.ReadOnly = true;
  1235. this.txtBarCode.ReadOnly = true;
  1236. this.txtReworkProcedure.ReadOnly = true;
  1237. this.txtReworkUserCode.ReadOnly = true;
  1238. DataSet dsSemiCheckByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1239. {
  1240. return PMModuleProxy.Service.GetSemiCheckByID(this._semicheckid);
  1241. }));
  1242. if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1243. {
  1244. // 设置返工工序等信息
  1245. if (dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureName"].ToString() != "")
  1246. {
  1247. this.txtReworkProcedure.Text = dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureName"].ToString();
  1248. }
  1249. if (dsSemiCheckByID.Tables[0].Rows[0]["ReworkUserCode"].ToString() != "")
  1250. {
  1251. this.txtReworkUserCode.Text = dsSemiCheckByID.Tables[0].Rows[0]["ReworkUserCode"].ToString();
  1252. }
  1253. if (dsSemiCheckByID.Tables[0].Rows[0]["UserCode"].ToString() != "")
  1254. {
  1255. this.txtUserCode.Text = dsSemiCheckByID.Tables[0].Rows[0]["UserCode"].ToString();
  1256. }
  1257. //#region 如果无编辑权限半检状态只能往下调,过滤掉上级状态
  1258. //if (this._AllowEdit == 0)
  1259. //{
  1260. // DataView dv = ((DataTable)this.dkSemiCheckType.DataSource).DefaultView;
  1261. // dv.RowFilter = "Semichecktypeid>=" + dsSemiCheckByID.Tables[0].Rows[0]["SemiCheckType"].ToString();
  1262. // this.dkSemiCheckType.ValueMember = "Semichecktypeid";
  1263. // this.dkSemiCheckType.DisplayMember = "Semichecktypename";
  1264. // this.dkSemiCheckType.DataSource = dv.ToTable();
  1265. //}
  1266. //#endregion 如果无编辑权限半检状态只能往下调,过滤掉上级状态 end
  1267. //this.dkSemiCheckType.SelectedValue = dsSemiCheckByID.Tables[0].Rows[0]["SemiCheckType"].ToString();
  1268. // 设置返工工序等信息 end
  1269. // 产品数据
  1270. DataRow drNew = TableProductionData.NewRow();
  1271. drNew["ProductionDataID"] = this._semicheckid;
  1272. drNew["BarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"];
  1273. drNew["GoodsID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsID"];
  1274. drNew["GoodsCode"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsCode"];
  1275. drNew["GoodsName"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsName"];
  1276. //drNew["DefectFlagID"] = dsSemiCheckByID.Tables[0].Rows[0]["DefectFlagID"];
  1277. //drNew["ReworkProcedureID"] = dsSemiCheckByID.Tables[0].Rows[0]["ReworkProcedureID"];
  1278. drNew["Remarks"] = dsSemiCheckByID.Tables[0].Rows[0]["Remarks"];
  1279. drNew["UserID"] = dsSemiCheckByID.Tables[0].Rows[0]["UserID"];
  1280. drNew["GoodsLevelTypeID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1281. drNew["UserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["UserCode"];
  1282. drNew["UserName"] = dsSemiCheckByID.Tables[0].Rows[0]["UserName"];
  1283. drNew["OrgGoodsLevelTypeID"] = dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1284. drNew["ReadOnly"] = this._ReadOnly;
  1285. // drNew["KilnCarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["KilnCarCode"];
  1286. // drNew["KilnCode"] = dsSemiCheckByID.Tables[0].Rows[0]["KilnCode"];
  1287. // drNew["Dictionaryvalue"] = dsSemiCheckByID.Tables[0].Rows[0]["Dictionaryvalue"];
  1288. drNew["UserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["UserCode"];
  1289. drNew["MouldCode"] = dsSemiCheckByID.Tables[0].Rows[0]["MouldCode"];
  1290. drNew["GroutingUserCode"] = dsSemiCheckByID.Tables[0].Rows[0]["GroutingUserCode"];
  1291. drNew["GroutingNum"] = dsSemiCheckByID.Tables[0].Rows[0]["GroutingNum"];
  1292. drNew["IsPublicBody"] = dsSemiCheckByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  1293. drNew["GroutingDate"] = Convert.ToDateTime(dsSemiCheckByID.Tables[0].Rows[0]["GroutingDate"]);
  1294. drNew["LogoCodeName"] = dsSemiCheckByID.Tables[0].Rows[0]["LogoName"] + "[" + dsSemiCheckByID.Tables[0].Rows[0]["LogoCode"] + "]";
  1295. drNew["LogoId"] = dsSemiCheckByID.Tables[0].Rows[0]["LogoId"];
  1296. //drNew["ReFine"] = dsSemiCheckByID.Tables[0].Rows[0]["Isrefire"];
  1297. drNew["SpecialRepairflag"] = dsSemiCheckByID.Tables[0].Rows[0]["SpecialRepairflag"];
  1298. TableProductionData.Rows.Add(drNew);
  1299. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1300. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1301. this._currentBarCode = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString();
  1302. this._currentGoodsID = Convert.ToInt32(dsSemiCheckByID.Tables[0].Rows[0]["GoodsID"]);
  1303. ////////if (dsSemiCheckByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
  1304. ////////{
  1305. //////// //次品设置只读的时候,原来默认不允许修改,目前注释掉
  1306. //////// //SetSubstandard();
  1307. //////// DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1308. //////// {
  1309. //////// return PMModuleProxy.Service.GetSubstandardInfo(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
  1310. //////// }));
  1311. //////// if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
  1312. //////// {
  1313. //////// // 提示信息
  1314. //////// MessageBox.Show("次品条码:" + dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
  1315. //////// this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1316. //////// return;
  1317. //////// }
  1318. //////// this.tsbtnAdd.Enabled = true;
  1319. ////////}
  1320. ////////else
  1321. ////////{
  1322. //////// this.tsbtnAdd.Enabled = true;
  1323. //////// if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1324. //////// {
  1325. //////// this.tsbtnEdit.Enabled = true;
  1326. //////// }
  1327. ////////}
  1328. }
  1329. if (DSTable.Tables.IndexOf(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1330. {
  1331. DataTable dtProductionDefectData = new DataTable(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
  1332. dtProductionDefectData.Columns.Add("BarCode");
  1333. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1334. dtProductionDefectData.Columns.Add("DefectName");
  1335. dtProductionDefectData.Columns.Add("DefectCode");
  1336. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1337. dtProductionDefectData.Columns.Add("DefectPositionName");
  1338. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1339. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1340. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1341. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1342. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1343. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1344. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1345. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1346. dtProductionDefectData.Columns.Add("JobsText");//工种
  1347. dtProductionDefectData.Columns.Add("DefectRemarks");
  1348. dtProductionDefectData.Columns.Add("TempCount");
  1349. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1350. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  1351. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  1352. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1353. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1354. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1355. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1356. //新添加的 wangx 2016/1/6
  1357. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1358. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1359. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1360. //新添加的 wangx 2016/1/6 end
  1361. DSTable.Tables.Add(dtProductionDefectData);
  1362. }
  1363. if (dsSemiCheckByID != null && dsSemiCheckByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1364. {
  1365. // 产品缺陷
  1366. if (DSTable.Tables.IndexOf(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1367. {
  1368. DataTable dtProductionDefectData = new DataTable(dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString());
  1369. dtProductionDefectData.Columns.Add("BarCode");
  1370. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1371. dtProductionDefectData.Columns.Add("DefectName");
  1372. dtProductionDefectData.Columns.Add("DefectCode");
  1373. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1374. dtProductionDefectData.Columns.Add("DefectPositionName");
  1375. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1376. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1377. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1378. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1379. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1380. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1381. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1382. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1383. dtProductionDefectData.Columns.Add("JobsText");//工种
  1384. dtProductionDefectData.Columns.Add("DefectRemarks");
  1385. dtProductionDefectData.Columns.Add("TempCount");
  1386. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1387. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1388. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  1389. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1390. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1391. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1392. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1393. //新添加的 wangx 2016/1/6
  1394. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1395. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1396. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1397. //新添加的 wangx 2016/1/6 end
  1398. DSTable.Tables.Add(dtProductionDefectData);
  1399. }
  1400. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1401. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1402. //this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  1403. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  1404. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  1405. //-----------------------
  1406. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1407. //{
  1408. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  1409. //}));
  1410. //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1411. //if (this.DSREWORK == null)
  1412. //{
  1413. // this.DSREWORK = new DataSet();
  1414. //}
  1415. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  1416. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  1417. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  1418. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  1419. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  1420. for (int i = 0; i < dsSemiCheckByID.Tables[1].Rows.Count; i++)
  1421. {
  1422. DataRow dr = DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  1423. dr["BarCode"] = dsSemiCheckByID.Tables[0].Rows[0]["BarCode"];
  1424. dr["DefectID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectID"];
  1425. dr["DefectName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectName"];
  1426. dr["DefectCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectCode"];
  1427. dr["DefectPositionID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionID"];
  1428. dr["DefectPositionName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionName"];
  1429. dr["DefectPositionCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectPositionCode"];
  1430. dr["DefectProcedureID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureID"];
  1431. dr["DefectProcedureName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureName"];
  1432. dr["DefectProcedureCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProcedureCode"];
  1433. dr["DefectUserID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserID"];
  1434. dr["DefectUserName"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserName"];
  1435. dr["DefectUserCode"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectUserCode"];
  1436. //dr["Jobs"] = dsSemiCheckByID.Tables[1].Rows[i]["Jobs"];
  1437. //dr["JobsText"] = dsSemiCheckByID.Tables[1].Rows[i]["JobsText"];
  1438. dr["DefectRemarks"] = dsSemiCheckByID.Tables[1].Rows[i]["remarks"];
  1439. dr["TempCount"] = this._tempCount;
  1440. dr["ProductionDataID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  1441. //dr["DefectFineID"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectFineID"];
  1442. //dr["DefectFineValue"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectFineValue"];
  1443. //dr["MissedUserID"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserID"];
  1444. //dr["MissedUserCode"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserCode"];
  1445. //dr["MissedUserName"] = dsSemiCheckByID.Tables[1].Rows[i]["MissedUserName"];
  1446. dr["IsAllowEdit"] = this._AllowEdit;
  1447. //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
  1448. //dr["DefectDeductionNum"] = dsSemiCheckByID.Tables[1].Rows[i]["DefectDeductionNum"];
  1449. //dr["IsOtherDefect"] = dsSemiCheckByID.Tables[1].Rows[i]["SpecialDefect"];
  1450. DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  1451. // 防止工种不选择的话,直接New一个
  1452. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  1453. {
  1454. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  1455. dtStaff.Columns.Add("IsSelected");
  1456. dtStaff.Columns.Add("StaffID");
  1457. dtStaff.Columns.Add("StaffCode");
  1458. dtStaff.Columns.Add("StaffName");
  1459. dtStaff.Columns.Add("StaffTempCount");
  1460. dtStaff.Columns.Add("StaffStatus");
  1461. dtStaff.Columns.Add("UjobsID");
  1462. dtStaff.Columns.Add("SjobsID");
  1463. this.DSTableStaff.Tables.Add(dtStaff);
  1464. }
  1465. // 责任员工
  1466. DataRow[] drRow = dsSemiCheckByID.Tables[2].Select("SemiCheckDefectID=" + dsSemiCheckByID.Tables[1].Rows[i]["SemiCheckDefectID"]);
  1467. if (drRow.Length > Constant.INT_IS_ZERO)
  1468. {
  1469. foreach (DataRow r in drRow)
  1470. {
  1471. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  1472. drStaff["IsSelected"] = 1;
  1473. drStaff["StaffID"] = r["StaffID"];
  1474. drStaff["StaffCode"] = r["StaffCode"];
  1475. drStaff["StaffName"] = r["StaffName"];
  1476. drStaff["StaffTempCount"] = this._tempCount;
  1477. drStaff["StaffStatus"] = r["StaffStatus"];
  1478. drStaff["UjobsID"] = r["UjobsID"];
  1479. drStaff["SjobsID"] = r["SjobsID"];
  1480. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  1481. }
  1482. }
  1483. this._currentTempSign = i.ToString();
  1484. this._tempCount = this._tempCount + 1;
  1485. }
  1486. this.dgvDefect.DataSource = DSTable.Tables[dsSemiCheckByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  1487. //////////控制产品等级,只有编辑权限的人才能随便改
  1488. ////////if (this._AllowEdit == 0) //
  1489. ////////{
  1490. //////// for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
  1491. //////// {
  1492. //////// int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  1493. //////// if (this._dsGoodsLevel != null)
  1494. //////// {
  1495. //////// DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
  1496. //////// DataView dv = dt.DefaultView;
  1497. //////// dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  1498. //////// DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
  1499. //////// dgcbc.DisplayMember = "DefectFlagName";
  1500. //////// dgcbc.ValueMember = "DefectFlagID";
  1501. //////// dgcbc.DataSource = dv.ToTable();
  1502. //////// }
  1503. //////// }
  1504. ////////}
  1505. }
  1506. }
  1507. catch (Exception ex)
  1508. {
  1509. throw ex;
  1510. }
  1511. }
  1512. }
  1513. }