123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- using HslCommunication;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicForm;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_GetTestFileData : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- LogStringBuilder sql;
- string oErrorMessage = "";
- string omakeCode = "";
- string oMsid = "";
- ftpOperater ftp = new ftpOperater();
- public Make_GetTestFileData()
- {
- InitializeComponent();
- }
- private void Make_LabelCheck_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- //聚焦SN号
- sncode.Focus();
- //打开界面提示用户:请输入SN
- sql = new LogStringBuilder();
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- sql.Clear();
- sql.Append("select bg_code,bg_code||':'||bg_name bg_name from PRODUCTBADGROUP left join productkind on ");
- sql.Append("pk_code= pb_kindcode left join product on pr_kind=pk_name left join ");
- sql.Append("badgroup on bg_code=pb_badgroup where pr_code='" + ma_prodcode.Text + "'");
- DataTable BadCode = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (BadCode.Rows.Count > 0)
- {
- BadGroupCode.DisplayMember = "bg_name";
- BadGroupCode.ValueMember = "bg_code";
- BadGroupCode.DataSource = BadCode;
- }
- else
- {
- BadCode = (DataTable)dh.ExecuteSql("select bg_code,bg_name from badgroup where bg_statuscode='AUDITED'", "select");
- BadGroupCode.DisplayMember = "bg_name";
- BadGroupCode.ValueMember = "bg_code";
- BadGroupCode.DataSource = BadCode;
- }
- DataTable dt = (DataTable)dh.ExecuteSql("select or_badcode bc_code,or_description bc_name,or_bgcode bg_code,bg_name from OQCNGReason left join badgroup on or_bgcode=bg_code where or_sncode='" + sncode.Text + "'", "select");
- BaseUtil.FillDgvWithDataTable(ChoosedDGV, dt);
- }
- private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void LoadCollectedNum()
- {
- //sql.Clear();
- //sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
- //sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
- //sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- //DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- //BaseUtil.SetFormValue(Controls, dt);
- }
- private void sncode_KeyDown(object sender, KeyEventArgs e)
- {
- //判断是enter事件
- if (e.KeyCode == Keys.Enter)
- {
- if (sncode.Text == "")
- {
- OperateResult.AppendText("SN不允许为空");
- return;
- }
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,pr_detail from makeserial left join product on pr_code=ms_prodcode where ms_sncode='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count == 0)
- {
- OperateResult.AppendText("SN【" + sncode.Text + "】不存在\n", Color.Red);
- return;
- }
-
- ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
- ma_prodcode.Text = dt.Rows[0]["ms_prodcode"].ToString();
- pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
- dt = (DataTable)dh.ExecuteSql("select msi_result from makeserial_inspect where msi_sncode='" + sncode.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- OperateResult.AppendText("SN【" + sncode.Text + "】已抽检,检验结果为'" + dt.Rows[0]["msi_result"].ToString() + "'\n");
- return;
- }
- if (OK.Checked)
- {
- dh.ExecuteSql("insert into makeserial_inspect(msi_id,msi_sncode,msi_makecode,msi_indate,msi_result,msi_inman,msi_source)values(makeserial_inspect_seq.nextval,'" + sncode.Text + "','" + ma_code.Text + "',sysdate,'OK','" + User.UserName + "','" + User.UserSourceCode + "')", "insert");
- sncode.Text = "";
- }
- else
- {
- List<string> bc_code = new List<string>();
- List<string> bc_name = new List<string>();
- List<string> bg_code = new List<string>();
- List<string> bg_name = new List<string>();
- for (int i = 0; i < ChoosedDGV.RowCount; i++)
- {
- bc_code.Add(ChoosedDGV.Rows[i].Cells["bc_code1"].Value.ToString());
- bc_name.Add(ChoosedDGV.Rows[i].Cells["bc_name1"].Value.ToString());
- bg_code.Add(ChoosedDGV.Rows[i].Cells["bg_code1"].Value.ToString());
- bg_name.Add(ChoosedDGV.Rows[i].Cells["bg_name1"].Value.ToString());
- }
- if (bc_code.ToArray().Length == 0)
- {
- OperateResult.AppendText(">>不良品请勾选不良明细\n", Color.Red);
- return;
- }
- sql.Clear();
- sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
- sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_soncode,mb_badname,mb_status,mb_bgname,mb_type)");
- sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + User.UserCode + "',sysdate,'" + User.CurrentStepCode + "',ms_sourcecode,:bc_code,:bg_code,'',");
- sql.Append("sp_soncode,:bc_name,'0',:bg_name,'Client' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
- sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
- dh.BatchInsert(sql.GetString(), new string[] { "bc_code", "bg_code", "bc_name", "bg_name" }, bc_code.ToArray(), bg_code.ToArray(), bc_name.ToArray(), bg_name.ToArray());
- dh.ExecuteSql("insert into makeserial_inspect(msi_id,msi_sncode,msi_makecode,msi_indate,msi_result,msi_inman,msi_source)values(makeserial_inspect_seq.nextval,'" + sncode.Text + "','" + ma_code.Text + "',sysdate,'NG','" + User.UserName + "','" + User.UserSourceCode + "')", "insert");
- sncode.Text = "";
- }
- LoadGridData();
- }
- }
- private void StepCount_Load(object sender, EventArgs e)
- {
- }
- private void LoadGridData()
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select MSI_ID, MSI_SNCODE, MSI_MAKECODE, MSI_INDATE, MSI_RESULT from makeserial_inspect where msi_makecode='" + ma_code.Text + "'", "select");
- CheckItemDGV.DataSource = dt;
- }
- private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
- {
- //系统值和
- if (e.ColumnIndex >= 0)
- {
- if (CheckItemDGV.Columns[e.ColumnIndex].Name == "std_testresult")
- {
- if (e.RowIndex >= 0)
- {
- if (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value.ToString() == "OK"))
- {
- e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.Black, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- else
- {
- e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.Black, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- }
- }
- }
- }
- private void BadGroupCode_SelectedIndexChanged(object sender, EventArgs e)
- {
- string bg_code = BadGroupCode.SelectedValue.ToString();
- sql.Clear();
- sql.Append("select 0 ChooseAll,bc_code,bc_name,bg_name,bg_code from badgroupdetail left join badgroup on bg_id=bgd_bgid ");
- sql.Append("left join badcode on bgd_badcode=bc_code where bg_code='" + ((bg_code != "" && bg_code != "System.Data.DataRowView") ? bg_code.ToString() : "") + "' and bg_code is not null ");
- sql.Append(" order by bc_code");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BadInfoSource.DataSource = dt;
- BaseUtil.FillDgvWithDataTable(WaitChooseDGV, dt);
- }
- private void ChooseedReject_Click(object sender, EventArgs e)
- {
- DataTable wait = BaseUtil.filterDataTable((DataTable)WaitChooseDGV.DataSource, "ChooseAll<>0");
- DataTable choose = (ChoosedDGV.DataSource as DataTable);
- List<string> Chooseed = new List<string>();
- for (int i = 0; i < choose.Rows.Count; i++)
- {
- Chooseed.Add(choose.Rows[i]["bc_code"].ToString());
- }
- if (wait.Rows.Count > 0)
- {
- for (int i = 0; i < wait.Rows.Count; i++)
- {
- if (!Chooseed.Contains(wait.Rows[i]["bc_code"].ToString()))
- {
- DataRow dr1 = choose.NewRow();
- dr1["bc_code"] = wait.Rows[i]["bc_code"];
- dr1["bc_name"] = wait.Rows[i]["bc_name"];
- dr1["bg_code"] = wait.Rows[i]["bg_code"];
- dr1["bg_name"] = wait.Rows[i]["bg_name"];
- choose.Rows.Add(dr1);
- }
- }
- for (int i = 0; i < WaitChooseDGV.Rows.Count; i++)
- {
- ((DataTable)WaitChooseDGV.DataSource).Rows[i]["ChooseAll"] = 0;
- }
- }
- else OperateResult.AppendText(">>请勾选不良明细\n", Color.Red);
- }
- private void WaitReject_Click(object sender, EventArgs e)
- {
- for (int i = ChoosedDGV.Rows.Count - 1; i >= 0; i--)
- {
- if (ChoosedDGV.Rows[i].Cells["choose1"].FormattedValue.ToString() == "True")
- {
- ChoosedDGV.Rows.RemoveAt(i);
- }
- }
- (ChoosedDGV.DataSource as DataTable).AcceptChanges();
- }
- private void StepCount_Load_1(object sender, EventArgs e)
- {
- }
- private void bccode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select bc_code bg_code,bc_name bg_name from badcode where bc_code='" + bccode.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- try
- {
- for (int i = 0; i < ChoosedDGV.Rows.Count; i++)
- {
- if (ChoosedDGV.Rows[i].Cells[1].Value.ToString() == dt.Rows[0][0].ToString())
- {
- OperateResult.AppendText(">>已添加过不良代码" + bccode.Text + "\n", Color.Red);
- bccode.Clear();
- return;
- }
- }
- dt.Merge(ChoosedDGV.DataSource as DataTable);
- BaseUtil.FillDgvWithDataTable(ChoosedDGV, dt);
- bccode.Clear();
- }
- catch (Exception) { }
- }
- else OperateResult.AppendText(">>不良代码不存在\n", Color.Red);
- }
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
- if (OK.Checked)
- {
- dh.ExecuteSql("insert into makeserial_inspect(msi_id,msi_sncode,msi_makecode,msi_indate,msi_result,msi_inman,msi_source)values(makeserial_inspect_seq.nextval,'" + sncode.Text + "','" + ma_code.Text + "',sysdate,'OK','" + User.UserName + "','" + User.UserSourceCode + "')", "insert");
- }
- else
- {
- List<string> bc_code = new List<string>();
- List<string> bc_name = new List<string>();
- List<string> bg_code = new List<string>();
- List<string> bg_name = new List<string>();
- for (int i = 0; i < ChoosedDGV.RowCount; i++)
- {
- bc_code.Add(ChoosedDGV.Rows[i].Cells["bc_code1"].Value.ToString());
- bc_name.Add(ChoosedDGV.Rows[i].Cells["bc_name1"].Value.ToString());
- bg_code.Add(ChoosedDGV.Rows[i].Cells["bg_code1"].Value.ToString());
- bg_name.Add(ChoosedDGV.Rows[i].Cells["bg_name1"].Value.ToString());
- }
- if (bc_code.ToArray().Length == 0)
- {
- OperateResult.AppendText(">>不良品请勾选不良明细\n", Color.Red);
- }
- sql.Clear();
- sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
- sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_soncode,mb_badname,mb_status,mb_bgname,mb_type)");
- sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + User.UserCode + "',sysdate,'" + User.CurrentStepCode + "',ms_sourcecode,:bc_code,:bg_code,'',");
- sql.Append("sp_soncode,:bc_name,'0',:bg_name,'Client' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
- sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
- dh.BatchInsert(sql.GetString(), new string[] { "bc_code", "bg_code", "bc_name", "bg_name" }, bc_code.ToArray(), bg_code.ToArray(), bc_name.ToArray(), bg_name.ToArray());
- dh.ExecuteSql("insert into makeserial_inspect(msi_id,msi_sncode,msi_makecode,msi_indate,msi_result,msi_inman,msi_source)values(makeserial_inspect_seq.nextval,'" + sncode.Text + "','" + ma_code.Text + "',sysdate,'NG','" + User.UserName + "','" + User.UserSourceCode + "')", "insert");
- }
- LoadGridData();
- }
- }
- }
|