void DoPrint(int invoiceID)
        {
            decimal cashFromCustomer = Convert.ToDecimal(txtCashFromCustomer.EditValue);
            decimal CashReturn       = Convert.ToDecimal(txtCashReturn.EditValue);

            Reports.SaleRpt rpt = new SaleRpt(Convert.ToDecimal(txtDiscount.EditValue), Convert.ToDecimal(txtAfterDiscount.EditValue), cashFromCustomer, CashReturn, invoiceID.ToString(), UserData.Default.UserName);
            ////var list = from s in db.vw_Sale2 where s.SaleInvoiceID == invoiceID select s;
            ////rpt.DataSource = list.ToList();
            rpt.DataSource = rptList.ToList();
            ////txtAfterDiscount.EditValue = 0;
            ////txtInvoiceTotal.EditValue = 0;
            ////txtDiscount.EditValue = 0;
            try
            {
                ReportPrintTool tool = new ReportPrintTool(rpt);
                //  string InvoicePrinter = System.Configuration.ConfigurationManager.AppSettings["InvoicePrinter"];
                if (InvoicePrinter == "")
                {
                    tool.Print();
                }
                else
                {
                    tool.Print(InvoicePrinter);
                }
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Exemple #2
0
        private void repositoryItemButtonEditSaleInvoice_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            try
            {
                if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.OK)
                {
                    var     currentRow = (DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow();
                    SaleRpt rpt        = new SaleRpt(Convert.ToDecimal(currentRow.Discount), Convert.ToDecimal(currentRow.Total), 0, 0, currentRow.ID.ToString(), currentRow.UserName.ToString());
                    var     list       = from s in db.vw_Sale2 where s.SaleInvoiceID == currentRow.ID select s;
                    rpt.DataSource = list.ToList();


                    try
                    {
                        ////string InvoicePrinter = System.Configuration.ConfigurationManager.AppSettings["InvoicePrinter"];
                        ReportPrintTool tool = new ReportPrintTool(rpt);
                        tool.ShowPreview();
                    }
                    catch (Exception ex)
                    {
                        ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
                    }
                }
                else
                if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Undo)
                {
                    var currentRow = (DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow();
                    if (currentRow.Flag == 1)
                    {
                        //     if (MessageBox.Show("هل أنت متأكد من إرجاع الفاتور؟", "إرجاع الفاتور", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        {
                            var     row  = (DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow();
                            SaleRpt rpt  = new SaleRpt(Convert.ToDecimal(currentRow.Discount), Convert.ToDecimal(currentRow.Total), 0, 0, currentRow.ID.ToString(), currentRow.UserName.ToString());
                            var     list = db.vw_Sale2.Where(s => s.SaleInvoiceID == row.ID).ToList <DataAccess.vw_Sale2>();
                            new ReturnForm(list, currentRow.ID).ShowDialog();
                            FillSaleInvoiceGrid();

                            ////DataAccess.SaleInvoice invoice = db.SaleInvoices.Where(s => s.ID == currentRow.ID).SingleOrDefault();
                            ////invoice.Flag = 2;
                            ////DataAccess.Inventory inv;
                            ////foreach (var item in invoice.SaleInvoiceDetails)
                            ////{
                            ////   // item.SaleInvoiceID = invoice.ID;
                            ////   /// invoice.SaleInvoiceDetails.Add(item);

                            ////    inv = db.Inventories.Where(s => s.ID == item.InventoryID).SingleOrDefault();
                            ////    inv.CurrentQuanity += item.Quanitity;
                            ////}
                            //if (db.SaveChanges() > 0)
                            //{
                            //    MessageBox.Show("تم ارجاع الفاتوره");
                            //}
                        }
                    }
                    else
                    {
                        MessageBox.Show("لا يمكن ارجاع الفاتوره");
                    }
                }
                else
                if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph)
                {
                    var currentRow = (DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow();
                    if (currentRow != null)
                    {
                        var     row  = (DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow();
                        SaleRpt rpt  = new SaleRpt(Convert.ToDecimal(currentRow.Discount), Convert.ToDecimal(currentRow.Total), 0, 0, currentRow.ID.ToString(), currentRow.UserName.ToString());
                        var     list = db.vw_Sale2.Where(s => s.SaleInvoiceID == row.ID).ToList <DataAccess.vw_Sale2>();


                        rpt.DataSource = list.ToList();
                        ReportPrintTool tool = new ReportPrintTool(rpt);

                        string InvoicePrinter = db.Companies.Take(1).SingleOrDefault().InvoicePrinter;         // System.Configuration.ConfigurationManager.AppSettings["InvoicePrinter"];
                        if (InvoicePrinter == "")
                        {
                            tool.Print();
                        }
                        else
                        {
                            tool.Print(InvoicePrinter);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }