Make_RepairOk.cs 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using UAS_MES_NEW.CustomControl.DataGrid_View;
  9. using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Make
  14. {
  15. public partial class Make_RepairOk : Form
  16. {
  17. string mb_id = "";
  18. string mbr_id = "";
  19. /// <summary>
  20. /// 存放父节点信息
  21. /// </summary>
  22. Dictionary<string, Dictionary<string, string>> BadInf_1 = new Dictionary<string, Dictionary<string, string>>();
  23. /// <summary>
  24. /// 存放子节点信息
  25. /// </summary>
  26. Dictionary<string, Dictionary<string, string>> BadInf_2 = new Dictionary<string, Dictionary<string, string>>();
  27. DataHelper dh = null;
  28. LogStringBuilder sql = new LogStringBuilder();
  29. List<string> sqls = new List<string>();
  30. DataTable dt = null;
  31. AutoSizeFormClass asc = new AutoSizeFormClass();
  32. string macode;
  33. string msid = "";
  34. string ifrework = "";
  35. string reworkstatus = "";
  36. string firstsn = "";
  37. string ms_stepcode = "";
  38. DataTable Dbfind;
  39. public Make_RepairOk()
  40. {
  41. InitializeComponent();
  42. }
  43. private void Make_Repair_Load(object sender, EventArgs e)
  44. {
  45. //为DBFind配置Call和Form的名称
  46. cr_code.FormName = Name;
  47. cr_code.TableName = "craft";
  48. cr_code.SelectField = "cr_name # 工艺名称,cr_code # 工艺编号,cr_prodcode # 物料编号";
  49. cr_code.SetValueField = new string[] { "cr_code" };
  50. cr_code.DBTitle = "回流工艺";
  51. cr_code.DbChange += Cr_code_DbChange;
  52. cd_stepcode.FormName = Name;
  53. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  54. cd_stepcode.SetValueField = new string[] { "cd_stepcode" };
  55. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  56. cd_stepcode.DBTitle = "回流工序";
  57. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  58. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  59. bd_soncode.FormName = Name;
  60. bd_soncode.TableName = "bom left join bomdetail on bd_bomid=bo_id left join product on bd_soncode=pr_code";
  61. bd_soncode.SetValueField = new string[] { "bd_soncode" };
  62. bd_soncode.SelectField = "bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格,bd_location # 位号";
  63. bd_soncode.DBTitle = "不良零件";
  64. bd_soncode.DbChange += Prodcode_DbChange;
  65. //nrg_name.BringToFront();
  66. nrg_name.TableName = "(select nrg_name,nrg_code from QUA_NGREASONGROUP left join DATAINPUTRECORD ON NRG_NAME = DIR_COMMENT AND DIR_GROUP = '不良原因组' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC)";
  67. nrg_name.Field = "nrg_name";
  68. nrg_name.ValueField = "nrg_code";
  69. nrg_name.Condition = " 1=1 ORDER BY ROWNUM asc";
  70. nr_name.TableName = "QUA_NGREASONGROUPDET left join QUA_NGREASONGROUP on nrgd_nrgid=nrg_id left join QUA_NGReason on nrgd_nrcode=nr_code left join DATAINPUTRECORD ON nr_name = DIR_COMMENT AND DIR_GROUP = '不良原因' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ";
  71. nr_name.Field = "nr_name";
  72. nr_name.ValueField = "nr_code";
  73. mbr_dutyname.TableName = "(select nd_name,nd_code from ngduty left join DATAINPUTRECORD ON nd_name = DIR_COMMENT AND DIR_GROUP = '责任别' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC) ";
  74. mbr_dutyname.Field = "nd_name";
  75. mbr_dutyname.ValueField = "nd_code";
  76. mbr_dutyname.Condition = " 1=1 ORDER BY ROWNUM asc";
  77. so_name.TableName = "(select so_name,so_code from solution left join DATAINPUTRECORD ON so_name = DIR_COMMENT AND DIR_GROUP = '解决方案' and DIR_SOURCECODE = '" + User.UserSourceCode + "' ORDER BY NVL(DIR_NUMBER,0) DESC)";
  78. so_name.Field = "so_name";
  79. so_name.ValueField = "so_code";
  80. so_name.Condition = " 1=1 ORDER BY ROWNUM asc";
  81. if (User.UserAccountType != "admin")
  82. {
  83. retsnlabel.Visible = false;
  84. retsn.Visible = false;
  85. }
  86. asc.controllInitializeSize(this);
  87. mbc_component.SendToBack();
  88. so_name.SendToBack();
  89. mbl_loc.SendToBack();
  90. bd_soncode.SendToBack();
  91. mbp_partdgv.SendToBack();
  92. mbp_part_label.SendToBack();
  93. dh = SystemInf.dh;
  94. GetSNCode.Focus();
  95. }
  96. private void Prodcode_DbChange(object sender, EventArgs e)
  97. {
  98. Dbfind = bd_soncode.ReturnData;
  99. BaseUtil.SetFormValue(this.Controls, Dbfind);
  100. if (bd_soncode.Text != "")
  101. {
  102. if (mbr_id != "")
  103. {
  104. if (!dh.CheckExist("makebadrspart", "mbp_sncode='" + GetSNCode.Text + "' and mbp_part='" + bd_soncode.Text + "' and mbp_badcode='" + bc_code.Text + "'"))
  105. {
  106. sql.Clear();
  107. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  108. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  109. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
  110. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  111. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  112. dh.ExecuteSql(sql.GetString(), "insert");
  113. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  114. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  115. }
  116. }
  117. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  118. }
  119. else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
  120. }
  121. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  122. {
  123. Dbfind = cd_stepcode.ReturnData;
  124. BaseUtil.SetFormValue(this.Controls, Dbfind);
  125. }
  126. private void Cr_code_DbChange(object sender, EventArgs e)
  127. {
  128. Dbfind = cr_code.ReturnData;
  129. BaseUtil.SetFormValue(this.Controls, Dbfind);
  130. }
  131. private void GetSNCode_KeyDown(object sender, KeyEventArgs e)
  132. {
  133. if (e.KeyCode == Keys.Enter)
  134. {
  135. if (GetSNCode.Text == "")
  136. {
  137. OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  138. string cdstepcode = cd_stepcode.Text;
  139. //cd_stepcode.Enabled = true;
  140. BaseUtil.CleanForm(this);
  141. cd_stepcode.Text = cdstepcode;
  142. BadCodeTree.Nodes.Clear();
  143. return;
  144. }
  145. sql.Clear();
  146. sql.Append("select ms_status,ms_outboxcode,ms_paststep,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework from makeserial left join make ");
  147. sql.Append("on ms_makecode=ma_code where ms_sncode = '" + GetSNCode.Text + "' order by ms_id desc");
  148. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  149. string ms_paststep = "";
  150. if (dt.Rows.Count > 0)
  151. {
  152. string ms_status = dt.Rows[0]["ms_status"].ToString();
  153. ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  154. ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  155. reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
  156. //if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  157. //{
  158. // OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已装箱,请先进行拆箱\n", Color.Red);
  159. // BaseUtil.CleanForm(this);
  160. // BadCodeTree.Nodes.Clear();
  161. // return;
  162. //}
  163. //如果不是返修序列号执行原来的步骤
  164. if (ifrework == "0")
  165. {
  166. if (ms_status == "4")
  167. {
  168. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
  169. string cdstepcode = cd_stepcode.Text;
  170. //cd_stepcode.Enabled = true;
  171. BaseUtil.CleanForm(this);
  172. cd_stepcode.Text = cdstepcode;
  173. BadCodeTree.Nodes.Clear();
  174. return;
  175. }
  176. if (ms_status != "3")
  177. {
  178. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
  179. string cdstepcode = cd_stepcode.Text;
  180. //cd_stepcode.Enabled = true;
  181. BaseUtil.CleanForm(this);
  182. cd_stepcode.Text = cdstepcode;
  183. BadCodeTree.Nodes.Clear();
  184. return;
  185. }
  186. }
  187. else
  188. {
  189. if (reworkstatus == "4")
  190. {
  191. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
  192. string cdstepcode = cd_stepcode.Text;
  193. //cd_stepcode.Enabled = true;
  194. BaseUtil.CleanForm(this);
  195. cd_stepcode.Text = cdstepcode;
  196. BadCodeTree.Nodes.Clear();
  197. return;
  198. }
  199. if (reworkstatus != "0" && reworkstatus != "3")
  200. {
  201. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
  202. string cdstepcode = cd_stepcode.Text;
  203. //cd_stepcode.Enabled = true;
  204. BaseUtil.CleanForm(this);
  205. cd_stepcode.Text = cdstepcode;
  206. BadCodeTree.Nodes.Clear();
  207. return;
  208. }
  209. }
  210. }
  211. else
  212. {
  213. OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不存在\n", Color.Red);
  214. string cdstepcode = cd_stepcode.Text;
  215. //cd_stepcode.Enabled = true;
  216. BaseUtil.CleanForm(this);
  217. cd_stepcode.Text = cdstepcode;
  218. BadCodeTree.Nodes.Clear();
  219. return;
  220. }
  221. //dt = (DataTable)dh.ExecuteSql("select mb_stepcode from makebad where mb_sncode='" + GetSNCode.Text + "' and mb_status=0 order by mb_id desc", "select");
  222. ////打不良的资源和当前资源相等可以快速维修,无须登录维修资源
  223. //bool QuickRepair = false;
  224. //if (dt.Rows.Count > 0)
  225. //{
  226. // if (dt.Rows[0]["mb_stepcode"].ToString() == User.CurrentStepCode)
  227. // {
  228. // QuickRepair = true;
  229. // }
  230. //}
  231. string ErrorMessage = "";
  232. //验证工序是否正确
  233. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  234. {
  235. BadInf_1.Clear();
  236. string oStatus = "";
  237. if (LogicHandler.GetMakeInfo(GetSNCode.Text, out macode, out oStatus, out ErrorMessage))
  238. {
  239. //验证makeserial或者ms_firstsn表序列号是否存在
  240. sql.Clear();
  241. sql.Append("select nvl(ms_badtimes,0)ms_badtimes,max(ms_id) ms_id,ms_makecode,ma_craftcode,ms_stepcode,ms_firstsn,ms_prodcode,ms_sncode,ma_bomversion,pr_detail,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno ");
  242. sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on pr_code=ms_prodcode where ms_makecode ='" + macode + "' and ms_sncode in(");
  243. sql.Append("select '" + GetSNCode.Text + "' from dual union select firstsn from makesnrelation where ");
  244. sql.Append("sn='" + GetSNCode.Text + "') group by ms_makecode,ms_stepcode,ms_prodcode,ma_craftcode,ms_sncode,ma_bomversion,pr_detail,ms_firstsn,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno,ms_badtimes");
  245. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  246. if (dt.Rows.Count > 0)
  247. {
  248. msid = dt.Rows[0]["ms_id"].ToString();
  249. ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
  250. BaseUtil.SetFormValue(this.Controls, dt);
  251. //判断是否当前工单途程的上料记录
  252. firstsn = dt.Rows[0]["ms_firstsn"].ToString();
  253. string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
  254. int ms_badtimes = int.Parse(dt.Rows[0]["ms_badtimes"].ToString());
  255. string cdstepcode = "";
  256. //sql.Clear();
  257. //sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
  258. //sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
  259. //sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
  260. //sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
  261. //sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
  262. sql.Clear();
  263. sql.Append("select sp_stepcode cm_stepcode,sp_craftcode cm_craftcode from stepproduct left join product on pr_code=sp_fsoncode where sp_bomversion='" + ma_bomversion + "' and ");
  264. sql.Append("sp_craftcode='" + cr_code.Text + "' And sp_mothercode ='" + ms_prodcode.Text + "' and sp_tracekind=1 ");
  265. //sql.Append("sp_craftcode=v_v_mscraftcode and sp_stepcode='' And sp_mothercode ='"+ms_prodcode.Text+"' and sp_tracekind=1");
  266. sql.Append("and not exists(select 1 from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
  267. sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_makecode='" + macode + "' and ");
  268. sql.Append("cm_fsoncode=sp_fsoncode and cm_status=0) and instr((select ms_paststep from makeserial where ms_firstsn='" + firstsn + "'),sp_stepcode)>0 order by SP_DETNO asc");
  269. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  270. if (dt.Rows.Count < 0)
  271. {
  272. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  273. //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
  274. if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
  275. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  276. else
  277. {
  278. string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
  279. if (ms_paststep.Contains(nextstep))
  280. {
  281. cdstepcode = nextstep;
  282. }
  283. else
  284. {
  285. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  286. }
  287. }
  288. }
  289. else
  290. {
  291. sql.Clear();
  292. sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
  293. sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
  294. sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
  295. sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
  296. sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
  297. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  298. if (dt.Rows.Count > 0)
  299. {
  300. cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
  301. }
  302. }
  303. if (cdstepcode == "")
  304. {
  305. //序号小于等于当前不良的序号
  306. string currentdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "cd_detno", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + ms_stepcode + "'").ToString();
  307. sql.Clear();
  308. sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
  309. sql.Append("cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ");
  310. sql.Append("nvl(cd_ifburnin,0)<>0 and cd_detno <='" + currentdetno + "'");
  311. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  312. if (dt.Rows.Count > 0)
  313. {
  314. cdstepcode = dt.Rows[0][0].ToString();
  315. }
  316. }
  317. //如果ms_stepcode和扣料工序均没有查到返修的工序
  318. if (cdstepcode == "")
  319. {
  320. string flowback = dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "cd_stepcode", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and nvl(cd_ifflowback,0)=-1").ToString();
  321. if (flowback != "")
  322. {
  323. cdstepcode = flowback;
  324. }
  325. else
  326. {
  327. cdstepcode = ms_stepcode;
  328. }
  329. }
  330. //cd_stepcode.Text = cdstepcode;
  331. //if (dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "nvl(cd_ifinput,0)cd_ifinput", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and cd_stepcode = '" + cd_stepcode.Text + "'").ToString() == "-1")
  332. // cd_stepcode.Enabled = false;
  333. //else
  334. // cd_stepcode.Enabled = true;
  335. LoadBadInfTree(sender, e);
  336. if (ms_badtimes > 3)
  337. {
  338. OperatResult.AppendText(">>SN:" + ms_sncode.Text + "累计维修次数超过3次,提示\n", Color.Red);
  339. }
  340. if (autoin.Checked)
  341. {
  342. RepairComplete_Click(sender, e);
  343. }
  344. }
  345. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  346. }
  347. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  348. }
  349. else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  350. }
  351. }
  352. private void Make_Repair_SizeChanged(object sender, EventArgs e)
  353. {
  354. mbc_component.BringToFront();
  355. so_name.BringToFront();
  356. mbl_loc.BringToFront();
  357. bd_soncode.BringToFront();
  358. mbp_partdgv.BringToFront();
  359. mbp_part_label.BringToFront();
  360. asc.controlAutoSize(this);
  361. mbc_component.SendToBack();
  362. so_name.SendToBack();
  363. mbl_loc.SendToBack();
  364. bd_soncode.SendToBack();
  365. mbp_partdgv.SendToBack();
  366. mbp_part_label.SendToBack();
  367. }
  368. private void BadCodeTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  369. {
  370. if (e.Node.Level == 0)
  371. {
  372. mb_id = e.Node.Tag.ToString();
  373. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  374. mbl_locdgv.DataSource = null;
  375. mbp_partdgv.DataSource = null;
  376. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  377. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  378. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  379. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  380. //mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
  381. mbr_id = "";
  382. SaveRepairInf.Enabled = true;
  383. }
  384. if (e.Node.Level == 1)
  385. {
  386. //展示父节点信息
  387. mb_id = e.Node.Parent.Tag.ToString();
  388. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  389. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  390. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  391. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  392. //展示子节点信息
  393. mbr_id = e.Node.Tag.ToString();
  394. nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
  395. nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
  396. nr_code.Text = BadInf_2[mbr_id]["nr_code"];
  397. nr_name.Text = BadInf_2[mbr_id]["nr_name"];
  398. so_code.Text = BadInf_2[mbr_id]["so_code"];
  399. so_name.Text = BadInf_2[mbr_id]["so_name"];
  400. mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
  401. mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];//mbr_remark
  402. mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
  403. mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
  404. //加载两个Grid的数据源
  405. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  406. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  407. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  408. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  409. SaveRepairInf.Enabled = false;
  410. }
  411. }
  412. private void LoadBadInfTree(object sender, EventArgs e)
  413. {
  414. BadCodeTree.Nodes.Clear();
  415. sql.Clear();
  416. //不是返工工单时的取当前工单
  417. sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name,");
  418. sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup ");
  419. sql.Append("on bg_code=mb_bgcode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode='" + macode + "' and mb_status=0");
  420. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  421. if (dt.Rows.Count == 0)
  422. {
  423. sql.Clear();
  424. sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name, ");
  425. sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup on bg_code=mb_bgcode ");
  426. sql.Append("left join make on ma_code=mb_makecode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode<>'" + macode + "' and mb_status=0");
  427. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  428. }
  429. for (int i = 0; i < dt.Rows.Count; i++)
  430. {
  431. //添加根节点
  432. TreeNode tnode_0 = new TreeNode();
  433. string bg_name = dt.Rows[i]["bg_name"].ToString();
  434. string bc_name = dt.Rows[i]["bc_name"].ToString();
  435. string mb_badcode = dt.Rows[i]["mb_badcode"].ToString();
  436. string mb_bgcode = dt.Rows[i]["mb_bgcode"].ToString();
  437. tnode_0.Text = (bg_name == "" ? mb_bgcode : bg_name) + ":" + (bc_name == "" ? mb_bgcode : bc_name);
  438. tnode_0.Name = dt.Rows[i]["mb_bgcode"].ToString();
  439. //作为Dictionary的主标识
  440. string mb_id = dt.Rows[i]["mb_id"].ToString();
  441. tnode_0.Tag = mb_id;
  442. Dictionary<string, string> dic = new Dictionary<string, string>();
  443. dic.Add("mb_id", mb_id);
  444. dic.Add("mb_sncode", dt.Rows[i]["mb_sncode"].ToString());
  445. dic.Add("mb_badcode", dt.Rows[i]["mb_badcode"].ToString());
  446. dic.Add("mb_bgcode", dt.Rows[i]["mb_bgcode"].ToString());
  447. dic.Add("bc_name", dt.Rows[i]["bc_name"].ToString());
  448. dic.Add("bg_name", dt.Rows[i]["bg_name"].ToString());
  449. //dic.Add("mb_badremark", dt.Rows[i]["mb_badremark"].ToString());
  450. if (!BadInf_1.ContainsKey(tnode_0.Tag.ToString()))
  451. BadInf_1.Add(tnode_0.Tag.ToString(), dic);
  452. BadCodeTree.Nodes.Add(tnode_0);
  453. BadCodeTree.SelectedNode = BadCodeTree.Nodes[0];
  454. //添加子节点
  455. sql.Clear();
  456. sql.Append("select mbr_id,mbr_brcode,mbr_brgcode,mbr_solutioncode,so_code,so_name,mbr_dutycode,mbr_dutyname,nd_name,nrg_name");
  457. sql.Append(",nr_name,nr_code,nrg_code,mbr_remark from makebadreason left join QUA_NGReason on nr_code=mbr_brcode left join ");
  458. sql.Append("QUA_NGREASONGROUPdet on nrgd_nrcode=nr_code left join QUA_NGREASONGROUP on nrg_id=nrgd_nrgid and ");
  459. sql.Append("mbr_brgcode=nrg_code left join solution on so_code=mbr_solutioncode left join ngduty on nd_code=mbr_dutycode ");
  460. sql.Append("where mbr_mbid=" + mb_id);
  461. DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  462. for (int j = 0; j < dt1.Rows.Count; j++)
  463. {
  464. TreeNode tnode_1 = new TreeNode();
  465. //存放子节点的信息
  466. Dictionary<string, string> dic1 = new Dictionary<string, string>();
  467. string mbr_id = dt1.Rows[j]["mbr_id"].ToString();
  468. tnode_1.Tag = mbr_id;
  469. dic1.Add("mbr_id", mbr_id);
  470. dic1.Add("mbr_brcode", dt1.Rows[j]["mbr_id"].ToString());
  471. dic1.Add("mbr_brgcode", dt1.Rows[j]["mbr_brcode"].ToString());
  472. dic1.Add("mbr_solutioncode", dt1.Rows[j]["mbr_solutioncode"].ToString());
  473. dic1.Add("mbr_dutycode", dt1.Rows[j]["mbr_dutycode"].ToString());
  474. dic1.Add("mbr_dutyname", dt1.Rows[j]["mbr_dutyname"].ToString());
  475. dic1.Add("mbr_remark", dt1.Rows[j]["mbr_remark"].ToString());
  476. dic1.Add("nd_name", dt1.Rows[j]["nd_name"].ToString());
  477. dic1.Add("so_name", dt1.Rows[j]["so_name"].ToString());
  478. dic1.Add("so_code", dt1.Rows[j]["so_code"].ToString());
  479. dic1.Add("nrg_name", dt1.Rows[j]["nrg_name"].ToString());
  480. dic1.Add("nrg_code", dt1.Rows[j]["nrg_code"].ToString());
  481. dic1.Add("nr_name", dt1.Rows[j]["nr_name"].ToString());
  482. dic1.Add("nr_code", dt1.Rows[j]["nr_code"].ToString());
  483. tnode_1.Text = dt1.Rows[j]["nr_name"].ToString();
  484. if (!BadInf_2.ContainsKey(mbr_id))
  485. BadInf_2.Add(mbr_id, dic1);
  486. tnode_0.Nodes.Add(tnode_1);
  487. }
  488. }
  489. try
  490. {
  491. if (bg_code.Text != "")
  492. BadCodeTree.Nodes[bg_code.Text].Expand();
  493. }
  494. catch (Exception) { }
  495. }
  496. private void RefreshTreeView_Click(object sender, EventArgs e)
  497. {
  498. LoadBadInfTree(sender, e);
  499. }
  500. private void RepairComplete_Click(object sender, EventArgs e)
  501. {
  502. if (ms_sncode.Text == "")
  503. {
  504. OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  505. return;
  506. }
  507. if (ifrework != "0" && reworkstatus == "0")
  508. {
  509. if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0") == 0)
  510. {
  511. OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
  512. return;
  513. }
  514. }
  515. //判断是否所有的不良信息都有维护不良原因
  516. DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0", "select");
  517. string ErrorMessage = "";
  518. for (int i = 0; i < dt.Rows.Count; i++)
  519. {
  520. if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
  521. ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
  522. }
  523. if (ErrorMessage != "")
  524. {
  525. OperatResult.AppendText(">>" + ErrorMessage + "未维护不良原因\n", Color.Red);
  526. return;
  527. }
  528. //如果岗位资源对应工序的版面不为空的时候
  529. if (dh.getFieldDataByCondition("makeserial left join step on ms_stepcode=st_code", "st_table", "ms_id='" + msid + "'").ToString() != "")
  530. {
  531. if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_makecode='" + ms_makecode.Text + "' and mbl_sncode='" + GetSNCode.Text + "' "))
  532. {
  533. OperatResult.AppendText(">>工序存在版面必须维护不良位置\n", Color.Red);
  534. return;
  535. }
  536. }
  537. //查询拆解的物料
  538. sql.Clear();
  539. sql.Append("select distinct cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
  540. sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_craftcode<>'" + cr_code.Text + "' and cm_makecode<>'" + ms_makecode.Text + "' and cm_status=-1 ");
  541. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  542. //如果含有序列号物料有被拆解过
  543. if (dt.Rows.Count > 0)
  544. {
  545. string soncode = "";
  546. for (int i = 0; i < dt.Rows.Count; i++)
  547. {
  548. soncode += "'" + dt.Rows[i][0].ToString() + "',";
  549. }
  550. //查询对应的上料记录
  551. sql.Clear();
  552. sql.Append("select cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union select sn from ");
  553. sql.Append(" makesnrelation where firstsn='" + firstsn + "') and cm_status=0 and cm_soncode in (" + soncode.Substring(0, soncode.Length - 1) + ")");
  554. DataTable LoadSoncode = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  555. //查询的结果不相等表示未完成上料
  556. if (dt.Rows.Count != LoadSoncode.Rows.Count)
  557. {
  558. for (int i = 0; i < LoadSoncode.Rows.Count; i++)
  559. {
  560. if (soncode.Contains(LoadSoncode.Rows[i][0].ToString()))
  561. {
  562. soncode = soncode.Replace(LoadSoncode.Rows[i][0].ToString(), "");
  563. }
  564. }
  565. OperatResult.AppendText(">>" + soncode.Replace("'", "") + "物料尚未备料,不允许回流\n", Color.Red);
  566. return;
  567. }
  568. }
  569. dt = (DataTable)dh.ExecuteSql("select cr_id from craft where cr_statuscode='AUDITED' and cr_code='" + cr_code.Text + "'", "select");
  570. if (dt.Rows.Count == 0)
  571. OperatResult.AppendText(">>回流工序不存在\n", Color.Red);
  572. else
  573. {
  574. string cr_id = dt.Rows[0]["cr_id"].ToString();
  575. dt = (DataTable)dh.ExecuteSql("select cd_ifinput from craftdetail left join step on st_code=cd_stepcode where cd_crid='" + cr_id + "' and cd_stepcode='" + cd_stepcode.Text + "' and st_statuscode='AUDITED'", "select");
  576. if (dt.Rows.Count == 0)
  577. OperatResult.AppendText(">>回流工序不在回流工艺中\n", Color.Red);
  578. else
  579. {
  580. dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  581. List<string> SQLS = new List<string>();
  582. if (dt.Rows.Count > 0)
  583. {
  584. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  585. string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
  586. //如果回流的执行过的工序为空
  587. //if (!ms_paststep.Contains(cd_stepcode.Text) && ms_paststep != "")
  588. //{
  589. // OperatResult.AppendText(">>不允许回流到未执行的工序\n", Color.Red);
  590. // return;
  591. //}
  592. if (ms_ifrework == "0")
  593. SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1 where ms_id='" + msid + "'");
  594. else
  595. SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1 where ms_id='" + msid + "'");
  596. }
  597. SQLS.Add("update makebad set mb_status=-1,mb_okman ='"+User.UserName+"' where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status = 0");
  598. //取消最近拆解部件
  599. SQLS.Add("update craftmaterial set cm_lastdeco=0 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode.Text + "' and nvl(cm_lastdeco,0)<>0");
  600. //if (checkBox1.Checked)
  601. //{
  602. // if (dh.CheckExist("makeserial", "ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "' and ms_key is not null"))
  603. // {
  604. // SQLS.Add("update makeserial set ms_bs = '',MS_IFCCLEAN ='Y',ms_key='',ms_keyid='',MS_HARDWREID='',MS_KEYSTATEID='',MS_BIOS='',ms_ec='',ms_uuid='',MS_KEYPARTNUMBER='',ms_bt='',ms_mac='',ms_imei='',ms_imei1='' where ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "'");
  605. // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "需要清空写入信息", "需要清空写入信息", ms_sncode.Text, ms_checkno.Text);
  606. // }
  607. // else {
  608. // SQLS.Add("update makeserial set ms_bs = '',ms_key='',ms_keyid='',MS_HARDWREID='',MS_KEYSTATEID='',MS_BIOS='',ms_ec='',ms_uuid='',MS_KEYPARTNUMBER='',ms_bt='',ms_mac='',ms_imei='',ms_imei1='' where ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "'");
  609. // }
  610. // }
  611. //SQLS.Add("update MakeBadCount set mbc_status=-1 where mbc_sncode='" + ms_sncode.Text + "'");
  612. dh.ExecuteSQLTran(SQLS.ToArray());
  613. LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "回流工序", "完成维修回流", User.UserCode);
  614. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "回流工序", "完成维修回流", ms_sncode.Text, ms_checkno.Text);
  615. OperatResult.AppendText(">>序列号" + ms_sncode.Text + "回流成功\n", Color.Green);
  616. string cdstepcode = cd_stepcode.Text;
  617. cd_stepcode.Enabled = true;
  618. BaseUtil.CleanForm(this);
  619. cd_stepcode.Text = cdstepcode;
  620. BadCodeTree.Nodes.Clear();
  621. GetSNCode.Clear();
  622. GetSNCode.Focus();
  623. i = 0;
  624. }
  625. }
  626. }
  627. private void Scrap_Click(object sender, EventArgs e)
  628. {
  629. if (ms_sncode.Text != "")
  630. {
  631. //判断是否有无法维修的记录
  632. int ScrapNum = int.Parse(dh.getFieldDataByCondition("makebadreason left join makebad on mb_id=mbr_mbid", "count(0) cn", "mb_sncode='" + ms_sncode.Text + "' and mb_status=0").ToString());
  633. if (ScrapNum == 0)
  634. OperatResult.AppendText(">>" + ms_sncode.Text + "报废必须维护不良原因\n", Color.Red);
  635. else
  636. {
  637. string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
  638. if (confirm == "Yes")
  639. {
  640. DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  641. if (dt.Rows.Count > 0)
  642. {
  643. string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
  644. string reworkcode = dt.Rows[0]["ms_reworkcode"].ToString();
  645. if (ms_ifrework == "0")
  646. {
  647. dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_nextstepcode=''", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  648. }
  649. else
  650. {
  651. sqls.Clear();
  652. sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_reworkstatus= 4,ms_nextstepcode='' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
  653. sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_reworkcheckno.Text + "'");
  654. sqls.Add("delete from oqcbatchdetail where obd_sncode='" + ms_sncode.Text + "' and obd_checkno='" + ms_reworkcheckno.Text + "'");
  655. sqls.Add("update ReworkDetail set rd_rwstatus='报废' where rd_reid=(select re_id from rework where re_code='" + reworkcode + "') and rd_sncode='" + reworkcode + "'");
  656. dh.ExecuteSQLTran(sqls.ToArray());
  657. }
  658. }
  659. dh.ExecuteSql("update makebad set mb_status=-2,mb_okman ='" + User.UserName + "' where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status = 0","update");
  660. dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ms_makecode.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
  661. dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1", "ma_code='" + macode + "'");
  662. LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "报废", "序列号报废", User.UserCode);
  663. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "报废", "序列号报废", ms_sncode.Text, ms_checkno.Text);
  664. OperatResult.AppendText(">>报废成功\n", Color.Green);
  665. GetSNCode.Clear();
  666. GetSNCode.Focus();
  667. BaseUtil.CleanForm(this);
  668. BadCodeTree.Nodes.Clear();
  669. }
  670. }
  671. }
  672. else OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
  673. }
  674. private void NewBadCode_Click(object sender, EventArgs e)
  675. {
  676. if (GetSNCode.Text == "" || macode == null || macode == "")
  677. {
  678. OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
  679. }
  680. else
  681. {
  682. Make_NewBadCode badcode = new Make_NewBadCode(GetSNCode.Text, macode);
  683. badcode.FormClosed += LoadBadInfTree;
  684. BaseUtil.SetFormCenter(badcode);
  685. badcode.ShowDialog();
  686. }
  687. }
  688. private void NewRepairInf_Click(object sender, EventArgs e)
  689. {
  690. if (bg_name.Text == "" && bc_name.Text == "")
  691. {
  692. OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
  693. }
  694. else
  695. {
  696. Make_NewMatainInf mataininf = new Make_NewMatainInf(bg_name.Text, bg_code.Text, bc_name.Text, bc_code.Text, GetSNCode.Text, msid, mb_id);
  697. mataininf.FormClosed += LoadBadInfTree;
  698. BaseUtil.SetFormCenter(mataininf);
  699. mataininf.ShowDialog();
  700. }
  701. }
  702. private void SaveRepairInf_Click(object sender, EventArgs e)
  703. {
  704. string ErrorMessage = "";
  705. if (bg_name.Text == "" || bc_name.Text == "")
  706. {
  707. OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
  708. return;
  709. }
  710. if (nrg_name.Text == "")
  711. ErrorMessage += " 不良原因组 ";
  712. if (nr_name.Text == "")
  713. ErrorMessage += " 不良原因 ";
  714. if (mbr_dutyname.Text == "")
  715. ErrorMessage += " 责任别 ";
  716. //if (mbr_dutyname.Text == "物料问题" && mbc_component.Text == "")
  717. // ErrorMessage += "责任别为物料问题时必须选择不良零件";
  718. if (ErrorMessage != "")
  719. {
  720. ErrorMessage += "不能为空";
  721. OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  722. return;
  723. }
  724. string mbr_id = dh.GetSEQ("makebadreason_seq");
  725. //存在不良组件进行提示
  726. if (dh.CheckExist("makebadreason left join makebad on mbr_mbid=mb_id and mbr_sncode=mb_sncode", "mbr_badcode='" + bc_code.Text + "' and mbr_sncode='" + ms_sncode.Text + "' and mbr_brcode='" + nr_code.Text + "' and mb_status=0"))
  727. {
  728. OperatResult.AppendText(">>不良代码【" + bc_name.Text + "】已存在不良原因【" + nr_name.Text + "】\n", Color.Red);
  729. return;
  730. }
  731. if (!dh.CheckExist("QUA_NGREASONGROUP", "nrg_name='" + nrg_name.Text + "'"))
  732. {
  733. OperatResult.AppendText(">>不良原因组不存在\n", Color.Red);
  734. return;
  735. }
  736. if (!dh.CheckExist("QUA_NGReason", "nr_name='" + nr_name.Text + "'"))
  737. {
  738. OperatResult.AppendText(">>不良原因不存在\n", Color.Red);
  739. return;
  740. }
  741. if (!dh.CheckExist("ngduty", "nd_name='" + mbr_dutyname.Text + "'"))
  742. {
  743. OperatResult.AppendText(">>责任别不存在\n", Color.Red);
  744. return;
  745. }
  746. if (!dh.CheckExist("solution", "so_name='" + so_name.Text + "'"))
  747. {
  748. OperatResult.AppendText(">>解决方案不存在\n", Color.Red);
  749. return;
  750. }
  751. //保存选择记录至后台,根据岗位资源代码记录
  752. dh.ExecuteSql("merge into DATAINPUTRECORD using (select NRG_NAME from QUA_NGREASONGROUP where NRG_NAME = '" + nrg_name.Text + "') ON (NRG_NAME = DIR_COMMENT AND DIR_GROUP = '不良原因组' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (NRG_NAME,1,'" + User.UserSourceCode + "','不良原因组')", "select");
  753. dh.ExecuteSql("merge into DATAINPUTRECORD using (select nr_name from QUA_NGReason left join QUA_NGREASONGROUPDET on nrgd_nrcode=nr_code left join QUA_NGREASONGROUP on nrgd_nrgid=nrg_id where nr_name = '" + nr_name.Text + "' and NRG_NAME = '" + nrg_name.Text + "') ON (nr_name = DIR_COMMENT AND DIR_GROUP = '不良原因' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (nr_name,1,'" + User.UserSourceCode + "','不良原因')", "select");
  754. dh.ExecuteSql("merge into DATAINPUTRECORD using (select nd_name from ngduty where nd_name = '" + mbr_dutyname.Text + "') ON (nd_name = DIR_COMMENT AND DIR_GROUP = '责任别' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (nd_name,1,'" + User.UserSourceCode + "','责任别')", "select");
  755. dh.ExecuteSql("merge into DATAINPUTRECORD using (select so_name from solution where so_name = '" + so_name.Text + "') ON (so_name = DIR_COMMENT AND DIR_GROUP = '解决方案' and DIR_SOURCECODE = '" + User.UserSourceCode + "') when matched then update set DIR_NUMBER = DIR_NUMBER +1 when not matched then insert (DIR_COMMENT,DIR_NUMBER,DIR_SOURCECODE,DIR_GROUP) VALUES (so_name,1,'" + User.UserSourceCode + "','解决方案')", "select");
  756. //保存不良原因
  757. sql.Clear();
  758. sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
  759. sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
  760. sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname,mbr_remark) select '" + mb_id + "','" + mbr_id + "','" + nr_code.Text + "',");
  761. sql.Append("'" + so_code.Text + "','" + mbr_dutyname.Text + "','" + nrg_code.Text + "','" + bc_code.Text + "',");
  762. sql.Append("'" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "','" + nr_name.Text + "','" + so_name.Text + "','" + bc_name.Text + "','" + nrg_name.Text + "','" + mbr_dutyname.Text + "','" + mb_badremark.Text + "' from dual");
  763. dh.ExecuteSql(sql.GetString(), "insert");
  764. if (mbc_component.Text != "")
  765. {
  766. sql.Clear();
  767. sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
  768. sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
  769. sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + mbc_component.Text + "',");
  770. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "')");
  771. dh.ExecuteSql(sql.GetString(), "insert");
  772. }
  773. OperatResult.AppendText(">>不良原因保存成功\n", Color.Green);
  774. SaveRepairInf.Enabled = false;
  775. LoadBadInfTree(sender, e);
  776. }
  777. private void DeleteRepairInf_Click(object sender, EventArgs e)
  778. {
  779. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  780. if (dt.Rows.Count > 0)
  781. {
  782. if (mbr_id != "")
  783. {
  784. string delete1 = "delete from makebadrsloc where mbl_mbrid='" + mbr_id + "'";
  785. string delete2 = "delete from makebadrspart where mbp_mbrid='" + mbr_id + "'";
  786. string delete3 = "delete from makebadrscom where mbc_mbrid='" + mbr_id + "'";
  787. string delete4 = "delete from makebadreason where mbr_id='" + mbr_id + "'";
  788. dh.ExecuteSQLTran(delete1, delete2, delete3, delete4);
  789. OperatResult.AppendText(">>删除成功\n", Color.Green);
  790. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  791. mbp_partdgv.DataSource = null;
  792. mbl_locdgv.DataSource = null;
  793. mbr_id = "";
  794. //删除后重新加载Tree的信息
  795. LoadBadInfTree(sender, e);
  796. }
  797. else OperatResult.AppendText(">>必须选择不良原因\n", Color.Red);
  798. }
  799. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  800. }
  801. private void SaveBadLocation_Click(object sender, EventArgs e)
  802. {
  803. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  804. if (dt.Rows.Count > 0)
  805. {
  806. if (mbl_loc.Text != "")
  807. {
  808. if (mbr_id != "")
  809. {
  810. if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_sncode='" + GetSNCode.Text + "' and mbl_loc='" + mbl_loc.Text.ToUpper() + "'"))
  811. {
  812. sql.Clear();
  813. sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
  814. sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
  815. sql.Append(",'" + mbl_loc.Text.ToUpper() + "','" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  816. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  817. dh.ExecuteSql(sql.GetString(), "insert");
  818. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  819. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  820. sql.Clear();
  821. sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
  822. sql.Append(" start with bo_mothercode='" + ms_prodcode.Text + "' connect by bo_mothercode= prior bd_soncode) ");
  823. sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + mbl_loc.Text.ToUpper() + ",')>0");
  824. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  825. if (dt.Rows.Count > 0)
  826. {
  827. sql.Clear();
  828. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  829. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  830. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][0].ToString() + "',");
  831. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  832. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  833. dh.ExecuteSql(sql.GetString(), "insert");
  834. dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  835. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  836. mbl_loc.Clear();
  837. }
  838. }
  839. else OperatResult.AppendText(">>已存在该不良位置\n", Color.Red);
  840. }
  841. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  842. }
  843. else OperatResult.AppendText(">>不良位置不能为空\n", Color.Red);
  844. }
  845. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  846. }
  847. private void nr_name_TextChanged(object sender, EventArgs e)
  848. {
  849. if (nr_name.Text == "")
  850. SaveBadLocation.Enabled = false;
  851. else
  852. SaveBadLocation.Enabled = true;
  853. }
  854. private void mbl_loc_KeyDown(object sender, KeyEventArgs e)
  855. {
  856. if (e.KeyCode == Keys.Enter)
  857. SaveBadLocation_Click(sender, e);
  858. }
  859. private void prodcode_TextKeyDown(object sender, KeyEventArgs e)
  860. {
  861. if (e.KeyCode == Keys.Enter)
  862. {
  863. if (bd_soncode.Text != "")
  864. {
  865. if (mbr_id != "")
  866. {
  867. sql.Clear();
  868. sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
  869. sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
  870. sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
  871. sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
  872. sql.Append("sysdate,'" + User.UserCode + "' from dual");
  873. dh.ExecuteSql(sql.GetString(), "insert");
  874. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  875. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  876. }
  877. else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
  878. }
  879. else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
  880. }
  881. }
  882. private void cr_code_UserControlTextChanged(object sender, EventArgs e)
  883. {
  884. //cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ( cd_ifburnout <>0) order by cd_stepno";
  885. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  886. }
  887. private void Clean_Click(object sender, EventArgs e)
  888. {
  889. OperatResult.Clear();
  890. }
  891. private void mbl_locdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
  892. {
  893. if (e.RowIndex >= 0)
  894. {
  895. if (mbl_locdgv.Columns[e.ColumnIndex].Name == "DeletePos")
  896. {
  897. dh.ExecuteSql("delete from makebadrsloc where mbl_id='" + mbl_locdgv.Rows[e.RowIndex].Cells["mbl_id"].Value.ToString() + "'", "insert");
  898. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  899. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  900. }
  901. }
  902. }
  903. private void mbp_partdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
  904. {
  905. if (e.RowIndex >= 0)
  906. {
  907. if (mbp_partdgv.Columns[e.ColumnIndex].Name == "DeleteCom")
  908. {
  909. dh.ExecuteSql("delete from makebadrspart where mbp_id='" + mbp_partdgv.Rows[e.RowIndex].Cells["mbp_id"].Value.ToString() + "'", "insert");
  910. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  911. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  912. }
  913. }
  914. }
  915. private void Make_Repair_FormClosing(object sender, FormClosingEventArgs e)
  916. {
  917. dh.Dispose();
  918. }
  919. private void ms_prodcode_TextChanged(object sender, EventArgs e)
  920. {
  921. if (ms_prodcode.Text != "")
  922. cr_code.Condition = "cr_prodcode='" + ms_prodcode.Text + "'";
  923. else
  924. cr_code.Condition = "";
  925. bd_soncode.Condition = "bd_mothercode='" + ms_prodcode.Text + "' and NVL(bd_usestatus,' ')<>'DISABLE'";
  926. //设置工序的条件
  927. //cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ( cd_ifburnout <>0) order by cd_stepno";
  928. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ST_IFOFFLINE = -1 order by cd_stepno";
  929. }
  930. public void RefreshData()
  931. {
  932. GetSNCode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
  933. }
  934. private void nr_name_UserControlTextChanged(object sender, EventArgs e)
  935. {
  936. if (nr_name.Text != "")
  937. {
  938. SaveBadLocation.Enabled = true;
  939. if (nrg_name.Text == "")
  940. {
  941. OperatResult.AppendText(">>请先填写不良代码组\n", Color.Red);
  942. nr_name.Text = "";
  943. }
  944. else
  945. {
  946. if (nr_code.Text == "" || (nr_code.Text != "" && nr_code.Text != nr_name.Value))
  947. nr_code.Text = nr_name.Value;
  948. }
  949. }
  950. else SaveBadLocation.Enabled = false;
  951. }
  952. private void nrg_name_UserControlTextChanged(object sender, EventArgs e)
  953. {
  954. if (nrg_code.Text == "" || (nrg_code.Text != "" && nrg_code.Text != nrg_name.Value))
  955. nrg_code.Text = nrg_name.Value;
  956. nr_name.Condition = "nrg_code in('" + (nrg_code.Text == "" ? "''" : nrg_code.Text) + "')";
  957. }
  958. private void mbr_dutyname_UserControlTextChanged(object sender, EventArgs e)
  959. {
  960. if (mbr_dutycode.Text == "" || (mbr_dutycode.Text != "" && mbr_dutycode.Text != mbr_dutyname.Value))
  961. mbr_dutycode.Text = mbr_dutyname.Value;
  962. }
  963. private void mbc_component_UserControlTextChanged(object sender, EventArgs e)
  964. {
  965. }
  966. private void so_name_UserControlTextChanged(object sender, EventArgs e)
  967. {
  968. if (so_code.Text == "" || (so_code.Text != "" && so_code.Text != so_name.Value))
  969. so_code.Text = so_name.Value;
  970. }
  971. private void BadCodeTree_AfterSelect(object sender, TreeViewEventArgs e)
  972. {
  973. if (e.Node.Level == 0)
  974. {
  975. mb_id = e.Node.Tag.ToString();
  976. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  977. mbl_locdgv.DataSource = null;
  978. mbp_partdgv.DataSource = null;
  979. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  980. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  981. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  982. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  983. // mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
  984. mbr_id = "";
  985. SaveRepairInf.Enabled = true;
  986. }
  987. if (e.Node.Level == 1)
  988. {
  989. //展示父节点信息
  990. mb_id = e.Node.Parent.Tag.ToString();
  991. bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
  992. bc_name.Text = BadInf_1[mb_id]["bc_name"];
  993. bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
  994. bg_name.Text = BadInf_1[mb_id]["bg_name"];
  995. //展示子节点信息
  996. mbr_id = e.Node.Tag.ToString();
  997. nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
  998. nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
  999. nr_code.Text = BadInf_2[mbr_id]["nr_code"];
  1000. nr_name.Text = BadInf_2[mbr_id]["nr_name"];
  1001. so_code.Text = BadInf_2[mbr_id]["so_code"];
  1002. so_name.Text = BadInf_2[mbr_id]["so_name"];
  1003. mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
  1004. mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];
  1005. mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
  1006. mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
  1007. //加载两个Grid的数据源
  1008. DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
  1009. BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
  1010. dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
  1011. BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
  1012. SaveRepairInf.Enabled = false;
  1013. }
  1014. }
  1015. private void normalButton1_Click(object sender, EventArgs e)
  1016. {
  1017. DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
  1018. if (dt.Rows.Count > 0)
  1019. {
  1020. if (mb_id != "")
  1021. {
  1022. string delete1 = "delete from makebadrsloc where mbl_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1023. string delete2 = "delete from makebadrspart where mbp_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1024. string delete3 = "delete from makebadrscom where mbc_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
  1025. string delete4 = "delete from makebadreason where mbr_mbid='" + mb_id + "'";
  1026. string delete = "delete from makebad where mb_id = '" + mb_id + "'";
  1027. dh.ExecuteSQLTran(delete1, delete2, delete3, delete4, delete);
  1028. OperatResult.AppendText(">>删除成功\n", Color.Green);
  1029. BaseUtil.CleanControlsText(bc_name, bc_code, bg_name, bg_code, mb_badremark, nrg_name, nrg_code, nr_name, nr_code, so_name, so_code, mbr_dutyname, mbr_dutycode, mbc_component);
  1030. mbp_partdgv.DataSource = null;
  1031. mbl_locdgv.DataSource = null;
  1032. mb_id = "";
  1033. //删除后重新加载Tree的信息
  1034. LoadBadInfTree(sender, e);
  1035. }
  1036. else OperatResult.AppendText(">>必须选择不良现象\n", Color.Red);
  1037. }
  1038. else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
  1039. }
  1040. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  1041. {
  1042. if (e.KeyCode == Keys.Enter)
  1043. {
  1044. if (retsn.Text != "")
  1045. {
  1046. if (dh.CheckExist("makeserial","ms_sncode = '"+retsn.Text+ "' and MS_IFCCLEAN is not null"))
  1047. {
  1048. dh.ExecuteSql("update makeserial set MS_IFCCLEAN ='' where ms_sncode = '" + retsn.Text + "'", "select");
  1049. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "完成清空写入信息", "完成清空写入信息", retsn.Text, "");
  1050. OperatResult.AppendText(">>" + retsn.Text + "序列号清空写入信息完成\n", Color.Green, retsn);
  1051. }
  1052. else OperatResult.AppendText(">>" + retsn.Text + "序列号不存在或不需要录入\n", Color.Red, retsn);
  1053. }
  1054. else OperatResult.AppendText(">>" + retsn.Text + "录入不可为空\n", Color.Red, retsn);
  1055. }
  1056. }
  1057. int i = 0;
  1058. private void timer1_Tick(object sender, EventArgs e)
  1059. {
  1060. if (GetSNCode.Text == "" && cd_stepcode.Text != "")
  1061. {
  1062. i = i + 1;
  1063. }
  1064. if (i > 300 && GetSNCode.Text == "" && cd_stepcode.Text != "")
  1065. {
  1066. i = 0;
  1067. cd_stepcode.Text = "";
  1068. OperatResult.AppendText(">>清空回流工序\n", Color.Black);
  1069. }
  1070. }
  1071. }
  1072. }