Exemple #1
0
        private bool PrintDetails(DataAccess.PurchaseInvoiceDetail detail, Int16 noOfCopies)
        {
            bool result = true;
            var  item   = db.Items.Where(s => s.ID == detail.ItemID).SingleOrDefault();

            DataAccess.ItemBarcode ibc = db.ItemBarcodes.Where(s => s.SystemBarcode == true && s.ItemID == item.ID).SingleOrDefault();
            string BarcodeText         = ibc.BarcodeText;                                                                                 // item.BarcodeText;

            ZebraBarcodeLabelRPT rpt = new ZebraBarcodeLabelRPT(BarcodeText, item.Name, item.SalePrice.ToString(), cbPrintPrice.Checked); // detail.SalePrice.ToString());
            // rpt.DataSource = list;
            ReportPrintTool tool = new ReportPrintTool(rpt);

            rpt.PrintingSystem.StartPrint += new DevExpress.XtraPrinting.PrintDocumentEventHandler(PrintingSystem_StartPrint);
            NoOfCopies = noOfCopies;                     // detail.Quantity;
            string BarcodePrinter = this.BarcodePrinter; //  System.Configuration.ConfigurationManager.AppSettings["BarcodePrinter"];

            if (BarcodePrinter == "")
            {
                tool.Print();
            }
            else
            {
                tool.Print(BarcodePrinter);
            }
            return(result);
        }
Exemple #2
0
        private void repositoryItemButtonEdit1_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            //Print all quantities
            if (e.Button.Kind == ButtonPredefines.OK)
            {
                if (MessageBox.Show("Are you sure ?", "Print barcode stickets", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    DataAccess.PurchaseInvoiceDetail currentRow = (DataAccess.PurchaseInvoiceDetail)gridView1.GetFocusedRow();
                    DataAccess.BarCodeTemplateList   list       = new DataAccess.BarCodeTemplateList();
                    for (int i = 0; i < currentRow.Quantity; i++)
                    {
                        list.Add(new DataAccess.BarCodeTemplate {
                            Barcode = currentRow.Item.BarcodeText, Name = currentRow.Item.Name, Price = currentRow.SalePrice.ToString()
                        });
                    }
                    if (PrintDetails(currentRow, Convert.ToInt16(currentRow.Quantity)))
                    {
                        ShowMessageInStatusBar("New item printed successfully " + currentRow.Quantity + " Times", 9000);
                    }
                }
            }
            else
            if (e.Button.Kind == ButtonPredefines.Down)
            {
                DataAccess.PurchaseInvoiceDetail currentRow = (DataAccess.PurchaseInvoiceDetail)gridView1.GetFocusedRow();
                DataAccess.BarCodeTemplateList   list       = new DataAccess.BarCodeTemplateList();
                for (int i = 0; i < currentRow.Quantity; i++)
                {
                    list.Add(new DataAccess.BarCodeTemplate {
                        Barcode = currentRow.Item.BarcodeText, Name = currentRow.Item.Name, Price = currentRow.SalePrice.ToString()
                    });
                }
                if (PrintDetails(currentRow, 1))
                {
                    ShowMessageInStatusBar("New item printed successfully", 9000);
                }
            }
            else
            if (e.Button.Kind == ButtonPredefines.Delete)
            {
                if (MessageBox.Show("تأكيد مسح الصنف من الفاتورة", "مسح الفاتورة", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    DataAccess.PurchaseInvoiceDetail currentRow = (DataAccess.PurchaseInvoiceDetail)gridView1.GetFocusedRow();
                    gridView1.DeleteRow(gridView1.FocusedRowHandle);

                    db.PurchaseInvoiceDetails.Remove(currentRow);

                    if (db.SaveChanges() > 0)
                    {
                        ShowMessageInStatusBar("تم حفظ اليانات", 9000);
                    }
                }
            }
            else
            if (e.Button.Kind == ButtonPredefines.Glyph)
            {
                // if (MessageBox.Show("طباعة البار كود ؟", currentRow.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    //Set buttons language Czech/English/German/Slovakian/Spanish (default English)
                    InputBox.SetLanguage(InputBox.Language.English);
                    //Save the DialogResult as res
                    DialogResult res = InputBox.ShowDialog("العدد:", "طباعة باركود",                                                //Text message (mandatory), Title (optional)
                                                           InputBox.Icon.Question,                                                  //Set icon type Error/Exclamation/Question/Warning (default info)
                                                           InputBox.Buttons.OkCancel,                                               //Set buttons set OK/OKcancel/YesNo/YesNoCancel (default ok)
                                                           InputBox.Type.TextBox,                                                   //Set type ComboBox/TextBox/Nothing (default nothing)
                                                           new string[] { "Item1", "Item2", "Item3" },                              //Set string field as ComboBox items (default null)
                                                           true,                                                                    //Set visible in taskbar (default false)
                                                           new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold)); //Set font (default by system)
                    //Check InputBox result
                    if (((InputBox.ResultValue != "") && (res == System.Windows.Forms.DialogResult.OK || res == System.Windows.Forms.DialogResult.Yes)))
                    {
                        Int16 copies = Convert.ToInt16(InputBox.ResultValue);
                        DataAccess.PurchaseInvoiceDetail currentRow = (DataAccess.PurchaseInvoiceDetail)gridView1.GetFocusedRow();
                        DataAccess.BarCodeTemplateList   list       = new DataAccess.BarCodeTemplateList();
                        if (PrintDetails(currentRow, copies))
                        {
                            // ShowMessageInStatusBar("New item printed successfully " + currentRow.Quantity + " Times", 9000);
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void AddToInvoice(int ItemID)
        {
            // int ItemID = 0;
            // ItemID = Convert.ToInt32(cmbItem.EditValue);

            int quantity = 0;

            quantity = Convert.ToInt32(txtQunatity.Text);

            decimal purchasePrice = 0;

            purchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);

            decimal salePrice = 0;

            salePrice = Convert.ToDecimal(txtSalePrice.Text);

            decimal discountPrice = 0;

            discountPrice = Convert.ToDecimal(txtItemDiscount.Text);

            /*
             * Validation
             * Check dupicated items
             */

            var found = (from s in purchaseDetails where s.ItemID == ItemID select s).Count();

            if (found != 0)
            {
                MessageBox.Show(cmbItem.Text + "  already in the invoice", "Duplicate item", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DataAccess.PurchaseInvoiceDetail detail = db.PurchaseInvoiceDetails.Create();

            detail.PurchaseInvoiceID = invoice.ID;
            detail.ItemID            = ItemID;
            detail.Quantity          = quantity;
            detail.PurchasePrice     = purchasePrice;
            detail.SalePrice         = salePrice;
            detail.DiscountPrice     = discountPrice;

            purchaseDetails.Add(detail);
            if (checkEditAutoSave.Checked)
            {
                if (db.SaveChanges() > 0)
                {
                    ShowMessageInStatusBar("New item saved successfully", 9000);
                }
            }
            if (checkEditAutoPrint.Checked)
            {
                if (PrintDetails(detail, Convert.ToInt16(detail.Quantity)))
                {
                    ShowMessageInStatusBar("New item printed successfully", 9000);
                }
            }
            bindingSource2.ResetBindings(false);
            txtQunatity.EditValue      = 0;
            txtPurchasePrice.EditValue = 0;
            txtDiscount.EditValue      = 0;
            txtSalePrice.EditValue     = 0;

            cmbItem.Focus();
        }