12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.CustomControl.DataGrid_View;
- using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_RepairNew : Form
- {
- string mb_id = "";
- string mbr_id = "";
- /// <summary>
- /// 存放父节点信息
- /// </summary>
- Dictionary<string, Dictionary<string, string>> BadInf_1 = new Dictionary<string, Dictionary<string, string>>();
- /// <summary>
- /// 存放子节点信息
- /// </summary>
- Dictionary<string, Dictionary<string, string>> BadInf_2 = new Dictionary<string, Dictionary<string, string>>();
- DataHelper dh = null;
- LogStringBuilder sql = new LogStringBuilder();
- List<string> sqls = new List<string>();
- DataTable dt = null;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- string macode;
- string msid = "";
- string ifrework = "";
- string reworkstatus = "";
- string firstsn = "";
- string ms_stepcode = "";
- DataTable Dbfind;
- public Make_RepairNew()
- {
- InitializeComponent();
- }
- private void Make_Repair_Load(object sender, EventArgs e)
- {
- //为DBFind配置Call和Form的名称
- cr_code.FormName = Name;
- cr_code.TableName = "craft";
- cr_code.SelectField = "cr_name # 工艺名称,cr_code # 工艺编号,cr_prodcode # 物料编号";
- cr_code.SetValueField = new string[] { "cr_code" };
- cr_code.DBTitle = "回流工艺";
- cr_code.DbChange += Cr_code_DbChange;
- cd_stepcode.FormName = Name;
- cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
- cd_stepcode.SetValueField = new string[] { "cd_stepcode" };
- cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
- cd_stepcode.DBTitle = "回流工序";
- cd_stepcode.DbChange += Cd_stepcode_DbChange;
- bd_soncode.FormName = Name;
- bd_soncode.TableName = "bom left join bomdetail on bd_bomid=bo_id left join product on bd_soncode=pr_code";
- bd_soncode.SetValueField = new string[] { "bd_soncode" };
- bd_soncode.SelectField = "bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格,bd_location # 位号";
- bd_soncode.DBTitle = "不良零件";
- bd_soncode.DbChange += Prodcode_DbChange;
- //nrg_name.BringToFront();
- 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)";
- nrg_name.Field = "nrg_name";
- nrg_name.ValueField = "nrg_code";
- nrg_name.Condition = " 1=1 ORDER BY ROWNUM asc";
- 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 + "' ";
- nr_name.Field = "nr_name";
- nr_name.ValueField = "nr_code";
- 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) ";
- mbr_dutyname.Field = "nd_name";
- mbr_dutyname.ValueField = "nd_code";
- mbr_dutyname.Condition = " 1=1 ORDER BY ROWNUM asc";
- 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)";
- so_name.Field = "so_name";
- so_name.ValueField = "so_code";
- so_name.Condition = " 1=1 ORDER BY ROWNUM asc";
- if (User.UserAccountType != "admin")
- {
- retsnlabel.Visible = false;
- retsn.Visible = false;
- }
- asc.controllInitializeSize(this);
- mbc_component.SendToBack();
- so_name.SendToBack();
- mbl_loc.SendToBack();
- bd_soncode.SendToBack();
- mbp_partdgv.SendToBack();
- mbp_part_label.SendToBack();
- dh = SystemInf.dh;
- GetSNCode.Focus();
- }
- private void Prodcode_DbChange(object sender, EventArgs e)
- {
- Dbfind = bd_soncode.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- if (bd_soncode.Text != "")
- {
- if (mbr_id != "")
- {
- if (!dh.CheckExist("makebadrspart", "mbp_sncode='" + GetSNCode.Text + "' and mbp_part='" + bd_soncode.Text + "' and mbp_badcode='" + bc_code.Text + "'"))
- {
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
- sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- }
- }
- else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
- }
- else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
- }
- private void Cd_stepcode_DbChange(object sender, EventArgs e)
- {
- Dbfind = cd_stepcode.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- }
- private void Cr_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = cr_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- }
- private void GetSNCode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (GetSNCode.Text == "")
- {
- OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- sql.Clear();
- sql.Append("select ms_status,ms_outboxcode,ms_paststep,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework from makeserial left join make ");
- sql.Append("on ms_makecode=ma_code where ms_sncode = '" + GetSNCode.Text + "' order by ms_id desc");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- string ms_paststep = "";
- if (dt.Rows.Count > 0)
- {
- string ms_status = dt.Rows[0]["ms_status"].ToString();
- ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
- ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
- //if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
- //{
- // OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已装箱,请先进行拆箱\n", Color.Red);
- // BaseUtil.CleanForm(this);
- // BadCodeTree.Nodes.Clear();
- // return;
- //}
- //如果不是返修序列号执行原来的步骤
- if (ifrework == "0")
- {
- if (ms_status == "4")
- {
- OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- if (ms_status != "3")
- {
- OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- }
- else
- {
- if (reworkstatus == "4")
- {
- OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- if (reworkstatus != "0" && reworkstatus != "3")
- {
- OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- }
- }
- else
- {
- OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不存在\n", Color.Red);
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- return;
- }
- //dt = (DataTable)dh.ExecuteSql("select mb_stepcode from makebad where mb_sncode='" + GetSNCode.Text + "' and mb_status=0 order by mb_id desc", "select");
- ////打不良的资源和当前资源相等可以快速维修,无须登录维修资源
- //bool QuickRepair = false;
- //if (dt.Rows.Count > 0)
- //{
- // if (dt.Rows[0]["mb_stepcode"].ToString() == User.CurrentStepCode)
- // {
- // QuickRepair = true;
- // }
- //}
- string ErrorMessage = "";
- //验证工序是否正确
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
- {
- BadInf_1.Clear();
- string oStatus = "";
- if (LogicHandler.GetMakeInfo(GetSNCode.Text, out macode, out oStatus, out ErrorMessage))
- {
- //验证makeserial或者ms_firstsn表序列号是否存在
- sql.Clear();
- 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 ");
- 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(");
- sql.Append("select '" + GetSNCode.Text + "' from dual union select firstsn from makesnrelation where ");
- 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");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- msid = dt.Rows[0]["ms_id"].ToString();
- ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- //判断是否当前工单途程的上料记录
- firstsn = dt.Rows[0]["ms_firstsn"].ToString();
- string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
- int ms_badtimes = int.Parse(dt.Rows[0]["ms_badtimes"].ToString());
- string cdstepcode = "";
- //sql.Clear();
- //sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
- //sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
- //sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
- //sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
- //sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
- sql.Clear();
- 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 ");
- sql.Append("sp_craftcode='" + cr_code.Text + "' And sp_mothercode ='" + ms_prodcode.Text + "' and sp_tracekind=1 ");
- //sql.Append("sp_craftcode=v_v_mscraftcode and sp_stepcode='' And sp_mothercode ='"+ms_prodcode.Text+"' and sp_tracekind=1");
- sql.Append("and not exists(select 1 from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
- sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_makecode='" + macode + "' and ");
- 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");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count < 0)
- {
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
- //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
- 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")
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
- else
- {
- string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
- if (ms_paststep.Contains(nextstep))
- {
- cdstepcode = nextstep;
- }
- else
- {
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
- }
- }
- }
- else
- {
- sql.Clear();
- sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
- sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
- sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
- sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
- sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
- }
- }
- if (cdstepcode == "")
- {
- //序号小于等于当前不良的序号
- 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();
- sql.Clear();
- sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
- sql.Append("cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ");
- sql.Append("nvl(cd_ifburnin,0)<>0 and cd_detno <='" + currentdetno + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- cdstepcode = dt.Rows[0][0].ToString();
- }
- }
- //如果ms_stepcode和扣料工序均没有查到返修的工序
- if (cdstepcode == "")
- {
- 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();
- if (flowback != "")
- {
- cdstepcode = flowback;
- }
- else
- {
- cdstepcode = ms_stepcode;
- }
- }
- //cd_stepcode.Text = cdstepcode;
- //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")
- // cd_stepcode.Enabled = false;
- //else
- // cd_stepcode.Enabled = true;
- LoadBadInfTree(sender, e);
- if (ms_badtimes > 3)
- {
- OperatResult.AppendText(">>SN:" + ms_sncode.Text + "累计维修次数超过3次,提示\n", Color.Red);
- }
- }
- else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- }
- }
- private void Make_Repair_SizeChanged(object sender, EventArgs e)
- {
- mbc_component.BringToFront();
- so_name.BringToFront();
- mbl_loc.BringToFront();
- bd_soncode.BringToFront();
- mbp_partdgv.BringToFront();
- mbp_part_label.BringToFront();
- asc.controlAutoSize(this);
- mbc_component.SendToBack();
- so_name.SendToBack();
- mbl_loc.SendToBack();
- bd_soncode.SendToBack();
- mbp_partdgv.SendToBack();
- mbp_part_label.SendToBack();
- }
- private void BadCodeTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- if (e.Node.Level == 0)
- {
- mb_id = e.Node.Tag.ToString();
- 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);
- mbl_locdgv.DataSource = null;
- mbp_partdgv.DataSource = null;
- bc_name.Text = BadInf_1[mb_id]["bc_name"];
- bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
- bg_name.Text = BadInf_1[mb_id]["bg_name"];
- bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
- //mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
- mbr_id = "";
- SaveRepairInf.Enabled = true;
- }
- if (e.Node.Level == 1)
- {
- //展示父节点信息
- mb_id = e.Node.Parent.Tag.ToString();
- bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
- bc_name.Text = BadInf_1[mb_id]["bc_name"];
- bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
- bg_name.Text = BadInf_1[mb_id]["bg_name"];
- //展示子节点信息
- mbr_id = e.Node.Tag.ToString();
- nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
- nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
- nr_code.Text = BadInf_2[mbr_id]["nr_code"];
- nr_name.Text = BadInf_2[mbr_id]["nr_name"];
- so_code.Text = BadInf_2[mbr_id]["so_code"];
- so_name.Text = BadInf_2[mbr_id]["so_name"];
- mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
- mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];//mbr_remark
- mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
- mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
- //加载两个Grid的数据源
- DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
- SaveRepairInf.Enabled = false;
- }
- }
- private void LoadBadInfTree(object sender, EventArgs e)
- {
- BadCodeTree.Nodes.Clear();
- sql.Clear();
- //不是返工工单时的取当前工单
- 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,");
- sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup ");
- 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");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count == 0)
- {
- sql.Clear();
- 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, ");
- sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup on bg_code=mb_bgcode ");
- 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");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- //添加根节点
- TreeNode tnode_0 = new TreeNode();
- string bg_name = dt.Rows[i]["bg_name"].ToString();
- string bc_name = dt.Rows[i]["bc_name"].ToString();
- string mb_badcode = dt.Rows[i]["mb_badcode"].ToString();
- string mb_bgcode = dt.Rows[i]["mb_bgcode"].ToString();
- tnode_0.Text = (bg_name == "" ? mb_bgcode : bg_name) + ":" + (bc_name == "" ? mb_bgcode : bc_name);
- tnode_0.Name = dt.Rows[i]["mb_bgcode"].ToString();
- //作为Dictionary的主标识
- string mb_id = dt.Rows[i]["mb_id"].ToString();
- tnode_0.Tag = mb_id;
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("mb_id", mb_id);
- dic.Add("mb_sncode", dt.Rows[i]["mb_sncode"].ToString());
- dic.Add("mb_badcode", dt.Rows[i]["mb_badcode"].ToString());
- dic.Add("mb_bgcode", dt.Rows[i]["mb_bgcode"].ToString());
- dic.Add("bc_name", dt.Rows[i]["bc_name"].ToString());
- dic.Add("bg_name", dt.Rows[i]["bg_name"].ToString());
- //dic.Add("mb_badremark", dt.Rows[i]["mb_badremark"].ToString());
- if (!BadInf_1.ContainsKey(tnode_0.Tag.ToString()))
- BadInf_1.Add(tnode_0.Tag.ToString(), dic);
- BadCodeTree.Nodes.Add(tnode_0);
- BadCodeTree.SelectedNode = BadCodeTree.Nodes[0];
- //添加子节点
- sql.Clear();
- sql.Append("select mbr_id,mbr_brcode,mbr_brgcode,mbr_solutioncode,so_code,so_name,mbr_dutycode,mbr_dutyname,nd_name,nrg_name");
- sql.Append(",nr_name,nr_code,nrg_code,mbr_remark from makebadreason left join QUA_NGReason on nr_code=mbr_brcode left join ");
- sql.Append("QUA_NGREASONGROUPdet on nrgd_nrcode=nr_code left join QUA_NGREASONGROUP on nrg_id=nrgd_nrgid and ");
- sql.Append("mbr_brgcode=nrg_code left join solution on so_code=mbr_solutioncode left join ngduty on nd_code=mbr_dutycode ");
- sql.Append("where mbr_mbid=" + mb_id);
- DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- for (int j = 0; j < dt1.Rows.Count; j++)
- {
- TreeNode tnode_1 = new TreeNode();
- //存放子节点的信息
- Dictionary<string, string> dic1 = new Dictionary<string, string>();
- string mbr_id = dt1.Rows[j]["mbr_id"].ToString();
- tnode_1.Tag = mbr_id;
- dic1.Add("mbr_id", mbr_id);
- dic1.Add("mbr_brcode", dt1.Rows[j]["mbr_id"].ToString());
- dic1.Add("mbr_brgcode", dt1.Rows[j]["mbr_brcode"].ToString());
- dic1.Add("mbr_solutioncode", dt1.Rows[j]["mbr_solutioncode"].ToString());
- dic1.Add("mbr_dutycode", dt1.Rows[j]["mbr_dutycode"].ToString());
- dic1.Add("mbr_dutyname", dt1.Rows[j]["mbr_dutyname"].ToString());
- dic1.Add("mbr_remark", dt1.Rows[j]["mbr_remark"].ToString());
- dic1.Add("nd_name", dt1.Rows[j]["nd_name"].ToString());
- dic1.Add("so_name", dt1.Rows[j]["so_name"].ToString());
- dic1.Add("so_code", dt1.Rows[j]["so_code"].ToString());
- dic1.Add("nrg_name", dt1.Rows[j]["nrg_name"].ToString());
- dic1.Add("nrg_code", dt1.Rows[j]["nrg_code"].ToString());
- dic1.Add("nr_name", dt1.Rows[j]["nr_name"].ToString());
- dic1.Add("nr_code", dt1.Rows[j]["nr_code"].ToString());
- tnode_1.Text = dt1.Rows[j]["nr_name"].ToString();
- if (!BadInf_2.ContainsKey(mbr_id))
- BadInf_2.Add(mbr_id, dic1);
- tnode_0.Nodes.Add(tnode_1);
- }
- }
- try
- {
- if (bg_code.Text != "")
- BadCodeTree.Nodes[bg_code.Text].Expand();
- }
- catch (Exception) { }
- }
- private void RefreshTreeView_Click(object sender, EventArgs e)
- {
- LoadBadInfTree(sender, e);
- }
- private void RepairComplete_Click(object sender, EventArgs e)
- {
- if (ms_sncode.Text == "")
- {
- OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
- return;
- }
- if (ifrework != "0" && reworkstatus == "0")
- {
- if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0") == 0)
- {
- OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
- return;
- }
- }
- //判断是否所有的不良信息都有维护不良原因
- 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");
- string ErrorMessage = "";
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["mb_id"].ToString() != dt.Rows[i]["mbr_mbid"].ToString())
- ErrorMessage += "【" + dt.Rows[i]["bc_name"].ToString() + "】";
- }
- if (ErrorMessage != "")
- {
- OperatResult.AppendText(">>" + ErrorMessage + "未维护不良原因\n", Color.Red);
- return;
- }
- //如果岗位资源对应工序的版面不为空的时候
- if (dh.getFieldDataByCondition("makeserial left join step on ms_stepcode=st_code", "st_table", "ms_id='" + msid + "'").ToString() != "")
- {
- if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_makecode='" + ms_makecode.Text + "' and mbl_sncode='" + GetSNCode.Text + "' "))
- {
- OperatResult.AppendText(">>工序存在版面必须维护不良位置\n", Color.Red);
- return;
- }
- }
- //查询拆解的物料
- sql.Clear();
- sql.Append("select distinct cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
- 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 ");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- //如果含有序列号物料有被拆解过
- if (dt.Rows.Count > 0)
- {
- string soncode = "";
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- soncode += "'" + dt.Rows[i][0].ToString() + "',";
- }
- //查询对应的上料记录
- sql.Clear();
- sql.Append("select cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union select sn from ");
- sql.Append(" makesnrelation where firstsn='" + firstsn + "') and cm_status=0 and cm_soncode in (" + soncode.Substring(0, soncode.Length - 1) + ")");
- DataTable LoadSoncode = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- //查询的结果不相等表示未完成上料
- if (dt.Rows.Count != LoadSoncode.Rows.Count)
- {
- for (int i = 0; i < LoadSoncode.Rows.Count; i++)
- {
- if (soncode.Contains(LoadSoncode.Rows[i][0].ToString()))
- {
- soncode = soncode.Replace(LoadSoncode.Rows[i][0].ToString(), "");
- }
- }
- OperatResult.AppendText(">>" + soncode.Replace("'", "") + "物料尚未备料,不允许回流\n", Color.Red);
- return;
- }
- }
- dt = (DataTable)dh.ExecuteSql("select cr_id from craft where cr_statuscode='AUDITED' and cr_code='" + cr_code.Text + "'", "select");
- if (dt.Rows.Count == 0)
- OperatResult.AppendText(">>回流工序不存在\n", Color.Red);
- else
- {
- string cr_id = dt.Rows[0]["cr_id"].ToString();
- 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");
- if (dt.Rows.Count == 0)
- OperatResult.AppendText(">>回流工序不在回流工艺中\n", Color.Red);
- else
- {
- dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
- List<string> SQLS = new List<string>();
- if (dt.Rows.Count > 0)
- {
- string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- string ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
- //如果回流的执行过的工序为空
- if (!ms_paststep.Contains(cd_stepcode.Text) && ms_paststep != "")
- {
- OperatResult.AppendText(">>不允许回流到未执行的工序\n", Color.Red);
- return;
- }
- if (ms_ifrework == "0")
- 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 + "'");
- else
- 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 + "'");
- }
- SQLS.Add("update makebad set mb_status=-1 where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "'");
- //取消最近拆解部件
- 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");
- //if (checkBox1.Checked)
- //{
- // if (dh.CheckExist("makeserial", "ms_sncode = '" + ms_sncode.Text + "' and ms_makecode = '" + ms_makecode.Text + "' and ms_key is not null"))
- // {
- // 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 + "'");
- // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "需要清空写入信息", "需要清空写入信息", ms_sncode.Text, ms_checkno.Text);
- // }
- // else {
- // 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 + "'");
- // }
- // }
- //SQLS.Add("update MakeBadCount set mbc_status=-1 where mbc_sncode='" + ms_sncode.Text + "'");
- dh.ExecuteSQLTran(SQLS.ToArray());
- LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "回流工序", "完成维修回流", User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "回流工序", "完成维修回流", ms_sncode.Text, ms_checkno.Text);
- OperatResult.AppendText(">>序列号" + ms_sncode.Text + "回流成功\n", Color.Green);
- cd_stepcode.Enabled = true;
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- GetSNCode.Clear();
- GetSNCode.Focus();
- }
- }
- }
- private void Scrap_Click(object sender, EventArgs e)
- {
- if (ms_sncode.Text != "")
- {
- //判断是否有无法维修的记录
- 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());
- if (ScrapNum == 0)
- OperatResult.AppendText(">>" + ms_sncode.Text + "报废必须维护不良原因\n", Color.Red);
- else
- {
- string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
- if (confirm == "Yes")
- {
- DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
- if (dt.Rows.Count > 0)
- {
- string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- string reworkcode = dt.Rows[0]["ms_reworkcode"].ToString();
- if (ms_ifrework == "0")
- {
- dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "'", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
- }
- else
- {
- sqls.Clear();
- sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_reworkstatus= 4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
- sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_reworkcheckno.Text + "'");
- sqls.Add("delete from oqcbatchdetail where obd_sncode='" + ms_sncode.Text + "' and obd_checkno='" + ms_reworkcheckno.Text + "'");
- sqls.Add("update ReworkDetail set rd_rwstatus='报废' where rd_reid=(select re_id from rework where re_code='" + reworkcode + "') and rd_sncode='" + reworkcode + "'");
- dh.ExecuteSQLTran(sqls.ToArray());
- }
- }
- dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ms_makecode.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
- dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1", "ma_code='" + macode + "'");
- LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "报废", "序列号报废", User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "报废", "序列号报废", ms_sncode.Text, ms_checkno.Text);
- OperatResult.AppendText(">>报废成功\n", Color.Green);
- GetSNCode.Clear();
- BaseUtil.CleanForm(this);
- BadCodeTree.Nodes.Clear();
- }
- }
- }
- else OperatResult.AppendText(">>序列号不允许为空\n", Color.Red);
- }
- private void NewBadCode_Click(object sender, EventArgs e)
- {
- if (GetSNCode.Text == "" || macode == null || macode == "")
- {
- OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
- }
- else
- {
- Make_NewBadCode badcode = new Make_NewBadCode(GetSNCode.Text, macode);
- badcode.FormClosed += LoadBadInfTree;
- BaseUtil.SetFormCenter(badcode);
- badcode.ShowDialog();
- }
- }
- private void NewRepairInf_Click(object sender, EventArgs e)
- {
- if (bg_name.Text == "" && bc_name.Text == "")
- {
- OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
- }
- else
- {
- Make_NewMatainInf mataininf = new Make_NewMatainInf(bg_name.Text, bg_code.Text, bc_name.Text, bc_code.Text, GetSNCode.Text, msid, mb_id);
- mataininf.FormClosed += LoadBadInfTree;
- BaseUtil.SetFormCenter(mataininf);
- mataininf.ShowDialog();
- }
- }
- private void SaveRepairInf_Click(object sender, EventArgs e)
- {
- string ErrorMessage = "";
- if (bg_name.Text == "" || bc_name.Text == "")
- {
- OperatResult.AppendText(">>不良代码组和不良代码不能为空\n", Color.Red);
- return;
- }
- if (nrg_name.Text == "")
- ErrorMessage += " 不良原因组 ";
- if (nr_name.Text == "")
- ErrorMessage += " 不良原因 ";
- if (mbr_dutyname.Text == "")
- ErrorMessage += " 责任别 ";
- //if (mbr_dutyname.Text == "物料问题" && mbc_component.Text == "")
- // ErrorMessage += "责任别为物料问题时必须选择不良零件";
- if (ErrorMessage != "")
- {
- ErrorMessage += "不能为空";
- OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- return;
- }
- string mbr_id = dh.GetSEQ("makebadreason_seq");
- //存在不良组件进行提示
- 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"))
- {
- OperatResult.AppendText(">>不良代码【" + bc_name.Text + "】已存在不良原因【" + nr_name.Text + "】\n", Color.Red);
- return;
- }
- if (!dh.CheckExist("QUA_NGREASONGROUP", "nrg_name='" + nrg_name.Text + "'"))
- {
- OperatResult.AppendText(">>不良原因组不存在\n", Color.Red);
- return;
- }
- if (!dh.CheckExist("QUA_NGReason", "nr_name='" + nr_name.Text + "'"))
- {
- OperatResult.AppendText(">>不良原因不存在\n", Color.Red);
- return;
- }
- if (!dh.CheckExist("ngduty", "nd_name='" + mbr_dutyname.Text + "'"))
- {
- OperatResult.AppendText(">>责任别不存在\n", Color.Red);
- return;
- }
- if (!dh.CheckExist("solution", "so_name='" + so_name.Text + "'"))
- {
- OperatResult.AppendText(">>解决方案不存在\n", Color.Red);
- return;
- }
- //保存选择记录至后台,根据岗位资源代码记录
- 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");
- 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");
- 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");
- 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");
- //保存不良原因
- sql.Clear();
- sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
- sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
- sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname,mbr_remark) select '" + mb_id + "','" + mbr_id + "','" + nr_code.Text + "',");
- sql.Append("'" + so_code.Text + "','" + mbr_dutyname.Text + "','" + nrg_code.Text + "','" + bc_code.Text + "',");
- 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");
- dh.ExecuteSql(sql.GetString(), "insert");
- if (mbc_component.Text != "")
- {
- sql.Clear();
- sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
- sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
- sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + mbc_component.Text + "',");
- sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "')");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
- OperatResult.AppendText(">>不良原因保存成功\n", Color.Green);
- SaveRepairInf.Enabled = false;
- LoadBadInfTree(sender, e);
- }
- private void DeleteRepairInf_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
- if (dt.Rows.Count > 0)
- {
- if (mbr_id != "")
- {
- string delete1 = "delete from makebadrsloc where mbl_mbrid='" + mbr_id + "'";
- string delete2 = "delete from makebadrspart where mbp_mbrid='" + mbr_id + "'";
- string delete3 = "delete from makebadrscom where mbc_mbrid='" + mbr_id + "'";
- string delete4 = "delete from makebadreason where mbr_id='" + mbr_id + "'";
- dh.ExecuteSQLTran(delete1, delete2, delete3, delete4);
- OperatResult.AppendText(">>删除成功\n", Color.Green);
- 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);
- mbp_partdgv.DataSource = null;
- mbl_locdgv.DataSource = null;
- mbr_id = "";
- //删除后重新加载Tree的信息
- LoadBadInfTree(sender, e);
- }
- else OperatResult.AppendText(">>必须选择不良原因\n", Color.Red);
- }
- else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
- }
- private void SaveBadLocation_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
- if (dt.Rows.Count > 0)
- {
- if (mbl_loc.Text != "")
- {
- if (mbr_id != "")
- {
- if (!dh.CheckExist("makebadrsloc", "mbl_mbrid='" + mbr_id + "' and mbl_sncode='" + GetSNCode.Text + "' and mbl_loc='" + mbl_loc.Text.ToUpper() + "'"))
- {
- sql.Clear();
- sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
- sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
- sql.Append(",'" + mbl_loc.Text.ToUpper() + "','" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
- sql.Clear();
- sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
- sql.Append(" start with bo_mothercode='" + ms_prodcode.Text + "' connect by bo_mothercode= prior bd_soncode) ");
- sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + mbl_loc.Text.ToUpper() + ",')>0");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][0].ToString() + "',");
- sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- mbl_loc.Clear();
- }
- }
- else OperatResult.AppendText(">>已存在该不良位置\n", Color.Red);
- }
- else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
- }
- else OperatResult.AppendText(">>不良位置不能为空\n", Color.Red);
- }
- else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
- }
- private void nr_name_TextChanged(object sender, EventArgs e)
- {
- if (nr_name.Text == "")
- SaveBadLocation.Enabled = false;
- else
- SaveBadLocation.Enabled = true;
- }
- private void mbl_loc_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- SaveBadLocation_Click(sender, e);
- }
- private void prodcode_TextKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (bd_soncode.Text != "")
- {
- if (mbr_id != "")
- {
- sql.Clear();
- sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
- sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
- sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
- sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
- sql.Append("sysdate,'" + User.UserCode + "' from dual");
- dh.ExecuteSql(sql.GetString(), "insert");
- DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- }
- else OperatResult.AppendText(">>请先选择不良原因\n", Color.Red);
- }
- else OperatResult.AppendText(">>不良零件不能为空\n", Color.Red);
- }
- }
- private void cr_code_UserControlTextChanged(object sender, EventArgs e)
- {
- //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";
- cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperatResult.Clear();
- }
- private void mbl_locdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- if (mbl_locdgv.Columns[e.ColumnIndex].Name == "DeletePos")
- {
- dh.ExecuteSql("delete from makebadrsloc where mbl_id='" + mbl_locdgv.Rows[e.RowIndex].Cells["mbl_id"].Value.ToString() + "'", "insert");
- dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
- }
- }
- }
- private void mbp_partdgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- if (mbp_partdgv.Columns[e.ColumnIndex].Name == "DeleteCom")
- {
- dh.ExecuteSql("delete from makebadrspart where mbp_id='" + mbp_partdgv.Rows[e.RowIndex].Cells["mbp_id"].Value.ToString() + "'", "insert");
- DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- }
- }
- }
- private void Make_Repair_FormClosing(object sender, FormClosingEventArgs e)
- {
- dh.Dispose();
- }
- private void ms_prodcode_TextChanged(object sender, EventArgs e)
- {
- if (ms_prodcode.Text != "")
- cr_code.Condition = "cr_prodcode='" + ms_prodcode.Text + "'";
- else
- cr_code.Condition = "";
- bd_soncode.Condition = "bd_mothercode='" + ms_prodcode.Text + "' and NVL(bd_usestatus,' ')<>'DISABLE'";
- //设置工序的条件
- //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";
- cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
- }
- public void RefreshData()
- {
- GetSNCode_KeyDown(new object(), new KeyEventArgs(Keys.Enter));
- }
- private void nr_name_UserControlTextChanged(object sender, EventArgs e)
- {
- if (nr_name.Text != "")
- {
- SaveBadLocation.Enabled = true;
- if (nrg_name.Text == "")
- {
- OperatResult.AppendText(">>请先填写不良代码组\n", Color.Red);
- nr_name.Text = "";
- }
- else
- {
- if (nr_code.Text == "" || (nr_code.Text != "" && nr_code.Text != nr_name.Value))
- nr_code.Text = nr_name.Value;
- }
- }
- else SaveBadLocation.Enabled = false;
- }
- private void nrg_name_UserControlTextChanged(object sender, EventArgs e)
- {
- if (nrg_code.Text == "" || (nrg_code.Text != "" && nrg_code.Text != nrg_name.Value))
- nrg_code.Text = nrg_name.Value;
- nr_name.Condition = "nrg_code in('" + (nrg_code.Text == "" ? "''" : nrg_code.Text) + "')";
- }
- private void mbr_dutyname_UserControlTextChanged(object sender, EventArgs e)
- {
- if (mbr_dutycode.Text == "" || (mbr_dutycode.Text != "" && mbr_dutycode.Text != mbr_dutyname.Value))
- mbr_dutycode.Text = mbr_dutyname.Value;
- }
- private void mbc_component_UserControlTextChanged(object sender, EventArgs e)
- {
- }
- private void so_name_UserControlTextChanged(object sender, EventArgs e)
- {
- if (so_code.Text == "" || (so_code.Text != "" && so_code.Text != so_name.Value))
- so_code.Text = so_name.Value;
- }
- private void BadCodeTree_AfterSelect(object sender, TreeViewEventArgs e)
- {
- if (e.Node.Level == 0)
- {
- mb_id = e.Node.Tag.ToString();
- 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);
- mbl_locdgv.DataSource = null;
- mbp_partdgv.DataSource = null;
- bc_name.Text = BadInf_1[mb_id]["bc_name"];
- bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
- bg_name.Text = BadInf_1[mb_id]["bg_name"];
- bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
- // mb_badremark.Text = BadInf_1[mb_id]["mb_badremark"];
- mbr_id = "";
- SaveRepairInf.Enabled = true;
- }
- if (e.Node.Level == 1)
- {
- //展示父节点信息
- mb_id = e.Node.Parent.Tag.ToString();
- bc_code.Text = BadInf_1[mb_id]["mb_badcode"];
- bc_name.Text = BadInf_1[mb_id]["bc_name"];
- bg_code.Text = BadInf_1[mb_id]["mb_bgcode"];
- bg_name.Text = BadInf_1[mb_id]["bg_name"];
- //展示子节点信息
- mbr_id = e.Node.Tag.ToString();
- nrg_code.Text = BadInf_2[mbr_id]["nrg_code"];
- nrg_name.Text = BadInf_2[mbr_id]["nrg_name"];
- nr_code.Text = BadInf_2[mbr_id]["nr_code"];
- nr_name.Text = BadInf_2[mbr_id]["nr_name"];
- so_code.Text = BadInf_2[mbr_id]["so_code"];
- so_name.Text = BadInf_2[mbr_id]["so_name"];
- mbr_dutycode.Text = BadInf_2[mbr_id]["mbr_dutycode"];
- mbr_dutyname.Text = BadInf_2[mbr_id]["mbr_dutyname"];
- mb_badremark.Text = BadInf_2[mbr_id]["mbr_remark"];
- mbc_component.Text = dh.getFieldDataByCondition("makebadrscom", "mbc_component", "mbc_mbrid=" + mbr_id).ToString();
- //加载两个Grid的数据源
- DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbp_partdgv, dt);
- dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
- BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
- SaveRepairInf.Enabled = false;
- }
- }
- private void normalButton1_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + GetSNCode.Text + "' and ms_status=3", "select");
- if (dt.Rows.Count > 0)
- {
- if (mb_id != "")
- {
- string delete1 = "delete from makebadrsloc where mbl_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
- string delete2 = "delete from makebadrspart where mbp_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
- string delete3 = "delete from makebadrscom where mbc_mbrid in (select mbr_id from makebadreason where mbr_mbid = '" + mb_id + "' )";
- string delete4 = "delete from makebadreason where mbr_mbid='" + mb_id + "'";
- string delete = "delete from makebad where mb_id = '" + mb_id + "'";
- dh.ExecuteSQLTran(delete1, delete2, delete3, delete4, delete);
- OperatResult.AppendText(">>删除成功\n", Color.Green);
- 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);
- mbp_partdgv.DataSource = null;
- mbl_locdgv.DataSource = null;
- mb_id = "";
- //删除后重新加载Tree的信息
- LoadBadInfTree(sender, e);
- }
- else OperatResult.AppendText(">>必须选择不良现象\n", Color.Red);
- }
- else OperatResult.AppendText(">>" + GetSNCode.Text + "序列号错误,不存在或者不处于维修状态\n", Color.Red);
- }
- private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (retsn.Text != "")
- {
- if (dh.CheckExist("makeserial","ms_sncode = '"+retsn.Text+ "' and MS_IFCCLEAN is not null"))
- {
- dh.ExecuteSql("update makeserial set MS_IFCCLEAN ='' where ms_sncode = '" + retsn.Text + "'", "select");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "完成清空写入信息", "完成清空写入信息", retsn.Text, "");
- OperatResult.AppendText(">>" + retsn.Text + "序列号清空写入信息完成\n", Color.Green, retsn);
- }
- else OperatResult.AppendText(">>" + retsn.Text + "序列号不存在或不需要录入\n", Color.Red, retsn);
- }
- else OperatResult.AppendText(">>" + retsn.Text + "录入不可为空\n", Color.Red, retsn);
- }
- }
- }
- }
|