//订单查询确定 private void button6_Click(object sender, EventArgs e) { this.dataGridView6.DataSource = null; string tt_task = this.textBox10.Text.Trim(); string tt_sql1 = "select hprintman 总工单,taskscode 子工单, pcbasn 单板号,hostlable 主机条码,maclable MAC, " + "boxlable 生产序列号,Bosasn BOSA, shelllable GPSN, Smtaskscode 串号, Dystlable 电源号, " + "sprinttime 关联时间 " + "from odc_alllable " + "where taskscode = '" + tt_task + "' order by hostlable "; DataSet ds1 = Dataset1.GetDataSet(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView6.DataSource = ds1; dataGridView6.DataMember = "Table"; } else { MessageBox.Show("sorry,没有查询到数据"); } }
//查询确定 private void button7_Click(object sender, EventArgs e) { this.dataGridView2.DataSource = null; //-----不良时间 string tt_date1 = this.dateTimePicker1.Text; string tt_date2 = this.dateTimePicker2.Text; //工单号 string tt_task = ""; if (this.textBox5.Text != "") { tt_task = " and Ftaskscode = '" + this.textBox5.Text + "' "; } //单板号 string tt_pcba = ""; if (this.textBox6.Text != "") { tt_pcba = " and SN = '" + this.textBox6.Text + "' "; } //主机条码 string tt_hostlable = ""; if (this.textBox7.Text != "") { tt_hostlable = " and CMCC_SN = '" + this.textBox7.Text + "' "; } //MAC string tt_mac = ""; if (this.textBox8.Text != "") { tt_hostlable = " and Fmac = '" + this.textBox8.Text + "' "; } string tt_sql1 = "select Ftaskscode 工单号, SN 单板号, CMCC_SN 主机条码, Fmac MAC, analysisDate 过站日期,Fcode 过站站位, Ffilename 过站文件 " + "from ODC_Analysis_Log " + "where analysisDate between '" + tt_date1 + "' and '" + tt_date2 + "' " + tt_task + tt_pcba + tt_hostlable + tt_mac; DataSet ds1 = Dataset1.GetDataSet(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView2.DataSource = ds1; dataGridView2.DataMember = "Table"; } else { MessageBox.Show("sorry,没有查询到数据"); } }
private void UpMessage_Load(object sender, EventArgs e) { tt_conn = @"server=" + sip + @";database=oracle;uid=sa;pwd=adminsa"; string tt_sql = "select top 1 up_message from printsoft_up_messages order by id desc"; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); string Messageshow_Text = ds.Tables[0].Rows[0].ItemArray[0].ToString(); this.Messageshow.Text = "打印软件有更新,原因是:\n" + Messageshow_Text + ",\n立刻更新打印软件吗?"; }
//获取MAC全部过站信息 public static DataSet getMacAllCodeInfo(string tt_shortmac, string tt_conn) { DataSet tt_dt = null; string tt_sql1 = "select Id,Ccode,Ncode,Napplytype,Fremark from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' order by id "; tt_dt = Dataset1.GetDataSet(tt_sql1, tt_conn); return(tt_dt); }
//确定 private void button2_Click(object sender, EventArgs e) { this.label16.Text = null; this.dataGridView1.DataSource = null; bool tt_flag = false; if (this.textBox5.Text != "") { tt_flag = true; } else { MessageBox.Show("工单号不能为空!"); } if (tt_flag) { string tt_task = this.textBox5.Text.ToUpper().Trim(); string tt_sql = "select 1 "; string tt_sql1 = "select taskcode 工单号,count(1) 数量 from odc_insertcode " + "where taskcode = '" + tt_task + "' group by taskcode "; string tt_sql2 = "select Taskcode 工单号,MAC,PCBA 单板号,Ncode 跳转站位,Fdate 日期 from odc_insertcode " + "where Taskcode = '" + tt_task + "' "; if (this.radioButton1.Checked) { tt_sql = tt_sql1; } if (this.radioButton2.Checked) { tt_sql = tt_sql2; } DataSet ds1 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds1; dataGridView1.DataMember = "Table"; if (this.radioButton2.Checked) { this.label16.Text = ds1.Tables[0].Rows.Count.ToString(); } } else { MessageBox.Show("sorry,没有查询到数据"); } } }
//重置 private void button10_Click(object sender, EventArgs e) { this.dataGridView1.DataSource = null; Boolean tt_flag = false; if (this.textBox4.Text == "" && this.textBox5.Text == "") { MessageBox.Show("工单号和MAC不能都为空!"); } else { tt_flag = true; } if (tt_flag) { //工单号 string tt_task = ""; if (this.textBox4.Text.Trim() != "") { tt_task = " and taskscode = '" + this.textBox4.Text.Trim() + "' "; } //MAC string tt_mac = ""; if (this.textBox5.Text.Trim() != "") { tt_mac = " and mac = '" + this.textBox5.Text.Trim() + "' "; } string tt_sql = "select taskscode 工单号,MAC, barcode 设备标示符, SN GPSN,state 打印次数, Fusestate 是否使用, Fnameplate 打印时间 " + "from odc_macinfo " + "where 1=1 " + tt_task + tt_mac; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds; dataGridView1.DataMember = "Table"; } else { MessageBox.Show("sorry,没有查询到数据"); } } }
//刷新站位 private void CheckStation(string tt_mac) { string tt_sql = "select ccode 前站 ,Ncode 后站,napplytype 过站,taskscode 工单,pcba_pn MAC, createtime,fremark " + "from ODC_ROUTINGTASKLIST where pcba_pn = '" + tt_mac + "' order by id desc"; DataSet ds1 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds1; dataGridView1.DataMember = "Table"; this.label55.Text = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //当前站位 } }
//获取产品地区 private string Getproductarea(string tt_mac) { string tt_productname = ""; string tt_sql = "select areacode from ODC_TASKS " + "where taskscode in " + "(select taskscode from odc_alllable where maclable = '" + tt_mac + "')"; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { tt_productname = ds.Tables[0].Rows[0][0].ToString(); } return(tt_productname); }
//获取可跳站位 private string GetNcode(string tt_code) { string tt_routnum = "0"; string tt_sql = "select ncode from odc_routing_change where ccode = '" + tt_code + "'"; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { tt_routnum = ds.Tables[0].Rows[0].ItemArray[0].ToString(); } return(tt_routnum); }
//获取站位的数量 private DataSet GetStationInfo() { string tt_sql = "select T1.pcba_pn MAC, T2.pcbasn 单板,T2.hostlable 主机码,T2.smtaskscode 移动码,T1.ccode 前站,T1.ncode 后站 " + "from odc_routingtasklist T1 " + "left outer join odc_alllable T2 " + "on T1.pcba_pn = T2.maclable " + "where T1.taskscode = '" + this.textBox1.Text + "' and T1.Napplytype is null and T1.Ncode = '" + this.textBox2.Text + "' "; DataSet ds1 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds1; dataGridView1.DataMember = "Table"; this.label10.Text = ds1.Tables[0].Rows.Count.ToString(); } return(ds1); }
//获取未比对信息列表 private void getCheckNumber2(string tt_task, string tt_package) { this.richTextBox2.Text = null; string tt_sql = "select T2.boxlable " + "from odc_package T1 " + "left outer join odc_alllable T2 " + "on T1.pasn = T2.pcbasn " + "where T1.taskcode = '" + tt_task + "' and T1.pagesn = '" + tt_package + "' and T1.pageperson <> '中箱已比对' "; DataSet ds3 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0) { //遍历一个表多行一列 foreach (DataRow row in ds3.Tables[0].Rows) { this.richTextBox2.Text = row[0].ToString() + "\n" + this.richTextBox2.Text; } } }
//查询确定 private void button15_Click(object sender, EventArgs e) { this.dataGridView3.DataSource = null; //-----日期---- string tt_date1 = this.dateTimePicker4.Text; string tt_date2 = this.dateTimePicker3.Text; //----工单---- string tt_ftask = ""; if (!this.textBox10.Text.Equals("")) { tt_ftask = " and Ftask = '" + this.textBox10.Text + "' "; } //-----文件名---- string tt_fsn = ""; if (!this.textBox11.Text.Equals("")) { tt_fsn = " and Fsn = '" + this.textBox11.Text + "' "; } string tt_sql = "select ID,Fsn,Fpc,Fcode," + "FN01,FN02,FN03,FN04,FN05,FN06,FN07,FN08,FN09,FN10,FN11,FN12,FN13,FN14,FN15,FN16,FN17,FN18,FN19,FN20," + "Fid,Ftask,Ffilename,Fdate " + "from odc_wifilog " + "where Fdate between '" + tt_date1 + "' and '" + tt_date2 + "' " + tt_ftask + tt_fsn; DataSet ds1 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView3.DataSource = ds1; dataGridView3.DataMember = "Table"; } else { MessageBox.Show("sorry,没有查询到数据!"); } }
//获取3350前的站位 private string GetFixBeforStation(string tt_mac, string tt_process, int tt_productname_check) { string tt_fixbefor = "0"; string tt_sql = "select id,Ncode from ODC_ROUTINGTASKLIST " + "where pcba_pn = '" + tt_mac + "' and Napplytype is not null " + "order by id desc "; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { tt_fixbefor = ds.Tables[0].Rows[i][1].ToString(); if (tt_process.Contains(tt_fixbefor) || (tt_productname_check == 1 && tt_fixbefor == "2111")) { break; } } } return(tt_fixbefor); }
//查询站位显示站位 private void GetMacStation(string tt_mac) { this.dataGridView1.DataSource = null; string tt_sql3 = "select ID,taskscode 工单号, pcba_pn MAC, ccode 前站位, Createtime 创建时间, " + "Ncode 当前站位,Napplytype 状态, Enddate 完成时间, Fremark 备注 " + "from ODC_ROUTINGTASKLIST " + "where pcba_pn = '" + tt_mac + "' " + "order by id desc "; DataSet ds3 = Dataset1.GetDataSet(tt_sql3, tt_conn); if (ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds3; dataGridView1.DataMember = "Table"; } else { PutLableInfor("没有查询到数据,请检查!"); } }
//查询确定 private void button8_Click(object sender, EventArgs e) { this.dataGridView1.DataSource = null; //-----日期---- string tt_date1 = this.dateTimePicker1.Text; string tt_date2 = this.dateTimePicker2.Text; //----工单---- string tt_task = ""; if (!this.textBox7.Text.Equals("")) { tt_task = " and Ftaskcode = '" + this.textBox7.Text + "' "; } //-----文件名---- string tt_filename = ""; if (!this.textBox8.Text.Equals("")) { tt_filename = " and Flogname like '%" + this.textBox8.Text + "%' "; } string tt_sql = "select Ftaskcode 工单,Flogname 文件名,Fnewname 新文件名,Fpath 保存路径, Fdate 记录时间 " + "from ODC_LOGUPLOAD " + "where Fdate between '" + tt_date1 + "' and '" + tt_date2 + "' " + tt_task + tt_filename; DataSet ds1 = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds1; dataGridView1.DataMember = "Table"; } else { MessageBox.Show("sorry,没有查询到数据!"); } }
private void selectShowMain() { ClearLabelone(); string tt_date = DateTime.Now.ToString("yyyy-MM-dd"); string tt_date1 = tt_date.Replace("-", ""); this.label14.Text = tt_date1; //---工序 string tt_code = ""; if (this.textBox1.Text != "") { tt_code = " and STANCE = '" + this.textBox1.Text + "' "; } //---线别 string tt_line = ""; if (this.textBox2.Text != "") { tt_line = " and LINE = '" + this.textBox2.Text + "' "; } string tt_sql = ""; //汇总一 string tt_sql1 = "select RECORD_ID 日期,STANCE 站位,sum(cast(PASSNUM as int)) 通过数,sum(cast(NGNUM as int)) NG数 " + "from ODC_STATISTICS " + "where RECORD_ID = '" + tt_date1 + "'" + tt_code + tt_line + " group by RECORD_ID,STANCE " + " order by STANCE"; //汇总三 string tt_sql2 = "select RECORD_ID 日期,STANCE 站位,COMPUTER_NAME 电脑名称,sum(cast(PASSNUM as int)) 通过数,sum(cast(NGNUM as int)) NG数 " + "from ODC_STATISTICS " + "where RECORD_ID = '" + tt_date1 + "'" + tt_code + tt_line + " group by RECORD_ID,STANCE,COMPUTER_NAME " + " order by STANCE"; if (this.radioButton1.Checked == true) { tt_sql = tt_sql1; } if (this.radioButton2.Checked == true) { tt_sql = tt_sql2; } DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { dataGridView1.DataSource = ds; dataGridView1.DataMember = "Table"; DataGridViewTextBoxColumn acCode = new DataGridViewTextBoxColumn(); acCode.Name = "acCode"; acCode.DataPropertyName = "acCode"; acCode.HeaderText = "良率"; dataGridView1.Columns.Add(acCode); } if (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0) { //MessageBox.Show("sorry,没有查询到数据"); } else { decimal tt_pass = 0; //通过数 decimal tt_ngnum = 0; //NG数 decimal tt_pass1 = 0; //通过数 decimal tt_ngnum1 = 0; //NG数 decimal tt_sum = 0; //总数 decimal tt_radio = 0; //良率 decimal tt_coderadio = 0; //站位良率 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { tt_pass1 = 0; tt_ngnum1 = 0; tt_coderadio = 0; if (ds.Tables[0].Rows[i]["通过数"].ToString() != "") { tt_pass = tt_pass + decimal.Parse(ds.Tables[0].Rows[i]["通过数"].ToString()); tt_pass1 = decimal.Parse(ds.Tables[0].Rows[i]["通过数"].ToString()); } if (ds.Tables[0].Rows[i]["NG数"].ToString() != "") { tt_ngnum = tt_ngnum + decimal.Parse(ds.Tables[0].Rows[i]["NG数"].ToString()); tt_ngnum1 = decimal.Parse(ds.Tables[0].Rows[i]["NG数"].ToString()); } if (tt_pass1 != 0 || tt_ngnum1 != 0) { tt_coderadio = Math.Round(tt_pass1 / (tt_pass1 + tt_ngnum1) * 100, 2); dataGridView1.Rows[i].Cells["acCode"].Value = tt_coderadio.ToString() + "%"; } } tt_sum = tt_pass + tt_ngnum; if (tt_sum > 0 && tt_pass > 0) { tt_radio = Math.Round(tt_pass / tt_sum * 100, 2); } this.label2.Text = tt_sum.ToString(); this.label5.Text = tt_pass.ToString(); this.label7.Text = tt_ngnum.ToString(); this.label3.Text = tt_radio.ToString() + "%"; } }
//铭牌主机条码扫描 private void textBox2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ClearLabelInfo1(); tt_hostlable = this.textBox2.Text.ToUpper().Trim(); //第一步位数效验 Boolean tt_flag1 = false; if (CheckStrLengh(tt_hostlable, this.textBox3.Text)) { tt_flag1 = true; } else { this.textBox14.Text = "位数不对"; this.textBox14.BackColor = Color.Red; } //第二步 包含效验 Boolean tt_flag2 = false; if (tt_flag1) { if (CheckStrContain(tt_hostlable, this.textBox4.Text)) { tt_flag2 = true; } else { this.textBox14.Text = "包含符不对"; this.textBox14.BackColor = Color.Red; } } //第三步工单检验 Boolean tt_flag3 = false; if (tt_flag1 && tt_flag2) { string tt_sql3 = "select count(1),min(taskscode),0 from odc_alllable " + "where hostlable = '" + tt_hostlable + "' "; string[] tt_array3 = new string[3]; tt_array3 = Dataset1.GetDatasetArray(tt_sql3, tt_conn); if (tt_array3[0] == "1") { if (tt_array3[1] == this.textBox1.Text) { tt_flag3 = true; } else { this.textBox14.Text = "工单不对," + tt_array3[1]; this.textBox14.BackColor = Color.Red; } } else { this.textBox14.Text = "没找到该记录"; this.textBox14.BackColor = Color.Red; } } //第四步查找信息 Boolean tt_flag4 = false; if (tt_flag1 && tt_flag2 && tt_flag3) { string tt_sql4 = "select bprintuser,boxlable,dystlable,id from odc_alllable " + "where taskscode = '" + this.textBox1.Text + "' and hostlable = '" + tt_hostlable + "'"; DataSet ds4 = Dataset1.GetDataSet(tt_sql4, tt_conn); if (ds4.Tables.Count > 0 && ds4.Tables[0].Rows.Count > 0) { tt_flag4 = true; tt_shortmac = ds4.Tables[0].Rows[0].ItemArray[0].ToString().Substring(0, 17); tt_boxlable = ds4.Tables[0].Rows[0].ItemArray[1].ToString(); tt_shellable = ds4.Tables[0].Rows[0].ItemArray[2].ToString(); tt_id = ds4.Tables[0].Rows[0].ItemArray[3].ToString(); } else { this.textBox14.Text = "该工单下,没找到该记录"; this.textBox14.BackColor = Color.Red; } } //最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4) { this.textBox14.Text = "PASS"; this.textBox14.BackColor = Color.Chartreuse; if (this.checkBox3.Checked) { if (this.checkBox7.Checked) { this.textBox10.Focus(); this.textBox10.SelectAll(); } else { this.textBox17.Focus(); this.textBox17.SelectAll(); } } else { this.textBox7.Focus(); this.textBox7.SelectAll(); } } else { this.textBox2.Focus(); this.textBox2.SelectAll(); } } }
//MAC扫描过站 private void tabControl2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //---开始MAC扫描 ScanDataInitial(); setRichtexBox("-----开始MAC过站扫描--------"); string tt_smalltask = this.textBox1.Text.Trim(); string tt_bigtask = this.textBox9.Text.Trim(); string tt_scanmac = this.textBox2.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_flag1 && tt_flag2) { tt_flag3 = getPathIstrue(tt_path); if (tt_flag3) { setRichtexBox("3、已找到一个铭牌模板,:" + tt_path + ",goon"); } else { setRichtexBox("3、没有找到铭牌模板,:" + tt_path + ",over"); PutLableInfor("没有找到铭牌模板,请检查!"); } } //第四步第一次数量检查(同时生产的话会出现问题) Boolean tt_flag4 = false; int tt_tasknumber = int.Parse(this.label12.Text); if (tt_flag1 && tt_flag2 && tt_flag3) { int tt_productnum = int.Parse(this.label59.Text); if (tt_productnum < tt_tasknumber) { tt_flag4 = true; setRichtexBox("4、第一次数量检查,已获取序列号生产数量:" + tt_productnum.ToString() + ",小于计划数量:" + tt_tasknumber.ToString() + ",还可以再生产gong"); } else { setRichtexBox("4、第一次数量检查,已获取序列号生产数量:" + tt_productnum.ToString() + ",大于等于计划数量:" + tt_tasknumber.ToString() + ",不能再生产gong"); PutLableInfor("生产数量已满不能再生产了!"); } } //第五步第二次数量检查 Boolean tt_flag5 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4) { string tt_sql5 = "select count(1),0,0 from odc_alllable " + "where taskscode = '" + tt_smalltask + "' "; string[] tt_array5 = new string[3]; tt_array5 = Dataset1.GetDatasetArray(tt_sql5, tt_conn); int tt_productnum1 = int.Parse(tt_array5[0]); if (tt_productnum1 < tt_tasknumber) { tt_flag5 = true; setRichtexBox("5、第二次数量检查,已获取序列号生产数量:" + tt_productnum1.ToString() + ",小于计划数量:" + tt_tasknumber.ToString() + ",还可以再生产gong"); } else { setRichtexBox("5、第二次数量检查,已获取序列号生产数量:" + tt_productnum1.ToString() + ",大于等于计划数量:" + tt_tasknumber.ToString() + ",不能再生产gong"); PutLableInfor("生产数量已满不能再生产了!"); } } //第六步流程检查 Boolean tt_flag6 = false; string tt_gyid = this.label54.Text; string tt_ccode = this.label56.Text; string tt_ncode = this.label57.Text; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5) { if (tt_ccode == "" || tt_ncode == "") { setRichtexBox("6、该工单没有配置流程," + tt_ccode + "," + tt_ncode + ",over"); PutLableInfor("没有获取到当前待测站位,及下一站位,请检查"); } else { tt_flag6 = true; setRichtexBox("6、该工单已配置流程," + tt_ccode + "," + tt_ncode + ",goon"); } } //第七步查找关联表数据 Boolean tt_flag7 = false; string tt_hostlable = ""; string tt_smtaskscode = ""; string tt_longmac = ""; string tt_oldtype = ""; string tt_id = ""; string tt_gpsn = ""; string tt_pcba = ""; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6) { string tt_sql7 = "select hostlable,maclable,smtaskscode,bprintuser,id,ageing,shelllable,pcbasn from odc_alllable " + "where hprintman = '" + tt_bigtask + "' and taskscode = '" + tt_smalltask + "' and maclable = '" + tt_shortmac + "' "; DataSet ds7 = Dataset1.GetDataSet(tt_sql7, tt_conn); if (ds7.Tables.Count > 0 && ds7.Tables[0].Rows.Count > 0) { tt_flag7 = true; tt_hostlable = ds7.Tables[0].Rows[0].ItemArray[0].ToString(); //主机条码 tt_shortmac = ds7.Tables[0].Rows[0].ItemArray[1].ToString(); //短MAC tt_smtaskscode = ds7.Tables[0].Rows[0].ItemArray[2].ToString(); //移动串号 tt_longmac = ds7.Tables[0].Rows[0].ItemArray[3].ToString(); //长MAC tt_id = ds7.Tables[0].Rows[0].ItemArray[4].ToString(); //行ID tt_oldtype = ds7.Tables[0].Rows[0].ItemArray[5].ToString(); //老化状态 tt_gpsn = ds7.Tables[0].Rows[0].ItemArray[6].ToString(); //GPSN tt_pcba = ds7.Tables[0].Rows[0].ItemArray[7].ToString(); //单板号 setRichtexBox("7、关联表查询到一条数据,hostlable=" + tt_hostlable + ",mac=" + tt_shortmac + ",smtaskscode=" + tt_smtaskscode + ",id=" + tt_id + ",老化ageing=" + tt_oldtype + ",goon"); } else { setRichtexBox("7、关联表没有查询到数据,over"); PutLableInfor("关联表没有查询到数据,请检查!"); } } //第八步 查找站位信息 Boolean tt_flag8 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7) { string tt_sql8 = "select count(1),min(ccode),min(ncode) from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' and napplytype is null "; string[] tt_array8 = new string[3]; tt_array8 = Dataset1.GetDatasetArray(tt_sql8, tt_conn); if (tt_array8[0] == "1") { if (tt_array8[2] == tt_ccode) { tt_flag8 = true; setRichtexBox("8、该单板有待测站位,站位:" + tt_array8[1] + "," + tt_array8[2] + ",可以过站 goon"); } else { setRichtexBox("8、该单板待测站位不在" + tt_ccode + ",站位:" + tt_array8[1] + "," + tt_array8[2] + ",不可以过站 goon"); PutLableInfor("该单板当前站位:" + tt_array8[2] + "不在" + tt_ccode + "站位!"); } } else { setRichtexBox("8、没有找到待测站位,或有多条待测站位,流程异常,over"); PutLableInfor("没有找到待测站位,或有多条待测站位,流程异常!"); } } //第九步查询MACINFO信息 Boolean tt_flag9 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8) { tt_flag9 = true; setRichtexBox("9、查找Macinfo表信息过 goon"); } //第十步物料追溯添加 Boolean tt_flag10 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8 && tt_flag9) { tt_flag10 = true; setRichtexBox("10、物料追溯记录过,gong"); } //第十一步是否获取主机条码判断 Boolean tt_flag11 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8 && tt_flag9 && tt_flag10) { if (tt_hostlable == tt_shortmac) { tt_flag11 = true; setRichtexBox("10、该条码主机条码:" + tt_hostlable + ",数据与MAC:" + tt_shortmac + "一致,还没有获取主机条码,gong"); } else { setRichtexBox("10、该条码主机条码:" + tt_hostlable + ",数据与MAC:" + tt_shortmac + "不一致,可能已获取主机条码,ober"); setRichtexBox("10、可能已获取主机条码:" + tt_hostlable + ",请确认"); } } //第十二步开始过站 Boolean tt_flag12 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8 && tt_flag10 && tt_flag11) { string tt_username = STR; tt_flag12 = Dataset1.FhwifSnInStation(tt_smalltask, tt_bigtask, tt_username, tt_hostlable, tt_shortmac, tt_gyid, tt_ccode, tt_ncode, tt_conn); if (tt_flag12) { setRichtexBox("12、该产品过站成功,请继续扫描,ok"); } else { setRichtexBox("12、过站不成功,事务已回滚"); PutLableInfor("过站不成功,请检查或再次扫描!"); } } //第十三站:查询身程序序列号 Boolean tt_flag13 = false; string tt_boxlable = ""; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8 && tt_flag10 && tt_flag11 && tt_flag12) { string tt_sql13 = "select count(1), min(boxlable),0 from odc_alllable " + "where taskscode = '" + tt_smalltask + "' and hprintman = '" + tt_bigtask + "' and maclable = '" + tt_shortmac + "' "; string[] tt_array13 = new string[3]; tt_array13 = Dataset1.GetDatasetArray(tt_sql13, tt_conn); if (tt_array13[0] == "1") { tt_flag13 = true; tt_boxlable = tt_array13[1]; this.label67.Text = tt_boxlable; setRichtexBox("13、生产序列号获取成功,已获取序列号:" + tt_boxlable + ", goon"); } else { setRichtexBox("13、生产序列号获取不成功,序列号:" + tt_boxlable + ", over"); PutLableInfor("生产序列号获取不成功,请检查!"); } } //最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6 && tt_flag7 && tt_flag8 && tt_flag10 && tt_flag11 && tt_flag12 && tt_flag13) { //条码信息 this.label42.Text = tt_pcba; //单板号 this.label43.Text = tt_boxlable; //主机条码 this.label44.Text = tt_smtaskscode; //移动串号 this.label45.Text = tt_shortmac; //短MAC this.label46.Text = tt_longmac; //长MAC this.label47.Text = tt_gpsn; //GPSN //生产节拍 getProductRhythm(); //打印 GetParaDataPrint(1); GetProductNumInfo(); CheckStation(tt_shortmac); this.richTextBox1.BackColor = Color.Chartreuse; PutLableInfor("过站成功,请继续扫描!"); textBox2.Focus(); textBox2.SelectAll(); } else { this.richTextBox1.BackColor = Color.Red; textBox2.Focus(); textBox2.SelectAll(); } } }
//扫描MAC重打 private void textBox3_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //---开始MAC扫描 ScanDataInitial(); setRichtexBox("-----开始MAC扫描--------"); string tt_task = this.textBox1.Text.Trim(); string tt_scanmac = this.textBox3.Text.Trim(); string tt_shortmac = tt_scanmac.Replace("-", ""); //第一步位数判断 Boolean tt_flag1 = false; tt_flag1 = CheckStrLengh(tt_scanmac, this.textBox7.Text); //第二步包含符判断 Boolean tt_flag2 = false; if (tt_flag1) { tt_flag2 = CheckStrContain(tt_scanmac, this.textBox6.Text.Trim()); } //第三步 判断路径 Boolean tt_flag3 = false; if (tt_flag1 && tt_flag2) { tt_flag3 = getPathIstrue(tt_path); if (tt_flag3) { setRichtexBox("3、已找到一个铭牌模板,:" + tt_path + ",goon"); } else { setRichtexBox("3、没有找到铭牌模板,:" + tt_path + ",over"); PutLableInfor("没有找到铭牌模板,请检查!"); } } //第四步 MAC位数检查 Boolean tt_flag4 = false; string tt_longmac = ""; if (tt_flag1 && tt_flag2 && tt_flag3) { if (tt_shortmac.Length == 12) { tt_flag4 = true; tt_longmac = getLongMac(tt_shortmac); setRichtexBox("4、短MAC位数为12,:" + tt_shortmac + ",获取长MAC:" + tt_longmac + ",goon"); } else { setRichtexBox("4、MAC位数不为12,:" + tt_shortmac + ",over"); PutLableInfor("MAC位数不为12,请确认是否为MAC!"); } } //第五步 alllable数据检查 Boolean tt_flag5 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4) { tt_flag5 = true; setRichtexBox("5、alllable数据检查过,goon"); } //第六步 maninfo表检查 Boolean tt_flag6 = false; string tt_gpsn = ""; string tt_state = ""; string tt_task1 = this.textBox1.Text; string tt_task2 = ""; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5) { string tt_sql6 = "select taskscode, state ,SN " + "from odc_macinfo " + "where mac = '" + tt_longmac + "' "; DataSet ds = Dataset1.GetDataSet(tt_sql6, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { tt_task2 = ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim(); tt_state = ds.Tables[0].Rows[0].ItemArray[1].ToString(); tt_gpsn = ds.Tables[0].Rows[0].ItemArray[2].ToString(); if (tt_task1.Trim() == tt_task2.Trim()) { if (tt_state.Length > 0) { tt_flag6 = true; setRichtexBox("6、该MAC打印状态为:" + tt_state + ",可以重打过,goon"); } else { setRichtexBox("6、改MAC打印状态为:" + tt_state + ",还没有打印过,over"); PutLableInfor("该MAC还是没有打印过,不能重打 ,请确认!"); } } else { setRichtexBox("6、工单不一致,该MAC工单为:" + tt_task2 + ",over"); PutLableInfor("工单不一致,该MAC工单为:" + tt_task2 + ",请检查!"); } } else { setRichtexBox("6、MACINFO没有查询到改MAC数据,over"); PutLableInfor("MAC表没有查询到数据,请检查!"); } } //最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6) { this.label7.Text = tt_shortmac; this.label8.Text = tt_longmac; this.label9.Text = tt_gpsn; GetParaDataPrint(0); this.richTextBox1.BackColor = Color.Chartreuse; setRichtexBox("7、查询完毕,可以重打标签或修改模板,over"); PutLableInfor("MAC查询完毕"); textBox3.Focus(); textBox3.SelectAll(); } else { this.richTextBox1.BackColor = Color.Red; textBox3.Focus(); textBox3.SelectAll(); } } }
//异常处理 private void Button3_Click(object sender, EventArgs e) { //数据准备 string tt_scan = this.textBox1.Text.Trim().ToUpper(); string tt_scansn = GetShortMac(tt_scan); //第一步 条码确定 #region bool tt_flag1 = false; MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定要对条码:" + tt_scansn + ",进行处理吗?这个处理主要是出来没有待测站位\\有多个待测站位\\没有1920站位的情况,请确认你输入的是单板号,还是MAC", "异常处理", messButton); if (dr == DialogResult.OK)//如果点击“确定”按钮 { tt_flag1 = true; } #endregion //第二步 确定MAC #region bool tt_flag2 = false; string tt_shortmac = ""; if (tt_flag1) { //选择的是MAC if (this.radioButton1.Checked == true) { tt_flag2 = true; tt_shortmac = tt_scansn; } //选择的是单板号 if (this.radioButton2.Checked == true) { string tt_sql2 = "select count(1),min(maclable),min(taskscode) from odc_alllable where pcbasn = '" + tt_scansn + "' "; string[] tt_array2 = new string[3]; tt_array2 = Dataset1.GetDatasetArray(tt_sql2, tt_conn); if (tt_array2[0] == "1") { tt_flag2 = true; tt_shortmac = tt_array2[1]; } else { MessageBox.Show("根据你输入的单板号:" + tt_scansn + ",无法在关联表中找到对应的MAC"); } } } #endregion //第三步 确定单板号 #region bool tt_flag3 = false; string tt_pcba = ""; if (tt_flag2) { //选择的单板号 if (this.radioButton2.Checked == true) { tt_flag3 = true; tt_pcba = tt_scansn; } //选择的是MAC if (this.radioButton1.Checked == true) { string tt_sql3 = "select count(1),min(pcbasn),min(taskscode) from odc_alllable where maclable = '" + tt_scansn + "' "; string[] tt_array3 = new string[3]; tt_array3 = Dataset1.GetDatasetArray(tt_sql3, tt_conn); if (tt_array3[0] == "1") { tt_flag3 = true; tt_pcba = tt_array3[1]; } else { MessageBox.Show("根据你输入的MAC:" + tt_scansn + ",无法在关联表中找到对应的单板号"); } } } #endregion //第四步 确定待测站位个数/是否缺失1920站位 #region int tt_intrownum = 0; string tt_nullmaxid = ""; string tt_nullminid = ""; bool tt_flag4 = false; bool tt_flag4_1 = false; if (tt_flag3) { string tt_sql4 = "select count(1),max(id),min(id) from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' and napplytype is NULL "; string tt_sql4_1 = "select id,ncode,ccode from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' and ncode = '2100' and napplytype = '1' order by id"; string tt_sql4_2 = "select count(1),max(id),min(id) from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' and ncode = '2100' and napplytype = '1'"; DataSet tt_dataset1 = Dataset2.getMacAllCodeInfo(tt_shortmac, tt_conn); int tt_int1920id = Dataset2.getFirstCodeId(tt_dataset1); string[] tt_array4 = new string[3]; tt_array4 = Dataset1.GetDatasetArray(tt_sql4, tt_conn); string[] tt_array4_2 = new string[3]; tt_array4_2 = Dataset1.GetDatasetArray(tt_sql4_2, tt_conn); DataSet ds4_1 = Dataset1.GetDataSet(tt_sql4_1, tt_conn); if (ds4_1.Tables.Count > 0 && ds4_1.Tables[0].Rows.Count > 0 && tt_int1920id == -2) { string tt_id_1 = ds4_1.Tables[0].Rows[0].ItemArray[0].ToString(); string tt_ccode_1 = ds4_1.Tables[0].Rows[0].ItemArray[1].ToString(); string tt_ncode_1 = ds4_1.Tables[0].Rows[0].ItemArray[2].ToString(); if (int.Parse(tt_ccode_1) > 1920 && tt_id_1 == tt_array4_2[2]) { tt_flag4_1 = true; } } if (tt_array4[0] == "1" && tt_flag4_1 == false) { MessageBox.Show("该MAC:" + tt_shortmac + ",只有一个待测站位,没有异常,不需要处理"); } else if (tt_flag4_1) { int chang_ccode1920 = Change_ccode1920(tt_shortmac, tt_array4_2[2]); MessageBox.Show("该MAC:" + tt_shortmac + ",无1920站位的问题已处理完毕"); } else { tt_flag4 = true; tt_intrownum = GetStringToInt(tt_array4[0]); tt_nullmaxid = tt_array4[1]; tt_nullminid = tt_array4[2]; } } #endregion //第五步 确定异常问题 #region bool tt_flag5 = false; //没有待测站位 bool tt_flag6 = false; //多个待测站位 if (tt_flag4) { if (tt_intrownum == 0) { tt_flag5 = true; } else { if (tt_intrownum > 1) { tt_flag6 = true; } } } #endregion //第五步 没有待测站位处理 #region if (tt_flag5) { string tt_rowmaxid = ""; string tt_sql5 = "select count(1),max(id),0 from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' "; string[] tt_array5 = new string[3]; tt_array5 = Dataset1.GetDatasetArray(tt_sql5, tt_conn); //查找最大的ID值 bool tt_flag51 = false; if (tt_array5[0] == "0") { MessageBox.Show("MAC:" + tt_shortmac + ",在站位表中没有找到记录"); } else { tt_flag51 = true; tt_rowmaxid = tt_array5[1]; } if (tt_flag51) { string tt_sql51 = "update odc_routingtasklist set napplytype = NULL " + "where pcba_pn = '" + tt_shortmac + "' and id = " + tt_rowmaxid; int tt_intexec = Dataset1.ExecCommand(tt_sql51, tt_conn); if (tt_intexec > 0) { MessageBox.Show("---OK---,操作1成功,该MAC:" + tt_shortmac + ",没有待测站位,现在已给出一个待测站位,请再次查询"); } else { MessageBox.Show("---Fail---,操作1失败,该MAC:" + tt_shortmac + ",没有待测站位,现在还是没有给出待测站位,请再次检查"); } } } #endregion //第六步 有多个待测站位,确定处理方法 #region bool tt_flag7 = false; bool tt_flag8 = false; string tt_maxid2 = ""; if (tt_flag6) { string tt_sql6 = "select count(1),max(id),0 from odc_routingtasklist " + "where pcba_pn = '" + tt_shortmac + "' "; string[] tt_array6 = new string[3]; tt_array6 = Dataset1.GetDatasetArray(tt_sql6, tt_conn); if (tt_array6[0] == "0") { MessageBox.Show("程序逻辑有问题,这是查找有多个待测站位的最大ID值,但是MAC:" + tt_shortmac + ",在站位表中没有发现有多个待测站位"); } else { tt_maxid2 = tt_array6[1]; if (tt_nullmaxid == tt_maxid2) //MAC的最大ID值和多个待测站位的最大ID值一致 { tt_flag7 = true; } else { tt_flag8 = true; } } } #endregion //第七步 有多个待测值 最大待测ID值和MAC的最大ID值一致(正常情况) #region if (tt_flag7) { string tt_sql7 = "update odc_routingtasklist set napplytype = 1 " + "where pcba_pn = '" + tt_shortmac + "' and napplytype is NULL and ID <" + tt_nullmaxid + " and id>=" + tt_nullminid; int tt_intexec7 = Dataset1.ExecCommand(tt_sql7, tt_conn); if (tt_intexec7 > 0) { MessageBox.Show("---OK---,操作2成功,该MAC:" + tt_shortmac + ",有多个待测站位,最大ID值就是待测站位,现在已只有一个待测站位,请再次查询"); } else { MessageBox.Show("---Fail---,操作2失败,该MAC:" + tt_shortmac + ",有多个待测站位,最大ID值就是待测站位,现在还是没有给出一个待测站位,请再次检查"); } } #endregion //第八步 有多个待测值 最大待测ID值和MAC的最大ID值不一致(非正常情况) #region if (tt_flag8) { //第8.1步 将最大ID值的设置为待测站位 string tt_sql81 = "update odc_routingtasklist set napplytype = NULL " + "where pcba_pn = '" + tt_shortmac + "' and id = " + tt_maxid2; int tt_intexec81 = Dataset1.ExecCommand(tt_sql81, tt_conn); //第8.2步 将其他的待测站位取消 string tt_sql82 = "update odc_routingtasklist set napplytype = 1 " + "where pcba_pn = '" + tt_shortmac + "' and napplytype is NULL and ID <=" + tt_nullmaxid + " and id>=" + tt_nullminid; int tt_intexec82 = Dataset1.ExecCommand(tt_sql82, tt_conn); //第8.3步 判断 if (tt_intexec81 > 0 && tt_intexec82 > 0) { MessageBox.Show("---OK---,操作3成功,该MAC:" + tt_shortmac + ",有多个待测站位,最大ID值不是待测站位,现在已只有一个待测站位,请再次查询"); } else { MessageBox.Show("---Fail---,操作4失败,该MAC:" + tt_shortmac + ",有多个待测站位,最大ID值不是待测站位,现在还是没有给出一个待测站位,请再次检查"); } } #endregion }
//确定 private void button6_Click(object sender, EventArgs e) { this.dataGridView3.DataSource = null; this.dataGridView4.DataSource = null; this.dataGridView5.DataSource = null; string tt_task = ""; string tt_pcba = ""; string tt_mac = ""; Boolean tt_flag = false; string tt_sn1 = this.textBox11.Text.Trim(); string tt_sn = tt_sn1.Replace(":", ""); string tt_sql1 = "select hprintman 总工单,taskscode 子工单, pcbasn 单板号,hostlable 主机条码,maclable MAC, " + "boxlable 生产序列号,Bosasn BOSA, shelllable GPSN, Smtaskscode 串号, Dystlable 电源号, " + "sprinttime 关联时间 " + "from odc_alllable " + "where pcbasn = '" + tt_sn + "' or hostlable = '" + tt_sn + "' or maclable = '" + tt_sn + "' "; DataSet ds1 = Dataset1.GetDataSet(tt_sql1, tt_conn); if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0) { dataGridView3.DataSource = ds1; dataGridView3.DataMember = "Table"; tt_task = ds1.Tables[0].Rows[0].ItemArray[1].ToString(); //工单号 tt_pcba = ds1.Tables[0].Rows[0].ItemArray[2].ToString(); //单板条码 tt_mac = ds1.Tables[0].Rows[0].ItemArray[4].ToString(); //MAC tt_flag = true; } else { MessageBox.Show("sorry,没有查询到数据"); } //站位查询 if (tt_flag) { string tt_sql2 = "select ccode 前站 ,Ncode 后站,napplytype 过站,taskscode 工单,pcba_pn MAC, createtime 进站时间, enddate 出站时间, fremark 备注 " + "from ODC_ROUTINGTASKLIST where pcba_pn = '" + tt_mac + "' order by id desc"; DataSet ds2 = Dataset1.GetDataSet(tt_sql2, tt_conn); if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { dataGridView4.DataSource = ds2; dataGridView4.DataMember = "Table"; } } //箱号查询 if (tt_flag) { string tt_sql3 = "select taskcode 工单号,pasn 单板号, pagesn 箱号, polletsn 栈板号,pagetime 装箱时间 " + "from odc_package " + "where pasn = '" + tt_pcba + "' and taskcode = '" + tt_task + "' "; DataSet ds3 = Dataset1.GetDataSet(tt_sql3, tt_conn); if (ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0) { dataGridView5.DataSource = ds3; dataGridView5.DataMember = "Table"; } } }
//MAC查询重打 private void textBox7_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //---开始MAC扫描 ScanDataInitial(); setRichtexBox("-----开始MAC扫描查询--------"); string tt_task = this.textBox1.Text.Trim(); string tt_scanmac = this.textBox7.Text.Trim(); string tt_shortmac = tt_scanmac.Replace(":", ""); //第一步位数判断 Boolean tt_flag1 = false; tt_flag1 = CheckStrLengh(tt_scanmac, this.textBox6.Text); //第二步包含符判断 Boolean tt_flag2 = false; if (tt_flag1) { tt_flag2 = CheckStrContain(tt_scanmac, this.textBox5.Text.Trim()); } //第三步 判断路径 Boolean tt_flag3 = false; if (tt_flag1 && tt_flag2) { tt_flag3 = getPathIstrue(tt_path); if (tt_flag3) { setRichtexBox("3、已找到一个铭牌模板,:" + tt_path + ",goon"); } else { setRichtexBox("3、没有找到铭牌模板,:" + tt_path + ",over"); PutLableInfor("没有找到铭牌模板,请检查!"); } } //第四步查找信息 Boolean tt_flag4 = false; string tt_longmac = ""; if (tt_flag1 && tt_flag2 && tt_flag3) { string tt_sql3 = "select pcbasn,hostlable,maclable,smtaskscode,bprintuser,shelllable from odc_alllable " + "where taskscode = '" + tt_task + "' and maclable = '" + tt_shortmac + "' "; DataSet ds3 = Dataset1.GetDataSet(tt_sql3, tt_conn); if (ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0) { tt_flag4 = true; this.label42.Text = ds3.Tables[0].Rows[0].ItemArray[0].ToString(); //单板号 this.label43.Text = ds3.Tables[0].Rows[0].ItemArray[1].ToString(); //主机条码 this.label45.Text = ds3.Tables[0].Rows[0].ItemArray[2].ToString(); //短MAC this.label44.Text = ds3.Tables[0].Rows[0].ItemArray[3].ToString(); //移动串号 this.label46.Text = ds3.Tables[0].Rows[0].ItemArray[4].ToString(); //长MAC this.label47.Text = ds3.Tables[0].Rows[0].ItemArray[5].ToString(); //GPSN tt_longmac = this.label39.Text; setRichtexBox("4、关联表查询到一条数据,goon"); } else { setRichtexBox("4、关联表没有查询到数据,over"); PutLableInfor("关联表没有查询到数据,请检查!"); } } //第五步查询macinfo表信息 Boolean tt_flag5 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4) { tt_flag5 = true; setRichtexBox("5、Macinfo表查找数据过,goon"); } //第六步 查找站位信息 Boolean tt_flag6 = false; if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5) { tt_flag6 = true; setRichtexBox("6、查找站位信息,goon"); } //最后判断 if (tt_flag1 && tt_flag2 && tt_flag3 && tt_flag4 && tt_flag5 && tt_flag6) { GetParaDataPrint(0); GetProductNumInfo(); CheckStation(tt_shortmac); this.richTextBox1.BackColor = Color.Chartreuse; setRichtexBox("6、查询完毕,可以重打标签或修改模板,over"); PutLableInfor("MAC查询完毕"); textBox7.Focus(); textBox7.SelectAll(); } else { this.richTextBox1.BackColor = Color.Red; textBox7.Focus(); textBox7.SelectAll(); } } }
//扫描 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 putPrintToStar() { //ScanDataInitial(); setRichtexBox("-----" + tt_printtime.ToString() + "--------"); //第一步获取MAC Boolean tt_flag1 = false; string tt_taskscode = this.textBox1.Text.Trim(); string tt_shortmac = ""; string tt_longmac = ""; string tt_gpan = ""; string tt_sql = "select top 1 mac, sn from odc_macinfo " + "where taskscode = '" + tt_taskscode + "' and state is NULL " + "order by mac "; DataSet ds = Dataset1.GetDataSet(tt_sql, tt_conn); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { tt_longmac = ds.Tables[0].Rows[0].ItemArray[0].ToString(); tt_gpan = ds.Tables[0].Rows[0].ItemArray[1].ToString(); tt_shortmac = GetShortMac(tt_longmac); this.label7.Text = tt_shortmac; this.label8.Text = tt_longmac; this.label9.Text = tt_gpan; tt_flag1 = true; setRichtexBox("1、找到一个可打印的MAC:" + tt_longmac + ",GPSN:" + tt_gpan + ",over"); PutLableInfor("MAC查询完毕"); } else { setRichtexBox("1、没有可打印的MAC:over"); PutLableInfor("MAC查询完毕"); } //第二步 打印 Boolean tt_flag2 = false; if (tt_flag1) { try { GetParaDataPrint(1); tt_flag2 = true; setRichtexBox("2、完成MAC打印:goon"); } catch { setRichtexBox("2、打印失败请检查:over"); } } //第三步修改MAC状态 Boolean tt_flag3 = false; if (tt_flag2) { string tt_updata = "update odc_macinfo set state = 1, Fnameplate = CONVERT(varchar, getdate(),120) " + "where taskscode = '" + tt_taskscode + "' and mac = '" + tt_longmac + "' "; int tt_int = Dataset1.ExecCommand(tt_updata, tt_conn); if (tt_int > 0) { tt_flag3 = true; setRichtexBox("3、MAC状态值修改完毕:goon"); } else { setRichtexBox("3、MAC:" + tt_longmac + ",状态值修改不成功:-----over"); PutLableInfor("MAC:" + tt_longmac + ", 状态值修改不成功"); } } //第四步显示MAC值 if (tt_flag3) { PutListViewData(tt_longmac, tt_gpan); this.richTextBox1.BackColor = Color.Chartreuse; } else { timer1.Stop(); this.richTextBox1.BackColor = Color.Red; } }
//工单锁定 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(); } }