Exemple #1
0
 public void Close()
 {
     server.Documents.CloseAll();
     server.Quit();
     doc    = null;
     server = null;
 }
Exemple #2
0
        private void button_start_Click(object sender, EventArgs e)
        {
            flag     = true;
            this.db2 = new databaseSQL();
            this.db2.SSHConnectMySql();
            this.labelapp    = new LabelManager2.Application(); //创建lppa.exe进程
            textBox_log.Text = "创建lppa.exe进程\r\n";
            if (!textBox_path.Text.Trim().Equals(""))
            {
                //timer1.Enabled = true;
                task_thread = new Thread(get_task);
                task_thread.IsBackground = true;
                task_thread.Start();

                button_start.Enabled   = false;
                button_selfile.Enabled = false;
                button_stop.Enabled    = true;
            }
            else
            {
                MessageBox.Show("请指定一个打印CS模板文件!");
                this.textBox_path.Focus();
                return;
            }
        }
Exemple #3
0
        public static LabelManager2.Application labApp = null;//new LabelManager2.Application();


        public static void initCodesoftModel(string codesoftmodelname)
        {
            if (labApp == null)
            {
                labApp = new LabelManager2.Application();
            }

            if (POD != null)
            {
                POD.Close();
            }

            string labFileName = CodeSoftPath + codesoftmodelname.Replace("Model", "") + ".Lab";

            try
            {
                if (!File.Exists(labFileName))
                {
                    MessageBox.Show("沒有找到標簽模板文件:" + codesoftmodelname.Replace("Model", "") + ".Lab     請聯系系統管理員", "溫馨提示");
                    return;
                }
                labApp.Documents.Open(labFileName, false);// 调用设计好的label文件
                POD = labApp.ActiveDocument;
            }
            catch
            {
            }
            finally
            {
            }
        }
Exemple #4
0
        private void ConnectToLppx2()
        {
            if (_mCsApp != null)
            {
                return;
            }

            Object csObject;

            try
            {
                csObject = System.Runtime.InteropServices.Marshal.GetActiveObject(Lppx2ProgId);
            }
            catch
            {
                //No CODESOFT object Running !
                csObject = null;
            }

            try
            {
                if (csObject == null)
                {
                    _mCsApp       = new LabelManager2.Application();
                    _bDeleteCsApp = true;
                }
                else
                {
                    _mCsApp = (LabelManager2.Application)csObject;
                }
                //m_CsApp.Visible = true;
            }
            catch (Exception e)
            {
                string szerror = e.Message.ToString();
                MessageBox.Show(szerror);
            }

            if (bUnableToLoad == false)
            {
                if (_mCsApp.IsEval)
                {
                    MessageBox.Show(null,
                                    @"DemoMode, Check Dongle License",
                                    @"Quick Print",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show(null,
                                @"Unable to load CODESOFT",
                                @"Quick Print",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemple #5
0
 public static void initCodeSoft()
 {
     try
     {
         labApp = new LabelManager2.Application();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #6
0
        public void Printbarcode(LabelManager2.Application labelapp)
        {
            try
            {
                //db.SSHConnectMySql();
                String selstr = "select distinct tag_index from list_barcodeprint where print_status=0 and processpoint = '" + comboBox1.Text + "'";

                DataTable reader  = this.db2.Select(selstr);
                String    itemstr = "";

                if (reader != null)
                {
                    for (int i = 0; i < reader.Rows.Count; i++)
                    {
                        string strPath = textBox_path.Text.Trim();
                        this.labelapp.Documents.Open(strPath, false);
                        LabelManager2.Document labeldoc = labelapp.ActiveDocument;
                        int vcount = labeldoc.Variables.FormVariables.Count;

                        textBox_log.Text += "新建打印文档对象\r\n";
                        String    selsql1 = "select barcode,varible_index from list_barcodeprint where print_status=0 and tag_index=" + reader.Rows[i][0] + "  and processpoint = '" + comboBox1.Text + "' order by varible_index";
                        DataTable reader2 = this.db2.Select(selsql1);
                        if (reader2 != null && (reader2.Rows.Count == vcount))
                        {
                            for (int j = 0; j < reader2.Rows.Count; j++)
                            {
                                itemstr = "var_" + reader2.Rows[j][1].ToString();
                                labeldoc.Variables.FormVariables.Item(itemstr).Value = reader2.Rows[j][0].ToString();
                            }

                            textBox_log.Text += "文档开始打印:标签" + (i + 1).ToString() + "\r\n";
                            labeldoc.PrintDocument(); //打印一次
                            textBox_log.Text += "文档结束打印:标签" + (i + 1).ToString() + "\r\n";
                            labeldoc.FormFeed();      //结束打印

                            String updatesql1 = "update list_barcodeprint set print_status=1 where print_status=0 and tag_index=" + reader.Rows[i][0] + "  and processpoint = '" + comboBox1.Text + "'";
                            this.db2.Update(updatesql1);
                        }
                        textBox_log.Text += "文档关闭\r\n";
                        labeldoc.Close(true);
                    }
                }
            }
            catch (Exception exceptions)
            {
                MessageBox.Show("标签打印出错!请联系设备技术员处理。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                labelapp.Documents.CloseAll();
            }
        }
 private void Init()
 {
     try
     {
         MLppx2Manager = new Lppx2Manager();
         CsApp         = MLppx2Manager.GetApplication();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     _myCallback = ThumbnailCallback;
 }
Exemple #8
0
 public static void disposePrinter()
 {
     if (doc != null)
     {
         doc.Close();
         doc = null;
         // labApp.Quit();
     }
     if (labApp != null)
     {
         labApp.Quit();
         labApp = null;
     }
 }
Exemple #9
0
        public void QuitLppx2()
        {
            if (_mCsApp != null)
            {
                if (_bDeleteCsApp)
                {
                    _mCsApp.Documents.CloseAll(false);
                    _mCsApp.Quit();

                    _bDeleteCsApp = false;
                }

                System.Runtime.InteropServices.Marshal.ReleaseComObject(_mCsApp);
                _mCsApp = null;
            }
        }
        public void startprint()
        {
            Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            //根据Key读取<add>元素的Value
            templatepath = config.AppSettings.Settings["TemplatePATH"].Value;
            processpoint = config.AppSettings.Settings["processpoint"].Value;

            this.db2 = new databaseSQL();
            this.db2.SSHConnectMySql();
            this.labelapp = new LabelManager2.Application(); //创建lppa.exe进程

            System.Timers.Timer t = new System.Timers.Timer(100);
            t.Elapsed  += new System.Timers.ElapsedEventHandler(theout);
            t.AutoReset = true;   //设置是执行一次(false)还是一直执行(true);
            t.Enabled   = true;   //是否执行System.Timers.Timer.Elapsed事件;
        }
Exemple #11
0
Fichier : Form1.cs Projet : 88886/-
        private void Print(string pSN)
        {//print
            // string SN = pSN;
            lbl = new LabelManager2.Application();
            lbl.Documents.Open(docPath, true);
            LabelManager2.Document document = lbl.ActiveDocument;

            document.Variables.FreeVariables.Item("SN").Value = pSN;

            document.PrintDocument(1);
            document.FormFeed();
            lbl.Documents.CloseAll();
            document = null;
            lbl.Quit();
            //createLog("BOX_LABEL", CN, pSN, DateTime.Now.ToString("yyyy-MM-dd"), "Trinity");
            stopProcess("lppa");
        }
Exemple #12
0
        public bool Print(LabelType typ, List <String> detail)
        {
            core c    = new core();
            bool temp = false;

            server = new LabelManager2.Application();
            doc    = new LabelManager2.Document();
            string defaultprinter = getdefaultprinter();

            try
            {
                switch (typ)
                {
                //PRINT LABEL
                case LabelType.PRINTLABEL:
                    server.Documents.Open(Application.StartupPath + @"\PRINTLABEL.lab");
                    server.PrinterSystem();
                    doc = server.ActiveDocument;

                    //Nama printer harus sesuai dg Hardware yang dipasang
                    doc.Printer.SwitchTo(defaultprinter);
                    //doc.Printer.SwitchTo("HP DJ 2130 series");
                    //doc.Printer.SwitchTo("HP LaserJet Professional P1102");

                    doc.Variables.FormVariables.Item("olshopname").Value   = detail[0].ToString();
                    doc.Variables.FormVariables.Item("nama").Value         = detail[1].ToString();
                    doc.Variables.FormVariables.Item("alamat").Value       = detail[2].ToString();
                    doc.Variables.FormVariables.Item("email").Value        = detail[3].ToString();
                    doc.Variables.FormVariables.Item("hp").Value           = detail[4].ToString();
                    doc.Variables.FormVariables.Item("tanggalpesan").Value = detail[5].ToString();
                    doc.Variables.FormVariables.Item("qty").Value          = detail[6].ToString();

                    doc.PrintLabel(1);
                    doc.FormFeed();
                    temp = true;
                    c.killLppa();
                    break;
                }
            }
            catch (Exception ex) { }
            return(temp);
        }
Exemple #13
0
        public static void InitCodesoftForReturn()
        {
            try
            {
                labApp = new LabelManager2.Application();
                string labFileName = @"D:\printLab\test.Lab";
                if (!File.Exists(labFileName))
                {
                    MessageBox.Show("沒有找到標簽模板文件:" + labFileName + ",請聯系系統管理員", "溫馨提示");
                    return;
                }

                labApp.Documents.Open(labFileName, false); // 调用设计好的label文件
                doc = labApp.ActiveDocument;
                doc.Printer.SwitchTo("codesoft");          //打印机名字,自定义,可以修改
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
            }
        }
Exemple #14
0
        /// <summary>
        /// Prints the label.
        /// </summary>
        /// <param name="vendor">The vendor.</param>
        /// <param name="date">The date.</param>
        /// <param name="pn">The pn.</param>
        /// <param name="descrition">The descrition.</param>
        /// <param name="po">The po.</param>
        /// <param name="qty">The qty.</param>
        /// <param name="sn">The sn.</param>
        /// <param name="k1">The k1.</param>
        /// <param name="k2">The k2.</param>
        /// <param name="end">The end.</param>
        /// <remarks>Created At Time: [ 2017-10-30 22:36 ], By User:lishuai, On Machine:Brian-NB</remarks>
        private void PrintLabel()
        {
            string vendor     = string.Empty;
            string date       = string.Empty;
            string pn         = string.Empty;
            string descrition = string.Empty;
            string po         = string.Empty;
            string qty        = string.Empty;
            string sn         = string.Empty;
            string k1         = string.Empty;
            string k2         = string.Empty;
            string end        = string.Empty;
            string ph         = string.Empty;//生产批号;


            try
            {
                if (dataGridView1.Rows.Count > 0)
                {
                    vendor = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    DateTime dt  = DateTime.Now;
                    string   sdt = dt.GetDateTimeFormats('g')[0].ToString();         //供应商
                    date       = sdt;
                    pn         = dataGridView1.CurrentRow.Cells[5].Value.ToString(); //料号
                    ph         = dataGridView1.CurrentRow.Cells[2].Value.ToString(); //批号
                    descrition = dataGridView1.CurrentRow.Cells[6].Value.ToString(); //描述
                    po         = dataGridView1.CurrentRow.Cells[1].Value.ToString(); //订单

                    qty = dataGridView1.CurrentRow.Cells[9].Value.ToString();        //总托数

                    sn = dataGridView1.CurrentRow.Cells[4].Value.ToString();         //托号
                    k1 = dataGridView1.CurrentRow.Cells[7].Value.ToString();         //原始重量
                    k2 = lbl_weight.Text;                                            //实际重量



                    // double cy = Convert.ToDouble(dataGridView1.CurrentRow.Cells[7].Value) - Convert.ToDouble(lbl_weight.Text);
                    double cy = Convert.ToDouble(lbl_weight.Text) - Convert.ToDouble(dataGridView1.CurrentRow.Cells[7].Value);

                    cy = System.Math.Abs(cy);

                    if (cy <= 1)
                    {
                        end = "OK";
                    }
                    else
                    {
                        end = "NG";
                    }


                    #region print
                    LabelManager2.Application labelapp = new LabelManager2.Application(); //创建lppa.exe进程
                    string strPath = System.Windows.Forms.Application.StartupPath + "\\102X152.Lab";


                    labelapp.Documents.Open(strPath, false);
                    LabelManager2.Document labeldoc = labelapp.ActiveDocument;

                    labeldoc.Variables.FormVariables.Item("VENDOR").Value = vendor;
                    labeldoc.Variables.FormVariables.Item("DATE").Value   = date;
                    labeldoc.Variables.FormVariables.Item("PN").Value     = pn;
                    labeldoc.Variables.FormVariables.Item("PH").Value     = ph;//批号
                    labeldoc.Variables.FormVariables.Item("DSP").Value    = descrition;
                    labeldoc.Variables.FormVariables.Item("PO").Value     = po;
                    labeldoc.Variables.FormVariables.Item("QTY").Value    = qty;
                    labeldoc.Variables.FormVariables.Item("SN").Value     = sn;
                    labeldoc.Variables.FormVariables.Item("K1").Value     = k1;
                    labeldoc.Variables.FormVariables.Item("K2").Value     = k2;
                    labeldoc.Variables.FormVariables.Item("END").Value    = end;



                    labeldoc.PrintDocument(); //打印一次
                    labeldoc.FormFeed();      //结束打印

                    labeldoc.Close(true);
                    labelapp.Application.Quit();

                    #endregion
                }
                else
                {
                    MessageBox.Show("请先选中要称重的托盘数据!!");
                    return;
                }
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Exemple #15
0
        private void btn_print_Click(object sender, EventArgs e)
        {
            try
            {
                this.label4.Text = "";
                if (!string.IsNullOrEmpty(this.cmb_ph.Text))
                {
                    if (!string.IsNullOrEmpty(this.txt_fh.Text))
                    {
                        #region 简单根据第一码是否是%判断条码扫描是否正确
                        if (!txt_fh.Text.StartsWith("%"))
                        {
                            // MessageBox.Show("条码错误,请确认第一码是否是%");

                            #region 弹窗
                            //Form_Message f = new Form_Message();

                            //f.Show();
                            this.label4.Text = "条码第一码不为%";
                            #endregion

                            txt_fh.SelectAll();
                            return;
                        }

                        #endregion


                        #region  判断条码长度是否不为12码,如果是提示;

                        if (this.txt_fh.Text.Trim().Length != 10)
                        {
                            // MessageBox.Show("条码长度不正确!");
                            this.label4.Text = "条码长度不正确!";
                            // this.btn_print.Enabled = false;
                            FormLogin f = new FormLogin();
                            f.StartPosition = FormStartPosition.CenterScreen;
                            if (f.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                        }

                        #region 比对是否已经打过,已经存在于wps文件中。
                        if (heckisexit(this.txt_fh.Text.Trim().Substring(1).ToString(), this.cmb_ph.Text))
                        {
                            this.label4.Text = "条码重复,已经打印,请联系主管确认!!";

                            FormLogin f = new FormLogin();
                            f.StartPosition = FormStartPosition.CenterScreen;

                            if (f.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                        }
                        #endregion

                        #endregion
                        this.label4.Text = "";
                        #region print
                        LabelManager2.Application labelapp = new LabelManager2.Application(); //创建lppa.exe进程
                        string strPath = System.Windows.Forms.Application.StartupPath + "\\PrinteModel1.lab";


                        labelapp.Documents.Open(strPath, false);
                        LabelManager2.Document labeldoc = labelapp.ActiveDocument;

                        labeldoc.Variables.FormVariables.Item("p1").Value = cmb_ph.Text.Trim();
                        string fh = txt_fh.Text.Trim().Substring(1);
                        labeldoc.Variables.FormVariables.Item("p2").Value = fh;
                        //MessageBox.Show(fh);

                        labeldoc.PrintDocument(); //打印一次
                        labeldoc.FormFeed();      //结束打印

                        labeldoc.Close(true);
                        labelapp.Application.Quit();

                        #endregion

                        #region SaveToCsv
                        SaveDataToCsv();
                        #endregion

                        #region bindgrid

                        //BindGrid();
                        //改为一次只绑定一笔
                        BindDataManu();
                        #endregion

                        #region clear
                        // btn_clear_Click(null, null);
                        #endregion
                        this.txt_fh.Text = "";
                        this.txt_fh.Focus();
                    }
                    else
                    {
                        MessageBox.Show("请扫描番号条码");
                    }
                }
                else
                {
                    MessageBox.Show("请先选择品号!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }