Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private void gridView1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Delete)// && e.Modifiers == Keys.Control)
                {
                    if (MessageBox.Show("حذف ?", "تأكيد الحذف", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }

                    DataAccess.ItemBarcode currentRow = (DataAccess.ItemBarcode)gridView1.GetFocusedRow();

                    if (currentRow.SystemBarcode)
                    {
                        MessageBox.Show("لا يمكن حذف باركود الصنف الأساسي", "لا يمكن اتمام العملية ", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }

                    db.ItemBarcodes.Remove(currentRow);
                    if (db.SaveChanges() > 0)
                    {
                        bindingSourceItemBarcode.DataSource = this.item.ItemBarcodes;
                        ////MainScreen parent = (MainScreen)this.Parent.Parent.Parent.Parent;

                        ////parent.ShowMessageInStatusBar("Item Deleted", 9000);
                    }
                }
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Exemplo n.º 3
0
 private void repositoryItemButtonEditPrintBarcode_ButtonClick(object sender, ButtonPressedEventArgs e)
 {
     try
     {
         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 (res == System.Windows.Forms.DialogResult.OK || res == System.Windows.Forms.DialogResult.Yes)
                 {
                     Int16                          copies      = Convert.ToInt16(InputBox.ResultValue);
                     DataAccess.Item                currentRow  = (DataAccess.Item)gridView1.GetFocusedRow();
                     DataAccess.ItemBarcode         ibc         = db.ItemBarcodes.Where(s => s.SystemBarcode == true && s.ItemID == currentRow.ID).SingleOrDefault();
                     string                         BarcodeText = ibc.BarcodeText;// currentRow.BarcodeText;
                     DataAccess.BarCodeTemplateList list        = new DataAccess.BarCodeTemplateList();
                     if (PrintDetails(BarcodeText, currentRow.Name, currentRow.SalePrice.ToString(), copies))
                     {
                         // ShowMessageInStatusBar("New item printed successfully " + currentRow.Quantity + " Times", 9000);
                     }
                 }
             }
         }
         else
         if (e.Button.Kind == ButtonPredefines.Ellipsis)
         {
             DataAccess.Item currentRow = (DataAccess.Item)gridView1.GetFocusedRow();
             new ItemForm(currentRow).ShowDialog();
         }
         else
         if (e.Button.Kind == ButtonPredefines.Minus)
         {
             DataAccess.Item currentRow = (DataAccess.Item)gridView1.GetFocusedRow();
             currentRow.Hidden = true;
             if (db.SaveChanges() > 0)
             {
             }
         }
     }
     catch (Exception ex)
     {
         ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
     }
 }
Exemplo n.º 4
0
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     try
     {
         var row = gridView1.GetFocusedRow();
         if (row != null && row is DataAccess.ItemBarcode)
         {
             DataAccess.ItemBarcode itemBarcode = row as DataAccess.ItemBarcode;
             barCodeControlReda.Text = itemBarcode.BarcodeText;
         }
         //  e.FocusedRowHandle
     }
     catch (Exception ex)
     {
         ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
     }
 }
Exemplo n.º 5
0
        private void bindingSourceItemBarcode_AddingNew(object sender, AddingNewEventArgs e)
        {
            try
            {
                DataAccess.ItemBarcode ibc = db.ItemBarcodes.Create();//  new DataAccess.ItemBarcode();
                ibc.ItemID        = this.item.ID;
                ibc.SystemBarcode = false;
                e.NewObject       = ibc;

                //item.ItemBarcodes.Add(ibc);
                db.ItemBarcodes.Add(ibc);
                //bindingSourceItemBarcode.DataSource = this.item.ItemBarcodes;
                // bindingSourceItemBarcode.DataSource = this.item.ItemBarcodes;// db.ItemBarcodes.Where(s => s.ItemID == item.ID).ToList();
                //item.ItemBarcodes.Add(ibc);
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Exemplo n.º 6
0
        void SaveItem(bool closeWindow)
        {
            try
            {
                if (CustomValidateForm())
                {
                    if (isNew)
                    {
                        var    catId       = Convert.ToInt32(cmbCategory.GetColumnValue("ID"));
                        var    code        = cmbCategory.GetColumnValue("code").ToString();
                        int    count       = db.Items.Where(s => s.CategoryID == catId).Count();
                        string BarcodeText = "7" + code /*+ "-"*/ + (count + 1).ToString("000");
                        item.BarcodeText = BarcodeText;
                        item.Symbology   = "Code128";
                        isNew            = false;

                        DataAccess.ItemBarcode ibc = new DataAccess.ItemBarcode();
                        ibc.ItemID        = item.ID;
                        ibc.BarcodeText   = BarcodeText;
                        ibc.SystemBarcode = true;
                        db.ItemBarcodes.Add(ibc);
                    }
                    //this.item.SalePrice = 20;
                    //var res = db.ChangeTracker.Entries();
                    //if (res.Any())
                    //{
                    //}
                    if (db.SaveChanges() > 0)
                    {
                        //use to send notificationn when change price
                        if (oldPrice != null && oldPrice != item.SalePrice)
                        {
                            //Send notification message
                            string message = "تم تغيير سعر الصنف " + item.Name + " من " + oldPrice + " الي " + item.SalePrice;
                            PushMessage.SendPriceChangeMessage(message);
                            DataAccess.MarqueeMessage marqueeMessage;
                            int LifetimeDays = 3;
                            foreach (var branch in db.Branches.ToList())
                            {
                                marqueeMessage = new DataAccess.MarqueeMessage
                                {
                                    BranchID = branch.ID,

                                    LifetimeDays = LifetimeDays,
                                    Message      = message,
                                    Date         = DateTime.Now.AddDays(LifetimeDays),
                                    UserID       = Convert.ToInt32(UserData.Default.UserID)
                                };
                                db.MarqueeMessages.Add(marqueeMessage);
                            }
                            if (db.SaveChanges() > 0)
                            {
                            }
                        }
                        valid = true;
                        if (closeWindow)
                        {
                            this.Close();
                        }
                    }
                }
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "رقم الباركود قد يكون تم إدخاله لصنف آخر", null);
                bindingSourceItemBarcode.DataSource = /*this.item.ItemBarcodes;*/ db.ItemBarcodes.Where(s => s.ItemID == item.ID).ToList();
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }