using System; using System.Data; using System.Drawing; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Special { public partial class Special_AfterSaleIn : Form { DataHelper dh = SystemInf.dh; LogStringBuilder sql = new LogStringBuilder(); AutoSizeFormClass asc = new AutoSizeFormClass(); public Special_AfterSaleIn() { InitializeComponent(); } private void Special_CancelProdinout_Load(object sender, EventArgs e) { //cu_code.TableName = "customer"; //cu_code.DBTitle = "出货单查询"; //cu_code.SelectField = "cu_id # ID,cu_code # 客户编号,cu_name # 客户名城"; //cu_code.SetValueField = new string[] { "cu_code", "cu_name" }; //cu_code.FormName = Name; pr_code.TableName = "product"; pr_code.DBTitle = "出货单查询"; pr_code.SelectField = "pr_code # 物料编号,pr_detail # 物料名称,pr_spec # 物料规格"; pr_code.SetValueField = new string[] { "pr_code", "pr_detail", "pr_spec" }; pr_code.FormName = Name; InDate.Value = DateTime.Now; asc.controllInitializeSize(this); } private void Confirm_Click(object sender, EventArgs e) { //正常录入资料的时候 if (barcode.Text == "") { OperateResult.AppendText(">>输入信息不允许为空\n", Color.Red, barcode); return; } string oMSID = ""; string oMakecode = ""; string Err = ""; DataTable dt = (DataTable)dh.ExecuteSql("select ma_custname,ma_prodcode,pr_spec from makeserial_view left join make_view on ms_makecode=ma_code left join product on ms_prodcode=pr_code where ms_sncode='" + barcode.Text + "'", "select"); if (dt.Rows.Count > 0) { cu_code.Text = dt.Rows[0]["ma_custname"].ToString(); pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString(); pr_spec.Text = dt.Rows[0]["pr_spec"].ToString(); } if (cu_code.Text == "" || pr_code.Text == "") { OperateResult.AppendText(">>客户编号和物料编号不能为空\n", Color.Red, barcode); return; } if (LogicHandler.CheckStepSNAndMacode("MD22020001", "ZBRK", barcode.Text, User.UserCode, out oMakecode, out oMSID, out Err)) { dh.ExecuteSql("update makeserial set ms_custname='" + cu_code.Text + "',ms_prodcode1='" + pr_code.Text + "' where ms_id=" + oMSID, "update"); LoadGridData(); if (dh.getFieldDataByCondition("makeserial", "ms_stepcode", "ms_id=" + oMSID).ToString() == User.CurrentStepCode) { OperateResult.AppendText(">>条码已经执行过" + User.CurrentStepName + "\n", Color.Red, barcode); return; } if (LogicHandler.SetStepResult("MD22020001", "ZBRK", barcode.Text, "", "OK", User.UserCode, out Err)) { OperateResult.AppendText(">>条码" + barcode.Text + "录入成功\n", Color.Green, barcode); } else { OperateResult.AppendText(">>" + Err + "\n", Color.Red, barcode); } } else { OperateResult.AppendText(">>" + Err + "\n", Color.Red, barcode); } } private void Clean_Click(object sender, EventArgs e) { OperateResult.Clear(); } private void LoadGridData() { sql.Clear(); sql.Append("select * from makeserial where trunc(ms_indate)=trunc(to_date('" + InDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')) "); if (cu_code.Text != "") { sql.Append(" and ms_custname='" + cu_code.Text + "'"); } if (pr_code.Text != "") { sql.Append(" and ms_prodcode1='" + pr_code.Text + "'"); } DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); BaseUtil.FillDgvWithDataTable(Info, dt); } private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void barcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Confirm.PerformClick(); } } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { LoadGridData(); } private void cu_code_UserControlTextChanged(object sender, EventArgs e) { LoadGridData(); } private void pr_code_UserControlTextChanged(object sender, EventArgs e) { LoadGridData(); } } }