//工单选择 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql = " select tasksquantity,product_name,areacode,gyid " + "from odc_tasks where taskstate = 2 and taskscode = '" + this.textBox1.Text + "' "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label55.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label56.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //产品名称 this.label57.Text = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); //地区 tt_gyid = ds1.Tables[0].Rows[0].ItemArray[3].ToString(); //生产流程 this.label58.Text = getShouldScan(this.label55.Text); //获取应扫描数量 this.textBox1.Enabled = false; this.textBox7.Text = null; this.textBox7.Visible = true; GetProductNumInfo(); } else { MessageBox.Show("没有找到此工单!或者该工单还没有审批,请确认"); } } else { this.textBox7.Visible = false; ClearItemLable(); this.textBox1.Enabled = true; } }
//工单锁定 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql1 = "select tasksquantity,product_name " + "from odc_tasks where taskscode = '" + this.textBox5.Text + "' "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label7.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label9.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //工单数量 this.textBox5.Enabled = false; this.button4.Visible = true; } else { MessageBox.Show("没有查询此工单,请确认!"); } } else { this.textBox5.Enabled = true; this.label7.Text = null; this.label9.Text = null; this.button4.Visible = false; } }
//工单锁定 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql1 = "select tasksquantity,product_name, customer, flhratio, " + "convert(int,abs(tasksquantity*flhratio/100)) as Fshouldoldnum " + "from odc_tasks where taskscode = '" + this.textBox1.Text + "' and taskstate = 2 "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label6.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label7.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); this.label8.Text = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); this.label9.Text = ds1.Tables[0].Rows[0].ItemArray[3].ToString(); this.label22.Text = GetOldStation(this.label7.Text); //老化站位 tt_shouldoldnumber = Convert.ToInt32(ds1.Tables[0].Rows[0].ItemArray[4].ToString()); this.label18.Text = tt_shouldoldnumber.ToString(); GetProductInfor(); this.textBox1.Enabled = false; this.textBox2.Visible = true; textBox2.Focus(); textBox2.SelectAll(); } else { MessageBox.Show("没有查询此工单,或此工单没有审批,请确认!"); } } else { this.textBox1.Enabled = true; this.textBox2.Visible = false; ClearTaskInfo(); } }
//工单锁定 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql1 = "select tasksquantity,product_name,areacode,Gyid " + "from odc_tasks where taskscode = '" + this.textBox1.Text + "' "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label20.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label23.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //产品名称 this.label24.Text = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); //地区编码 this.label27.Text = ds1.Tables[0].Rows[0].ItemArray[3].ToString(); //流程 //第一步、流程检查 Boolean tt_flag1 = false; if (!this.label27.Text.Equals("")) { bool tt_flag = GetNextCode(this.textBox1.Text, str); if (tt_flag) { tt_flag1 = true; } } else { MessageBox.Show("该工单没有配置流程,请检查"); } if (tt_flag1) { this.textBox1.Enabled = false; this.button1.Visible = true; this.button3.Visible = true; this.button4.Visible = true; } } else { MessageBox.Show("没有查询此工单,请确认!"); } } else { this.textBox1.Enabled = true; clearItem1(); this.button1.Visible = false; this.button3.Visible = false; this.button4.Visible = false; } }
//从routing表获取全流程数据集 public static DataSet getGyidAllProcessDt(string tt_gyid, string tt_conn) { DataSet tt_dt = null; string tt_sql = "select pxid,lcbz from odc_routing where pid = " + tt_gyid; tt_dt = Dataset1.GetDataSetTwo(tt_sql, tt_conn); if (tt_dt.Tables.Count > 0 && tt_dt.Tables[0].Rows.Count > 0) { } else { MessageBox.Show("getGyidAllProcessDt,没有找到流程:" + tt_gyid + ",的流程数据集Dataset,请流程设置!"); } return(tt_dt); }
//扫描 private void textBox7_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //---开始MAC扫描 ScanDataInitial(); setRichtexBox("-----开始MAC扫描--------"); string tt_task = this.textBox1.Text.ToUpper().Trim(); string tt_scanmac = this.textBox7.Text.Trim(); string tt_shortmac = tt_scanmac.Replace("-", ""); //第一步位数判断 Boolean tt_flag1 = false; tt_flag1 = CheckStrLengh(tt_scanmac, this.textBox3.Text); //第二步包含符判断 Boolean tt_flag2 = false; if (tt_flag1) { tt_flag2 = CheckStrContain(tt_scanmac, this.textBox4.Text.Trim()); } //第三步 不包含符判断 Boolean tt_flag3 = false; if (tt_flag2) { tt_flag3 = CheckStrContain2(tt_scanmac, this.textBox2.Text.Trim()); } //第四步 扣数判断 Boolean tt_flag4 = false; if (tt_flag3) { int tt_shouldscan = getTransmitStrToInt(this.label58.Text); int tt_scanint = getTransmitStrToInt(this.label59.Text); if (tt_scanint <= tt_shouldscan) { tt_flag4 = true; setRichtexBox("4、还没有达到上限,应扫描数量:" + tt_shouldscan.ToString() + ",实际扫描数量:" + tt_scanint.ToString() + ",goon"); } else { } } //第五步 获取单板信息 string tt_pcba = ""; string tt_mac = ""; Boolean tt_flag5 = false; if (tt_flag4) { string tt_sql5 = "select pcbasn,maclable from odc_alllable " + "where hprintman = '" + tt_task + "' and maclable = '" + tt_shortmac + "' "; DataSet ds5 = Dataset1.GetDataSet(tt_sql5, tt_conn); if (ds5.Tables.Count > 0 && ds5.Tables[0].Rows.Count > 0) { tt_flag5 = true; tt_pcba = ds5.Tables[0].Rows[0].ItemArray[0].ToString(); //单板号 tt_mac = ds5.Tables[0].Rows[0].ItemArray[1].ToString(); //单板号 setRichtexBox("5、关联表查询到一条数据,pcba=" + tt_pcba + ",mac=" + tt_mac + ",goon"); } else { setRichtexBox("5、关联表没有查询到数据,over"); PutLableInfor("关联表没有查询到数据,请检查!"); } } //第六步 获取站位 Boolean tt_flag6 = false; if (tt_flag5) { string tt_sql6 = "select count(1),min(ccode),min(ncode) from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' and napplytype is null "; string[] tt_array6 = new string[3]; tt_array6 = Dataset1.GetDatasetArray(tt_sql6, tt_conn); if (tt_array6[0] == "1") { if (tt_array6[2] == tt_ccode) { tt_flag6 = true; setRichtexBox("6、该单板有待测站位,站位:" + tt_array6[1] + "," + tt_array6[2] + ",可以过站 goon"); } else if (tt_array6[2] == "2220") { tt_flag6 = true; setRichtexBox("6、该单板有待测站位,站位:" + tt_array6[1] + "," + tt_array6[2] + ",可以过站 goon"); } else if (int.Parse(tt_array6[2]) < int.Parse(tt_ccode) || "2200,2205".Contains(tt_array6[2])) { setRichtexBox("6、该单板待测站位不在" + tt_ccode + ",站位:" + tt_array6[1] + "," + tt_array6[2] + ",不可以过站 goon"); PutLableInfor("该单板当前站位:" + tt_array6[2] + "不在" + tt_ccode + "站位,产品尚未测试耦合,不允许进站"); } else { setRichtexBox("6、该单板待测站位不在" + tt_ccode + ",站位:" + tt_array6[1] + "," + tt_array6[2] + ",不可以过站 goon"); PutLableInfor("该单板当前站位:" + tt_array6[2] + "不在" + tt_ccode + "站位!"); } } else { setRichtexBox("6、没有找到待测站位,或有多条待测站位,流程异常,over"); PutLableInfor("没有找到待测站位,或有多条待测站位,流程异常!"); } } //第六步附 检查2115 站位状态 Boolean tt_flag6_1 = false; if (tt_flag6) { string tt_sql6_1 = "select ncode,napplytype from dbo.odc_routingtasklist where pcba_pn = '" + tt_shortmac + "' and ccode = '2115'"; string tt_allprocesses = Dataset2.getGyidAllProcess(tt_gyid, tt_conn); DataSet ds6_1 = Dataset1.GetDataSetTwo(tt_sql6_1, tt_conn); bool tt_processcheck = true; if (ds6_1.Tables.Count > 0 && ds6_1.Tables[0].Rows.Count > 0) { string tt_napplytype = "1"; for (int i = 0; i < ds6_1.Tables[0].Rows.Count; i++) { tt_napplytype = ds6_1.Tables[0].Rows[i].ItemArray[1].ToString(); if (tt_napplytype == "0") { tt_processcheck = false; break; } } if ((tt_allprocesses.Contains("2111") && tt_napplytype == "1") || tt_processcheck) { tt_flag6_1 = true; setRichtexBox("6.1、该产品产品耦合测试没有出现过不良,或者有2111站位,且当前已通过耦合测试,可以过站,goon"); } else if (!tt_allprocesses.Contains("2111") && !tt_processcheck) { setRichtexBox("6.1、该产品流程没有2111站位,且耦合测试曾经出现过测试失败,不允许过站,over"); PutLableInfor("该产品2111不是必测站位,且耦合测试曾经出现过测试失败,不建议测试吞吐量!"); } else if (tt_allprocesses.Contains("2111") && tt_napplytype == "0") { setRichtexBox("6.1、该产品流程有2111站位,但耦合测试没有通过测试,不允许过站,over"); PutLableInfor("该产品流程有2111站位,但耦合测试没有通过测试,不允许过站!"); } } else { string tt_sql6_2 = "select ncode,napplytype from dbo.odc_routingtasklist where pcba_pn = '" + tt_shortmac + "' and ccode = '2185'"; tt_allprocesses = Dataset2.getGyidAllProcess(tt_gyid, tt_conn); DataSet ds6_2 = Dataset1.GetDataSetTwo(tt_sql6_2, tt_conn); tt_processcheck = true; if (ds6_2.Tables.Count > 0 && ds6_2.Tables[0].Rows.Count > 0) { string tt_napplytype = "1"; for (int i = 0; i < ds6_2.Tables[0].Rows.Count; i++) { tt_napplytype = ds6_2.Tables[0].Rows[i].ItemArray[1].ToString(); if (tt_napplytype == "0") { tt_processcheck = false; break; } } if ((tt_allprocesses.Contains("2111") && tt_napplytype == "1") || tt_processcheck) { tt_flag6_1 = true; setRichtexBox("6.1、该产品产品耦合测试没有出现过不良,或者有2111站位,且当前已通过耦合测试,可以过站,goon"); } else if (!tt_allprocesses.Contains("2111") && !tt_processcheck) { setRichtexBox("6.1、该产品流程没有2111站位,且耦合测试曾经出现过测试失败,不允许过站,over"); PutLableInfor("该产品2111不是必测站位,且耦合测试曾经出现过测试失败,不建议测试吞吐量!"); } } else { setRichtexBox("6.1、没有找到耦合站位状态,流程异常,over"); PutLableInfor("没有找到耦合站位状态,流程异常!"); } } } //第七步 开始过站 Boolean tt_flag7 = false; if (tt_flag6_1) { string tt_sql7 = "update odc_routingtasklist set ncode = '2111',Fremark ='10%扫描耦合' " + "where pcba_pn = '" + tt_mac + "' and napplytype is null "; int tt_int7 = Dataset1.ExecCommand(tt_sql7, tt_conn); if (tt_int7 > 0) { tt_flag7 = true; setRichtexBox("7、OK过站成功,跳站到2111"); } else { setRichtexBox("7、Fail过站失败,over"); PutLableInfor("跳站2111失败,请重新扫描!"); } } //第八步 记录数据 Boolean tt_flag8 = false; if (tt_flag7) { string tt_sql8 = "insert into odc_insertcode(Taskcode,MAC,PCBA,Ncode,Fdate) " + "values('" + tt_task + "','" + tt_mac + "','" + tt_pcba + "','" + tt_ccode + "',getdate()) "; int tt_int8 = Dataset1.ExecCommand(tt_sql8, tt_conn); if (tt_int8 > 0) { tt_flag8 = true; setRichtexBox("8、过站记录成功,goon"); } else { setRichtexBox("8、过站记录成功,over"); PutLableInfor("过站记录失败,扫描其他单板!"); } } //最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8) { GetProductNumInfo(); this.richTextBox1.BackColor = Color.Chartreuse; setRichtexBox("9、over"); tt_yield++; this.label8.Text = tt_yield.ToString(); PutListViewData(tt_mac, tt_pcba); PutLableInfor("请继续扫描"); textBox7.Focus(); textBox7.SelectAll(); } else { this.richTextBox1.BackColor = Color.Red; textBox7.Focus(); textBox7.SelectAll(); } } }
//工单锁定 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql1 = "select tasksquantity,product_name,areacode,fec,Tasktype,VENDORID " + "from odc_tasks where taskscode = '" + this.textBox1.Text + "' "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label27.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label29.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //产品名称 this.label30.Text = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); //地区编码 this.label31.Text = ds1.Tables[0].Rows[0].ItemArray[3].ToString(); //EC编码 this.label49.Text = ds1.Tables[0].Rows[0].ItemArray[4].ToString(); //物料编码 this.label61.Text = ds1.Tables[0].Rows[0].ItemArray[5].ToString(); //COMMID //第一步 EC信息检查 Boolean tt_flag1 = false; string tt_sql2 = "select docdesc,Fpath01,Fdata01,Fmd01 from odc_ec where zjbm = '" + this.label31.Text + "' "; DataSet ds2 = Dataset1.GetDataSet(tt_sql2, tt_conn); if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { this.label34.Text = ds2.Tables[0].Rows[0].ItemArray[0].ToString(); //EC描述 this.label33.Text = ds2.Tables[0].Rows[0].ItemArray[1].ToString(); //模板路径 this.label32.Text = ds2.Tables[0].Rows[0].ItemArray[2].ToString(); //数据类型 this.label59.Text = ds2.Tables[0].Rows[0].ItemArray[3].ToString(); //MD5码 tt_path = Application.StartupPath + ds2.Tables[0].Rows[0].ItemArray[1].ToString(); tt_md5 = ds2.Tables[0].Rows[0].ItemArray[3].ToString(); tt_flag1 = true; } else { MessageBox.Show("没有找到工单表的EC表配置信息,请确认!"); } Boolean tt_flag2 = false; if (tt_flag1) { tt_flag2 = getPathIstrue(tt_path); if (!tt_flag2) { MessageBox.Show(" 找不到模板文件:" + tt_path + ",请确认!"); } } Boolean tt_flag3 = false; if (tt_flag2) { string tt_md6 = GetMD5HashFromFile(tt_path); if (tt_md5 == tt_md6) { tt_flag3 = true; } else { MessageBox.Show("系统设定模板MD5码: '" + tt_md5 + "'与你使用模板的MD5码:'" + tt_md6 + "'不一致,请确认!"); } } //最后验证 if (tt_flag1 && tt_flag2 && tt_flag3) { this.textBox1.Enabled = false; this.textBox2.Visible = true; this.textBox3.Visible = true; this.button4.Visible = true; this.button12.Visible = true; this.button13.Visible = true; GetMACPrintNumInfo(); //MAC打印信息 } } else { MessageBox.Show("没有查询此工单,请确认!"); } } else { this.textBox1.Enabled = true; this.textBox2.Visible = false; this.textBox3.Visible = false; this.button4.Visible = false; this.button12.Visible = false; this.button13.Visible = false; ClearLabelInfo(); ScanDataInitial(); } }
//子工单锁定事件 private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (this.checkBox1.Checked) { string tt_sql1 = "select tasksquantity,product_name,areacode,fec,convert(varchar, taskdate, 102) fdate,customer,flhratio,Gyid,Tasktype " + "from odc_tasks where taskscode = '" + this.textBox1.Text + "' "; DataSet ds1 = Dataset1.GetDataSetTwo(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { this.label12.Text = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); //工单数量 this.label13.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //产品名称 this.label14.Text = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); //地区 this.label17.Text = ds1.Tables[0].Rows[0].ItemArray[3].ToString(); //EC编码 this.label16.Text = ds1.Tables[0].Rows[0].ItemArray[4].ToString(); //生产日期 this.label54.Text = ds1.Tables[0].Rows[0].ItemArray[7].ToString(); //流程配置 this.label15.Text = ds1.Tables[0].Rows[0].ItemArray[8].ToString(); //物料编码 //第一步、流程检查 Boolean tt_flag1 = false; if (!this.label54.Text.Equals("")) { bool tt_flag = GetNextCode(this.textBox1.Text, str); if (tt_flag) { tt_flag1 = true; } } else { MessageBox.Show("该工单没有配置流程,请检查"); } //第二步、查找模板路径 Boolean tt_flag2 = false; if (tt_flag1) { string tt_eccode = this.label17.Text; string tt_sql2 = "select docdesc,Fpath04,Fdata04,Macxp from odc_ec where zjbm = '" + tt_eccode + "' "; DataSet ds2 = Dataset1.GetDataSet(tt_sql2, tt_conn); if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { this.label20.Text = ds2.Tables[0].Rows[0].ItemArray[0].ToString(); //EC描述 this.label18.Text = ds2.Tables[0].Rows[0].ItemArray[2].ToString(); //数据类型 tt_path = Application.StartupPath + ds2.Tables[0].Rows[0].ItemArray[1].ToString(); //模板路径 this.label19.Text = tt_path; tt_flag2 = true; } else { MessageBox.Show("没有找到工单表的EC表配置信息,请确认!"); } } //第三步、总工单与子工单包容性检查 Boolean tt_flag3 = false; string tt_sontask = this.textBox1.Text; string tt_fathertask = this.textBox9.Text; if (tt_flag1 && tt_flag2) { if (tt_sontask.Contains(tt_fathertask)) { tt_flag3 = true; } else { MessageBox.Show("总工单:" + tt_fathertask + ",与子工单:" + tt_sontask + ",不一致,请检查!"); } } //第四步、查找总工单是否存在 Boolean tt_flag4 = false; if (tt_flag1 && tt_flag2 && tt_flag3) { string tt_sql4 = "select count(1),0,0 from odc_tasks " + "where taskscode = '" + tt_fathertask + "' "; string[] tt_array4 = new string[3]; tt_array4 = Dataset1.GetDatasetArray(tt_sql4, tt_conn); if (tt_array4[0] == "1") { tt_flag4 = true; } else { MessageBox.Show("工单表中没有找到该总工单:" + tt_fathertask + ",请确认!"); } } //第五步、查找流水号配置信息 Boolean tt_flag5 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4) { string tt_sql5 = "select count(1),min(hostqzwh),0 from ODC_HOSTLABLEOPTIOAN " + "where taskscode = '" + this.textBox1.Text + "' "; string[] tt_array5 = new string[3]; tt_array5 = Dataset1.GetDatasetArray(tt_sql5, tt_conn); if (tt_array5[0] == "1") { tt_flag5 = true; this.label65.Text = tt_array5[1]; } else { MessageBox.Show("没有找到工单的串号表配置信息,请确认!"); } } //第六步 最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5) { this.textBox1.Enabled = false; this.textBox9.Enabled = false; this.textBox2.Visible = true; this.textBox7.Visible = true; GetProductNumInfo(); //生产信息 } } else { MessageBox.Show("没有查询此工单,请确认!"); } } else { this.textBox1.Enabled = true; this.textBox9.Enabled = true; this.textBox2.Visible = false; this.textBox7.Visible = false; ClearLabelInfo(); ScanDataInitial(); } }