F_PM_2202.cs 154 KB

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