F_PM_1202.cs 165 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1202.cs
  5. * 2.功能描述:成品检验
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/10/10 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. /// <summary>
  30. /// 成品检验
  31. /// </summary>
  32. public partial class F_PM_1202 : FormBase
  33. {
  34. #region 成员变量
  35. // 工序ID
  36. private int _procedureID;
  37. // 生产工号
  38. private int _userID = -1;
  39. // 生产编号
  40. private string _userCode;
  41. // 生产名称
  42. private string _userName;
  43. // 工序实体类
  44. ProcedureEntity _procedureDataEntity;
  45. // 产品数据表
  46. DataTable _dtProductionData = null;
  47. // 产品缺陷数据表
  48. DataTable _dtProductionDefectData = null;
  49. // 当前选择的行
  50. private int _selectedRowIndex;
  51. // ComBoxEditingControl
  52. private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
  53. // 当前产品条码的产品ID,用来查询缺陷位置
  54. private int _currentGoodsID = 0;
  55. // 当前产品条码,用来切换筛选列表数据
  56. private string _currentBarCode = "";
  57. // 当前产品缺陷
  58. private int _currentDefectFlag = 0;
  59. // 返工工序搜索列表对象
  60. C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
  61. // 过滤结果集
  62. private DataSet _ds = null;
  63. // 过滤员工结果集
  64. private DataSet _dsStaff = null;
  65. // 过滤缺陷图片
  66. private DataSet _dsImage = null;
  67. // 过滤漏检员工结果集
  68. private DataSet _dsMissdeStaff = null;
  69. // 临时数,用来过滤责任员工数据源标识
  70. private int _tempCount = 0;
  71. // 当前临时标记
  72. private string _currentTempSign = "";
  73. // 图片字节集
  74. private List<byte[]> _PicByte = new List<byte[]>();
  75. // 缩略图片字节集
  76. private List<byte[]> _smallByte = new List<byte[]>();
  77. // 当前产品缺陷
  78. private int _currentDefaultDefectFlag = 0;
  79. // 当前默认产品分级ID
  80. private int _currentGoodsLevelTypeID = 0;
  81. // 返工工序数据源
  82. private DataSet _dsRework = null;
  83. // 产品等级数据源
  84. private DataSet _dsGoodsLevel = null;
  85. //编辑生产数据ID
  86. private int _productiondataid = 0;
  87. // 是否查看
  88. private bool _isView = false;
  89. // 允许编辑
  90. private int _AllowEdit = 0;
  91. // 是否只读
  92. private int _ReadOnly = 0;// 1为只读
  93. // 时间戳
  94. private DateTime _optimestamp;
  95. // 成检登记改判限制天数
  96. private int _settingvaluedays = 0;
  97. #endregion
  98. #region 属性
  99. /// <summary>
  100. /// 条码返工工序数据源
  101. /// </summary>
  102. public DataSet DSREWORK
  103. {
  104. set
  105. {
  106. _dsRework = value;
  107. }
  108. get
  109. {
  110. if (_dsRework == null)
  111. {
  112. return _dsRework = new DataSet();
  113. }
  114. return _dsRework;
  115. }
  116. }
  117. /// <summary>
  118. /// 生产工号
  119. /// </summary>
  120. public int UserID
  121. {
  122. set
  123. {
  124. _userID = value;
  125. }
  126. get
  127. {
  128. return _userID;
  129. }
  130. }
  131. /// <summary>
  132. /// 生产编号
  133. /// </summary>
  134. public string UserCode
  135. {
  136. set
  137. {
  138. _userCode = value;
  139. }
  140. get
  141. {
  142. return _userCode;
  143. }
  144. }
  145. /// <summary>
  146. /// 用户名称
  147. /// </summary>
  148. public string UserName
  149. {
  150. set
  151. {
  152. _userName = value;
  153. }
  154. get
  155. {
  156. return _userName;
  157. }
  158. }
  159. /// <summary>
  160. /// 时间戳
  161. /// </summary>
  162. public DateTime PTimeStamp
  163. {
  164. get
  165. {
  166. return _optimestamp;
  167. }
  168. set
  169. {
  170. _optimestamp = value;
  171. }
  172. }
  173. /// <summary>
  174. /// 产品数据表
  175. /// </summary>
  176. public DataTable TableProductionData
  177. {
  178. set
  179. {
  180. _dtProductionData = value;
  181. }
  182. get
  183. {
  184. if (_dtProductionData == null)
  185. {
  186. _dtProductionData = new DataTable("ProductionData");
  187. _dtProductionData.Columns.Add("ProductionDataID");
  188. _dtProductionData.Columns.Add("BarCode");
  189. _dtProductionData.Columns.Add("GoodsID");
  190. _dtProductionData.Columns.Add("GoodsCode");
  191. _dtProductionData.Columns.Add("GoodsName");
  192. _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
  193. _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
  194. _dtProductionData.Columns.Add("Remarks");
  195. _dtProductionData.Columns.Add("UserID");
  196. _dtProductionData.Columns.Add("UserCode");
  197. _dtProductionData.Columns.Add("UserName");
  198. _dtProductionData.Columns.Add("GoodsLevelTypeID");
  199. _dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
  200. _dtProductionData.Columns.Add("ReFine");//重烧标识
  201. _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
  202. _dtProductionData.Columns.Add("ReadOnly");//1 为 只读
  203. _dtProductionData.Columns.Add("KilnCarCode");
  204. _dtProductionData.Columns.Add("KilnCode");
  205. _dtProductionData.Columns.Add("Dictionaryvalue");
  206. _dtProductionData.Columns.Add("MouldCode");//模具编号
  207. _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
  208. _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
  209. _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
  210. _dtProductionData.Columns.Add("GroutingNum");//注浆次数
  211. _dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
  212. _dtProductionData.Columns.Add("LogoCodeName");//
  213. _dtProductionData.Columns.Add("LogoID");//
  214. _dtProductionData.Columns.Add("CheckTime");//
  215. return _dtProductionData;
  216. }
  217. else
  218. {
  219. return _dtProductionData;
  220. }
  221. }
  222. }
  223. /// <summary>
  224. /// 缺陷数据集
  225. /// </summary>
  226. public DataSet DSTable
  227. {
  228. set
  229. {
  230. _ds = value;
  231. }
  232. get
  233. {
  234. if (_ds == null)
  235. {
  236. _ds = new DataSet();
  237. return _ds;
  238. }
  239. else
  240. {
  241. return _ds;
  242. }
  243. }
  244. }
  245. /// <summary>
  246. /// 员工数据集
  247. /// </summary>
  248. public DataSet DSTableStaff
  249. {
  250. set
  251. {
  252. _dsStaff = value;
  253. }
  254. get
  255. {
  256. if (_dsStaff == null)
  257. {
  258. _dsStaff = new DataSet();
  259. return _dsStaff;
  260. }
  261. else
  262. {
  263. return _dsStaff;
  264. }
  265. }
  266. }
  267. /// <summary>
  268. /// 漏检员工数据集
  269. /// </summary>
  270. public DataSet DSTableMissedStaff
  271. {
  272. set
  273. {
  274. _dsMissdeStaff = value;
  275. }
  276. get
  277. {
  278. if (_dsMissdeStaff == null)
  279. {
  280. _dsMissdeStaff = new DataSet();
  281. return _dsMissdeStaff;
  282. }
  283. else
  284. {
  285. return _dsMissdeStaff;
  286. }
  287. }
  288. }
  289. /// <summary>
  290. /// 缺陷图片
  291. /// </summary>
  292. public DataSet DSTableImage
  293. {
  294. set
  295. {
  296. _dsImage = value;
  297. }
  298. get
  299. {
  300. if (_dsImage == null)
  301. {
  302. _dsImage = new DataSet();
  303. return _dsImage;
  304. }
  305. else
  306. {
  307. return _dsImage;
  308. }
  309. }
  310. }
  311. #endregion
  312. #region 构造函数
  313. public F_PM_1202()
  314. {
  315. InitializeComponent();
  316. }
  317. public F_PM_1202(int procedureID, string fromTitle)
  318. {
  319. InitializeComponent();
  320. this._procedureID = procedureID;
  321. this.Text = fromTitle;
  322. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  323. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  324. this.btnSave.Text = ButtonText.BTN_SAVE;
  325. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  326. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  327. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  328. this.btnDelete.Text = ButtonText.BTN_DELETE;
  329. }
  330. public F_PM_1202(int procedureID, string fromTitle, int productiondataID, bool isView)
  331. {
  332. InitializeComponent();
  333. this._AllowEdit = 1;//允许编辑
  334. this._productiondataid = productiondataID;
  335. this._procedureID = procedureID;
  336. this.Text = fromTitle;
  337. this._isView = isView;
  338. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  339. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  340. this.btnSave.Text = ButtonText.BTN_SAVE;
  341. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  342. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  343. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  344. this.btnDelete.Text = ButtonText.BTN_DELETE;
  345. }
  346. #endregion
  347. #region 事件
  348. /// <summary>
  349. /// 窗体加载事件
  350. /// </summary>
  351. /// <param name="sender"></param>
  352. /// <param name="e"></param>
  353. private void F_PM_1202_Load(object sender, System.EventArgs e)
  354. {
  355. try
  356. {
  357. this.dgvProductionData.AutoGenerateColumns = false;
  358. this.dgvProductionData.DataSource = null;
  359. this.dgvProductionData.DataSource = TableProductionData;
  360. this.dgvDefect.AutoGenerateColumns = false;
  361. this.dgvDefectStaff.AutoGenerateColumns = false;
  362. // 加载权限
  363. FormPermissionManager.FormPermissionControl(this.Name, this,
  364. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  365. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  366. // 获取工序明细数据
  367. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  368. {
  369. return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  370. }));
  371. this._procedureDataEntity = procedureDataEntity;
  372. // 产品分级数据源
  373. DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  374. {
  375. return SystemModuleProxy.Service.GetGoodsLevel(2);//半成品检验
  376. }));
  377. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  378. {
  379. this.DefectFlag.DisplayMember = "DefectFlagName";
  380. this.DefectFlag.ValueMember = "DefectFlagID";
  381. this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
  382. this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"]);
  383. this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  384. this._dsGoodsLevel = dsGoodsLevel;
  385. }
  386. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  387. {
  388. return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  389. }));
  390. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  391. if (this.DSREWORK == null)
  392. {
  393. this.DSREWORK = new DataSet();
  394. }
  395. this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  396. // 返工工序数据源
  397. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  398. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  399. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  400. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  401. this.ReworkProcedureID.DataSource = ds.Tables[0];
  402. this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  403. this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  404. // 2016-10-10 是否启用成检登记改判限制天数 wangx
  405. DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  406. {
  407. return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_009.ToString());
  408. }));
  409. if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
  410. {
  411. _settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]);
  412. }
  413. // end
  414. // 设置控件禁用或启用
  415. SetControlEnable(); //判断此生产工号是否能成检
  416. if (this._productiondataid > Constant.INT_IS_ZERO)
  417. {
  418. SetEditDataSource();
  419. if (this._isView)
  420. {
  421. SetSubstandard();
  422. }
  423. }
  424. }
  425. catch (Exception ex)
  426. {
  427. // 对异常进行共通处理
  428. ExceptionManager.HandleEventException(this.ToString(),
  429. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  430. }
  431. }
  432. /// <summary>
  433. /// 设置控件禁用或启用
  434. /// </summary>
  435. private void SetControlEnable()
  436. {
  437. if (this._procedureDataEntity != null)
  438. {
  439. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  440. {
  441. this.txtUserCode.Enabled = true;
  442. this.btnSave.Visible = true;
  443. }
  444. else
  445. {
  446. this.txtUserCode.Enabled = true;
  447. this.txtUserCode.ReadOnly = true;
  448. // 此工号是否能生产工序
  449. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  450. {
  451. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  452. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  453. }));
  454. if (checkProcedureUser != null)
  455. {
  456. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  457. {
  458. // 此工号不允许生产工序
  459. MessageBox.Show(checkProcedureUser.ErrMsg,
  460. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  461. this.Close();
  462. return;
  463. }
  464. }
  465. UserID = checkProcedureUser.UserID;
  466. UserCode = checkProcedureUser.UserCode;
  467. UserName = checkProcedureUser.UserName;
  468. }
  469. this.txtUserCode.Text = UserCode;
  470. }
  471. }
  472. /// <summary>
  473. /// 条形码按键事件
  474. /// </summary>
  475. /// <param name="sender"></param>
  476. /// <param name="e"></param>
  477. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  478. {
  479. try
  480. {
  481. this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
  482. if (this.txtBarCode.ReadOnly)
  483. {
  484. return;
  485. }
  486. if ((int)e.KeyChar == 13) // 按了回车键
  487. {
  488. if (this.txtUserCode.Text.Trim() == string.Empty)
  489. {
  490. this.txtUserCode.Focus();
  491. this.txtBarCode.Text = string.Empty;
  492. return;
  493. }
  494. if (this.txtBarCode.Text.Trim() == string.Empty)
  495. {
  496. this.txtBarCode.Focus();
  497. return;
  498. }
  499. //检验之前查是否编辑还是新增
  500. SearchProductionDataEntity searchProductionDataEntity = new SearchProductionDataEntity();
  501. searchProductionDataEntity.ProcedureID = this._procedureID;
  502. searchProductionDataEntity.BarCode = this.txtBarCode.Text.Trim();
  503. DataTable ProductionData = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  504. {
  505. return PMModuleProxy.Service.GetProductionDataPDA(searchProductionDataEntity);
  506. }));
  507. if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
  508. {
  509. // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
  510. int CompleteProductionDataID = (int)DoAsync(new BaseAsyncMethod(() =>
  511. {
  512. return PMModuleProxy.Service.GetCompleteProductionDataID(this.txtBarCode.Text.Trim());
  513. }));
  514. // 走过的当前工序与在产工序相同,即在此工序上,未走到其它工序上,应该直接编辑,
  515. // 走过的当前工序与在产工序不相同时,首先校验条码,如果条码通过,还需判断是否重烧,及干补
  516. if (Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]) == CompleteProductionDataID)
  517. {
  518. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  519. ////是否己报损,如果已经报损也是查看记录
  520. //DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  521. //{
  522. // return PMModuleProxy.Service.GetSubstandardInfo(this.txtBarCode.Text.Trim());
  523. //}));
  524. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
  525. //{
  526. // this._ReadOnly = 1;
  527. //}
  528. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0)
  529. //{
  530. int auditstatus = (int)DoAsync(new BaseAsyncMethod(() =>
  531. {
  532. return PMModuleProxy.Service.CheckScrapProduct(this.txtBarCode.Text.Trim());
  533. }));
  534. if (auditstatus != -100)
  535. {
  536. //this._ReadOnly = 1;
  537. if (auditstatus == 0)
  538. {
  539. MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(待审批)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  540. }
  541. else
  542. {
  543. MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(审批通过)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  544. }
  545. this.txtBarCode.SelectAll();
  546. this.txtBarCode.Focus();
  547. return;
  548. }
  549. //}
  550. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  551. if (dr.Length > Constant.INT_IS_ZERO)
  552. {
  553. // 不允许重复添加
  554. this.txtBarCode.Text = "";
  555. return;
  556. }
  557. SetEditDataSource();
  558. this._currentBarCode = txtBarCode.Text.Trim();
  559. this.txtBarCode.Text = string.Empty;
  560. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)//集中
  561. {
  562. this.txtUserCode.Enabled = true;
  563. this.txtBarCode.Enabled = true;
  564. }
  565. else
  566. {
  567. this.txtBarCode.Enabled = true;
  568. }
  569. }
  570. else
  571. {
  572. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  573. {
  574. return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  575. }));
  576. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  577. {
  578. #region 如果是次品,回收后不允许编辑
  579. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
  580. {
  581. int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  582. {
  583. return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  584. }));
  585. if (recyclingflag > 0)
  586. {
  587. MessageBox.Show("此产品已经回收,不能改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  588. this.txtBarCode.Enabled = true;
  589. this.txtBarCode.Focus();
  590. return;
  591. }
  592. }
  593. #endregion
  594. }
  595. //int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  596. //{
  597. // return PMModuleProxy.Service.GetRecyclingflagByBarcode(this.txtBarCode.Text.Trim());
  598. //}));
  599. //if (recyclingflag > 0)
  600. //{
  601. // MessageBox.Show("【此产品已经回收,不能改判】", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  602. // this.txtBarCode.Enabled = true;
  603. // this.txtBarCode.Focus();
  604. // return;
  605. //}
  606. DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  607. {
  608. return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
  609. }));
  610. //当生产数据ID与当前工序生产数据ID不等时,还有一种况就是正品报废干补回来
  611. if (dsInProductionDataList.Tables[0].Rows.Count > 0 && dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == this._procedureID.ToString())
  612. {
  613. //新增
  614. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]);
  615. BindProductionDataEdit(null);
  616. this._currentBarCode = txtBarCode.Text.Trim();
  617. this.txtBarCode.Text = string.Empty;
  618. }
  619. else
  620. {
  621. //如果不相等的应该提示不允许编辑,因为尽管条码有效,但是并不在此工序流程中,只能列表搜索后进行编辑(只读查看)
  622. //但是还需要判断当前产品,是否重烧及干补,如果这两个都不是从而进行提示
  623. //1.校验条码是否有效
  624. // 校验条码 获取校验条码
  625. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  626. {
  627. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  628. }));
  629. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  630. {
  631. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  632. {
  633. //MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  634. //this.txtBarCode.SelectAll();
  635. //this.txtBarCode.Focus();
  636. //return;
  637. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  638. {
  639. // 表示有错误
  640. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  641. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  642. }
  643. else
  644. {
  645. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  646. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  647. frmscmn020.ShowDialog();
  648. }
  649. this.txtBarCode.Focus();
  650. this.txtBarCode.SelectAll();
  651. return;
  652. }
  653. else
  654. {
  655. #region 校验条码无错误 无论干补或者重烧只查在产表就可以
  656. //DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  657. //{
  658. // return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
  659. //}));
  660. // 只有干补才会出现这种情况
  661. if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() != dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString())
  662. {
  663. //新增
  664. BindProductionData(dsCheckBarcode);
  665. this._currentBarCode = txtBarCode.Text.Trim();
  666. this.txtBarCode.Text = string.Empty;
  667. }
  668. else if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString()
  669. && dsInProductionDataList.Tables[0].Rows[0]["IsReFire"].ToString() == "6") //重烧
  670. {
  671. //新增
  672. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  673. BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
  674. this._currentBarCode = txtBarCode.Text.Trim();
  675. this.txtBarCode.Text = string.Empty;
  676. }
  677. else
  678. {
  679. // 要不不显示,要不显示,应该过滤掉
  680. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  681. this._ReadOnly = 1;
  682. SetEditDataSource();
  683. this._currentBarCode = txtBarCode.Text.Trim();
  684. this.txtBarCode.Text = string.Empty;//////////但是只是显示,这个应该不能编辑,及提交的时候不应该保存
  685. }
  686. #endregion
  687. }
  688. }//--------------------------校验条码结束括号---------------------------------------------------------------
  689. }//--------------------------else结束括号---------------------------------------------------------------
  690. }
  691. }
  692. else //未走过当前工序
  693. {
  694. // 校验条码 获取校验条码信
  695. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  696. {
  697. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  698. }));
  699. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  700. {
  701. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  702. {
  703. // 表示有错误
  704. //MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  705. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  706. //this.txtBarCode.Focus();
  707. //return;
  708. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  709. {
  710. // 表示有错误
  711. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  712. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  713. }
  714. else
  715. {
  716. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  717. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  718. frmscmn020.ShowDialog();
  719. }
  720. this.txtBarCode.Focus();
  721. this.txtBarCode.SelectAll();
  722. return;
  723. }
  724. else
  725. {
  726. BindProductionData(dsCheckBarcode);//从来未走过此工序
  727. this._currentBarCode = txtBarCode.Text.Trim();
  728. this.txtBarCode.Text = string.Empty;
  729. }
  730. }
  731. }
  732. //if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
  733. //{
  734. // DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  735. // {
  736. // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim()); //生产数据取重烧标识
  737. // }));
  738. // // 重烧标识
  739. // if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  740. // {
  741. // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
  742. // {
  743. // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
  744. // }));
  745. // if (GetCompleteProcedureID != this._procedureID)//流程工序不等于当前工序
  746. // {
  747. // // 校验条码 获取校验条码
  748. // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  749. // {
  750. // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  751. // }));
  752. // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  753. // {
  754. // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  755. // // 表示有错误
  756. // {
  757. // MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  758. // this.txtBarCode.SelectAll();
  759. // this.txtBarCode.Focus();
  760. // return;
  761. // }
  762. // else
  763. // {
  764. // //生产数据ID
  765. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  766. // BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
  767. // this._currentBarCode = txtBarCode.Text.Trim();
  768. // this.txtBarCode.Text = string.Empty;
  769. // }
  770. // }
  771. // } // GetCompleteProcedureID != this._procedureID
  772. // else //流程工序与当前工序相,代码进行编辑
  773. // {
  774. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  775. // SetEditDataSource();
  776. // this._currentBarCode = txtBarCode.Text.Trim();
  777. // this.txtBarCode.Text = string.Empty;
  778. // }
  779. // }
  780. // else // 不是重烧
  781. // {
  782. // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
  783. // {
  784. // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
  785. // }));
  786. // if (GetCompleteProcedureID != this._procedureID)
  787. // {
  788. // // 表示有错误
  789. // MessageBox.Show("当前条码己不在此工序不允许编辑", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  790. // this.txtBarCode.SelectAll();
  791. // this.txtBarCode.Focus();
  792. // return;
  793. // }
  794. // else
  795. // {
  796. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  797. // SetEditDataSource();
  798. // this.txtUserCode.Enabled = true;
  799. // this.txtBarCode.Enabled = true;
  800. // this.txtBarCode.Text = string.Empty;
  801. // }
  802. // }
  803. //}
  804. //else
  805. //{
  806. // // 校验条码 获取校验条码信
  807. // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  808. // {
  809. // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  810. // }));
  811. // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  812. // {
  813. // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  814. // {
  815. // // 表示有错误
  816. // MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  817. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  818. // this.txtBarCode.Focus();
  819. // return;
  820. // }
  821. // else
  822. // {
  823. // BindProductionData(dsCheckBarcode);//从来未走过此工序
  824. // this._currentBarCode = txtBarCode.Text.Trim();
  825. // this.txtBarCode.Text = string.Empty;
  826. // }
  827. // }
  828. //}
  829. }
  830. }
  831. catch (Exception ex)
  832. {
  833. // 对异常进行共通处理
  834. ExceptionManager.HandleEventException(this.ToString(),
  835. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  836. }
  837. }
  838. /// <summary>
  839. /// 生产数据编辑控件显示事件
  840. /// </summary>
  841. /// <param name="sender"></param>
  842. /// <param name="e"></param>
  843. private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  844. {
  845. if (e.Control is DataGridViewComboBoxEditingControl
  846. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
  847. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  848. {
  849. this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
  850. //增加委托处理
  851. this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
  852. }
  853. if (e.Control is DKListBoxComboBox
  854. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
  855. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  856. {
  857. //_selectedRowIndex = TableProductionData.Rows.Count - 1;
  858. _selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  859. DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
  860. _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  861. _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  862. dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
  863. dkListBoxComboBox.ValueMember = "ReworkProcedureID";
  864. dkListBoxComboBox.DataSource = DSREWORK.Tables[0];// DSREWORK.Tables[_currentBarCode];
  865. }
  866. }
  867. /// <summary>
  868. /// 生产数据下拉列表改变事件
  869. /// </summary>
  870. /// <param name="sender"></param>
  871. /// <param name="e"></param>
  872. private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
  873. {
  874. this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
  875. SetGridView(this._currentDefectFlag);
  876. }
  877. /// <summary>
  878. /// 产品数据单元格进入事件
  879. /// </summary>
  880. /// <param name="sender"></param>
  881. /// <param name="e"></param>
  882. private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
  883. {
  884. try
  885. {
  886. if (this.dgvProductionData.CurrentCell != null)
  887. {
  888. // 记录最后选择行
  889. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  890. {
  891. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  892. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  893. this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  894. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  895. {
  896. return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  897. }));
  898. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  899. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  900. this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  901. this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  902. this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  903. }
  904. }
  905. }
  906. catch (Exception ex)
  907. {
  908. // 对异常进行共通处理
  909. ExceptionManager.HandleEventException(this.ToString(),
  910. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  911. }
  912. }
  913. /// <summary>
  914. /// 产品数据选定项改变事件
  915. /// </summary>
  916. /// <param name="sender"></param>
  917. /// <param name="e"></param>
  918. private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
  919. {
  920. try
  921. {
  922. if (this.dgvProductionData.CurrentCell != null)
  923. {
  924. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  925. // 有无缺陷 0无缺陷 1有缺陷
  926. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  927. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  928. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  929. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  930. this.dgvDefectStaff.CurrentCell = null;
  931. this.dgvDefectStaff.DataSource = null;
  932. this._smallByte.Clear();//防止重复绑定图片
  933. this.lvPic.Clear();//
  934. //设置只读数据,交不显示数据
  935. string readonlyFlag = this.dgvProductionData.Rows[_selectedRowIndex].Cells["ReadOnly"].Value.ToString();
  936. if (readonlyFlag == "1")
  937. {
  938. tsbtnAdd.Enabled = false;
  939. tsbtnEdit.Enabled = false;
  940. }
  941. else
  942. {
  943. tsbtnAdd.Enabled = true;
  944. tsbtnEdit.Enabled = true;
  945. }
  946. }
  947. }
  948. catch (Exception ex)
  949. {
  950. // 对异常进行共通处理
  951. ExceptionManager.HandleEventException(this.ToString(),
  952. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  953. }
  954. }
  955. /// <summary>
  956. /// 缺陷数据源选定项改变事件
  957. /// </summary>
  958. /// <param name="sender"></param>
  959. /// <param name="e"></param>
  960. private void dgvDefect_SelectionChanged(object sender, EventArgs e)
  961. {
  962. try
  963. {
  964. if (this.dgvDefect.CurrentCell != null)
  965. {
  966. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  967. if (dr.Length > 0)
  968. {
  969. if (dr[0]["ReadOnly"].ToString() == "1")
  970. {
  971. this.tsbtnEdit.Enabled = false;
  972. this.tsbtnAdd.Enabled = false;
  973. this.btnDelete.Enabled = false;
  974. this.btnUpload.Enabled = false;
  975. }
  976. else
  977. {
  978. this.tsbtnEdit.Enabled = true;
  979. this.tsbtnAdd.Enabled = true;
  980. this.btnDelete.Enabled = true;
  981. this.btnUpload.Enabled = true;
  982. }
  983. }
  984. else
  985. {
  986. //if (this._productiondataid > Constant.INT_IS_ZERO)
  987. //{
  988. if (this.btnSave.Enabled)
  989. {
  990. this.tsbtnEdit.Enabled = true;
  991. this.tsbtnAdd.Enabled = true;
  992. this.btnDelete.Enabled = true;
  993. this.btnUpload.Enabled = true;
  994. }
  995. }
  996. // }
  997. if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
  998. {
  999. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  1000. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1001. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1002. this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
  1003. this._smallByte.Clear();//防止重复绑定图片
  1004. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  1005. }
  1006. else
  1007. {
  1008. this.dgvDefectStaff.DataSource = null;
  1009. this.dgvMissStaff.DataSource = null;
  1010. this._smallByte.Clear();//防止重复绑定图片
  1011. this.lvPic.Clear();//
  1012. }
  1013. }
  1014. }
  1015. catch (Exception ex)
  1016. {
  1017. // 对异常进行共通处理
  1018. ExceptionManager.HandleEventException(this.ToString(),
  1019. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1020. }
  1021. }
  1022. /// <summary>
  1023. /// 单元格CheckBox事件
  1024. /// </summary>
  1025. /// <param name="sender"></param>
  1026. /// <param name="e"></param>
  1027. private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
  1028. {
  1029. if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
  1030. {
  1031. int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
  1032. if (checkValue == Constant.INT_IS_ZERO)
  1033. {
  1034. SetCheckBoxSelected(checkValue, e.RowIndex);
  1035. }
  1036. else
  1037. {
  1038. this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
  1039. }
  1040. }
  1041. }
  1042. /// <summary>
  1043. /// 上传图片按钮事件
  1044. /// </summary>
  1045. /// <param name="sender"></param>
  1046. /// <param name="e"></param>
  1047. private void btnUpload_Click(object sender, EventArgs e)
  1048. {
  1049. try
  1050. {
  1051. this.odlgFile.Filter = Constant.FILTER_PIC;
  1052. this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
  1053. this.odlgFile.RestoreDirectory = true;
  1054. this.odlgFile.Title = "选择缺陷图片";
  1055. this.odlgFile.FileName = null;
  1056. this.odlgFile.RestoreDirectory = true;
  1057. if (this.odlgFile.ShowDialog() == DialogResult.OK)
  1058. {
  1059. FileInfo file = new FileInfo(odlgFile.FileName);
  1060. if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
  1061. {
  1062. MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
  1063. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1064. }
  1065. else
  1066. {
  1067. Image PicImage = Image.FromStream(file.OpenRead());
  1068. byte[] orgImageByte = ImageToByte(PicImage);
  1069. this._PicByte.Add(orgImageByte);
  1070. GetThumbnail(file, orgImageByte);
  1071. BindImg();
  1072. }
  1073. }
  1074. }
  1075. catch (Exception ex)
  1076. {
  1077. // 对异常进行共通处理
  1078. ExceptionManager.HandleEventException(this.ToString(),
  1079. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1080. }
  1081. }
  1082. /// <summary>
  1083. /// 删除图片按钮事件
  1084. /// </summary>
  1085. /// <param name="sender"></param>
  1086. /// <param name="e"></param>
  1087. private void btnDelete_Click(object sender, EventArgs e)
  1088. {
  1089. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  1090. {
  1091. int index = lvSelect.Index;
  1092. if (index < Constant.INT_IS_ZERO)
  1093. {
  1094. index = Constant.INT_IS_ZERO;
  1095. }
  1096. if (this._currentTempSign != string.Empty)
  1097. {
  1098. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
  1099. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
  1100. }
  1101. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
  1102. }
  1103. }
  1104. /// <summary>
  1105. /// 关闭按钮事件
  1106. /// </summary>
  1107. /// <param name="sender"></param>
  1108. /// <param name="e"></param>
  1109. private void tsbtnClose_Click(object sender, EventArgs e)
  1110. {
  1111. this.Close();
  1112. }
  1113. /// <summary>
  1114. /// 产品条码列表删除事件
  1115. /// </summary>
  1116. /// <param name="sender"></param>
  1117. /// <param name="e"></param>
  1118. private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1119. {
  1120. try
  1121. {
  1122. string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
  1123. DSTable.Tables[BarCode].Rows.Clear();//清空行
  1124. this.dgvDefectStaff.DataSource = null;//责任员工数据源
  1125. this.dgvMissStaff.DataSource = null; //漏检员工数据源
  1126. this.lvPic.Clear();
  1127. }
  1128. catch (Exception ex)
  1129. {
  1130. throw ex;
  1131. }
  1132. }
  1133. /// <summary>
  1134. /// 产品缺陷删除行事件
  1135. /// </summary>
  1136. /// <param name="sender"></param>
  1137. /// <param name="e"></param>
  1138. private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1139. {
  1140. try
  1141. {
  1142. if (e.Row.Index != -1)
  1143. {
  1144. //ProductionDataID
  1145. if (this.dgvDefect.CurrentCell != null)
  1146. {
  1147. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1148. 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")
  1149. {
  1150. e.Cancel = true;
  1151. return;
  1152. }
  1153. string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
  1154. DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1155. this.dgvDefectStaff.DataSource = null;
  1156. DSTableMissedStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1157. this.dgvMissStaff.DataSource = null;
  1158. this.lvPic.Clear();
  1159. if (Convert.ToInt32(TempCount) > 0)
  1160. {
  1161. if (this.dgvDefect.CurrentCell != null)
  1162. {
  1163. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  1164. if (dr.Length > 0)
  1165. {
  1166. if (dr[0]["ReadOnly"].ToString() == "1")
  1167. {
  1168. this.tsbtnEdit.Enabled = false;
  1169. this.tsbtnAdd.Enabled = false;
  1170. this.btnDelete.Enabled = false;
  1171. this.btnUpload.Enabled = false;
  1172. }
  1173. else
  1174. {
  1175. this.tsbtnEdit.Enabled = true;
  1176. this.tsbtnAdd.Enabled = true;
  1177. this.btnDelete.Enabled = true;
  1178. this.btnUpload.Enabled = true;
  1179. }
  1180. }
  1181. else
  1182. {
  1183. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1184. //{
  1185. if (this.btnSave.Enabled)
  1186. {
  1187. this.tsbtnEdit.Enabled = true;
  1188. this.tsbtnAdd.Enabled = true;
  1189. this.btnDelete.Enabled = true;
  1190. this.btnUpload.Enabled = true;
  1191. }
  1192. }
  1193. // }
  1194. if (this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString() != string.Empty)
  1195. {
  1196. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString());
  1197. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1198. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1199. this._currentTempSign = this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString(); //当前临时标记
  1200. this._smallByte.Clear();//防止重复绑定图片
  1201. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  1202. }
  1203. else
  1204. {
  1205. this.dgvDefectStaff.DataSource = null;
  1206. this.dgvMissStaff.DataSource = null;
  1207. this._smallByte.Clear();//防止重复绑定图片
  1208. this.lvPic.Clear();//
  1209. }
  1210. }
  1211. }
  1212. }
  1213. }
  1214. }
  1215. catch (Exception ex)
  1216. {
  1217. throw ex;
  1218. }
  1219. }
  1220. /// <summary>
  1221. /// 新建按钮事件
  1222. /// </summary>
  1223. /// <param name="sender"></param>
  1224. /// <param name="e"></param>
  1225. private void tsbtnAdd_Click(object sender, EventArgs e)
  1226. {
  1227. if (this.dgvProductionData.CurrentCell != null)
  1228. {
  1229. int allow = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  1230. if (allow != Constant.INT_IS_FOUR) // 有缺陷才能新建
  1231. {
  1232. F_PM_1203 frm1203 = new F_PM_1203(
  1233. DSTable.Tables[this._currentBarCode], this._currentBarCode,
  1234. this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, -1);
  1235. frm1203.ShowDialog();
  1236. }
  1237. }
  1238. }
  1239. /// <summary>
  1240. /// 编辑按钮事件
  1241. /// </summary>
  1242. /// <param name="sender"></param>
  1243. /// <param name="e"></param>
  1244. private void tsbtnEdit_Click(object sender, EventArgs e)
  1245. {
  1246. if (this.dgvDefect.CurrentCell != null)
  1247. {
  1248. //int isallowedit = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString());
  1249. if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 1) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
  1250. {
  1251. string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
  1252. int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  1253. int goodsID = 0;
  1254. DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
  1255. if (dr.Length > Constant.INT_IS_ZERO)
  1256. {
  1257. goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
  1258. }
  1259. F_PM_1203 frm1203 = new F_PM_1203(
  1260. DSTable.Tables[barcode], barcode,
  1261. goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex);
  1262. frm1203.ShowDialog();
  1263. }
  1264. }
  1265. }
  1266. /// <summary>
  1267. /// 产品数据源值改变后
  1268. /// </summary>
  1269. /// <param name="sender"></param>
  1270. /// <param name="e"></param>
  1271. private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1272. {
  1273. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1274. {
  1275. //if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value.ToString() != string.Empty)
  1276. //{
  1277. // string barcode = dgvProductionData.Rows[e.RowIndex].Cells["BarCode"].Value.ToString();
  1278. // DataTable dt = this.DSREWORK.Tables[barcode];
  1279. // if (dt != null && dt.Rows.Count > Constant.INT_IS_ZERO)
  1280. // {
  1281. // DataRow[] dr = dt.Select("ReworkProcedureID=" + this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value);
  1282. // if (dr.Length > Constant.INT_IS_ZERO)
  1283. // {
  1284. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = dr[0]["ReworkProcedureName"];
  1285. // }
  1286. // }
  1287. //}
  1288. }
  1289. }
  1290. /// <summary>
  1291. /// 保存按钮事件
  1292. /// </summary>
  1293. /// <param name="sender"></param>
  1294. /// <param name="e"></param>
  1295. private void btnSave_Click(object sender, EventArgs e)
  1296. {
  1297. try
  1298. {
  1299. //ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1300. if (this.TableProductionData.Select("ReadOnly<>1").Length > 0)
  1301. {
  1302. this.TableProductionData = this.TableProductionData.Select("ReadOnly<>1").CopyToDataTable();
  1303. }
  1304. ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1305. bool isError = false; // 是否存在缺陷员工
  1306. int ErrorCount = -1;
  1307. int CurrentRowIndex = -1;
  1308. for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
  1309. {
  1310. if (this.TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
  1311. {
  1312. continue;
  1313. }
  1314. ProductionDataEntity productionDataEntity = new ProductionDataEntity();
  1315. //if (this._productiondataid > 0)
  1316. //{
  1317. // productionDataEntity.ProductionDataID = this._productiondataid;
  1318. //}
  1319. if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
  1320. {
  1321. productionDataEntity.ProductionDataID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
  1322. }
  1323. productionDataEntity.Barcode = this.TableProductionData.Rows[i]["BarCode"].ToString();
  1324. productionDataEntity.UserID = UserID;// Convert.ToInt32(this.TableProductionData.Rows[i]["UserID"]);
  1325. productionDataEntity.UserCode = UserCode;// this.TableProductionData.Rows[i]["UserCode"].ToString();
  1326. productionDataEntity.UserName = UserName;// this.TableProductionData.Rows[i]["UserName"].ToString(); ;
  1327. productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
  1328. productionDataEntity.GoodsLevelID = Convert.ToInt32(this.TableProductionData.Rows[i]["DefectFlagID"]);
  1329. productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  1330. productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
  1331. if (this.TableProductionData.Rows[i]["LogoID"].ToString() != "")
  1332. {
  1333. productionDataEntity.LogoID = Convert.ToInt32(this.TableProductionData.Rows[i]["LogoID"]);
  1334. }
  1335. if (this.TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
  1336. {
  1337. productionDataEntity.OPTimeStamp = Convert.ToDateTime(this.TableProductionData.Rows[i]["OPTimeStamp"]);
  1338. }
  1339. if (this.TableProductionData.Rows[i]["CheckTime"].ToString() != "")
  1340. {
  1341. productionDataEntity.CheckTime = Convert.ToDateTime(this.TableProductionData.Rows[i]["CheckTime"]);
  1342. }
  1343. if (this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
  1344. {
  1345. productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
  1346. }
  1347. if (!string.IsNullOrEmpty(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
  1348. {
  1349. productionDataEntity.ReworkProcedureID = int.Parse(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
  1350. productionDataEntity.IsReworked = 1;
  1351. }
  1352. productionDataEntitys[i] = productionDataEntity;
  1353. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == (int)Constant.GoodsLevelType.ReFire) //重烧
  1354. {
  1355. if (this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString() == "" ||
  1356. Convert.ToInt32(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()) == -Constant.INT_IS_ONE)
  1357. {
  1358. isError = true;
  1359. ErrorCount = 1;
  1360. CurrentRowIndex = i;
  1361. this.dgvProductionData.Rows[i].Selected = true;
  1362. break;
  1363. }
  1364. }
  1365. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != (int)Constant.GoodsLevelType.Quality) //正品
  1366. {
  1367. // 不是正品
  1368. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == Constant.INT_IS_ZERO)
  1369. {
  1370. isError = true;
  1371. ErrorCount = -2;
  1372. CurrentRowIndex = i;
  1373. this.dgvProductionData.Rows[i].Selected = true;
  1374. break;
  1375. }
  1376. }
  1377. List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
  1378. ProductionDefectEntity productionDefectEntity = null;
  1379. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
  1380. {
  1381. productionDefectEntity = new ProductionDefectEntity();
  1382. productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
  1383. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != "-1"
  1384. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
  1385. //{
  1386. // productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1387. //}
  1388. if (!string.IsNullOrEmpty(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"] + ""))
  1389. {
  1390. productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1391. }
  1392. productionDefectEntity.ScrapResponFlag = "0";
  1393. productionDefectEntity.DefectID =
  1394. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
  1395. productionDefectEntity.DefectCode =
  1396. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
  1397. productionDefectEntity.DefectName =
  1398. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  1399. productionDefectEntity.DefectPositionID =
  1400. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
  1401. productionDefectEntity.DefectPositionCode =
  1402. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
  1403. productionDefectEntity.DefectPositionName =
  1404. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  1405. productionDefectEntity.DefectProductionDataID =
  1406. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"].ToString());
  1407. if (productionDefectEntity.DefectProductionDataID == 0)
  1408. {
  1409. productionDefectEntity.DefectProductionDataID = null;
  1410. }
  1411. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
  1412. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
  1413. {
  1414. productionDefectEntity.DefectProcedureID =
  1415. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
  1416. }
  1417. productionDefectEntity.DefectProcedureCode =
  1418. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
  1419. productionDefectEntity.DefectProcedureName =
  1420. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
  1421. productionDefectEntity.DefectUserID =
  1422. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
  1423. productionDefectEntity.DefectUserCode =
  1424. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
  1425. productionDefectEntity.DefectUserName =
  1426. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
  1427. productionDefectEntity.DefectJobs =
  1428. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1429. productionDefectEntity.Remarks =
  1430. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1431. productionDefectEntity.Remarks =
  1432. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1433. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  1434. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  1435. {
  1436. productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  1437. }
  1438. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
  1439. {
  1440. //if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
  1441. //{
  1442. productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
  1443. //}
  1444. }
  1445. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
  1446. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
  1447. {
  1448. productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
  1449. productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
  1450. productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
  1451. }
  1452. // 遍历责任员工
  1453. List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
  1454. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1455. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1456. {
  1457. DefectResponsibleEntity defectResponsibleEntity = null;
  1458. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1459. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1460. foreach (DataRow drStaff in dtTemp.Rows)
  1461. {
  1462. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1463. {
  1464. defectResponsibleEntity = new DefectResponsibleEntity();
  1465. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1466. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1467. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1468. defectResponsibleEntity.UJobsID =
  1469. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1470. defectResponsibleEntity.SJobsID =
  1471. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1472. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1473. DefectResponsibles.Add(defectResponsibleEntity);
  1474. }
  1475. }
  1476. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  1477. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  1478. }
  1479. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  1480. {
  1481. isError = true;
  1482. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
  1483. this.dgvDefect.CurrentCell = null;
  1484. this.dgvDefect.Rows[j].Selected = true;
  1485. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1486. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1487. {
  1488. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1489. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1490. }
  1491. else
  1492. {
  1493. this.dgvDefectStaff.DataSource = null;
  1494. }
  1495. break;
  1496. }
  1497. // 遍历漏检责任员工
  1498. List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
  1499. if (this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}",
  1500. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1501. {
  1502. DefectMissedResponsibleEntity defectMissedResponsibleEntity = null;
  1503. DataTable dtTemp = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}",
  1504. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1505. foreach (DataRow drStaff in dtTemp.Rows)
  1506. {
  1507. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1508. {
  1509. defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
  1510. defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1511. defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1512. defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1513. defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
  1514. defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
  1515. defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1516. DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
  1517. }
  1518. }
  1519. //productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
  1520. productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
  1521. }
  1522. // 遍历缺陷图片
  1523. if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
  1524. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1525. {
  1526. List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
  1527. DefectImageEntity defectImageEntity = null;
  1528. DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
  1529. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1530. foreach (DataRow drImage in dtTemp.Rows)
  1531. {
  1532. defectImageEntity = new DefectImageEntity();
  1533. defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
  1534. defectImageEntity.Image = (byte[])drImage["orgImageByte"];
  1535. defectImageEntitys.Add(defectImageEntity);
  1536. }
  1537. //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
  1538. productionDefectEntity.DefectImages = defectImageEntitys;
  1539. }
  1540. productionDefectEntitys.Add(productionDefectEntity);
  1541. }
  1542. if (isError)
  1543. {
  1544. break;
  1545. }
  1546. //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
  1547. productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
  1548. }
  1549. // 有错误
  1550. if (isError)
  1551. {
  1552. if (CurrentRowIndex != -Constant.INT_IS_ONE)
  1553. {
  1554. this._currentDefectFlag = Convert.ToInt32(this.TableProductionData.Rows[CurrentRowIndex]["DefectFlagID"].ToString());
  1555. }
  1556. if (ErrorCount == -Constant.INT_IS_ONE)
  1557. {
  1558. // 提示信息
  1559. MessageBox.Show(Messages.MSG_PM_W002,
  1560. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1561. return;
  1562. }
  1563. else if (ErrorCount == -Constant.INT_IS_TWO)
  1564. {
  1565. // 提示信息
  1566. MessageBox.Show(Messages.MSG_PM_W004,
  1567. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1568. return;
  1569. }
  1570. else
  1571. {
  1572. this.dgvProductionData.DataSource = TableProductionData;
  1573. //this.TableProductionData.Columns["ReworkProcedureID"].DataType=typeof(decimal);// data typeof(decimal));
  1574. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1575. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1576. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1577. // 提示信息
  1578. MessageBox.Show(Messages.MSG_PM_W003,
  1579. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1580. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1581. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1582. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1583. return;
  1584. }
  1585. }
  1586. // 最外层For循环结束
  1587. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  1588. {
  1589. string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
  1590. {
  1591. return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
  1592. }));
  1593. if (string.IsNullOrEmpty(returnValue))//成功
  1594. {
  1595. // 提示信息
  1596. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1597. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1598. ////保存成功后,并且为编辑时候,把上次编辑的数据禁用
  1599. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1600. //{
  1601. // int deleteRow = (int)DoAsync(new BaseAsyncMethod(() =>
  1602. // {
  1603. // return PMModuleProxy.Service.DeleteProductionDataByID(this._productiondataid);
  1604. // }));
  1605. //}
  1606. // 保存成功后,清空相应数据源
  1607. this.TableProductionData.Rows.Clear();
  1608. this.dgvProductionData.DataSource = TableProductionData;
  1609. this.DSTable.Tables.Clear();
  1610. this.dgvDefect.DataSource = null;
  1611. this.DSTableStaff.Tables.Clear();
  1612. this.dgvDefectStaff.DataSource = null;
  1613. this.DSTableMissedStaff.Tables.Clear();
  1614. this.dgvMissStaff.DataSource = null;
  1615. this.DSTableImage.Tables.Clear();
  1616. this.lvPic.Clear();
  1617. this._PicByte.Clear();
  1618. this._smallByte.Clear();
  1619. this.txtBarCode.Text = string.Empty;
  1620. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  1621. {
  1622. this.txtUserCode.Text = string.Empty;
  1623. this.txtUserCode.ReadOnly = false;
  1624. }
  1625. //this.DSREWORK.Tables.Clear();
  1626. }
  1627. else
  1628. {
  1629. // 提示信息
  1630. MessageBox.Show(returnValue,
  1631. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1632. }
  1633. }
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. // 对异常进行共通处理
  1638. ExceptionManager.HandleEventException(this.ToString(),
  1639. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1640. }
  1641. }
  1642. /// <summary>
  1643. /// 关闭按钮事件
  1644. /// </summary>
  1645. /// <param name="sender"></param>
  1646. /// <param name="e"></param>
  1647. private void tsbCloseTop_Click(object sender, EventArgs e)
  1648. {
  1649. this.Close();
  1650. }
  1651. /// <summary>
  1652. /// 单元格编辑开始时事件
  1653. /// </summary>
  1654. /// <param name="sender"></param>
  1655. /// <param name="e"></param>
  1656. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  1657. {
  1658. //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1659. //{
  1660. // DataGridView dgv = (DataGridView)sender;
  1661. // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1662. // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1663. // {
  1664. // e.Cancel = true;
  1665. // }
  1666. //}
  1667. //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1668. //{
  1669. // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1670. // {
  1671. // e.Cancel = true;
  1672. // }
  1673. //}
  1674. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1675. {
  1676. DataGridView dgv = (DataGridView)sender;
  1677. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1678. if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1679. {
  1680. e.Cancel = true;
  1681. }
  1682. }
  1683. if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1684. {
  1685. if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1686. {
  1687. e.Cancel = true;
  1688. }
  1689. }
  1690. }
  1691. /// <summary>
  1692. /// 用户编码验证事件
  1693. /// </summary>
  1694. /// <param name="sender"></param>
  1695. /// <param name="e"></param>
  1696. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1697. {
  1698. try
  1699. {
  1700. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  1701. {
  1702. this.txtUserCode.IsMustInput = true;
  1703. this.txtUserCode.SelectAll();
  1704. e.Cancel = true;
  1705. return;
  1706. }
  1707. else if (!this.txtUserCode.ReadOnly)
  1708. {
  1709. SUserEntity userEntity = new SUserEntity();
  1710. userEntity.UserCode = this.txtUserCode.Text.Trim();
  1711. // 此工号是否能生产工序
  1712. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  1713. {
  1714. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  1715. }));
  1716. if (MsgCheckProcedureUser != null)
  1717. {
  1718. if (MsgCheckProcedureUser.ErrMsg != null)
  1719. {
  1720. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  1721. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1722. this.txtUserCode.SelectAll();
  1723. e.Cancel = true;
  1724. return;
  1725. }
  1726. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  1727. UserCode = MsgCheckProcedureUser.UserCode;
  1728. UserName = MsgCheckProcedureUser.UserName;
  1729. this.txtUserCode.ReadOnly = true;
  1730. }
  1731. }
  1732. }
  1733. catch (Exception ex)
  1734. {
  1735. // 对异常进行共通处理
  1736. ExceptionManager.HandleEventException(this.ToString(),
  1737. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1738. }
  1739. }
  1740. /// <summary>
  1741. /// 鼠标单击事件
  1742. /// </summary>
  1743. /// <param name="sender"></param>
  1744. /// <param name="e"></param>
  1745. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  1746. {
  1747. if (this.txtUserCode.Text.Trim() != string.Empty)
  1748. {
  1749. this.txtUserCode.SelectAll();
  1750. }
  1751. }
  1752. #endregion
  1753. #region 私有方法
  1754. /// <summary>
  1755. /// 设置数据源
  1756. /// </summary>
  1757. /// <param name="tempCount"></param>
  1758. public void SetDataSource(int tempCount)
  1759. {
  1760. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1761. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1762. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1763. this._tempCount = tempCount;
  1764. }
  1765. /// <summary>
  1766. /// 设置编辑产品为时设置只读
  1767. /// </summary>
  1768. private void SetSubstandard()
  1769. {
  1770. this.btnSave.Enabled = false;
  1771. this.dgvProductionData.ReadOnly = true;
  1772. this.tsbtnAdd.Enabled = false;
  1773. this.tsbtnEdit.Enabled = false;
  1774. this.dgvDefect.ReadOnly = true;
  1775. this.dgvDefectStaff.ReadOnly = true;
  1776. this.dgvMissStaff.ReadOnly = true;
  1777. this.btnDelete.Enabled = false;
  1778. this.btnUpload.Enabled = false;
  1779. }
  1780. /// <summary>
  1781. /// 编辑后设置数据源
  1782. /// </summary>
  1783. private void SetEditDataSource()
  1784. {
  1785. try
  1786. {
  1787. this.txtUserCode.Enabled = false;
  1788. this.txtBarCode.Enabled = false;
  1789. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1790. {
  1791. return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  1792. }));
  1793. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1794. {
  1795. #region wangx 2016-10-10 校验是否可以成检登记改判
  1796. if (_settingvaluedays > 0)
  1797. {
  1798. ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1799. {
  1800. return PMModuleProxy.Service.BarcodeAllowCancel(
  1801. Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]),
  1802. _settingvaluedays, Constant.SettingType.S_PM_009.ToString());
  1803. }));
  1804. if (Convert.ToInt32(resultEntity.Result) < 0)
  1805. {
  1806. MessageBox.Show(resultEntity.Message,
  1807. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1808. this.txtBarCode.Text = "";
  1809. this.btnSave.Visible = false;
  1810. }
  1811. }
  1812. #endregion wangx 2016-10-10 end
  1813. #region 如果是次品,回收后不允许编辑
  1814. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
  1815. {
  1816. int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1817. {
  1818. return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1819. }));
  1820. if (recyclingflag > 0)
  1821. {
  1822. MessageBox.Show("条码【" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "】已经回收,不允许改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1823. this.txtBarCode.Enabled = true;
  1824. this.txtBarCode.Focus();
  1825. return;
  1826. }
  1827. }
  1828. #endregion
  1829. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1830. {
  1831. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1832. }));
  1833. // 产品数据
  1834. DataRow drNew = TableProductionData.NewRow();
  1835. drNew["ProductionDataID"] = this._productiondataid;
  1836. drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
  1837. drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
  1838. drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
  1839. drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
  1840. drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
  1841. drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
  1842. drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
  1843. drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
  1844. drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1845. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1846. drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
  1847. UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1848. UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1849. UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1850. drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1851. drNew["ReadOnly"] = this._ReadOnly;
  1852. drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
  1853. drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
  1854. drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
  1855. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1856. drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
  1857. drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
  1858. drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
  1859. drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  1860. drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
  1861. drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
  1862. drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
  1863. drNew["CheckTime"] = dsProductionDataByID.Tables[0].Rows[0]["CheckTime"];
  1864. DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1865. {
  1866. return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1867. }));
  1868. if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
  1869. {
  1870. drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
  1871. }
  1872. //drNew["OPTimeStamp"]
  1873. // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
  1874. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1875. {
  1876. return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1877. }));
  1878. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  1879. {
  1880. drNew["ReFine"] = 1;
  1881. }
  1882. else
  1883. {
  1884. drNew["ReFine"] = 0;
  1885. }
  1886. drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
  1887. //原产品类别
  1888. //UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1889. //UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1890. //UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1891. TableProductionData.Rows.Add(drNew);
  1892. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1893. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1894. this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1895. this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
  1896. if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
  1897. {
  1898. //次品设置只读的时候,原来默认不允许修改,目前注释掉
  1899. //SetSubstandard();
  1900. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1901. {
  1902. return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1903. }));
  1904. if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
  1905. {
  1906. // 提示信息
  1907. MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
  1908. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1909. return;
  1910. }
  1911. this.tsbtnAdd.Enabled = true;
  1912. }
  1913. else
  1914. {
  1915. this.tsbtnAdd.Enabled = true;
  1916. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1917. {
  1918. this.tsbtnEdit.Enabled = true;
  1919. }
  1920. }
  1921. }
  1922. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1923. {
  1924. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1925. dtProductionDefectData.Columns.Add("BarCode");
  1926. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1927. dtProductionDefectData.Columns.Add("DefectName");
  1928. dtProductionDefectData.Columns.Add("DefectCode");
  1929. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1930. dtProductionDefectData.Columns.Add("DefectPositionName");
  1931. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1932. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1933. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1934. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1935. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1936. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1937. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1938. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1939. dtProductionDefectData.Columns.Add("JobsText");//工种
  1940. dtProductionDefectData.Columns.Add("DefectRemarks");
  1941. dtProductionDefectData.Columns.Add("TempCount");
  1942. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1943. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  1944. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  1945. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1946. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1947. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1948. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1949. //新添加的 wangx 2016/1/6
  1950. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1951. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1952. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1953. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  1954. //新添加的 wangx 2016/1/6 end
  1955. DSTable.Tables.Add(dtProductionDefectData);
  1956. }
  1957. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1958. {
  1959. // 产品缺陷
  1960. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1961. {
  1962. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1963. dtProductionDefectData.Columns.Add("BarCode");
  1964. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1965. dtProductionDefectData.Columns.Add("DefectName");
  1966. dtProductionDefectData.Columns.Add("DefectCode");
  1967. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1968. dtProductionDefectData.Columns.Add("DefectPositionName");
  1969. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1970. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1971. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1972. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1973. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1974. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1975. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1976. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1977. dtProductionDefectData.Columns.Add("JobsText");//工种
  1978. dtProductionDefectData.Columns.Add("DefectRemarks");
  1979. dtProductionDefectData.Columns.Add("TempCount");
  1980. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1981. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1982. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  1983. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1984. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1985. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1986. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1987. //新添加的 wangx 2016/1/6
  1988. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1989. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1990. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1991. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  1992. //新添加的 wangx 2016/1/6 end
  1993. DSTable.Tables.Add(dtProductionDefectData);
  1994. }
  1995. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1996. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1997. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  1998. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  1999. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  2000. //-----------------------
  2001. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2002. //{
  2003. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2004. //}));
  2005. //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  2006. //if (this.DSREWORK == null)
  2007. //{
  2008. // this.DSREWORK = new DataSet();
  2009. //}
  2010. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2011. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2012. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2013. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2014. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2015. for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
  2016. {
  2017. DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  2018. dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
  2019. dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
  2020. dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
  2021. dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
  2022. dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
  2023. dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
  2024. dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
  2025. dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
  2026. dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
  2027. dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
  2028. dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
  2029. dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
  2030. dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
  2031. dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
  2032. dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
  2033. dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
  2034. dr["TempCount"] = this._tempCount;
  2035. dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  2036. dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
  2037. dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
  2038. dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
  2039. dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
  2040. dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
  2041. dr["IsAllowEdit"] = this._AllowEdit;
  2042. //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
  2043. dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
  2044. dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
  2045. dr["CheckTime"] = dsProductionDataByID.Tables[1].Rows[i]["CheckTime"];
  2046. DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  2047. // 防止工种不选择的话,直接New一个
  2048. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2049. {
  2050. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2051. dtStaff.Columns.Add("IsSelected");
  2052. dtStaff.Columns.Add("StaffID");
  2053. dtStaff.Columns.Add("StaffCode");
  2054. dtStaff.Columns.Add("StaffName");
  2055. dtStaff.Columns.Add("StaffTempCount");
  2056. dtStaff.Columns.Add("StaffStatus");
  2057. this.DSTableStaff.Tables.Add(dtStaff);
  2058. }
  2059. // 责任员工
  2060. DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2061. if (drRow.Length > Constant.INT_IS_ZERO)
  2062. {
  2063. foreach (DataRow r in drRow)
  2064. {
  2065. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2066. drStaff["IsSelected"] = 1;
  2067. drStaff["StaffID"] = r["StaffID"];
  2068. drStaff["StaffCode"] = r["StaffCode"];
  2069. drStaff["StaffName"] = r["StaffName"];
  2070. drStaff["StaffTempCount"] = this._tempCount;
  2071. drStaff["StaffStatus"] = r["StaffStatus"];
  2072. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  2073. }
  2074. }
  2075. // 漏检员工临时表
  2076. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2077. {
  2078. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2079. dtMissedStaff.Columns.Add("IsSelected");
  2080. dtMissedStaff.Columns.Add("StaffID");
  2081. dtMissedStaff.Columns.Add("StaffCode");
  2082. dtMissedStaff.Columns.Add("StaffName");
  2083. dtMissedStaff.Columns.Add("StaffTempCount");
  2084. dtMissedStaff.Columns.Add("StaffStatus");
  2085. dtMissedStaff.Columns.Add("UJobsID");
  2086. dtMissedStaff.Columns.Add("SJobsID");
  2087. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  2088. }
  2089. //漏检员工临时表数据
  2090. DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2091. if (drMissedRow.Length > Constant.INT_IS_ZERO)
  2092. {
  2093. foreach (DataRow r in drMissedRow)
  2094. {
  2095. DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2096. drMissedStaff["IsSelected"] = 1;
  2097. drMissedStaff["StaffID"] = r["StaffID"];
  2098. drMissedStaff["StaffCode"] = r["StaffCode"];
  2099. drMissedStaff["StaffName"] = r["StaffName"];
  2100. drMissedStaff["StaffTempCount"] = this._tempCount;
  2101. drMissedStaff["StaffStatus"] = r["StaffStatus"];
  2102. drMissedStaff["UJobsID"] = r["UJobsID"];
  2103. drMissedStaff["SJobsID"] = r["SJobsID"];
  2104. this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
  2105. }
  2106. }
  2107. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
  2108. {
  2109. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
  2110. dtImage.Columns.Add("StaffTempCount");
  2111. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2112. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2113. this.DSTableImage.Tables.Add(dtImage);
  2114. }
  2115. this._currentTempSign = i.ToString();
  2116. // 缺陷图片
  2117. DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2118. if (drImageRow.Length > Constant.INT_IS_ZERO)
  2119. {
  2120. foreach (DataRow r in drImageRow)
  2121. {
  2122. if (r["SourcePathByte"] != DBNull.Value)
  2123. {
  2124. byte[] orgImageByte = (byte[])r["SourcePathByte"];
  2125. this._PicByte.Add(orgImageByte);
  2126. //this._smallByte.Add(orgImageByte);
  2127. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2128. {
  2129. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2130. dtImage.Columns.Add("StaffTempCount");
  2131. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2132. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2133. this.DSTableImage.Tables.Add(dtImage);
  2134. }
  2135. DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2136. drrow["StaffTempCount"] = this._currentTempSign;
  2137. drrow["ImageByte"] = orgImageByte;
  2138. drrow["OrgImageByte"] = orgImageByte;
  2139. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
  2140. BindImg();
  2141. }
  2142. }
  2143. }
  2144. this._tempCount = this._tempCount + 1;
  2145. }
  2146. this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  2147. //控制产品等级,只有编辑权限的人才能随便改
  2148. if (this._AllowEdit == 0) //
  2149. {
  2150. for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
  2151. {
  2152. int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  2153. if (this._dsGoodsLevel != null)
  2154. {
  2155. DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
  2156. DataView dv = dt.DefaultView;
  2157. dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2158. DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
  2159. dgcbc.DisplayMember = "DefectFlagName";
  2160. dgcbc.ValueMember = "DefectFlagID";
  2161. dgcbc.DataSource = dv.ToTable();
  2162. }
  2163. }
  2164. }
  2165. }
  2166. if (!this.btnSave.Visible)
  2167. {
  2168. this.tsbtnAdd.Enabled = false;
  2169. this.tsbtnEdit.Enabled = false;
  2170. }
  2171. }
  2172. catch (Exception ex)
  2173. {
  2174. throw ex;
  2175. }
  2176. }
  2177. /// <summary>
  2178. /// 绑定到第一个DataGriwView数据源
  2179. /// </summary>
  2180. private void BindProductionDataReFine(DataSet dsCheckBarcode)
  2181. {
  2182. try
  2183. {
  2184. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2185. if (dr.Length > Constant.INT_IS_ZERO)
  2186. {
  2187. // 不允许重复添加
  2188. return;
  2189. }
  2190. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2191. {
  2192. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2193. }));
  2194. string KilnCarCode = string.Empty;
  2195. string KilnCode = string.Empty;
  2196. string Dictionaryvalue = string.Empty;
  2197. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2198. {
  2199. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2200. }));
  2201. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2202. {
  2203. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2204. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2205. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2206. }
  2207. DataRow drNew = TableProductionData.NewRow();
  2208. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2209. drNew["ProductionDataID"] = this._productiondataid;
  2210. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2211. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2212. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2213. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2214. drNew["ReworkProcedureID"] = DBNull.Value;
  2215. drNew["Remarks"] = "";
  2216. drNew["UserID"] = UserID;
  2217. drNew["UserCode"] = UserCode;
  2218. drNew["UserName"] = UserName;
  2219. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2220. drNew["OrgGoodsLevelTypeID"] = -1;
  2221. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2222. drNew["KilnCarCode"] = KilnCarCode;
  2223. drNew["KilnCode"] = KilnCode;
  2224. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2225. // 校验条码是否重烧过
  2226. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2227. {
  2228. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2229. }));
  2230. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2231. {
  2232. drNew["ReFine"] = 1;
  2233. }
  2234. else
  2235. {
  2236. drNew["ReFine"] = 0;
  2237. }
  2238. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2239. // 由产品条码获取注浆信息
  2240. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2241. {
  2242. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2243. }));
  2244. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2245. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2246. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2247. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2248. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2249. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2250. drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
  2251. TableProductionData.Rows.Add(drNew);
  2252. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2253. {
  2254. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2255. dtProductionDefectData.Columns.Add("BarCode");
  2256. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2257. dtProductionDefectData.Columns.Add("DefectName");
  2258. dtProductionDefectData.Columns.Add("DefectCode");
  2259. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2260. dtProductionDefectData.Columns.Add("DefectPositionName");
  2261. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2262. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2263. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2264. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2265. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2266. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2267. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2268. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2269. dtProductionDefectData.Columns.Add("JobsText");//工种
  2270. dtProductionDefectData.Columns.Add("DefectRemarks");
  2271. dtProductionDefectData.Columns.Add("TempCount");
  2272. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2273. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2274. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2275. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2276. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2277. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2278. dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
  2279. //新添加的 wangx 2016/1/6
  2280. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2281. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2282. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2283. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2284. DSTable.Tables.Add(dtProductionDefectData);
  2285. }
  2286. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2287. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2288. this.dgvDefect.DataSource = null;
  2289. this.dgvDefectStaff.DataSource = null;
  2290. this.lvPic.Clear();
  2291. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2292. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2293. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2294. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2295. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2296. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2297. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2298. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2299. //{
  2300. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2301. //}));
  2302. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2303. //if (this.DSREWORK == null)
  2304. //{
  2305. // this.DSREWORK = new DataSet();
  2306. //}
  2307. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2308. //// 返工工序数据源
  2309. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2310. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2311. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2312. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2313. }
  2314. catch (Exception ex)
  2315. {
  2316. throw ex;
  2317. }
  2318. }
  2319. /// <summary>
  2320. /// 绑定到第一个DataGriwView数据源
  2321. /// </summary>
  2322. private void BindProductionDataEdit(DataSet dsCheckBarcode)
  2323. {
  2324. try
  2325. {
  2326. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2327. if (dr.Length > Constant.INT_IS_ZERO)
  2328. {
  2329. // 不允许重复添加
  2330. return;
  2331. }
  2332. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2333. {
  2334. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2335. }));
  2336. string KilnCarCode = string.Empty;
  2337. string KilnCode = string.Empty;
  2338. string Dictionaryvalue = string.Empty;
  2339. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2340. {
  2341. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2342. }));
  2343. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2344. {
  2345. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2346. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2347. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2348. }
  2349. DataRow drNew = TableProductionData.NewRow();
  2350. drNew["ProductionDataID"] = this._productiondataid;
  2351. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2352. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2353. {
  2354. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2355. }));
  2356. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2357. {
  2358. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2359. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2360. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2361. }
  2362. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2363. drNew["ReworkProcedureID"] = DBNull.Value;
  2364. drNew["Remarks"] = "";
  2365. drNew["UserID"] = UserID;
  2366. drNew["UserCode"] = UserCode;
  2367. drNew["UserName"] = UserName;
  2368. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2369. drNew["OrgGoodsLevelTypeID"] = -1;
  2370. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2371. drNew["KilnCarCode"] = KilnCarCode;
  2372. drNew["KilnCode"] = KilnCode;
  2373. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2374. // 校验条码是否重烧过
  2375. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2376. {
  2377. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2378. }));
  2379. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2380. {
  2381. drNew["ReFine"] = 1;
  2382. }
  2383. else
  2384. {
  2385. drNew["ReFine"] = 0;
  2386. }
  2387. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2388. // 由产品条码获取注浆信息
  2389. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2390. {
  2391. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2392. }));
  2393. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2394. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2395. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2396. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2397. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2398. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2399. drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
  2400. TableProductionData.Rows.Add(drNew);
  2401. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2402. {
  2403. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2404. dtProductionDefectData.Columns.Add("BarCode");
  2405. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2406. dtProductionDefectData.Columns.Add("DefectName");
  2407. dtProductionDefectData.Columns.Add("DefectCode");
  2408. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2409. dtProductionDefectData.Columns.Add("DefectPositionName");
  2410. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2411. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2412. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2413. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2414. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2415. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2416. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2417. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2418. dtProductionDefectData.Columns.Add("JobsText");//工种
  2419. dtProductionDefectData.Columns.Add("DefectRemarks");
  2420. dtProductionDefectData.Columns.Add("TempCount");
  2421. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2422. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2423. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2424. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2425. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2426. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2427. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2428. //新添加的 wangx 2016/1/6
  2429. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2430. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2431. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2432. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2433. DSTable.Tables.Add(dtProductionDefectData);
  2434. }
  2435. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2436. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2437. this.dgvDefect.DataSource = null;
  2438. this.dgvDefectStaff.DataSource = null;
  2439. this.lvPic.Clear();
  2440. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2441. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2442. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2443. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2444. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2445. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2446. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2447. }
  2448. catch (Exception ex)
  2449. {
  2450. throw ex;
  2451. }
  2452. }
  2453. /// <summary>
  2454. /// 绑定到第一个DataGriwView数据源
  2455. /// </summary>
  2456. private void BindProductionData(DataSet dsCheckBarcode)
  2457. {
  2458. try
  2459. {
  2460. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2461. if (dr.Length > Constant.INT_IS_ZERO)
  2462. {
  2463. // 不允许重复添加
  2464. return;
  2465. }
  2466. int SpecialRepairflag = 0;
  2467. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2468. {
  2469. SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2470. {
  2471. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2472. }));
  2473. }
  2474. else
  2475. {
  2476. SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
  2477. }
  2478. string KilnCarCode = string.Empty;
  2479. string KilnCode = string.Empty;
  2480. string Dictionaryvalue = string.Empty;
  2481. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2482. {
  2483. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2484. }));
  2485. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2486. {
  2487. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2488. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2489. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2490. }
  2491. DataRow drNew = TableProductionData.NewRow();
  2492. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2493. if (dsCheckBarcode != null)
  2494. {
  2495. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2496. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2497. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2498. }
  2499. else
  2500. {
  2501. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2502. {
  2503. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2504. }));
  2505. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2506. {
  2507. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2508. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2509. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2510. }
  2511. }
  2512. drNew["UserID"] = UserID;
  2513. drNew["KilnCarCode"] = KilnCarCode;
  2514. drNew["KilnCode"] = KilnCode;
  2515. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2516. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2517. drNew["ReworkProcedureID"] = DBNull.Value;
  2518. drNew["Remarks"] = "";
  2519. drNew["UserID"] = UserID;
  2520. drNew["UserCode"] = UserCode;
  2521. drNew["UserName"] = UserName;
  2522. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2523. drNew["OrgGoodsLevelTypeID"] = -1;
  2524. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2525. drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  2526. + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  2527. drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  2528. // 校验条码是否重烧过
  2529. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2530. {
  2531. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2532. }));
  2533. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2534. {
  2535. drNew["ReFine"] = 1;
  2536. }
  2537. else
  2538. {
  2539. drNew["ReFine"] = 0;
  2540. }
  2541. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2542. {
  2543. // 由产品条码获取注浆信息
  2544. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2545. {
  2546. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2547. }));
  2548. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2549. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2550. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2551. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2552. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2553. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2554. }
  2555. else
  2556. {
  2557. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2558. drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  2559. drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  2560. drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  2561. drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  2562. drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  2563. }
  2564. TableProductionData.Rows.Add(drNew);
  2565. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2566. {
  2567. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2568. dtProductionDefectData.Columns.Add("BarCode");
  2569. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2570. dtProductionDefectData.Columns.Add("DefectName");
  2571. dtProductionDefectData.Columns.Add("DefectCode");
  2572. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2573. dtProductionDefectData.Columns.Add("DefectPositionName");
  2574. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2575. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2576. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2577. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2578. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2579. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2580. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2581. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2582. dtProductionDefectData.Columns.Add("JobsText");//工种
  2583. dtProductionDefectData.Columns.Add("DefectRemarks");
  2584. dtProductionDefectData.Columns.Add("TempCount");
  2585. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2586. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2587. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2588. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2589. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2590. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2591. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2592. //新添加的 wangx 2016/1/6
  2593. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2594. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2595. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2596. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2597. DSTable.Tables.Add(dtProductionDefectData);
  2598. }
  2599. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2600. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2601. this.dgvDefect.DataSource = null;
  2602. this.dgvDefectStaff.DataSource = null;
  2603. this.lvPic.Clear();
  2604. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2605. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2606. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2607. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2608. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2609. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2610. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2611. //DataTable dt = this._dsGoodsLevel.Tables[0];
  2612. //DataView dv = dt.DefaultView;
  2613. //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2614. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2615. //{
  2616. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2617. //}));
  2618. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2619. //if (this.DSREWORK == null)
  2620. //{
  2621. // this.DSREWORK = new DataSet();
  2622. //}
  2623. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2624. //// 返工工序数据源
  2625. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2626. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2627. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2628. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2629. }
  2630. catch (Exception ex)
  2631. {
  2632. throw ex;
  2633. }
  2634. }
  2635. /// <summary>
  2636. /// 通过是否有缺陷来启用或禁用
  2637. /// </summary>
  2638. /// <param name="DefectFlag"></param>
  2639. private void SetGridView(int GoodsLevelID)
  2640. {
  2641. DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
  2642. int GoodsLevelTypeID = -1;
  2643. DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
  2644. if (dr.Length > Constant.INT_IS_ZERO)
  2645. {
  2646. GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
  2647. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2648. }
  2649. if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
  2650. {
  2651. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
  2652. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
  2653. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
  2654. if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //正品
  2655. {
  2656. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2657. try
  2658. {
  2659. string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
  2660. if (DSTable.Tables.Contains(BarCode))
  2661. {
  2662. DSTable.Tables[BarCode].Rows.Clear();//清空行
  2663. }
  2664. this.dgvDefectStaff.DataSource = null;
  2665. this.lvPic.Clear();
  2666. }
  2667. catch (Exception ex)
  2668. {
  2669. throw ex;
  2670. }
  2671. }
  2672. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //次品 或者正品
  2673. {
  2674. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2675. }
  2676. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
  2677. {
  2678. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2679. }
  2680. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//重烧
  2681. {
  2682. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2683. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2684. }
  2685. }
  2686. }
  2687. /// <summary>
  2688. /// 清空以前所选中的缺陷
  2689. /// </summary>
  2690. /// <param name="checkValue"></param>
  2691. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  2692. {
  2693. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  2694. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  2695. {
  2696. if (i == rowIndex)
  2697. {
  2698. dtOrgDataSource.Rows[i]["discarde"] = 1;
  2699. }
  2700. else
  2701. {
  2702. dtOrgDataSource.Rows[i]["discarde"] = 0;
  2703. }
  2704. }
  2705. }
  2706. /// <summary>
  2707. /// 绑定并显示图片
  2708. /// </summary>
  2709. /// <param name="ImageData"></param>
  2710. public void BindByteImage(DataTable ImageData)
  2711. {
  2712. this._smallByte.Clear();
  2713. foreach (DataRow dr in ImageData.Rows)
  2714. {
  2715. //将数据库中的缩略图取出
  2716. this._smallByte.Add((byte[])dr[1]);
  2717. }
  2718. //绑定缩略图
  2719. BindImg();
  2720. }
  2721. /// <summary>
  2722. /// 将图片文件转换成二进制
  2723. /// </summary>
  2724. /// <param name="img"></param>
  2725. /// <returns></returns>
  2726. public static byte[] ImageToByte(Image img)
  2727. {
  2728. byte[] smallbuffer = null;
  2729. using (MemoryStream ms = new MemoryStream())
  2730. {
  2731. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  2732. ms.Position = Constant.INT_IS_ZERO;
  2733. smallbuffer = new byte[ms.Length];
  2734. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  2735. ms.Flush();
  2736. }
  2737. return smallbuffer;
  2738. }
  2739. /// <SUMMARY>
  2740. /// 重绘缩略图并把缩略图转为二进制储存
  2741. /// </SUMMARY>
  2742. /// <PARAM name="sourceFile">图片源路径</PARAM>
  2743. /// <PARAM name="destHeight">缩放后图片高度</PARAM>
  2744. /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
  2745. /// <RETURNS></RETURNS>
  2746. public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
  2747. {
  2748. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  2749. ImageFormat thisFormat = imgSource.RawFormat;
  2750. int sW = 0, sH = 0;
  2751. // 按比例缩放
  2752. int sWidth = imgSource.Width;
  2753. int sHeight = imgSource.Height;
  2754. int destWidth = 100;
  2755. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  2756. if (sHeight > destHeight || sWidth > destWidth)
  2757. {
  2758. if ((sWidth * destHeight) > (sHeight * destWidth))
  2759. {
  2760. sW = destWidth;
  2761. sH = (destWidth * sHeight) / sWidth;
  2762. }
  2763. else
  2764. {
  2765. sH = destHeight;
  2766. sW = (sWidth * destHeight) / sHeight;
  2767. }
  2768. }
  2769. else
  2770. {
  2771. sW = sWidth;
  2772. sH = sHeight;
  2773. }
  2774. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  2775. Graphics g = Graphics.FromImage(outBmp);
  2776. g.Clear(Color.Black);
  2777. // 设置画布的描绘质量
  2778. g.CompositingQuality = CompositingQuality.HighQuality;
  2779. g.SmoothingMode = SmoothingMode.HighQuality;
  2780. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2781. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  2782. g.Dispose();
  2783. //将重绘的图片转为二进制并保存
  2784. Image image = (Image)outBmp;
  2785. byte[] smallbuffer = ImageToByte(image);
  2786. if (this._currentTempSign != string.Empty)
  2787. {
  2788. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2789. {
  2790. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2791. dtImage.Columns.Add("StaffTempCount");
  2792. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2793. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2794. this.DSTableImage.Tables.Add(dtImage);
  2795. }
  2796. DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2797. dr["StaffTempCount"] = this._currentTempSign;
  2798. dr["ImageByte"] = smallbuffer;
  2799. dr["OrgImageByte"] = orgImageByte;
  2800. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
  2801. }
  2802. this._smallByte.Add(smallbuffer);
  2803. imgSource.Dispose();
  2804. outBmp.Dispose();
  2805. }
  2806. /// <summary>
  2807. /// 根据原图片宽高比获取缩略图的高(根据宽)
  2808. /// </summary>
  2809. /// <param name="BigWidth"></param>
  2810. /// <param name="BigHeight"></param>
  2811. /// <param name="SmallWidth"></param>
  2812. /// <returns></returns>
  2813. protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  2814. {
  2815. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  2816. return Convert.ToInt32(SmallWidth / scale);
  2817. }
  2818. /// <summary>
  2819. /// 绑定缩略图到控件中
  2820. /// </summary>
  2821. protected void BindImg()
  2822. {
  2823. ImageList ilPic = new ImageList();
  2824. //每次绑定要清空数据源
  2825. ilPic.Images.Clear();
  2826. //将缩略图二进制集合中的数据转换成图片文件
  2827. List<Image> LSImageList = new List<Image>();
  2828. foreach (byte[] smallby in _smallByte)
  2829. {
  2830. LSImageList.Add(byteArrayToImage(smallby));
  2831. }
  2832. //添加数据源
  2833. foreach (Image img in LSImageList)
  2834. {
  2835. ilPic.Images.Add(img);
  2836. }
  2837. ilPic.ImageSize = new Size(100, 100);
  2838. this.lvPic.LargeImageList = ilPic;
  2839. this.lvPic.BeginUpdate();
  2840. //清空列表的数据源
  2841. lvPic.Items.Clear();
  2842. //添加列表的数据源
  2843. for (int i = 0; i < ilPic.Images.Count; i++)
  2844. {
  2845. ListViewItem lvi = new ListViewItem();
  2846. lvi.ImageIndex = i;
  2847. this.lvPic.Items.Add(lvi);
  2848. }
  2849. this.lvPic.EndUpdate();
  2850. }
  2851. /// <summary>
  2852. /// 将数据库中的二进制转换成图片
  2853. /// </summary>
  2854. /// <param name="data"></param>
  2855. /// <returns></returns>
  2856. public static Image byteArrayToImage(object data)
  2857. {
  2858. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  2859. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  2860. return returnImage;
  2861. }
  2862. #endregion
  2863. /// <summary>
  2864. /// 责任员工
  2865. /// </summary>
  2866. /// <param name="sender"></param>
  2867. /// <param name="e"></param>
  2868. private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2869. {
  2870. try
  2871. {
  2872. if (e.Row.Index != -1)
  2873. {
  2874. if (this.dgvDefect.CurrentCell != null)
  2875. {
  2876. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2877. 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")
  2878. {
  2879. e.Cancel = true;
  2880. return;
  2881. }
  2882. }
  2883. }
  2884. }
  2885. catch (Exception ex)
  2886. {
  2887. throw ex;
  2888. }
  2889. }
  2890. /// <summary>
  2891. /// 漏扫责任员工
  2892. /// </summary>
  2893. /// <param name="sender"></param>
  2894. /// <param name="e"></param>
  2895. private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2896. {
  2897. try
  2898. {
  2899. if (e.Row.Index != -1)
  2900. {
  2901. if (this.dgvDefect.CurrentCell != null)
  2902. {
  2903. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2904. 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")
  2905. {
  2906. e.Cancel = true;
  2907. return;
  2908. }
  2909. }
  2910. }
  2911. }
  2912. catch (Exception ex)
  2913. {
  2914. throw ex;
  2915. }
  2916. }
  2917. }
  2918. }