F_PM_2205.cs 80 KB

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