| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using DevExpress.Printing.Core.PdfExport.Metafile;
- 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_BarcodeIn : Form
- {
- DataHelper dh = SystemInf.dh;
- DataTable Dbfind;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- Thread InitPrint;
- BarTender.Application engine;
- public Query_BarcodeIn()
- {
- InitializeComponent();
- }
- private void InPrint()
- {
- try
- {
- engine = new BarTender.Application();
- }
- catch (Exception)
- {
- MessageBox.Show("未正确安装BarTender软件");
- }
- }
- private void Query_LoadMake_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- InitPrint = new Thread(InPrint);
- SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
- BaseUtil.SetFormCenter(stw);
- stw.ShowDialog();
- LoadGridData();
- }
- private void UpLoadMake_Click(object sender, EventArgs e)
- {
- LoadGridData();
- }
- private void LoadGridData()
- {
- DataTable dt = (DataTable)dh.ExecuteSql(" select * from gwlocation full outer join ( select * from Stencil where st_kind = '钢网' ) on gl_LOCATION = st_location left join stenilcanusepro on SP_STID = st_id left join product on pr_code = SP_PRODCODE" +
- " where (st_kind = '钢网' or st_kind is null) and (st_usestatus<>'报废' or st_usestatus is null) order by gl_id asc ", "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")
- {
- if(DGV.Rows[i].Cells["st_id"].Value.ToString() != "")
- return true;
- else
- return false;
- }
- }
- return false;
- }
- private void Print_Click(object sender, EventArgs e)
- {
- string ErrMsg = "";
- MessageBox.Show("生成明细成功");
- }
- private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e)
- {
- LoadGridData();
- }
- private void MakeCode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- //if (pi_inoutno.Text == "")
- //{
- // MessageBox.Show("出入库单号不能为空");
- // return;
- //}
- //DataTable dt = (DataTable)dh.ExecuteSql("select bi_inqty,bi_barcode from barcodeio left join product on pr_code=bi_prodcode" +
- // " where bi_inoutno='" + pi_inoutno.Text + "' and bi_barcode='" + barcode.Text + "'", "select");
- //if (dt.Rows.Count > 0)
- //{
- // MessageBox.Show("出入库单已采集条码" + barcode.Text);
- // return;
- //}
- //dt = (DataTable)dh.ExecuteSql("select bar_vendbarcode,to_char(nvl(bar_madedate,sysdate),'yyyy-mm-dd')bar_madedate,bar_code,bar_remain,bar_prodcode from barcode left " +
- // "join product on pr_code=bar_prodcode where bar_code='" + barcode.Text + "'", "select");
- //if (dt.Rows.Count == 0)
- //{
- // MessageBox.Show("条码" + barcode.Text + "不存在");
- // return;
- //}
- //BarCodePrint bar = new BarCodePrint(barcode.Text);
- //bar.StartPosition = FormStartPosition.CenterScreen;
- //bar.ShowDialog();
- //string newbarcode = bar.Controls["newbarcode"].Text;
- //string bar_remain = bar.Controls["bar_remain"].Text;
- //bar.Controls["PrintBarCode"].Click += Query_BarcodeIn_Click;
- //string pi_id = dh.getFieldDataByCondition("prodinout", "pi_id", "pi_inoutno='" + pi_inoutno.Text + "'").ToString();
- //string bar_code = dt.Rows[0]["bar_code"].ToString();
- //string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
- //string bar_madedate = dt.Rows[0]["bar_madedate"].ToString();
- //string bar_vendbarcode = dt.Rows[0]["bar_vendbarcode"].ToString();
- //dh.ExecuteSql("insert into barcodeio(bi_id,bi_piid,bi_barcode,bi_inoutno,bi_prodcode,bi_indate,bi_inqty,bi_vendbarcode,bi_madedate,bi_sourcecode,bi_printstatus)" +
- // "values(barcodeio_seq.nextval,'" + pi_id + "','" + newbarcode + "','" + pi_inoutno.Text + "','" + bar_prodcode + "',sysdate,'" + bar_remain + "','" + bar_vendbarcode + "',to_date('" + bar_madedate + "','yyyy-mm-dd'),'" + bar_code + "',1)", "insert");
- //LoadGridData();
- //string ErrorMessage = "";
- //if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, newbarcode, int.Parse("1"), pi_inoutno.Text, bar_prodcode, "自定义", "0", out ErrorMessage))
- //{
- //}
- }
- }
- private void Query_BarcodeIn_Click(object sender, EventArgs e)
- {
- }
- private void DeleteBarcode_Click(object sender, EventArgs e)
- {
-
- //LoadGridData();
- }
- private void ChooseAll_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < DGV.Rows.Count; i++)
- {
- DGV.Rows[i].Cells["choose"].Value = true;
- }
- }
- private void Print_Click_1(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")
- {
- if (DGV.Rows[i].Cells["st_id"].Value.ToString() != "")
- {
- BarTender.Format doc2 = engine.Formats.Open(System.Windows.Forms.Application.StartupPath + @"\钢网条码.btw");
- DataTable ddt = (DataTable)dh.ExecuteSql(" select * from Stencil where st_id = '" + DGV.Rows[i].Cells["st_id"].Value.ToString() + "' ", "select");
- doc2.SetNamedSubStringValue("储位", ddt.Rows[0]["st_location"].ToString());
- doc2.SetNamedSubStringValue("机型", ddt.Rows[0]["st_name"].ToString());
- doc2.SetNamedSubStringValue("编号", ddt.Rows[0]["st_code"].ToString());
- doc2.SetNamedSubStringValue("客户", ddt.Rows[0]["st_vendcode"].ToString());
- doc2.SetNamedSubStringValue("面别", ddt.Rows[0]["st_table"].ToString());
- doc2.SetNamedSubStringValue("厚度", ddt.Rows[0]["st_thickness"].ToString());
- // 同样标签的份数
- doc2.PrintSetup.IdenticalCopiesOfLabel = 1;
- // 序列标签数
- doc2.PrintSetup.NumberSerializedLabels = 1;
- doc2.PrintSetup.Printer = PrinterList.Text;
- doc2.PrintOut(false, false);
- doc2.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
- }
- }
- }
- }
- private void Query_BarcodeIn_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (engine != null)
- engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
- dh.Dispose();
- }
- private void Query_BarcodeIn_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- }
- }
|