| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using System;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES.DataOperate;
- using UAS_MES.Entity;
- using UAS_MES.PublicMethod;
- namespace UAS_MES.Make
- {
- public partial class Make_PositionStock : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- DataTable dt;
- LogStringBuilder sql = new LogStringBuilder();
- string ma_id;
- public Make_PositionStock()
- {
- InitializeComponent();
- }
- private void 岗位备料_Load(object sender, EventArgs e)
- {
- dh = new DataHelper();
- asc.controllInitializeSize(this);
- ma_code.TableName = "make left join product on ma_prodcode=pr_code ";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_craftcode # 工艺路线,pr_detail # 产品名称";
- ma_code.FormName = Name;
- ma_code.DBTitle = "工单查询";
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "pr_detail", "ma_craftcode" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- sc_linecode.Text = User.UserLineCode;
- sc_stepcode.Text = User.CurrentStepCode;
- }
- private void 岗位备料_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- //物料批号Enter事件
- private void pr_batchnum_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (pr_batchnum.Text != "")
- {
- if (ma_code.Text != "")
- {
- dt = (DataTable)dh.ExecuteSql("select bar_remain,bar_prodcode from barcode inner join product on pr_code=bar_prodcode where bar_code ='" + pr_batchnum.Text + "' and bar_status = 1 ", "select");
- if (dt.Rows.Count > 0)
- {
- string bar_remain = dt.Rows[0]["bar_remain"].ToString();
- string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
- sql.Clear();
- sql.Append("select * from stepproduct inner join product on pr_code=sp_soncode left join makematerial on mm_prodcode=sp_soncode where ");
- sql.Append("sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode+"' and sp_mothercode='"+ bar_prodcode + "' and pr_tracekind=2 ");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- string mm_oneuseqty = dt.Rows[0]["mm_oneuseqty"].ToString();
- string mm_prodcode = dt.Rows[0]["mm_prodcode"].ToString();
- if (dh.getRowCount("makesourcestock", "mss_makecode='" + ma_code.Text + "' and mss_prodcode='" + mm_prodcode + "' and mss_barcode='" + pr_batchnum.Text + "'") == 0)
- {
- sql.Clear();
- sql.Append("insert into makesourcestock (mss_id,mss_makecode,mss_linecode ,mss_craftcode,");
- sql.Append("mss_stepcode,mss_barcode,mss_fprodcode,mss_indate,mss_inman,mss_qty,");
- sql.Append("mss_remain ,mss_baseqty ,mss_prodcode,mss_maid) values(makesourcestock_seq.nextval,'" + ma_code.Text + "','" + sc_linecode.Text + "',");
- sql.Append("'" + ma_craftcode.Text + "','" + sc_stepcode.Text + "','" + pr_batchnum.Text + "','" + mm_prodcode + "',");
- sql.Append("sysdate,'" + User.UserName + "'," + bar_remain + "," + bar_remain + ",'" + mm_oneuseqty + "','" + bar_prodcode + "'," + ma_id + ")");
- dh.ExecuteSql(sql.GetString(), "insert");
- dh.UpdateByCondition("barcode", "bar_place='" + ma_code.Text + "'", "bar_code='" + pr_batchnum.Text + "'");
- //数据插入成功后加载Grid的数据
- FillDataGridView();
- OperateResult.AppendText(">>批次号" + pr_batchnum.Text + "备料成功\n", Color.Green, pr_batchnum);
- }
- else OperateResult.AppendText(">>批次号" + pr_batchnum.Text + "的物料已分配\n", Color.Red, pr_batchnum);
- }
- else OperateResult.AppendText(">>批次" + pr_batchnum.Text + "对应的物料不是当前工单当前工序需要备的物料\n", Color.Red, pr_batchnum);
- }
- else OperateResult.AppendText(">>批号:" + pr_batchnum.Text + "不存在,或者状态无效\n", Color.Red, pr_batchnum);
- }
- else OperateResult.AppendText(">>工单号不能为空\n", Color.Red, pr_batchnum);
- }
- else OperateResult.AppendText(">>物料批号不允许为空\n", Color.Red);
- }
- }
- //加载Grid数据
- private void FillDataGridView()
- {
- sql.Clear();
- sql.Append("select mm_prodcode,mss_baseqty,mss_prodcode,mss_barcode,nvl(mss_qty,0) mss_qty,mss_remain");
- sql.Append(",mm_qty,pr_detail,pr_spec from makematerial left join product on pr_code=mm_prodcode left join makesourcestock on ");
- sql.Append("mss_maid=mm_maid and mss_stepcode = mm_stepcode and mm_prodcode=mss_fprodcode ");
- sql.Append("where mm_maid='" + ma_id + "' and mm_stepcode='" + sc_stepcode.Text + "' and pr_tracekind=2");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.FillDgvWithDataTable(BatchProduct, dt);
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
- KeyEventArgs e1 = new KeyEventArgs(Keys.Enter);
- pr_batchnum_KeyDown(sender, e1);
- }
- private void Screen_Click(object sender, EventArgs e)
- {
- FillDataGridView();
- }
- private void ma_prodcode_TextChanged(object sender, EventArgs e)
- {
- if (ma_code.Text != "")
- {
- dt = (DataTable)dh.ExecuteSql("select ma_id,ma_craftcode,ma_statuscode,ma_code,ma_prodcode,pr_spec,pr_detail from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
- //查询工单号是否存在
- if (dt.Rows.Count > 0)
- {
- ma_id = dt.Rows[0]["ma_id"].ToString();
- string craftcode = dt.Rows[0]["ma_craftcode"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- //必须是已下放的工单才允许进行岗位备料
- if (dt.Rows[0]["ma_statuscode"].ToString() == "STARTED")
- {
- //判断当前用户的执行工序和岗位资源是否对应
- sql.Clear();
- sql.Append("select sp_soncode,mm_oneuseqty,mss_prodcode,mss_barcode,nvl(mss_qty,0)mss_qty,mss_remain,mm_qty,pr_detail,pr_spec ");
- sql.Append("from stepproduct inner join makematerial on sp_soncode=mm_Prodcode left join product on pr_code=mm_prodcode left join ");
- sql.Append("makesourcestock on mss_maid=mm_maid and mss_stepcode=mm_stepcode and mm_prodcode=mss_fprodcode where ");
- sql.Append("mm_maid='" + ma_id + "' and sp_mothercode='" + ma_prodcode.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and pr_tracekind=2");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- //查询到有记录的话表示对应
- if (dt.Rows.Count > 0)
- FillDataGridView();
- //查询到没有结果表示不对应
- else OperateResult.AppendText(">>当前工单物料无需备料\n", Color.Red);
- }
- else OperateResult.AppendText(">>必须状态为已下放的工单才允许进行岗位备料\n", Color.Red);
- }
- else OperateResult.AppendText(">>工单号不存在\n", Color.Red);
- }
- else OperateResult.AppendText(">>工单号不允许为空\n", Color.Red);
- }
- }
- }
|