123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- 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_Sndown : Form
- {
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataTable ComBoxData = new DataTable();
- DataTable Dbfind;
- public Make_Sndown()
- {
- InitializeComponent();
- }
- private void Query_OnlineTraceBack_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- dh = SystemInf.dh;
-
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += Ma_code_DbChange;
- DataTable dt = (DataTable)dh.ExecuteSql(" select li_code,li_name from line ", "select");
- linecode.DisplayMember = "li_name";
- linecode.ValueMember = "li_code";
- linecode.DataSource = dt;
- linecode.Text = "";
- em_name.TableName = "employee";
- em_name.SelectField = "em_code # 人员编号,em_name # 人员名称";
- em_name.FormName = Name;
- em_name.SetValueField = new string[] { "em_name" };
- }
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- // Query.PerformClick();
- }
- private void Query_OnlineTraceBack_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void Query_Click(object sender, EventArgs e)
- {
- if (dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
- {
- string condition = BaseUtil.GetScreenSqlCondition(ma_code, linecode, ms_stepcode,em_name);
- sql.Clear();
- sql.Append("select sp_id,sp_sncode,sp_makecode,sp_prodcode,li_name,st_name,sp_date,em_name from steppassed left join line on sp_linecode = li_code left join step on sp_stepcode = st_code left join employee on sp_inman = em_code ");
- sql.Append(condition);
- sql.Append("and sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and not EXISTS (select 1 from makedown where (md_sncode = sp_sncode or md_code = sp_sncode) and md_status = 0 and md_macode = sp_makecode)");
- sql.Append(" order by sp_date asc ");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.FillDgvWithDataTable(SnInf, dt);
-
- checkBox1.Checked = false;
- Count.Text = "";
- }
- else
- {
- MessageBox.Show("工单号" + ma_code.Text + "不存在");
- //BaseUtil.CleanDataGridView(SnInf);
- //ma_code.Text = "";
- }
- }
-
- private void normalButton1_Click(object sender, EventArgs e)
- {
- Thread InitPrint;
- InitPrint = new Thread(InPrint);
- SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "SN锁定中");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- }
- private void InPrint()
- {
- try
- {
- int count = SnInf.Rows.Count;
- int check = 0;
- for (int i = 0; i < count; i++)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)SnInf.Rows[i].Cells["choose1"];
- Boolean flag = Convert.ToBoolean(checkCell.Value);
- if (flag == true)
- {
- if (!dh.CheckExist("MAKEDOWN", "(MD_SNCODE = '" + SnInf.Rows[i].Cells["sp_sncode"].Value.ToString() + "' or MD_CODE = '" + SnInf.Rows[i].Cells["sp_sncode"].Value.ToString() + "') and MD_MACODE = '" + SnInf.Rows[i].Cells["sp_makecode"].Value.ToString() + "' and MD_STATUS = 0 "))
- {
- sql.Clear();
- sql.Append("INSERT INTO MAKEDOWN (MD_ID,MD_MSID,MD_LINECODE,MD_STEPCODE,");
- sql.Append("MD_SNCODE,MD_PRODCODE,MD_MACODE, MD_CODE,");
- sql.Append("MD_DOWNDATE,MD_DOWNMAN,MD_STATUS) select MAKEDOWN_seq.nextval,ms_id,'" + SnInf.Rows[i].Cells["li_name"].Value.ToString() + "',");
- sql.Append("'" + SnInf.Rows[i].Cells["st_name"].Value.ToString() + "',ms_sncode,'" + SnInf.Rows[i].Cells["sp_prodcode"].Value.ToString() + "','" + SnInf.Rows[i].Cells["sp_makecode"].Value.ToString() + "',ms_code,sysdate,'" + User.UserCode + "','0' from makeserial where (ms_sncode = '" + SnInf.Rows[i].Cells["sp_sncode"].Value.ToString() + "' or ms_code = '" + SnInf.Rows[i].Cells["sp_sncode"].Value.ToString() + "') and ms_makecode = '" + SnInf.Rows[i].Cells["sp_makecode"].Value.ToString() + "'");
- //执行
- dh.ExecuteSql(sql.GetString(), "insert");
- check++;
- }
- }
- }
- MessageBox.Show(check + "条数据下地锁定成功");
- Thread.Sleep(500);
- Query_Click(null, null);
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.Message);
- }
-
- }
- private void Query_OnlineTraceBack_FormClosing(object sender, FormClosingEventArgs e)
- {
- dh.Dispose();
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- int count = SnInf.Rows.Count;
- for (int i = 0; i < count; i++)
- {
- DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)SnInf.Rows[i].Cells["choose1"];
- Boolean flag = Convert.ToBoolean(checkCell.Value);
- if (flag != checkBox1.Checked)
- {
- checkCell.Value = checkBox1.Checked;
- }
- else
- {
- continue;
- }
- }
- countcheck();
- }
- private void normalButton2_Click(object sender, EventArgs e)
- {
- }
- private void countcheck()
- {
- int checkedRowCount = 0;
- foreach (DataGridViewRow row in SnInf.Rows)
- {
- DataGridViewCheckBoxCell checkBoxCell = row.Cells["choose1"] as DataGridViewCheckBoxCell;
- if (checkBoxCell != null && Convert.ToBoolean(checkBoxCell.Value) == true)
- {
- checkedRowCount++;
- }
- }
- Count.Text = checkedRowCount.ToString();
- }
- private void ma_code_UserControlTextChanged(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql(" select mcd_stepcode,mcd_stepname from MAKECRAFTDETAIL where mcd_macode = '" + ma_code.Text+"' order by mcd_detno asc ", "select");
- ms_stepcode.DisplayMember = "mcd_stepname";
- ms_stepcode.ValueMember = "mcd_stepcode";
- ms_stepcode.DataSource = dt;
- ms_stepcode.Text = "";
- }
- private void SnInf_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- if (SnInf.CurrentCell is DataGridViewCheckBoxCell)
- {
- SnInf.CommitEdit(DataGridViewDataErrorContexts.Commit);
- countcheck();
- // 执行你的操作,使用 checkedRows
- }
- }
- }
- }
|