コード例 #1
0
ファイル: BarcodeWindow.xaml.cs プロジェクト: laensil/cmc
        private void btnPrintBarcode_Click(object sender, System.EventArgs e)
        {
            //myDymoAddin = new DymoAddIn();
            //myLabel = new DymoLabels();
            IPrinter printer = Framework.GetPrinters()[cboPrinterName.Text];

            if (printer is ILabelWriterPrinter)
            {
                ////_label.SetObjectText("BARCODE_TEST", "54321");
                //ILabelWriterPrintParams printParams = null;
                //ILabelWriterPrinter labelWriterPrinter = printer as ILabelWriterPrinter;
                //_label.Print(printer, printParams);
            }
            else
            {
                _label.Print(printer); // print with default params
            }
            myDymoAddin = new DymoAddIn();
            myLabel     = new DymoLabels();
            if (myDymoAddin.Open(@"C:\Users\Aaron\Documents\DYMO Label\Labels\SmallNameBadgeTest.label"))
            {
                myLabel.SetField("lblPrice", _test);
                myDymoAddin.StartPrintJob();
                myDymoAddin.Print(1, false);
                myDymoAddin.EndPrintJob();
            }
        }
コード例 #2
0
        //private void txtBoughtPrice_TextChanged(object sender, TextChangedEventArgs e)
        //{
        //    int errorCounter = 0;
        //    errorCounter = Regex.Matches(txtBoughtPrice.Text, @"[a-zA-Z]").Count;
        //    if (errorCounter > 0)
        //    {
        //        MessageBox.Show("Bought Price cannot contain characters. Please try again");
        //        txtBoughtPrice.Text = txtBoughtPrice.Text.Substring(0, txtBoughtPrice.Text.Length - 1);
        //    }
        //}

        //private void txtContactNum_TextChanged(object sender, TextChangedEventArgs e)
        //{
        //    int errorCounter = 0;
        //    errorCounter = Regex.Matches(txtContactNum.Text, @"[a-zA-Z]").Count;
        //    if (errorCounter > 0)
        //    {
        //        MessageBox.Show("Contact Number cannot contain characters. Please try again");
        //        txtContactNum.Text = txtContactNum.Text.Substring(0, txtContactNum.Text.Length - 1);
        //    }
        //}
        #endregion

        #region Barcode Button
        private void btnBarcode_Click(object sender, RoutedEventArgs e)
        {
            //Switcher.Switch(new BarcodeWindow());



            myDymoAddin = new DymoAddIn();
            myLabel     = new DymoLabels();

            try
            {
                if (myDymoAddin.Open(@"C:\Labels\SaleSmall.label"))
                {
                    if ((txtBrand.Text.ToString().Equals(null) || txtBrand.Text.ToString().Equals("")) ||
                        //(txtModel.Text.ToString().Equals(null) || txtModel.Text.ToString().Equals("")) ||
                        (txtSaleDate.Text.ToString().Equals(null) || txtSaleDate.Text.ToString().Equals("")) ||
                        (txtNetwork.Text.ToString().Equals(null) || txtNetwork.Text.ToString().Equals("")) ||
                        (txtDisplayPrice.Text.ToString().Equals(null) || txtDisplayPrice.Text.ToString().Equals("")))
                    {
                        MessageBox.Show("Sale Date, Brand, Model, Network or DisplayPrice is empty");
                    }
                    else
                    {
                        if (!listOfIDs.Contains(txtSaleDate.Text))
                        {
                            btnSaveSaleForm_Click(this, new RoutedEventArgs());
                        }
                        else
                        {
                            MessageBox.Show("Barcode has printed and Item already has been saved");
                        }

                        string combine = txtBrand.Text;// +" " + txtModel.Text;
                        string combineAddDetailsNetwork = txtAdditionalNotice.Text + "  " + txtNetwork.Text;

                        //open the connection
                        if (myConn.State != System.Data.ConnectionState.Open)
                        {
                            myConn.Open();
                        }

                        //define the command reference
                        MySqlCommand mySQLcommand = new MySqlCommand();

                        //define the connection used by the command object
                        mySQLcommand.Connection = myConn;

                        ////define the command text
                        mySQLcommand.CommandText = "SELECT * FROM cmc_repairs_stock WHERE date_sold=@date_sold";

                        DateTime mydate = DateTime.Now;

                        //add values provided by user

                        if (txtSaleDate.Text.Equals(null) || txtSaleDate.Text.Equals(""))
                        {
                            MessageBox.Show("This cannot be null");
                        }
                        else
                        {
                            mySQLcommand.Parameters.AddWithValue("@date_sold", txtSaleDate.Text);
                        }

                        //mySQLcommand.ExecuteNonQuery();
                        MySqlDataReader mySQLDataReader;
                        mySQLDataReader = mySQLcommand.ExecuteReader();

                        while (mySQLDataReader.Read())
                        {
                            id = mySQLDataReader.GetString("id");
                        }

                        //close the connection
                        myConn.Close();

                        myLabel.SetField("lblBrand", combine.ToString());
                        myLabel.SetField("lblSaleDate", txtSaleDate.Text);
                        myLabel.SetField("lbl_ID", id.ToString());
                        myLabel.SetField("lblNetwork", combineAddDetailsNetwork.ToString());
                        myLabel.SetField("lblPrice", "£" + txtDisplayPrice.Text);
                        myDymoAddin.StartPrintJob();
                        myDymoAddin.Print(1, false);
                        myDymoAddin.EndPrintJob();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There is an error with the label, please check all fields and try again.");
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: Whazor/SocialA12
 private void print(Enrollment enrollment)
 {
     var oldtitle = window.Title;
       window.Title = oldtitle + " (printing...)";
       var printjob = new DymoAddIn();
       var label = new DymoLabels();
       if (printjob.Open(@"Person.LWL"))
       {
     label.SetField("Name", enrollment.FullName);
     label.SetField("School", enrollment.School);
     printjob.StartPrintJob();
     printjob.Print(1, false);
     printjob.EndPrintJob();
     window.Title = oldtitle;
       }
 }
コード例 #4
0
        public void Print(IList<string> indirizzi, string labelType, string printer, int? tray)
        {
            try
            {
                if (IsPrinterInstalled())
                {
                    var dymoAddin = new DymoAddIn();
                    var label = new DymoLabels();

                    byte[] labelLayout = null;

                    if (string.IsNullOrEmpty(labelType))
                        labelType = GetTipoEtichetta();

                    switch (labelType)
                    {
                        case "Address":
                            labelLayout = StampaEtichetteDymoResources.Indirizzo_28x89;
                            break;
                        case "ReturnAddressInt":
                            labelLayout = StampaEtichetteDymoResources.Indirizzo_mittente_25x54;
                            break;
                        case "LargeAddress":
                            labelLayout = StampaEtichetteDymoResources.Indirizzo_grande_36x89;
                            break;
                        case "ArchiviazioneOttica":
                            labelLayout = StampaEtichetteDymoResources.ArchiviazioneOttica_25x54;
                            break;
                    }

                    if (labelLayout != null)
                    {
                        var doc = new DocumentInfo { Body = labelLayout, FileName = "sfera.label" };
                        var tempFolder = _manageDocumentService.GetTempFolder(doc, null);
                        if (!string.IsNullOrEmpty(tempFolder))
                        {
                            doc.FileName = tempFolder;
                            var fileName = _manageDocumentService.Save(doc);
                            if (dymoAddin.Open(fileName))
                            {
                                dymoAddin.SelectPrinter(printer);
                                dymoAddin.StartPrintJob();

                                foreach (var indirizzo in indirizzi)
                                {
                                    label.SetField("TESTO", indirizzo);
                                    if(tray == null)
                                        dymoAddin.Print(1, false);
                                    else
                                        dymoAddin.Print2(1, false, tray.Value);
                                }
                                dymoAddin.EndPrintJob();
                            }
                        }
                    }
                    else
                    {
                        _log.WarnFormat("Tipo di etichetta Dymo non riconosciuta - {0} - layout:{1} - printer:{2}", Utility.GetMethodDescription(), labelType, printer);
                    }
                }
            }
            catch (COMException ex)
            {
                _log.ErrorFormat("Richiesto elenco stampante Dymo per sistema su cui il software Dymo non è installato - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Errore inaspettato nella stampa delle etichette Dymo - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda);
                throw;
            }
        }