예제 #1
0
        private void btnBGen_Click(object sender, EventArgs e)
        {
            try
            {
                int[]       selRows   = ((GridView)grdPOrders.MainView).GetSelectedRows();
                DataRowView oPOrderID = (DataRowView)(((GridView)grdPOrders.MainView).GetRow(selRows[0]));
                int         nPOrderID = Convert.ToInt32(oPOrderID["POrderID"]);


                if (nPOrderID <= 0)
                {
                    MessageBox.Show("select an item for BC Generate", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                POrder oPOr = null;
                if (nPOrderID > 0)
                {
                    oPOr = db.POrders.FirstOrDefault(po => po.POrderID == nPOrderID);
                }

                PrintInvoice oPInovice = new PrintInvoice();
                if (oPOr != null)
                {
                    oPInovice.PrintBarcode(oPOr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void btnCreateInvoice_Click(object sender, EventArgs e)
        {
            if (!ValidateFields() || !stbFeePercent.Validate())
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName   = "faktura-sag-" + cCase.Id + ".txt";
            sfd.Filter     = "Text File | *.txt";
            sfd.DefaultExt = "txt";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                double feePercent = Convert.ToDouble(stbFeePercent.Text) / 100;
                double fee        = Convert.ToInt64(stbSellingPrice.Text) * feePercent;

                CaseController.Instance.SaveActiveCase();

                StreamWriter writer = new StreamWriter(sfd.OpenFile());
                writer.Write(PrintInvoice.CreatePrintInvoice(cCase, CaseController.Instance.GetDocuments(), fee));
                writer.Close();
                Process.Start(sfd.FileName);

                baseView.NextStep();
            }
        }
예제 #3
0
        private void btnPOS_Click(object sender, EventArgs e)
        {
            try
            {
                int[]       selRows   = ((GridView)grdOrders.MainView).GetSelectedRows();
                DataRowView oOrderID  = (DataRowView)((GridView)grdOrders.MainView).GetRow(selRows[0]);
                int         nOrdersID = Convert.ToInt32(oOrderID["OrderID"]);

                if (nOrdersID <= 0)
                {
                    MessageBox.Show("Select an item to generate invoice ", "item yet not selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (nOrdersID > 0)
                {
                    _Order = db.SOrders.FirstOrDefault(s => s.SOrderID == nOrdersID);
                }

                if (_Order == null)
                {
                    MessageBox.Show("select an item to generate invoice", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                PrintInvoice oPriInvoice = new PrintInvoice();
                oPriInvoice.print(_Order);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Cannot generate invoice due to " + Ex.Message);
            }
        }
예제 #4
0
파일: Normal.cs 프로젝트: mercaditu/ERP
        public Normal(object Document, app_document_range app_range, PrintStyles PrintStyle)
        {
            if (app_range.app_document != null ? app_range.app_document.style_reciept : false || app_range.app_document != null ? app_range.app_document.id_application == App.Names.PointOfSale:false)
            {
                TicketPrint.Document_Print(app_range.app_document.id_document, Document);
            }
            else
            {
                string DocumentName = string.Empty;
                if (app_range != null)
                {
                    DocumentName = app_range.app_document.name;
                }
                else
                {
                    DocumentName = "PurchaseInvoice";
                }

                string PathFull = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CogntivoERP\\TemplateFiles\\" + app_range.app_document.name + ".rdlc";


                if (Directory.Exists(PathFull) == false)
                {
                    CreateFile(app_range);
                }

                DataSource DataSource = new DataSource();

                ///
                if (PrintStyle == PrintStyles.Automatic && !app_range.use_default_printer && app_range.printer_name != null)
                {
                    LocalReport  LocalReport  = new LocalReport();
                    PrintInvoice PrintInvoice = new PrintInvoice();
                    LocalReport.ReportPath = PathFull; // Path of the rdlc file
                    LocalReport.DataSources.Add(DataSource.Create(Document));
                    PrintInvoice.Export(LocalReport);
                    PrintInvoice.Print(app_range.printer_name);
                }
                else
                {
                    DocumentViewr DocumentViewr = new DocumentViewr();
                    DocumentViewr.reportViewer.LocalReport.ReportPath = PathFull; // Path of the rdlc file
                    DocumentViewr.reportViewer.LocalReport.DataSources.Add(DataSource.Create(Document));
                    DocumentViewr.reportViewer.RefreshReport();

                    Window window = new Window
                    {
                        Title   = "Report",
                        Content = DocumentViewr
                    };

                    window.ShowDialog();
                }
            }
        }
예제 #5
0
        public void should_call_PrintInvoice()
        {
            //arrange
            var request = new PrintInvoice();
            //act
            var actual = Sut.PrintInvoice(TakeInvoice(), request);

            //assert
            Assert.AreEqual(200, actual.Code);
            Assert.IsEmpty(actual.Message);
            Assert.AreEqual("OK", actual.Status);
        }
 /// <summary>
 /// Print & mail an invoice
 /// details: https://developer.chargeover.com/apidocs/rest/#print-an-invoice
 /// </summary>
 public ICustomResponse <bool> PrintInvoice(int invoiceId, PrintInvoice request)
 {
     return(GetCustomBool($"/invoice/{invoiceId}?action=print", request));
 }
예제 #7
0
        static void Main(string[] args)
        {
            PrintInvoice printInvoice = new PrintInvoice(new Invoice(1, "invoice2", 120, 23.1f, .18f));

            printInvoice.Print();
        }
예제 #8
0
        private void createInvoice()
        {
            try
            {
                string mucDichID = "";
                string mucDichSD = "";
                if (poorRadioButton.Checked)
                {
                    mucDichID = "a770acf2-0f54-43ce-8695-10c7c4072c64";
                    mucDichSD = "Hộ nghèo";
                }
                else if (lowIncomeRadioButton.Checked)
                {
                    mucDichID = "7e17ce3d-ea0c-4a6a-9048-47c563991fd6";
                    mucDichSD = "Hộ thu nhập thấp";
                }
                else if (sinhHoatRadioButton.Checked)
                {
                    mucDichID = "e00f133e-f43c-4dc5-8ebb-a747200416c9";
                    mucDichSD = "Sinh hoạt";
                }
                else if (hanhChinhRadioButton.Checked)
                {
                    mucDichID = "068b5479-814c-4576-86ea-8684b07ffb4a";
                    mucDichSD = "Hành chính";
                }
                else if (kinhDoanh1RadioButton.Checked)
                {
                    mucDichID = "0cd8fc10-1369-4b21-9c59-806ada969bdb";
                    mucDichSD = "Kinh doanh 1";
                }
                else if (kinhDoanh2RadioButton.Checked)
                {
                    mucDichID = "3f4627cb-3ae3-4fcf-86e1-117b1dfcac4d";
                    mucDichSD = "Kinh doanh 2";
                }
                else if (sanXuat1RadioButton.Checked)
                {
                    mucDichID = "a8794644-b056-41dd-b515-bec60477947a";
                    mucDichSD = "Sản xuất 1";
                }
                else if (sanXuat2RadioButton.Checked)
                {
                    mucDichID = "d4770373-51bb-4d7a-90d1-327c7043cdeb";
                    mucDichSD = "Sản xuất 2";
                }
                else if (sanXuat3RadioButton.Checked)
                {
                    mucDichID = "422cf080-b750-411d-a895-9550b8950b66";
                    mucDichSD = "Sản xuất 3";
                }
                Customer kh = new Customer(soThuTuComboBox.SelectedValue.ToString(), tenKhachTextBox.Text, diaChiTextBox.Text, soHoKhauTextBox.Text, maSoThueTextBox.Text);
                if (!kh.edit())
                {
                    MessageBox.Show("Việc thay đổi thông tin của khách hàng đã thất bại!\nBạn hãy thử thay đổi thông tin khách hàng trong form khách hàng rồi quay lại làm lại hóa đơn.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    Invoice hoaDon;
                    if (congToChetCheckBox.Checked == true)
                    {
                        hoaDon = new Invoice(soThuTuComboBox.SelectedValue.ToString(), mucDichID, int.Parse(thangComboBox.Text), int.Parse(namComboBox.Text), int.Parse(soCuTextBox.Text), int.Parse(soMoiTextBox.Text), int.Parse(soCu2TextBox.Text), int.Parse(soMoi2TextBox.Text), int.Parse(heSoNhanTextBox.Text), int.Parse(noCuTextBox.Text), 0);
                    }
                    else
                    {
                        hoaDon = new Invoice(soThuTuComboBox.SelectedValue.ToString(), mucDichID, int.Parse(thangComboBox.Text), int.Parse(namComboBox.Text), int.Parse(soCuTextBox.Text), int.Parse(soMoiTextBox.Text), 0, 0, int.Parse(heSoNhanTextBox.Text), int.Parse(noCuTextBox.Text), 0);
                    }
                    Program.calculateInvoice(tramComboBox.Text.Split(' '), hoaDon.NewNumber, hoaDon.OldNumber, hoaDon.NewNumber2, hoaDon.OldNumber2, hoaDon.Multiplier, poorRadioButton.Checked, giaPoorLabel.Text, lowIncomeRadioButton.Checked, giaLowIncome.Text, sinhHoatRadioButton.Checked, DataTier.getPrice("e00f133e-f43c-4dc5-8ebb-a747200416c9").Split(','), hanhChinhRadioButton.Checked, giaHCLabel.Text, kinhDoanh1RadioButton.Checked, giaKD1Label.Text, kinhDoanh2RadioButton.Checked, giaKD2Label.Text, sanXuat1RadioButton.Checked, giaSX1Label.Text, sanXuat2RadioButton.Checked, giaSX2Label.Text, sanXuat3RadioButton.Checked, giaSX3Label.Text, thangComboBox.Text, namComboBox.Text, int.Parse(noCuTextBox.Text));
                    string title = "Hóa đơn của khách hàng số " + soThuTuComboBox.Text + ", " + tramComboBox.Text + ", tháng " + thangComboBox.Text + ", năm " + namComboBox.Text + ", mục đích " + mucDichSD;
                    if (mucDichSD == "Sinh hoạt")
                    {
                        Program.fillKetQuaSH(ketQuaSH);
                        ketQuaSH.Text = title;
                        dialogResult  = ketQuaSH.ShowDialog();
                    }
                    else if (mucDichSD == "Sản xuất 3")
                    {
                        ketQuaSX3Form.mucDichSD = mucDichSD;
                        Program.fillKetQuaSX3(ketQuaSX3);
                        ketQuaSX3.Text = title;
                        dialogResult   = ketQuaSX3.ShowDialog();
                    }
                    else
                    {
                        ketQuaMDKForm.mucDichSD = mucDichSD;
                        Program.fillKetQuaMDK(ketQuaMDK);
                        if (mucDichSD == "Hộ nghèo" || mucDichSD == "Hộ thu nhập thấp")
                        {
                            title = "Hóa đơn của khách hàng số " + soThuTuComboBox.Text + ", " + tramComboBox.Text + ", tháng " + thangComboBox.Text + ", năm " + namComboBox.Text + " (" + mucDichSD + ")";
                        }
                        ketQuaMDK.Text = title;
                        dialogResult   = ketQuaMDK.ShowDialog();
                    }
                    if (dialogResult == DialogResult.OK)
                    {
                        if (hoaDon.createHoaDon())
                        {
                            var         isOldInvoice = Program.isUsingOldInvoice();
                            ReportClass invoice      = null;

                            if (sanXuat3RadioButton.Checked)
                            {
                                if (isOldInvoice)
                                {
                                    invoice = new PrintInvoiceSX3();
                                    invoice.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;
                                    invoice.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
                                }
                                else
                                {
                                    invoice = new PrintInvoiceSX3_201609();
                                    invoice.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA5;
                                    invoice.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                                }

                                Program.setSX3InvoiceParams(hoaDon.getHoaDonID(), invoice);

                                try
                                {
                                    if (mayInCheckBox.Checked)
                                    {
                                        invoice.PrintToPrinter(1, false, 1, 1);
                                        //MessageBox.Show("Hóa đơn đã được in.", "In hóa đơn thành công", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                    }

                                    if (vanBanCheckBox.Checked)
                                    {
                                        string invoiceName = "HD Số thứ tự " + soThuTuComboBox.Text + " - " + tramComboBox.Text + " - Tháng " + thangComboBox.Text + " - Năm " + namComboBox.Text + ".doc";
                                        invoice.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, pathTextBox.Text + "\\" + invoiceName);
                                        //MessageBox.Show("Hóa đơn đã được xuất ra thư mục \"" + pathTextBox.Text + "\" \nvà có tên là \"" + invoiceName + "\"", "Xuất hóa đơn thành công", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("Xuất hóa đơn thất bại: " + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                                }

                                invoice.Dispose();
                            }
                            else
                            {
                                if (isOldInvoice)
                                {
                                    invoice = new PrintInvoice();
                                    invoice.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;
                                    invoice.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
                                }
                                else
                                {
                                    invoice = new PrintInvoice_201609();
                                    invoice.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA5;
                                    invoice.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                                }

                                Program.setInvoiceParams(hoaDon.getHoaDonID(), invoice);

                                try
                                {
                                    if (mayInCheckBox.Checked)
                                    {
                                        invoice.PrintToPrinter(1, false, 1, 1);
                                        //MessageBox.Show("Hóa đơn đã được in.", "In hóa đơn thành công", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                    }

                                    if (vanBanCheckBox.Checked)
                                    {
                                        string invoiceName = "HD Số thứ tự " + soThuTuComboBox.Text + " - " + tramComboBox.Text + " - Tháng " + thangComboBox.Text + " - Năm " + namComboBox.Text + ".doc";
                                        invoice.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, pathTextBox.Text + "\\" + invoiceName);
                                        //MessageBox.Show("Hóa đơn đã được xuất ra thư mục \"" + pathTextBox.Text + "\" \nvà có tên là \"" + invoiceName + "\"", "Xuất hóa đơn thành công", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("Xuất hóa đơn thất bại: " + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                                }

                                invoice.Dispose();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Xuất hóa đơn thất bại! Bạn hãy thử nhập lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Xuất hóa đơn thất bại! Bạn hãy thử nhập lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                MessageBox.Show(ex.Message);
            }
            clearTextBoxes();
            congToChetCheckBox.Checked = false;
            fillSTTKH();
            soMoiTextBox.Focus();
        }
예제 #9
0
        public void loadSalesReturnReport(int id)
        {
            try
            {
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc
                sales_return sales_return = db.sales_return.Where(x => x.id_sales_return == id).FirstOrDefault();
                List <sales_return_detail> sales_return_detail = db.sales_return_detail.Where(x => x.id_sales_return == sales_return.id_sales_return).ToList();

                reportDataSource.Value = sales_return_detail
                                         .Select(g => new
                {
                    id_sales_return        = g.id_sales_return,
                    id_sales_return_detail = g.id_sales_return_detail,
                    sales_return           = g.id_sales_return_detail,
                    id_company             = g.id_company,
                    add1             = g.sales_return.contact.address,
                    telephone        = g.sales_return.contact.telephone,
                    email            = g.sales_return.contact.email,
                    company_name     = g.app_company.name,
                    item_code        = g.item.code,
                    item_description = g.item.name,
                    Description      = g.item.item_brand != null ? g.item.item_brand.name : "",
                    quantity         = g.quantity,
                    sub_Total        = g.SubTotal,
                    sub_Total_vat    = g.SubTotal_Vat,
                    unit_cost        = g.unit_cost,
                    unit_price       = g.unit_cost,
                    unit_price_vat   = g.UnitPrice_Vat,
                    terminale_name   = g.sales_return.app_terminal.name,
                    code             = g.sales_return.code,
                    contact_name     = g.sales_return.contact.name,
                    trans_date       = g.sales_return.trans_date,
                    id_vat_group     = g.id_vat_group,
                    gov_id           = g.sales_return.contact.gov_code,
                    Number           = g.sales_return.number,
                }).ToList();

                string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                path = path + "\\CogntivoERP";
                string SubFolder = "";
                SubFolder = "\\TemplateFiles";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Return.rdlc", path + SubFolder + "\\Sales_Return.rdlc");
                }
                else if (!Directory.Exists(path + SubFolder))
                {
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Return.rdlc", path + SubFolder + "\\Sales_Return.rdlc");
                }
                else if (!File.Exists(path + SubFolder + "\\Sales_Return.rdlc"))
                {
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Return.rdlc", path + SubFolder + "\\Sales_Return.rdlc");
                }
                if (!sales_return.app_document_range.use_default_printer)
                {
                    reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Return.rdlc"; // Path of the rdlc file
                    reportViewer.LocalReport.DataSources.Add(reportDataSource);
                    reportViewer.RefreshReport();
                }
                else
                {
                    try
                    {
                        if (sales_return.app_document_range.printer_name != null)
                        {
                            LocalReport  report       = new LocalReport();
                            PrintInvoice PrintInvoice = new PrintInvoice();
                            report.ReportPath = path + SubFolder + "\\Sales_Return.rdlc"; // Path of the rdlc file
                            report.DataSources.Add(reportDataSource);
                            PrintInvoice.Export(report);
                            PrintInvoice.Print(sales_return.app_document_range.printer_name);
                        }
                        else
                        {
                            NotSupportedException ex = new NotSupportedException();
                            throw ex;
                        }
                    }
                    catch
                    {
                        reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Return.rdlc"; // Path of the rdlc file
                        reportViewer.LocalReport.DataSources.Add(reportDataSource);
                        reportViewer.RefreshReport();
                        Window window = new Window
                        {
                            Title   = "Report",
                            Content = this
                        };

                        window.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        public void loadSalesInvoiceReport(int id)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = path + "\\CogntivoERP";
            string SubFolder = "";

            SubFolder = "\\TemplateFiles";
            ReportDataSource reportDataSource = new ReportDataSource();

            try
            {
                reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc
                //find the all sales invoice Detail
                List <sales_invoice_detail> sales_invoice_detail = db.sales_invoice_detail.Where(x => x.id_sales_invoice == id).ToList();
                reportDataSource.Value = sales_invoice_detail
                                         .Select(g => new
                {
                    //id_sales_invoice = g.id_sales_invoice,
                    //id_sales_invoice_detail = g.id_sales_invoice_detail,
                    sales_invoice           = g.id_sales_invoice,
                    id_company              = g.id_company,
                    add1                    = g.sales_invoice.contact.address,
                    telephone               = g.sales_invoice.contact.telephone,
                    email                   = g.sales_invoice.contact.email,
                    company_name            = g.app_company.name,
                    item_code               = g.item.code,
                    item_description        = g.item.name,
                    Description             = g.item.item_brand != null ? g.item.item_brand.name : "",
                    quantity                = g.quantity,
                    sub_Total               = g.SubTotal,
                    sub_Total_vat           = g.SubTotal_Vat,
                    unit_cost               = g.unit_cost,
                    unit_price              = g.unit_price,
                    unit_price_vat          = g.UnitPrice_Vat,
                    terminal_name           = g.sales_invoice.app_terminal.name,
                    code                    = g.sales_invoice.code,
                    customer_contact_name   = g.sales_invoice.contact.name,
                    customer_code           = g.sales_invoice.contact.code,
                    customer_alias          = g.sales_invoice.contact.alias,
                    project_name            = g.sales_invoice.project != null ? g.sales_invoice.project.name : "",
                    sales_invoice_rep_name  = g.sales_invoice.sales_rep != null ? g.sales_invoice.sales_rep.name : "",
                    trans_date              = g.sales_invoice.trans_date,
                    id_vat_group            = g.id_vat_group,
                    gov_id                  = g.sales_invoice.contact.gov_code,
                    sales_invoice_contract  = g.sales_invoice.app_contract.name,
                    sales_invoice_condition = g.sales_invoice.app_contract.app_condition.name,
                    sales_number            = g.sales_invoice.number,
                    sales_invoice_Comment   = g.sales_invoice.comment
                }).ToList();

                //copy report to the template folder
                path      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                path      = path + "\\CogntivoERP";
                SubFolder = "";
                SubFolder = "\\TemplateFiles";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "Sales_Invoice.rdlc", path + SubFolder + "\\Sales_Invoice.rdlc");
                }
                else if (!Directory.Exists(path + SubFolder))
                {
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "Sales_Invoice.rdlc", path + SubFolder + "\\Sales_Invoice.rdlc");
                }
                else if (!File.Exists(path + SubFolder + "\\Sales_Invoice.rdlc"))
                {
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "Sales_Invoice.rdlc", path + SubFolder + "\\Sales_Invoice.rdlc");
                }


                //print report as per the use_default_printer
                if (!sales_invoice_detail.FirstOrDefault().sales_invoice.app_document_range.use_default_printer)
                {
                    reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Invoice.rdlc"; // Path of the rdlc file
                    reportViewer.LocalReport.DataSources.Add(reportDataSource);
                    reportViewer.RefreshReport();
                }
                else
                {
                    try
                    {
                        if (sales_invoice_detail.FirstOrDefault().sales_invoice.app_document_range.printer_name != null)
                        {
                            LocalReport  report       = new LocalReport();
                            PrintInvoice PrintInvoice = new PrintInvoice();
                            report.ReportPath = path + SubFolder + "\\Sales_Invoice.rdlc"; // Path of the rdlc file
                            report.DataSources.Add(reportDataSource);
                            PrintInvoice.Export(report);
                            PrintInvoice.Print(sales_invoice_detail.FirstOrDefault().sales_invoice.app_document_range.printer_name);
                        }
                        else
                        {
                            NotSupportedException ex = new NotSupportedException();
                            throw ex;
                        }
                    }
                    catch
                    {
                        reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Invoice.rdlc"; // Path of the rdlc file
                        reportViewer.LocalReport.DataSources.Add(reportDataSource);
                        reportViewer.RefreshReport();
                        Window window = new Window
                        {
                            Title   = "Report",
                            Content = this
                        };

                        window.ShowDialog();
                    }
                }
            }
            catch
            {
                reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Invoice.rdlc"; // Path of the rdlc file
                reportViewer.LocalReport.DataSources.Add(reportDataSource);
                reportViewer.RefreshReport();
                Window window = new Window
                {
                    Title   = "Report",
                    Content = this
                };

                window.ShowDialog();
            }
        }
예제 #11
0
        public void loadSalesPackingList(int id)
        {
            try
            {
                ReportDataSource reportDataSource = new ReportDataSource();
                reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc
                sales_packing sales_packing = db.sales_packing.Where(x => x.id_sales_packing == id).FirstOrDefault();
                List <sales_packing_detail> sales_packing_detail = db.sales_packing_detail.Where(x => x.id_sales_packing == sales_packing.id_sales_packing).ToList();

                reportDataSource.Value = sales_packing_detail
                                         .Select(g => new
                {
                    contact_name        = g.sales_packing.contact.name,
                    customer_address    = g.sales_packing.contact.address,
                    customer_telephone  = g.sales_packing.contact.telephone,
                    customer_email      = g.sales_packing.contact.email,
                    company_Name        = g.app_company.name,
                    sales_terminal      = g.sales_packing.app_terminal.name,
                    branch_Name         = g.sales_packing.app_branch.name,
                    security_user_name  = g.sales_packing.security_user.name,
                    trans_date          = g.sales_packing.trans_date,
                    sales_order_Comment = g.sales_packing.comment,
                    item_code           = g.item.code,
                    item_description    = g.item.name,
                    item_brand          = g.item.item_brand != null ? g.item.item_brand.name : "",
                    quantity            = g.quantity,
                }).ToList();

                string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                path = path + "\\CogntivoERP";
                string SubFolder = "";
                SubFolder = "\\TemplateFiles";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_PackingList.rdlc", path + SubFolder + "\\Sales_PackingList.rdlc");
                }
                else if (!Directory.Exists(path + SubFolder))
                {
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_PackingList.rdlc", path + SubFolder + "\\Sales_PackingList.rdlc");
                }
                else if (!File.Exists(path + SubFolder + "\\Sales_PackingList.rdlc"))
                {
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_PackingList.rdlc", path + SubFolder + "\\Sales_PackingList.rdlc");
                }

                if (!sales_packing.app_document_range.use_default_printer)
                {
                    reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_PackingList.rdlc"; // Path of the rdlc file
                    reportViewer.LocalReport.DataSources.Add(reportDataSource);
                    reportViewer.RefreshReport();
                }
                else
                {
                    try
                    {
                        if (sales_packing.app_document_range.printer_name != null)
                        {
                            LocalReport  report       = new LocalReport();
                            PrintInvoice PrintInvoice = new PrintInvoice();
                            report.ReportPath = path + SubFolder + "\\Sales_PackingList.rdlc"; // Path of the rdlc file
                            report.DataSources.Add(reportDataSource);
                            PrintInvoice.Export(report);
                            PrintInvoice.Print(sales_packing.app_document_range.printer_name);
                        }
                        else
                        {
                            NotSupportedException ex = new NotSupportedException();
                            throw ex;
                        }
                    }
                    catch
                    {
                        reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_PackingList.rdlc"; // Path of the rdlc file
                        reportViewer.LocalReport.DataSources.Add(reportDataSource);
                        reportViewer.RefreshReport();
                        Window window = new Window
                        {
                            Title   = "Report",
                            Content = this
                        };

                        window.ShowDialog();
                    }
                }
            }
            catch { }
        }
예제 #12
0
        public void loadSalesOrderReport(int id)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = path + "\\CogntivoERP";
            string SubFolder = "";

            SubFolder = "\\TemplateFiles";
            ReportDataSource reportDataSource = new ReportDataSource();

            try
            {
                reportDataSource.Name = "DataSet1"; // Name of the DataSet we set in .rdlc
                sales_order sales_order = db.sales_order.Where(x => x.id_sales_order == id).FirstOrDefault();
                List <sales_order_detail> sales_order_detail = db.sales_order_detail.Where(x => x.id_sales_order == sales_order.id_sales_order).ToList();

                reportDataSource.Value = sales_order_detail
                                         .Select(g => new
                {
                    sales_budget_number        = g.sales_order.sales_budget != null ? g.sales_order.sales_budget.number : "",
                    contact_name               = g.sales_order.contact.name,
                    customer_address           = g.sales_order.contact.address,
                    customer_telephone         = g.sales_order.contact.telephone,
                    customer_email             = g.sales_order.contact.email,
                    company_Name               = g.app_company.name,
                    sales_order_terminal       = g.sales_order.app_terminal.name,
                    branch_Name                = g.sales_order.app_branch.name,
                    order_Code                 = g.sales_order.code,
                    delivery_Date              = g.sales_order.delivery_date,
                    sales_number               = g.sales_order.number,
                    order_Total                = g.sales_order.GrandTotal,
                    project_Name               = g.sales_order.project != null ? g.sales_order.project.name : "",
                    sales_order_representative = g.sales_order.sales_rep != null ? g.sales_order.sales_rep.name : "",
                    security_user_name         = g.sales_order.security_user.name,
                    trans_date                 = g.sales_order.trans_date,
                    sales_order_contract       = g.sales_order.app_contract.name,
                    sales_order_condition      = g.sales_order.app_condition.name,
                    DeliveryDate               = g.sales_order.delivery_date,
                    sales_order_Comment        = g.sales_order.comment,
                    item_code        = g.item.code,
                    item_description = g.item.name,
                    item_brand       = g.item.item_brand != null ? g.item.item_brand.name : "",
                    quantity         = g.quantity,
                    sub_Total        = g.SubTotal,
                    sub_Total_vat    = g.SubTotal_Vat,
                    unit_cost        = g.unit_cost,
                    unit_price       = g.unit_price,
                    unit_price_vat   = g.UnitPrice_Vat,
                }).ToList();


                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Order.rdlc", path + SubFolder + "\\Sales_Order.rdlc");
                }
                else if (!Directory.Exists(path + SubFolder))
                {
                    Directory.CreateDirectory(path + SubFolder);
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Order.rdlc", path + SubFolder + "\\Sales_Order.rdlc");
                }
                else if (!File.Exists(path + SubFolder + "\\Sales_Order.rdlc"))
                {
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + "\\bin\\debug\\Sales_Order.rdlc", path + SubFolder + "\\Sales_Order.rdlc");
                }



                if (!sales_order.app_document_range.use_default_printer)
                {
                    reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Order.rdlc"; // Path of the rdlc file
                    reportViewer.LocalReport.DataSources.Add(reportDataSource);
                    reportViewer.RefreshReport();
                    Window window = new Window
                    {
                        Title   = "Report",
                        Content = this
                    };

                    window.ShowDialog();
                }
                else
                {
                    try
                    {
                        if (sales_order.app_document_range.printer_name != null)
                        {
                            LocalReport  report       = new LocalReport();
                            PrintInvoice PrintInvoice = new PrintInvoice();
                            report.ReportPath = path + SubFolder + "\\Sales_Order.rdlc"; // Path of the rdlc file
                            report.DataSources.Add(reportDataSource);
                            PrintInvoice.Export(report);
                            PrintInvoice.Print(sales_order.app_document_range.printer_name);
                        }
                        else
                        {
                            NotSupportedException ex = new NotSupportedException();
                            throw ex;
                        }
                    }
                    catch
                    {
                        reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Order.rdlc"; // Path of the rdlc file
                        reportViewer.LocalReport.DataSources.Add(reportDataSource);
                        reportViewer.RefreshReport();
                        Window window = new Window
                        {
                            Title   = "Report",
                            Content = this
                        };

                        window.ShowDialog();
                    }
                }
            }
            catch
            {
                reportViewer.LocalReport.ReportPath = path + SubFolder + "\\Sales_Order.rdlc"; // Path of the rdlc file
                reportViewer.LocalReport.DataSources.Add(reportDataSource);
                reportViewer.RefreshReport();
                Window window = new Window
                {
                    Title   = "Report",
                    Content = this
                };

                window.ShowDialog();
            }
        }
예제 #13
0
        public bool CheckedOut(WholeOrPartialCheckoutDto req, bool isLocked)
        {
            bool result = true;

            #region 验证数据
            //_checkOutService.VerifyOrderInfo(req);
            //var checkOutOrderDTO = _checkOutService.GetCheckOutOrderDTO(req.OrderId, req.TableIds);
            //_checkOutService.VerifyAndCalcDetailInfo(req, checkOutOrderDTO);
            #endregion

            var userInfo  = OperatorProvider.Provider.GetCurrent();
            var tableList = _tableRepository.GetlistByIds(req.TableIds);    //获取台号列表
            var model     = new CheckOutPrint()
            {
                OrderType          = isLocked ? "结账单" : "预结单",
                RestaurantName     = req.RestaurantName ?? string.Empty,
                CheckOutUser       = userInfo.UserName,
                OpenUser           = req.OperUserName ?? string.Empty,
                ReserveUser        = string.Empty,
                PrintDate          = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                BillDate           = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                Market             = string.Empty,
                PersonNum          = "0",
                OrderNo            = "",
                TableName          = string.Join(",", tableList.Select(p => p.Name).ToArray()),
                ListOrderDetailDTO = req.ListOrderDetailDTO,
                ConAmount          = req.ConAmount.ToString(),
                GiveAmount         = req.GiveAmount.ToString(),
                DiscountRateNow    = req.DiscountRateNow.ToString(),
                DiscountAmount     = req.DiscountAmount.ToString(),
                OriginalAmount     = req.OriginalAmount.ToString(),
                ContactPerson      = req.ContactPerson
            };
            Type type       = typeof(CheckOutPrint);
            Type typeDetail = typeof(OrderDetailDTO);

            #region 打印内容
            PrintInvoice print       = new PrintInvoice();
            var          tcpClient   = print.GetMyPrint();
            var          stream      = print.BuildStream();
            var          inputStream = print.GetStream(tcpClient, stream);
            string       txt         = string.Empty;
            int          left        = 0;
            string       key         = string.Empty;
            foreach (var item in print.root.Element("Page").Elements())
            {
                if (item.Name == "Text")
                {
                    txt  = item.Value;
                    left = Convert.ToInt32(item.Attribute("Left").Value);
                    if (txt.Contains("{{") && txt.Contains("}}"))
                    {
                        key = ReplaceTemplate(txt);
                        txt = txt.Replace("{{" + key + "}}", type.GetProperty(key).GetValue(model).ToString());
                    }
                    print.PrintText(inputStream, txt, left);
                }
                else if (item.Name == "Loop")
                {
                    string lopValues = item.Attribute("Values").Value;
                    if (lopValues == "Detials")
                    {
                        if (model.ListOrderDetailDTO.Any())
                        {
                            foreach (var detail in model.ListOrderDetailDTO)
                            {
                                foreach (var loopItem in item.Elements("Text"))
                                {
                                    txt  = loopItem.Value;
                                    left = Convert.ToInt32(item.Attribute("Left"));
                                    if (txt.Contains("{{") && txt.Contains("}}"))
                                    {
                                        key = ReplaceTemplate(txt);
                                        txt = txt.Replace("{{" + key + "}}", typeDetail.GetProperty(key).GetValue(detail).ToString());
                                    }
                                    print.PrintText(inputStream, txt, left);
                                }
                            }
                        }
                    }
                }
            }
            //inputStream.Close();
            print.PrintText(inputStream, print.root.ToString(), 0);
            print.QieZhi(inputStream);
            print.DiposeStreamClient(tcpClient, inputStream);

            #endregion
            return(result);
        }
예제 #14
0
        public void TestExcel()
        {
            //var excelApplication = new Application();
            //var _WorkBook = excelApplication.Workbooks.Open(
            //    @"d:\20100429.xlsx",
            //    0,
            //    false,
            //    5,
            //    "comin",
            //    "",
            //    false,
            //    XlPlatform.xlWindows,
            //    "",
            //    true,
            //    false,
            //    0,
            //    true,
            //    false,
            //    false);

            ////excelApplication.Visible = true;
            ////_WorkBook.PrintPreview(true);
            //try
            //{
            //    _WorkBook.PrintOut(
            //        1,
            //        1,
            //        1,
            //        false,
            //        "HP Color LaserJet 2600n (Network)",
            //        false,
            //        false,
            //        "");
            //}
            //catch (Exception exception)
            //{
            //    MessageBox.Show(exception.Message);
            //}
            //finally
            //{
            //    excelApplication.Workbooks.Close();
            //}

            var saleItemBindingList = new BindingList <SaleItem>
            {
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem(),
                CreateSaleItem()
            };

            var printReceipt = new PrintInvoice();

            printReceipt.ExcelInvoicePrintingHandler(
                "EPSON LQ-300+ /II ESC/P 2",
                @"D:\users\ysakal\private\point of sales\ezpos\source code\bin\Debug\invoice-sale.xlsx",
                string.Empty,
                "Customer",
                "Address",
                "InvoiceNumber",
                DateTime.Now,
                10,
                5,
                10,
                saleItemBindingList,
                false);

            Assert.AreEqual(1, 1, "Test performed");
        }