Beispiel #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (!CheckErrorOnForm())
            {
                return;
            }
            if(GoodsSaleController.PurchaseOrder == null || pODList.Count == 0)
            {
                MessageBox.Show(" Không có hàng để lưu hóa đơn");
                return;
            }
            RemoveEmptyProductMasterIdRow();
            FormToModel();
            if(!string.IsNullOrEmpty(txtCustomer.Text))
            {
                GoodsSaleController.PurchaseOrder.Customer = new Customer{CustomerName = txtCustomer.Text};
            }

            Receipt receipt = new Receipt();
            receipt.PurchaseOrder = GoodsSaleController.PurchaseOrder;
            receipt.ReceiptPK = new ReceiptPK{ DepartmentId = CurrentDepartment.Get().DepartmentId};
            receipt.CreateDate = DateTime.Now;
            receipt.UpdateDate = DateTime.Now;
            receipt.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.ReceiptName = "HDBH";
            receipt.ReceiptNumber = GoodsSaleController.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId;
            receipt.TotalAmount = Int64.Parse(string.IsNullOrEmpty(txtTotalAmount.Text)?"0":txtTotalAmount.Text);
            receipt.CustomerPayment = Int64.Parse(string.IsNullOrEmpty(txtPayment.Text)?"0":txtPayment.Text);
            receipt.Charge = Int64.Parse(string.IsNullOrEmpty(txtCharge.Text)?"0":txtCharge.Text);
            GoodsSaleController.PurchaseOrder.Receipts = new ArrayList();
            GoodsSaleController.PurchaseOrder.Receipts.Add(receipt);

            if (GlobalCache.Instance().Session.ContainsKey("EmployeeId"))
            {
                string employeeId = GlobalCache.Instance().Session["EmployeeId"] as string;
                if(!string.IsNullOrEmpty(employeeId))
                {
                    GoodsSaleController.PurchaseOrder.CreateId = employeeId;
                    GoodsSaleController.PurchaseOrder.UpdateId = employeeId;
                    foreach (PurchaseOrderDetail purchaseOrderDetail in GoodsSaleController.PurchaseOrder.PurchaseOrderDetails)
                    {
                        purchaseOrderDetail.CreateId = employeeId;
                        purchaseOrderDetail.UpdateId = employeeId;
                    }
                }
            }
            GoodsSaleEventArgs eventArgs = new GoodsSaleEventArgs();
            if(ReturnPurchaseOrder!=null)
            {
                eventArgs.RefPurchaseOrder = ReturnPurchaseOrder;
            }
            EventUtility.fireEvent(SavePurchaseOrderEvent, this, eventArgs);
            if (eventArgs.HasErrors)
            {
                MessageBox.Show("Có lỗi khi lưu hoá đơn");
                return;
            }

            IList returnDetails = new ArrayList();
            IList purchaseDetails = GoodsSaleController.PurchaseOrder.PurchaseOrderDetails;
            int maxIndex = GoodsSaleController.PurchaseOrder.PurchaseOrderDetails.Count-1;
            PurchaseOrder purchaseOrder = GoodsSaleController.PurchaseOrder;
            while(maxIndex >= 0)
            {
                PurchaseOrderDetail detail = (PurchaseOrderDetail)purchaseDetails[maxIndex];
                if (detail.PurchaseOrder != null
                   && detail.PurchaseOrder.PurchaseOrderPK != null
                   && !string.IsNullOrEmpty(detail.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId)
                   && !detail.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId.Equals(purchaseOrder.PurchaseOrderPK.PurchaseOrderId) )
                {
                    if(detail.Price < 0 )
                    {
                        detail.Price = 0 - detail.Price;
                    }
                    returnDetails.Add(detail);
                    purchaseDetails.RemoveAt(maxIndex);
                }
                maxIndex -= 1;
            }

            PurchaseOrderBill = new LocalReport();
            bool isReturnOrder = false;
            if(returnDetails.Count > 0 )
            {
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.ReturnPurchaseOrder.rdlc";

                receipt.ReceiptName = "HDDTH";
                if (purchaseDetails.Count == 0)
                {
                    receipt.ReceiptNumber = receipt.ReceiptNumber + "RET";
                }
                isReturnOrder = true;
            }
            else
            {
                receipt.ReceiptName = "HDBH";
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.PurchaseOrder.rdlc";

            }

            this.PurchaseOrderBindingSource.DataSource = goodsSaleController.PurchaseOrder;
            PurchaseOrderDetailCollection printPOD = new PurchaseOrderDetailCollection();
            foreach (PurchaseOrderDetail detail in purchaseDetails)
            {
                printPOD.Add(detail);
            }
            this.PurchaseOrderDetailCollectionBindingSource.DataSource = CreateNonDuplicate(printPOD);
            this.ReceiptBindingSource.DataSource = receipt;
            this.DepartmentBindingSource.DataSource = CurrentDepartment.Get();

                PurchaseOrderDetailBindingSource.DataSource = ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(returnDetails);

                ReportDataSource PODataRDS = new ReportDataSource("AppFrame_Model_PurchaseOrder");
                PODataRDS.Value = PurchaseOrderBindingSource;
                PurchaseOrderBill.DataSources.Add(PODataRDS);

                ReportDataSource PODetRDS = new ReportDataSource("AppFrame_Collection_PurchaseOrderDetailCollection");
                PODetRDS.Value = PurchaseOrderDetailCollectionBindingSource;
                PurchaseOrderBill.DataSources.Add(PODetRDS);

                ReportDataSource DepartmentRDS = new ReportDataSource("AppFrame_Model_Department");
                DepartmentRDS.Value = DepartmentBindingSource;
                PurchaseOrderBill.DataSources.Add(DepartmentRDS);

                ReportDataSource ReceiptRDS = new ReportDataSource("AppFrame_Model_Receipt");
                ReceiptRDS.Value = ReceiptBindingSource;
                PurchaseOrderBill.DataSources.Add(ReceiptRDS);

                ReportDataSource POReturnDetRDS = new ReportDataSource("AppFrame_Model_PurchaseOrderDetail");
                POReturnDetRDS.Value = PurchaseOrderDetailBindingSource;
                PurchaseOrderBill.DataSources.Add(POReturnDetRDS);

            this.reportPurchaseOrder.LocalReport.Refresh();
            PrintDirectlyToPrinter();
            ClearGoodsSaleForm();
            ClearReturnInput();
            ClearInput();
        }
Beispiel #2
0
 public Receipt Add(Receipt data)
 {
     ReceiptDAO.Add(data);
     return data;
 }
Beispiel #3
0
 public void Delete(Receipt data)
 {
     ReceiptDAO.Delete(data);
 }
Beispiel #4
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (!CheckErrorOnForm())
            {
                return;
            }
            if(GoodsSaleController.PurchaseOrder == null || pODList.Count == 0)
            {
                MessageBox.Show(" Không có hàng để lưu hóa đơn");
                return;
            }
            RemoveEmptyProductMasterIdRow();
            FormToModel();
            if(!string.IsNullOrEmpty(txtCustomer.Text))
            {
                GoodsSaleController.PurchaseOrder.Customer = new Customer{CustomerName = txtCustomer.Text};
            }
            Receipt receipt = new Receipt();
            receipt.PurchaseOrder = GoodsSaleController.PurchaseOrder;
            receipt.ReceiptPK = new ReceiptPK{ DepartmentId = CurrentDepartment.Get().DepartmentId};
            receipt.CreateDate = DateTime.Now;
            receipt.UpdateDate = DateTime.Now;
            receipt.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.ReceiptName = "HDBH";
            receipt.ReceiptNumber = GoodsSaleController.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId;
            receipt.TotalAmount = Int64.Parse(string.IsNullOrEmpty(txtTotalAmount.Text)?"0":txtTotalAmount.Text);
            receipt.CustomerPayment = Int64.Parse(string.IsNullOrEmpty(txtPayment.Text)?"0":txtPayment.Text);
            receipt.Charge = Int64.Parse(string.IsNullOrEmpty(txtCharge.Text)?"0":txtCharge.Text);
            GoodsSaleController.PurchaseOrder.Receipts = new ArrayList();
            GoodsSaleController.PurchaseOrder.Receipts.Add(receipt);

            GoodsSaleEventArgs eventArgs = new GoodsSaleEventArgs();
            if(ReturnPurchaseOrder!=null)
            {
                eventArgs.RefPurchaseOrder = ReturnPurchaseOrder;
            }
            EventUtility.fireEvent(SavePurchaseOrderEvent, this, eventArgs);
            if (eventArgs.HasErrors)
            {
                MessageBox.Show("Có lỗi khi lưu hoá đơn");
                return;
            }

            IList returnDetails = new ArrayList();
            IList purchaseDetails = GoodsSaleController.PurchaseOrder.PurchaseOrderDetails;
            int maxIndex = GoodsSaleController.PurchaseOrder.PurchaseOrderDetails.Count-1;
            PurchaseOrder purchaseOrder = GoodsSaleController.PurchaseOrder;
            while(maxIndex >= 0)
            {
                PurchaseOrderDetail detail = (PurchaseOrderDetail)purchaseDetails[maxIndex];
                if (detail.PurchaseOrder != null
                   && detail.PurchaseOrder.PurchaseOrderPK != null
                   && !string.IsNullOrEmpty(detail.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId)
                   && !detail.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId.Equals(purchaseOrder.PurchaseOrderPK.PurchaseOrderId) )
                {
                    if(detail.Price < 0 )
                    {
                        detail.Price = 0 - detail.Price;
                    }
                    returnDetails.Add(detail);
                    purchaseDetails.RemoveAt(maxIndex);
                }
                maxIndex -= 1;
            }

            /*printForm = new GoodsSalePrintForm();
            printForm.FillForm(GoodsSaleController.PurchaseOrder);
            printForm.Show();
            printForm.Shown += new EventHandler(printForm_Shown);*/

            /*reportPurchaseOrder.LocalReport.DataSources.Add(new ReportDataSource("Department",CurrentDepartment.Get()));
            reportPurchaseOrder.LocalReport.DataSources.Add(new ReportDataSource("PurchaseOrder",GoodsSaleController.PurchaseOrder));
            reportPurchaseOrder.LocalReport.DataSources.Add(new ReportDataSource("PurchaseOrderDetail", pODList));*/
            PurchaseOrderBill = new LocalReport();
            bool isReturnOrder = false;
            if(returnDetails.Count > 0 )
            {
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.ReturnPurchaseOrder.rdlc";

                receipt.ReceiptName = "HDDTH";
                if (purchaseDetails.Count == 0)
                {
                    receipt.ReceiptNumber = receipt.ReceiptNumber + "RET";
                }
                isReturnOrder = true;
            }
            else
            {
                receipt.ReceiptName = "HDBH";
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.PurchaseOrder.rdlc";

            }

            this.PurchaseOrderBindingSource.DataSource = goodsSaleController.PurchaseOrder;
            PurchaseOrderDetailCollection printPOD = new PurchaseOrderDetailCollection();
            foreach (PurchaseOrderDetail detail in purchaseDetails)
            {
                printPOD.Add(detail);
            }
            this.PurchaseOrderDetailCollectionBindingSource.DataSource = CreateNonDuplicate(printPOD);
            this.ReceiptBindingSource.DataSource = receipt;
            this.DepartmentBindingSource.DataSource = CurrentDepartment.Get();

                PurchaseOrderDetailBindingSource.DataSource = ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(returnDetails);

                ReportDataSource PODataRDS = new ReportDataSource("AppFrame_Model_PurchaseOrder");
                PODataRDS.Value = PurchaseOrderBindingSource;
                PurchaseOrderBill.DataSources.Add(PODataRDS);

                ReportDataSource PODetRDS = new ReportDataSource("AppFrame_Collection_PurchaseOrderDetailCollection");
                PODetRDS.Value = PurchaseOrderDetailCollectionBindingSource;
                PurchaseOrderBill.DataSources.Add(PODetRDS);

                ReportDataSource DepartmentRDS = new ReportDataSource("AppFrame_Model_Department");
                DepartmentRDS.Value = DepartmentBindingSource;
                PurchaseOrderBill.DataSources.Add(DepartmentRDS);

                ReportDataSource ReceiptRDS = new ReportDataSource("AppFrame_Model_Receipt");
                ReceiptRDS.Value = ReceiptBindingSource;
                PurchaseOrderBill.DataSources.Add(ReceiptRDS);

                ReportDataSource POReturnDetRDS = new ReportDataSource("AppFrame_Model_PurchaseOrderDetail");
                POReturnDetRDS.Value = PurchaseOrderDetailBindingSource;
                PurchaseOrderBill.DataSources.Add(POReturnDetRDS);

            /*this.PurchaseOrderDetailBindingSource.DataSource =
                ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(args.ReturnPurchaseOrderDetails);

            this.PurchaseOrderDetailCollectionBindingSource.DataSource = pODNewList;

            this.DepartmentBindingSource.DataSource = CurrentDepartment.Get();

            this.PurchaseOrderBindingSource.DataSource = goodsSaleController.PurchaseOrder;
            this.PurchaseOrderDetailCollectionBindingSource.DataSource = CreateNonDuplicate(pODList);
            this.ReceiptBindingSource.DataSource = receipt;*/

            /*string deviceInfo = "<DeviceInfo>" +
            "  <OutputFormat>EMF</OutputFormat>" +
            "  <PageWidth>3.145in</PageWidth>" +
            "  <PageHeight>5.3in</PageHeight>" +
            "  <MarginTop>0.0in</MarginTop>" +
            "  <MarginLeft>0.0in</MarginLeft>" +
            "  <MarginRight>0.0in</MarginRight>" +
            "  <MarginBottom>0.0in</MarginBottom>" +
            "</DeviceInfo>";
            Warning[] warnings;*/

            this.reportPurchaseOrder.LocalReport.Refresh();
            PrintDirectlyToPrinter();
            ClearGoodsSaleForm();
            ClearReturnInput();
            ClearInput();
        }
Beispiel #5
0
 public void Update(Receipt data)
 {
     ReceiptDAO.Update(data);
 }
Beispiel #6
0
 /// <summary>
 /// Add Receipt to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public Receipt Add(Receipt data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
Beispiel #7
0
 /// <summary>
 /// Delete Receipt from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(Receipt data)
 {
     HibernateTemplate.Delete(data);
 }
Beispiel #8
0
 /// <summary>
 /// Update Receipt to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(Receipt data)
 {
     HibernateTemplate.Update(data);
 }
Beispiel #9
0
        private void PrintPage(PurchaseOrderView view)
        {
            // create bill and printing

            Receipt receipt = new Receipt();
            receipt.PurchaseOrder = view.PurchaseOrder;
            receipt.ReceiptPK = new ReceiptPK { DepartmentId = CurrentDepartment.Get().DepartmentId };
            receipt.CreateDate = DateTime.Now;
            receipt.UpdateDate = DateTime.Now;
            receipt.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            receipt.ReceiptName = "HDBH";
            receipt.ReceiptNumber = view.PurchaseOrder.PurchaseOrderPK.PurchaseOrderId;
            receipt.TotalAmount = view.SellAmount-view.ReturnAmount;
            receipt.CustomerPayment = 0;
            receipt.Charge = 0;
            view.PurchaseOrder.Receipts = new ArrayList();
            view.PurchaseOrder.Receipts.Add(receipt);
            IList returnDetails = new ArrayList();
            IList purchaseDetails = view.PurchaseOrder.PurchaseOrderDetails;
            int maxIndex = view.PurchaseOrder.PurchaseOrderDetails.Count - 1;
            PurchaseOrder purchaseOrder = view.PurchaseOrder;

            if(view.ReturnPOList !=null && view.ReturnPOList.Count > 0)
            {
                foreach (ReturnPo returnPo in view.ReturnPOList)
                {
                    returnDetails.Add(returnPo);
                }
            }

            PurchaseOrderBill = new LocalReport();
            bool isReturnOrder = false;
            if (returnDetails.Count > 0)
            {
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.ReturnPurchaseOrder.rdlc";

                receipt.ReceiptName = "HDDTH";
                if (purchaseDetails.Count == 0)
                {
                    receipt.ReceiptNumber = receipt.ReceiptNumber + "RET";
                }
                isReturnOrder = true;
            }
            else
            {
                receipt.ReceiptName = "HDBH";
                PurchaseOrderBill.ReportEmbeddedResource = "AppFrameClient.Report.PurchaseOrder.rdlc";

            }

            PurchaseOrderBindingSource.DataSource = view.PurchaseOrder;
            PurchaseOrderDetailCollection printPOD = new PurchaseOrderDetailCollection();
            foreach (PurchaseOrderDetail detail in purchaseDetails)
            {
                printPOD.Add(detail);
            }
            PurchaseOrderDetailCollectionBindingSource.DataSource = CreateNonDuplicate(printPOD);
            ReceiptBindingSource.DataSource = receipt;
            DepartmentBindingSource.DataSource = CurrentDepartment.Get();

            PurchaseOrderDetailBindingSource.DataSource = ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(returnDetails);

            ReportDataSource PODataRDS = new ReportDataSource("AppFrame_Model_PurchaseOrder");
            PODataRDS.Value = PurchaseOrderBindingSource;
            PurchaseOrderBill.DataSources.Add(PODataRDS);

            ReportDataSource PODetRDS = new ReportDataSource("AppFrame_Collection_PurchaseOrderDetailCollection");
            PODetRDS.Value = PurchaseOrderDetailCollectionBindingSource;
            PurchaseOrderBill.DataSources.Add(PODetRDS);

            ReportDataSource DepartmentRDS = new ReportDataSource("AppFrame_Model_Department");
            DepartmentRDS.Value = DepartmentBindingSource;
            PurchaseOrderBill.DataSources.Add(DepartmentRDS);

            ReportDataSource ReceiptRDS = new ReportDataSource("AppFrame_Model_Receipt");
            ReceiptRDS.Value = ReceiptBindingSource;
            PurchaseOrderBill.DataSources.Add(ReceiptRDS);

            ReportDataSource POReturnDetRDS = new ReportDataSource("AppFrame_Model_PurchaseOrderDetail");
            POReturnDetRDS.Value = PurchaseOrderDetailBindingSource;
            PurchaseOrderBill.DataSources.Add(POReturnDetRDS);

            //this.reportPurchaseOrder.LocalReport.Refresh();
            PrintDirectlyToPrinter();
        }
        private void PrintReturnReceipt(GoodsSaleReturnEventArgs args, Receipt receipt)
        {
            this.DepartmentBindingSource.DataSource = CurrentDepartment.Get();
            if (args.NextPurchaseOrder == null)
            {
                this.PurchaseOrderBindingSource.DataSource = args.RefPurchaseOrder;
            }
            else
            {
                this.PurchaseOrderBindingSource.DataSource = args.NextPurchaseOrder;
            }
            this.PurchaseOrderDetailBindingSource.DataSource =
                ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(args.ReturnPurchaseOrderDetails);

            this.PurchaseOrderDetailCollectionBindingSource.DataSource = pODNewList;
            this.reportViewer1.RenderingComplete += new Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(reportViewer1_RenderingComplete);
            //this.reportViewer1.LocalReport.Refresh();

            this.reportViewer1.RefreshReport();
        }
        private void PrintDirectlyToPrinter(GoodsSaleReturnEventArgs args, Receipt receipt)
        {
            this.DepartmentBindingSource.DataSource = CurrentDepartment.Get();
            if (args.NextPurchaseOrder == null)
            {
                args.RefPurchaseOrder.PurchaseOrderPK.PurchaseOrderId =
                    args.RefPurchaseOrder.PurchaseOrderPK.PurchaseOrderId + "RET";
                this.PurchaseOrderBindingSource.DataSource = args.RefPurchaseOrder;
            }
            else
            {
                this.PurchaseOrderBindingSource.DataSource = args.NextPurchaseOrder;
            }
            this.PurchaseOrderDetailBindingSource.DataSource =
                ObjectConverter.ConvertGenericList<PurchaseOrderDetail>(args.ReturnPurchaseOrderDetails);

            this.PurchaseOrderDetailCollectionBindingSource.DataSource = pODNewList;
            this.ReceiptBindingSource.DataSource = receipt;
            this.reportViewer1.RenderingComplete += new Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(reportViewer1_RenderingComplete);
            this.reportViewer1.LocalReport.Refresh();

            streamList.Clear();
            //const string printerName = "Epson TM-T88IV";
            var configurationAppSettings = new AppSettingsReader();
            string printerName = (string)configurationAppSettings.GetValue("PrinterName", typeof(String));
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrinterSettings.PrinterName = printerName;

            if (!printDoc.PrinterSettings.IsValid)
            {
                MessageBox.Show(String.Format("Can't find printer \"{0}\".", printerName));

                return;
            }
            printDoc.PrinterSettings.DefaultPageSettings.PrinterResolution.X = 180;
            printDoc.PrinterSettings.DefaultPageSettings.PrinterResolution.Y = 180;
            printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);

            printDoc.Print();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (pODReturnList.Count <= 0)
            {
                MessageBox.Show("Không có hàng để trả !");
                return;
            }
            if(Int64.Parse(txtCharge.Text) < 0)
            {
                MessageBox.Show("Số tiền trả thêm chưa đủ !");
                return;
            }
            if (goodsSaleReturnController.ReturnPurchaseOrder == null)
            {
                // tra hang nghi van
            }
            else
            {
                // tra hang da co doi chieu
                GoodsSaleReturnEventArgs eventArgs = new GoodsSaleReturnEventArgs();
                eventArgs.RefPurchaseOrder = goodsSaleReturnController.ReturnPurchaseOrder;
                eventArgs.ReturnPurchaseOrderDetails = ObjectConverter.ConvertToNonGenericList<PurchaseOrderDetail>(pODReturnList);

                Receipt receipt = new Receipt();
                receipt.PurchaseOrder = goodsSaleReturnController.ReturnPurchaseOrder;
                receipt.ReceiptPK = new ReceiptPK
                                        {
                                            DepartmentId = CurrentDepartment.Get().DepartmentId
                                        };
                receipt.CreateDate = DateTime.Now;
                receipt.UpdateDate = DateTime.Now;
                receipt.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                receipt.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                receipt.ReceiptName = "HDDTH";
                receipt.ReceiptNumber = goodsSaleReturnController.ReturnPurchaseOrder.PurchaseOrderPK.PurchaseOrderId;
                receipt.TotalAmount = Int64.Parse(txtTotalAmount.Text);
                receipt.CustomerPayment = Int64.Parse(txtPayment.Text);
                receipt.Charge = Int64.Parse(txtCharge.Text);
                receipt.ReturnAmount = Int64.Parse(txtReturnPayment.Text);

                if(pODNewList!=null && pODNewList.Count > 0 )
                {
                   PurchaseOrder nextOrder = new PurchaseOrder();
                    nextOrder.PurchaseOrderPK = new PurchaseOrderPK
                                                    {DepartmentId = CurrentDepartment.Get().DepartmentId};
                    nextOrder.PurchaseOrderDescription = " Next Purchase Order ";
                    nextOrder.DelFlg = 0;
                    nextOrder.ExclusiveKey = 1;

                    nextOrder.PurchaseOrderDetails = ObjectConverter.ConvertToNonGenericList(pODNewList);
                    foreach (PurchaseOrderDetail orderDetail in nextOrder.PurchaseOrderDetails)
                    {
                        nextOrder.PurchasePrice += orderDetail.Price;
                    }

                    eventArgs.NextPurchaseOrder = nextOrder;
                }

                EventUtility.fireEvent(SavePurchaseOrderEvent, this, eventArgs);
                if(!eventArgs.HasErrors)
                {
                    MessageBox.Show("Lưu thành công !");
                    PrintDirectlyToPrinter(eventArgs,receipt);
                    ClearForm();
                }

            }
        }