//const string PaperSizeName = "6 x 6";
 //public Int32 GetPaperSize(String sPrinterName, String sPaperSizeName)
 //{
 //    PrintDocument docPrintDoc = new PrintDocument();
 //    docPrintDoc.PrinterSettings.PrinterName = sPrinterName;
 //    for (int i = 0; i < docPrintDoc.PrinterSettings.PaperSizes.Count; i++)
 //    {
 //        int raw = docPrintDoc.PrinterSettings.PaperSizes[i].RawKind;
 //        if (docPrintDoc.PrinterSettings.PaperSizes[i].PaperName == sPaperSizeName)
 //        {
 //            return raw;
 //        }
 //    }
 //    return 0;
 //}
 //private void CrystalReportCustomPaperSize(string ProgramCode, string ReportID, ref ReportDocument Report)
 //{
 //    string PrinterName = null;
 //    string[] PaperSizeList = null;
 //    System.Drawing.Printing.PrinterSettings aPrinterSettings = new System.Drawing.Printing.PrinterSettings();
 //    PrinterName = aPrinterSettings.PrinterName.ToString();
 //    if ((PaperSizeName != null))
 //    {
 //        System.Drawing.Printing.PrintDocument DocToPrint = new System.Drawing.Printing.PrintDocument();
 //        DocToPrint.PrinterSettings.PrinterName = PrinterName;
 //        PaperSizeList = new string[DocToPrint.PrinterSettings.PaperSizes.Count + 1];
 //        for (int i = 0; i <= DocToPrint.PrinterSettings.PaperSizes.Count - 1; i++)
 //        {
 //            int rawKind = 0;
 //            // PaperSizeList(i) = DocToPrint.PrinterSettings.PaperSizes(i).PaperName;
 //            if (DocToPrint.PrinterSettings.PaperSizes[i].PaperName == PaperSizeName)
 //            {
 //                rawKind = Convert.ToInt32(DocToPrint.PrinterSettings.PaperSizes[i].GetType().GetField("kind", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(DocToPrint.PrinterSettings.PaperSizes[i]));
 //                Report.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
 //                CrystalDecisions.Shared.PageMargins Margins = new CrystalDecisions.Shared.PageMargins();
 //                Margins = Report.PrintOptions.PageMargins;
 //                Margins.leftMargin = 0;
 //                Margins.topMargin = 0;
 //                Margins.rightMargin = 0;
 //                Margins.bottomMargin = 0;
 //                //if (LefMargin >= 0)
 //                //    Margins.leftMargin = LefMargin * TWIP;
 //                //if (RightMargin >= 0)
 //                //    Margins.rightMargin = RightMargin * TWIP;
 //                //if (TopMargin >= 0)
 //                //    Margins.topMargin = TopMargin * TWIP;
 //                //if (ButtomMargin >= 0)
 //                //    Margins.bottomMargin = ButtomMargin * TWIP;
 //                //Report.PrintOptions.ApplyPageMargins(Margins);
 //                break; // TODO: might not be correct. Was : Exit For
 //            }
 //        }
 //    }
 //}
 private void BtnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(lblProduct.Text))
         {
             throw new Exception("กรุณาเลือกสินค้า!");
         }
         var frm = new Form_Barcode
         {
             ProductCode = productIssued.product_code
         };
         frm.ShowDialog();
     }
     catch (Exception ex)
     {
         DisplayNotification("Error", ex.Message, Color.Red);
     }
 }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(lblReceiveNo.Text))
         {
             throw new Exception("กรุณาเลือกข้อมูล");
         }
         var frmBarcode = new Form_Barcode
         {
             ReceiveNo       = lblReceiveNo.Text,
             CoreProductCode = "04001"
         };
         frmBarcode.ShowDialog();
     }
     catch (Exception ex)
     {
         var toastNotification = new Notification("Error", ex.Message, 2, Color.Red, animationMethod, animationDirection);
         toastNotification.Show();
     }
 }
Пример #3
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(lblReceiveNo.Text))
         {
             throw new Exception("กรุณาเลือกข้อมูล");
         }
         var frmBarcode = new Form_Barcode
         {
             ReceiveNo       = lblReceiveNo.Text,
             ProductCode     = "",
             CoreProductCode = CoreProductCode
         };
         frmBarcode.ShowDialog();
         LoadProductByProductGroup();
     }
     catch (Exception ex)
     {
         DisplayNotification("Error", ex.Message, Color.Red);
     }
 }