using DevExpress.Printing.Core.PdfExport.Metafile; using HslCommunication; using LabelManager2; using Seagull.BarTender.Print; using System; using System.Data; using System.Drawing; 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; using static System.Runtime.CompilerServices.RuntimeHelpers; namespace UAS_MES_NEW.Query { public partial class Query_Barcodeio : Form { DataHelper dh = SystemInf.dh; ApplicationClass lbl; Engine engine; Document doc; DataTable Dbfind; Thread InitPrint; public Query_Barcodeio() { InitializeComponent(); } private void Query_LoadMake_Load(object sender, EventArgs e) { pi_inoutno.TableName = "prodinout"; pi_inoutno.SelectField = "pi_inoutno#单号"; pi_inoutno.FormName = Name; pi_inoutno.SetValueField = new string[] { "pi_inoutno" }; pi_inoutno.Condition = "1=1"; pi_inoutno.DbChange += Ma_code_DbChange; InitPrint = new Thread(InPrint); SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序"); BaseUtil.SetFormCenter(stw); stw.ShowDialog(); LoadGridData(); DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='退料标签' 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"; } } private void InPrint() { try { engine = new Engine(true); } catch (Exception) { MessageBox.Show("未正确安装BarTender软件"); } } private void Ma_code_DbChange(object sender, EventArgs e) { Dbfind = pi_inoutno.ReturnData; BaseUtil.SetFormValue(this.Controls, Dbfind); } private void UpLoadMake_Click(object sender, EventArgs e) { LoadGridData(); } private void LoadGridData() { DataTable dt = (DataTable)dh.ExecuteSql("select * from barcodeio left join product on pr_code=bi_prodcode where bi_inoutno='" + pi_inoutno.Text + "'", "select"); BaseUtil.FillDgvWithDataTable(DGV, dt); } private bool ifcheckrow() { for (int i = 0; i < DGV.Rows.Count; i++) { if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True") { return true; } } return false; } private void Print_Click(object sender, EventArgs e) { if (!ifcheckrow()) { MessageBox.Show("请勾选需要操作的行"); return; } for (int i = 0; i < DGV.Rows.Count; i++) { if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True") { string barcode = DGV.Rows[i].Cells["bi_barcode"].Value.ToString(); string prodcode = DGV.Rows[i].Cells["bi_prodcode"].Value.ToString(); string ErrorMessage = ""; if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, barcode, int.Parse("1"), pi_inoutno.Text, prodcode, "自定义", "0", out ErrorMessage)) { } } } } private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e) { LoadGridData(); } private void PrintLabel_SelectedIndexChanged(object sender, EventArgs e) { } private void label3_Click(object sender, EventArgs e) { } } }