|
|
@@ -8,6 +8,7 @@ using UAS_MES.Entity;
|
|
|
using UAS_MES.PublicMethod;
|
|
|
using System.Drawing;
|
|
|
using System.Threading;
|
|
|
+using UAS_MES.PublicForm;
|
|
|
|
|
|
namespace UAS_MES.Make
|
|
|
{
|
|
|
@@ -21,6 +22,8 @@ namespace UAS_MES.Make
|
|
|
Thread thread;
|
|
|
DataTable Dbfind;
|
|
|
|
|
|
+ System.DateTime[] indate;
|
|
|
+
|
|
|
public Make_PackageCollection()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -35,18 +38,20 @@ namespace UAS_MES.Make
|
|
|
private void 包装采集_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
dh = new DataHelper();
|
|
|
- thread = new Thread(NewPrint);
|
|
|
- thread.Start();
|
|
|
AutoPrint.Checked = true;
|
|
|
//设置DbFind的必须的数据
|
|
|
ma_code.FormName = Name;
|
|
|
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_prodname", "pr_id" };
|
|
|
+ ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_prodname" };
|
|
|
ma_code.TableName = "Make left join product on ma_prodcode=pr_code";
|
|
|
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 物料编号,ma_qty # 数量,ma_prodname # 物料名册,ma_wccode # 工作中心编号";
|
|
|
+ ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 物料编号,pr_detail # 物料名称";
|
|
|
ma_code.Condition = "ma_statuscode='STARTED'";
|
|
|
ma_code.DbChange += Ma_code_DbChange;
|
|
|
PrintNum.Value = 1;
|
|
|
asc.controllInitializeSize(this);
|
|
|
+ thread = new Thread(NewPrint);
|
|
|
+ SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
|
|
|
+ BaseUtil.SetFormCenter(stw);
|
|
|
+ stw.ShowDialog();
|
|
|
}
|
|
|
|
|
|
private void Ma_code_DbChange(object sender, EventArgs e)
|
|
|
@@ -62,35 +67,41 @@ namespace UAS_MES.Make
|
|
|
|
|
|
private void 包装采集_Activated(object sender, EventArgs e)
|
|
|
{
|
|
|
- pa_code.Focus();
|
|
|
+ pa_outboxcode.Focus();
|
|
|
}
|
|
|
|
|
|
//刷新表单的数据的数据
|
|
|
private void LoadData()
|
|
|
{
|
|
|
- //加载Grid数据
|
|
|
- dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_code.Text + "'", "select");
|
|
|
- BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
|
|
|
//加载表单数据
|
|
|
sql.Clear();
|
|
|
- sql.Append("select pr_id,pa_id,pa_totalqty,pa_packageqty,pa_totalqty-pa_packageqty pa_restqty,ma_prodcode,pr_detail,pr_colorboxmaxw,pr_colorboxminw,pr_code,pa_makecode as ma_code ");
|
|
|
- sql.Append("from package left join packagedetail on pd_paid=pa_id left join product left join make on ma_prodcode=pr_code on pa_prodcode=pr_code where pa_outboxcode='" + pa_code.Text + "' and rownum=1");
|
|
|
+ sql.Append("select pa_outboxcode,pr_id,pa_id,pa_totalqty,pa_packageqty,pa_totalqty-pa_packageqty pa_restqty,ma_prodcode,pr_detail,");
|
|
|
+ sql.Append("pr_colorboxmaxw,pr_colorboxminw,pr_code,pa_makecode as ma_code from package left join packagedetail on ");
|
|
|
+ sql.Append("pd_paid=pa_id left join product left join make on ma_prodcode=pr_code on pa_prodcode=pr_code where ");
|
|
|
+ sql.Append("(pa_outboxcode='" + pa_outboxcode.Text + "' or pd_barcode='" + barcode.Text + "') and rownum=1 ");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
+ //加载Grid数据
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
|
|
|
+ BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
|
|
|
+ barcode.Clear();
|
|
|
}
|
|
|
|
|
|
private void InsertDetail()
|
|
|
{
|
|
|
- //插入工序表MakeSerial,如果是第一道工序的话
|
|
|
- //插入PackageDetail从表信息
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into packagedetail(pd_id,pd_paid,pd_outboxcode,pd_innerqty,pd_barcode) ");
|
|
|
- sql.Append("select packagedetail_seq.nextval,pa_id,pa_outboxcode,pa_totalqty,'" + barcode.Text + "' from package where pa_outboxcode='" + pa_code.Text + "'");
|
|
|
- dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
- dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty+1", "pa_outboxcode='" + pa_code.Text + "'");
|
|
|
- OperateResult.AppendText("序列号" + barcode.Text + "采集成功!\n", Color.Green);
|
|
|
- barcode.Clear();
|
|
|
- LoadData();
|
|
|
+ if (int.Parse(pa_restqty.Text == "" ? "1" : pa_restqty.Text) > 0)
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into packagedetail(pd_id,pd_paid,pd_outboxcode,pd_innerqty,pd_barcode) ");
|
|
|
+ sql.Append("select packagedetail_seq.nextval,pa_id,pa_outboxcode,pa_totalqty,'" + barcode.Text + "' from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
+ dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty+1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
+ OperateResult.AppendText("序列号" + barcode.Text + "采集成功!\n", Color.Green);
|
|
|
+ barcode.Clear();
|
|
|
+ LoadData();
|
|
|
+ }
|
|
|
+ else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "已采集满\n", Color.Red);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void Print_Click(object sender, EventArgs e)
|
|
|
@@ -104,7 +115,7 @@ namespace UAS_MES.Make
|
|
|
try
|
|
|
{
|
|
|
OperateResult.AppendText("开始打印\n", Color.Green);
|
|
|
- Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
|
|
|
+ Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -115,7 +126,7 @@ namespace UAS_MES.Make
|
|
|
else
|
|
|
{
|
|
|
if (PrintLabel.SelectedValue != null)
|
|
|
- Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
|
|
|
+ Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -144,7 +155,7 @@ namespace UAS_MES.Make
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
{
|
|
|
//先判断箱号不为空
|
|
|
- if (pa_code.Text != "" && barcode.Text != "")
|
|
|
+ if (pa_outboxcode.Text != "" && barcode.Text != "")
|
|
|
{
|
|
|
//判断箱内总数必须大于0
|
|
|
if (pa_totalqty.Text == "" || pa_totalqty.Text == "0")
|
|
|
@@ -159,19 +170,20 @@ namespace UAS_MES.Make
|
|
|
if (dh.CheckExist("packagedetail", "pd_barcode='" + barcode.Text + "'"))
|
|
|
{
|
|
|
OperateResult.AppendText("序列号" + barcode.Text + "已经装箱!\n", Color.Red);
|
|
|
+ barcode.Clear();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//箱号不存在的情况
|
|
|
- if (!dh.CheckExist("package", "pa_outboxcode='" + pa_code.Text + "'"))
|
|
|
+ if (!dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
|
|
|
{
|
|
|
//插入Package主表箱号信息
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into package (pa_id,pa_outboxcode,pa_packageqty,pa_totalqty,pa_status,pa_indate,pa_makecode,pa_prodcode,pa_salecode,pa_custcode)");
|
|
|
- sql.Append("select package_seq.nextval,'" + pa_code.Text + "',0," + pa_totalqty.Text + ",0,");
|
|
|
+ sql.Append("select package_seq.nextval,'" + pa_outboxcode.Text + "',0," + pa_totalqty.Text + ",0,");
|
|
|
sql.Append("sysdate,'" + ma_code.Text + "', ma_prodcode,ma_salecode,ma_custcode from make where ma_code = '" + ma_code.Text + "'");
|
|
|
dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
- OperateResult.AppendText("箱号" + pa_code.Text + "采集成功!\n", Color.Green);
|
|
|
+ OperateResult.AppendText("箱号" + pa_outboxcode.Text + "采集成功!\n", Color.Green);
|
|
|
//验证序列号插入明细表的数据
|
|
|
InsertDetail();
|
|
|
}
|
|
|
@@ -203,21 +215,21 @@ namespace UAS_MES.Make
|
|
|
//勾选了取消箱号先验证箱号存不存在,存在的话移除掉,重新加载一次数据
|
|
|
else
|
|
|
{
|
|
|
- dt = (DataTable)dh.ExecuteSql("select pd_outboxcode from packagedetail where pd_outboxcode='" + pa_code.Text + "' and pd_barcode='" + barcode.Text + "'", "select");
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pd_outboxcode from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "' and pd_barcode='" + barcode.Text + "'", "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
//删除明细行的数据
|
|
|
- dh.ExecuteSql("delete from packagedetail where pd_barcode='" + barcode.Text + "' and pd_paid=(select pa_id from package where pa_outboxcode='" + pa_code.Text + "')", "delete");
|
|
|
+ dh.ExecuteSql("delete from packagedetail where pd_barcode='" + barcode.Text + "' and pd_paid=(select pa_id from package where pa_outboxcode='" + pa_outboxcode.Text + "')", "delete");
|
|
|
//更新已装数
|
|
|
- dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty-1", "pa_outboxcode='" + pa_code.Text + "'");
|
|
|
+ dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty-1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
|
|
|
dh.UpdateByCondition("makeserial", "ms_nextstepcode=ms_stepcode", "ms_sncode='" + barcode.Text + "'");
|
|
|
- OperateResult.AppendText(">>已从该箱中移除该序列号\n", Color.Green);
|
|
|
+ OperateResult.AppendText(">>已从该箱中移除序列号" + barcode.Text + "\n", Color.Green);
|
|
|
LoadData();
|
|
|
}
|
|
|
else OperateResult.AppendText(">>序列号" + barcode.Text + "不在该箱内,请输入正确的序列号\n", Color.Red);
|
|
|
}
|
|
|
}
|
|
|
- else OperateResult.AppendText(">>请先输入箱号和工单号\n", Color.Red);
|
|
|
+ else LoadData();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -232,14 +244,8 @@ namespace UAS_MES.Make
|
|
|
{
|
|
|
if (pa_totalqty.Text == pa_packageqty.Text)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, barcode.Text);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- BaseUtil.ShowError("打印程序异常,请检查是否连接打印机或者打印软件是否安装");
|
|
|
- }
|
|
|
+ OperateResult.AppendText(">>打印箱号"+pa_outboxcode.Text+"\n", Color.Green);
|
|
|
+ Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -254,20 +260,22 @@ namespace UAS_MES.Make
|
|
|
|
|
|
private void pr_code_TextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + ma_prodcode.Text + "'", "select");
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select pl_labelcode||':'||pl_labelname pl_laname,pl_labelname,pl_labelcode,pl_labelurl,pl_indate from productlabel where pl_prodcode='" + ma_prodcode.Text + "'", "select");
|
|
|
PrintLabel.DataSource = dt;
|
|
|
- PrintLabel.DisplayMember = "pl_labelname";
|
|
|
+ PrintLabel.DisplayMember = "pl_laname";
|
|
|
PrintLabel.ValueMember = "pl_labelcode";
|
|
|
ftpOperater ftp = new ftpOperater();
|
|
|
+ indate = new System.DateTime[dt.Rows.Count];
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
- ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
|
|
|
+ BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
|
|
|
+ indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void pr_id_TextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- pa_code.Pr_id = pr_id.Text;
|
|
|
+ pa_outboxcode.Pr_id = pr_id.Text;
|
|
|
}
|
|
|
|
|
|
private void 包装采集_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
@@ -279,7 +287,11 @@ namespace UAS_MES.Make
|
|
|
{
|
|
|
if (ma_code.Text.Length > 5)
|
|
|
{
|
|
|
-
|
|
|
+ //加载表单数据
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select ma_prodcode,pr_detail,pr_id,ma_code from product left join make on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
}
|
|
|
}
|
|
|
}
|