123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using DevExpress.Printing.Core.PdfExport.Metafile;
- using HslCommunication;
- using LabelManager2;
- using Seagull.BarTender.Print;
- using System;
- using System.Data;
- using System.Drawing;
- using System.Security.Cryptography;
- 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.Query
- {
- public partial class Query_SN : Form
- {
- DataHelper dh = SystemInf.dh;
- Engine engine;
- Thread InitPrint;
- DataTable Dbfind;
- Document doc;
- DataTable _dt;
- public Query_SN()
- {
- InitializeComponent();
- }
- private void Query_SpecialReport_Load(object sender, EventArgs e)
- {
- InitPrint = new Thread(InPrint);
- SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- ma_code.TableName = " make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += pr_code_DbChange;
- }
- private void pr_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
- ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
- ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
- pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
- }
- }
- private void InPrint()
- {
- try
- {
- engine = new Engine(true);
- }
- catch (Exception)
- {
- MessageBox.Show("未正确安装BarTender软件");
- }
- }
- private void Print_Click(object sender, EventArgs e)
- {
- DataTable dt = new DataTable();
- string ErrorMessage = "";
- dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_makecode='" + ma_code.Text + "' and nvl(mil_printstatus,0)=0 order by mil_sncode", "select");
- if (dt.Rows.Count < PrintNum.Value)
- {
- OperateResult.AppendText("未打印数量不足,剩余" + dt.Rows.Count + "未打印\n");
- return;
- }
- for (int i = 0; i < PrintNum.Value; i++)
- {
- string mil_sncode = dt.Rows[i]["mil_sncode"].ToString();
- if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, mil_sncode, int.Parse("1"), ma_code.Text, pr_code.Text, "机身标", "0", out ErrorMessage))
- {
- //提示用户打印成功
- dh.ExecuteSql("update makeimeilist set mil_printstatus=-1 where mil_sncode='" + mil_sncode + "'", "update");
- OperateResult.AppendText(">>序列号:" + mil_sncode + "打印结束\n", Color.Green);
- }
- else
- {
- dh.ExecuteSql("update makeimeilist set mil_printstatus=-1 where mil_sncode='" + mil_sncode + "'", "update");
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Green);
- }
- }
- dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
- ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
- ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
- pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
- }
- }
- private void pr_code_TextChanged(object sender, EventArgs e)
- {
- _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='" + pr_code.Text + "' and la_templatetype='机身标' and la_statuscode='AUDITED' order by la_isdefault", "select");
- if (_dt.Rows.Count == 0)
- {
- _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode is null and la_templatetype='机身标' and la_statuscode='AUDITED' order by la_isdefault", "select");
- }
- if (_dt.Rows.Count > 0)
- {
- string la_id = _dt.Rows[0]["la_id"].ToString();
- _dt = (DataTable)dh.ExecuteSql("select fp_name la_url,'" + la_id + "' la_id from FILEPATH where fp_id in (select * from table(select parsestring(LA_SOFTTYPE,';') from label where la_templatetype='机身标' and la_id='" + la_id + "') where COLUMN_VALUE is not null)", "select");
- PrintLabel.DataSource = _dt;
- PrintLabel.DisplayMember = "la_url";
- PrintLabel.ValueMember = "la_id";
- }
- }
- }
- }
|