Exemple #1
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            ErrorMessage = string.Empty;
            ////Validate new row only
            //if (e.RowHandle != GridControl.NewItemRowHandle)
            //{
            //    return;
            //}
            DataAccess.Item currentRow = (DataAccess.Item)gridView1.GetFocusedRow();

            if (currentRow.Name == null || currentRow.Name == string.Empty)
            {
                e.Valid       = false;
                e.ErrorText   = "Error 0";
                ErrorMessage += "- Name must have a value \n";
                gridView1.SetColumnError(colName, "Name must have a value");
            }
            else
            if (currentRow.Name != null && currentRow.Name.Length > 50)
            {
                e.Valid       = false;
                ErrorMessage += "- Name must have 50 characters maximum \n";
                gridView1.SetColumnError(colName, "50 characters maximum");
            }

            if (currentRow.CategoryID == null || currentRow.CategoryID == 0)
            {
                e.Valid       = false;
                ErrorMessage += "- You must select a category  \n";
                gridView1.SetColumnError(colCategoryID, "Category must have a value");
            }
        }
Exemple #2
0
        public ItemForm(string p, bool quickInsert = false)
        {
            InitializeComponent();
            _quickInsert = quickInsert;
            if (_quickInsert)
            {
                bindingSourceCategory.DataSource = db.ItemCategories.Where(s => s.ID == 2014).ToList();
            }
            else
            {
                bindingSourceCategory.DataSource = db.ItemCategories.ToList();
            }

            gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None;
            item              = db.Items.Create();
            item.SalePrice    = 0;
            item.ReorderPoint = 5;
            item.CategoryID   = db.ItemCategories.First().ID;
            db.Items.Add(item);
            bindingSourceItem.DataSource        = item;
            bindingSourceItemBarcode.DataSource = this.item.ItemBarcodes;
            item.Name = p;
            txtName.Focus();
            isNew = true;
        }
Exemple #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);
     }
 }
 /// <summary>
 /// Convert ItemViewModel Entity  into Item Object
 /// </summary>
 ///<param name="model">ItemViewModel</param>
 ///<param name="RegionEntity">DataAccess.Item</param>
 ///<returns>ItemViewModel</returns>
 public static ItemViewModel ToViewModel(this DataAccess.Item entity,
                                         ItemViewModel model)
 {
     model.SessionUserId     = entity.CreatedUserId;
     model.Id                = entity.Id;
     model.ProductCategoryId = entity.ProductSize.Product.ProductCategoryId;
     model.ProductId         = entity.ProductSize.ProductId;
     model.ProductSizeId     = entity.ProductSizeId;
     model.Product           = entity.ProductSize.Product.Name;
     model.ProductCategory   = entity.ProductSize.Product.Name;
     model.Quantity          = entity.Quantity;
     model.Size              = entity.ProductSize.Size.Name;
     model.ProductSizes      = entity.ProductSize.Product.ProductSizes.ToSelectListItem(x => x.Size.ShortName, x => x.Id.ToString());
     model.Products          = entity.ProductSize.Product.ProductCategory.Products.ToSelectListItem(x => x.Name, x => x.Id.ToString());
     return(model);
 }
        /// <summary>
        /// Convert ItemViewModel Object into Item Entity
        /// </summary>
        ///<param name="model">ItemViewModel</param>
        ///<param name="RegionEntity">DataAccess.Item</param>
        ///<returns>DataAccess.Item</returns>
        public static DataAccess.Item ToEntity(this ItemViewModel model,
                                               DataAccess.Item entity
                                               )
        {
            if (entity.Id == 0)
            {
                entity.CreatedUserId = model.SessionUserId;
            }
            else
            {
                entity.UpdatedUserId    = model.SessionUserId;
                entity.UpdatedTimestamp = DateTime.Now;
            }

            entity.ProductSizeId = model.ProductSizeId;
            entity.Quantity      = model.Quantity;

            return(entity);
        }
Exemple #6
0
 private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colHidden)
     {
         try
         {
             var             row        = gridView1.GetRow(e.RowHandle);
             DataAccess.Item currentRow = (DataAccess.Item)row;
             currentRow.Hidden = false;
             if (db.SaveChanges() > 0)
             {
             }
         }
         catch (Exception ex)
         {
             ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
         }
     }
 }
Exemple #7
0
        private void gridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)// && e.Modifiers == Keys.Control)
            {
                if (MessageBox.Show("Delete row?", "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                DataAccess.Item currentRow = (DataAccess.Item)gridView1.GetFocusedRow();
                //GridView view = sender as GridView;
                db.Items.Remove(currentRow);
                if (db.SaveChanges() > 0)
                {
                    MainScreen parent = (MainScreen)this.Parent.Parent.Parent.Parent;
                    parent.ShowMessageInStatusBar("Item Deleted", 9000);
                }
            }
        }
Exemple #8
0
        public ItemForm(DataAccess.Item item)
        {
            InitializeComponent();
            bindingSourceCategory.DataSource = db.ItemCategories.ToList();
            this.item = db.Items.Where(s => s.ID == item.ID).SingleOrDefault();;
            //use to send notificationn when change price
            oldPrice = item.SalePrice;

            bindingSourceItem.DataSource        = this.item;
            bindingSourceItemBarcode.DataSource = /*this.item.ItemBarcodes;*/ db.ItemBarcodes.Where(s => s.ItemID == item.ID).ToList();
            // item.Name = p;
            txtName.Focus();

            var itm = db.Items.Where(s => s.Name.Contains("osman")).SingleOrDefault();

            itm.SalePrice = 20;
            if (db.SaveChanges() > 0)
            {
            }
        }
Exemple #9
0
        public ItemForm(int ItemID, bool quickInsert = false)
        {
            InitializeComponent();
            _quickInsert = quickInsert;
            if (_quickInsert)
            {
                bindingSourceCategory.DataSource = db.ItemCategories.Where(s => s.ID == 2014).ToList();
            }
            else
            {
                bindingSourceCategory.DataSource = db.ItemCategories.ToList();
            }
            gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Top;

            item = db.Items.Where(s => s.ID == ItemID).SingleOrDefault();
            //use to send notificationn when change price
            oldPrice = item.SalePrice;
            bindingSourceItem.DataSource        = item;
            bindingSourceItemBarcode.DataSource = this.item.ItemBarcodes;
            // item.Name = p;
            txtName.Focus();
        }