Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _myReport = new CrystalReport1();

            //_myReport.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;

            if (string.IsNullOrEmpty(Settings.Default.PaperOrientation))
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (Settings.Default.PaperOrientation.ToString() == "DefaultPaperOrientation")
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (Settings.Default.PaperOrientation.ToString() == "Portrait")
            {
                comboBox1.SelectedIndex = 1;
            }
            else if (Settings.Default.PaperOrientation.ToString() == "Landscape")
            {
                comboBox1.SelectedIndex = 2;
            }

            //더미로 해 놓아야 Manual로 입력한 것을 Export할 수 있다.
            CartonDataSet ds = new CartonDataSet();

            ds.Tables[0].Columns.Remove("ProdCodeBarCode");
            //ds.Tables[0].Columns.Remove("MCIDImage");
            this.dataGridView1.DataSource = ds.Tables[0];

            //Printer 기본설정
            if (string.IsNullOrEmpty(Settings.Default.PrinterName))               //프로그램에서의 기본 프린터
            {
                Settings.Default.PrinterName = new PrinterSettings().PrinterName; //작업 컴퓨터의 Default 프린터로 출력하게 한다.
            }

            PrinterSingleton.Instance.PrinterName = Settings.Default.PrinterName;
            PrinterName(PrinterSingleton.Instance.PrinterName);

            //this.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Version myVersion;

            myVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
            this.Text = myVersion.Major.ToString() + "." + myVersion.Minor + "." + myVersion.Build + "," + myVersion.Revision;
        }
Exemple #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            CartonDataSet cartonDataSet = new CartonDataSet();
            DataTable     dt            = new DataTable();
            DataRow       dr;
            string        mcid = string.Empty;

            BarcodeLibSingleton.Instance.Barcode.IncludeLabel = false;
            BarcodeLibSingleton.Instance.Barcode.ImageFormat  = System.Drawing.Imaging.ImageFormat.Bmp;

            printerSettings.PrinterName = PrinterSingleton.Instance.PrinterName;

            System.Drawing.Printing.PageSettings pageSettings = new System.Drawing.Printing.PageSettings(printerSettings);
            //pageSettings.Landscape = true; //작동 안함...차이 없음.....

            PrintLayout.FitHorizontalPages = true;
            PrintLayout.Scaling            = PrintLayoutSettings.PrintScaling.DoNotScale;
            PrintLayout.Centered           = true;


            foreach (DataGridViewRow Rows in this.dataGridView1.Rows)
            {
                if (Rows.Cells["Print"].Value != null)
                {
                    if (Rows.Cells["Print"].Value.ToString() == "True")
                    {
                        if (Rows.Cells["ProdCode"].Value != null)
                        {
                            dr = cartonDataSet.Tables[0].NewRow();

                            dr["ProdName"]        = string.IsNullOrEmpty(Rows.Cells["ProdName"].Value.ToString()) ? string.Empty : Rows.Cells["ProdName"].Value.ToString().Trim();
                            dr["SubCode"]         = string.IsNullOrEmpty(Rows.Cells["SubCode"].Value.ToString()) ? string.Empty : Rows.Cells["SubCode"].Value.ToString().Trim();
                            dr["ProdColor"]       = string.IsNullOrEmpty(Rows.Cells["ProdColor"].Value.ToString()) ? string.Empty : Rows.Cells["ProdColor"].Value.ToString().Trim();
                            dr["Price"]           = string.IsNullOrEmpty(Rows.Cells["Price"].Value.ToString()) ? string.Empty : Rows.Cells["Price"].Value.ToString().Trim();
                            dr["Price2"]          = string.IsNullOrEmpty(Rows.Cells["Price2"].Value.ToString()) ? string.Empty : Rows.Cells["Price2"].Value.ToString().Trim();
                            dr["ProdCode"]        = string.IsNullOrEmpty(Rows.Cells["ProdCode"].Value.ToString()) ? string.Empty : Rows.Cells["ProdCode"].Value.ToString().Trim();
                            dr["SizeType"]        = string.IsNullOrEmpty(Rows.Cells["SizeType"].Value.ToString()) ? string.Empty : Rows.Cells["SizeType"].Value.ToString().Trim();
                            dr["CountryOfOrigin"] = string.IsNullOrEmpty(Rows.Cells["CountryOfOrigin"].Value.ToString()) ? string.Empty : Rows.Cells["CountryOfOrigin"].Value.ToString().Trim();

                            mcid = string.IsNullOrEmpty(Rows.Cells["ProdCode"].Value.ToString()) ? string.Empty : Rows.Cells["ProdCode"].Value.ToString().Trim();

                            if (string.IsNullOrEmpty(mcid))
                            {
                                dr["ProdCodeBarCode"] = null;
                            }
                            else
                            {
                                BarcodeLibSingleton.Instance.Barcode.Encode(BarcodeLib.TYPE.CODE128, mcid, 800, 100);
                                dr["ProdCodeBarCode"] = string.IsNullOrEmpty(mcid) ? null : BarcodeLibSingleton.Instance.Barcode.Encoded_Image_Bytes;
                            }

                            cartonDataSet.Tables[0].Rows.Add(dr);
                        }
                    }
                }
            }

            PrintOptions printOptions = this._myReport.PrintOptions;

            printOptions.DissociatePageSizeAndPrinterPaperSize = false;

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                printOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation;
                break;

            case 1:
                printOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
                break;

            case 2:
                printOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                break;
            }

            //printOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;

            _myReport.SetDataSource(cartonDataSet);
            this._myReport.PrintToPrinter(printerSettings, pageSettings, false, PrintLayout);
            //this._myReport.PrintToPrinter(1, false, 0, 0);
        }