public void SaveProduct(object parameter)
 {
     try
     {
         string path = InventoryHelper.GetSaveFilePath() + "\\" + ProductName + System.IO.Path.GetExtension(SelectedPath);
         if (SelectedPath != InventoryHelper.ImageNA)
         {
             System.IO.File.Copy(SelectedPath, path, true);
         }
         product temp = new product();
         temp.product_name = ProductName.Trim();
         if (!ProductServices.CheckProductNameAvailable(temp.product_name))
         {
             InventoryHelper.SimpleAlert("Warning", "Product Name is Already taken");
             return;
         }
         temp.brand        = Brand == null ? "" : Brand;
         temp.sub_category = SelectedSubCategory.id;
         temp.category     = SelectedCategory.id;
         temp.sell_price   = SellingPrice;
         temp.cost_price   = CostPrice;
         temp.image_url    = SelectedPath == InventoryHelper.ImageNA ? "" : path;
         temp.weight       = Weight == null ? "" : Weight;
         temp.Stock        = 0;
         temp.status       = true;
         int productId = ProductServices.AddUpdateProduct(temp);
         if (productId > 0)
         {
             // MessageBox.Show("Product Added");
             InventoryHelper.SuccessAlert("Success", "Product Added");
             Brand               = "";
             SellingPrice        = 0;
             CostPrice           = 0;
             Weight              = "";
             SelectedPath        = InventoryHelper.ImageNA;
             ProductName         = "";
             SelectedSubCategory = null;
             SelectedCategory    = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Product Entry Fails:" + ex.ToString());
     }
 }
        protected void DeleteProduct(object Parameter)
        {
            int     ProductId = (int)Parameter;
            product ob        = ProductServices.GetProduct(ProductId);

            ob.status = false;
            int x = ProductServices.AddUpdateProduct(ob);

            if (x > 0)
            {
                ProductEntity        temp    = (from p in Products where (p.id == ProductId) select p).First();
                List <ProductEntity> lsttemp = Products;
                lsttemp.Remove(temp);
                Products = null;
                Products = lsttemp;
                //MessageBox.Show("Product Deleted");
                InventoryHelper.SuccessAlert("Success", "Product Deleted");
            }
        }
示例#3
0
 public void SaveProduct(object parameter)
 {
     try
     {
         path = InventoryHelper.GetSaveFilePath() + "\\" + ProductName + System.IO.Path.GetExtension(SelectedPath);
         if (SelectedPath != InventoryHelper.ImageNA)
         {
             worker.DoWork             += worker_DoWork;
             worker.RunWorkerCompleted += worker_RunWorkerCompleted;
             worker.RunWorkerAsync();
         }
         product temp = new product();
         temp.id           = ProductId;
         temp.product_name = ProductName.Trim();
         if (!ProductServices.CheckProductNameAvailable(temp.product_name) && (ProductServices.GetProduct(temp.id).product_name != temp.product_name))
         {
             InventoryHelper.SimpleAlert("Warning", "Product Name is Already taken");
             return;
         }
         temp.brand        = Brand == null ? "" : Brand;
         temp.sub_category = SelectedSubCategory.id;
         temp.category     = SelectedCategory.id;
         temp.sell_price   = SellingPrice;
         temp.cost_price   = CostPrice;
         temp.image_url    = SelectedPath == InventoryHelper.ImageNA ? "" : path;
         temp.weight       = Weight == null ? "" : Weight;
         temp.status       = true;
         ProductId         = ProductServices.AddUpdateProduct(temp);
         if (ProductId > 0)
         {
             //MessageBox.Show("Product Edited");
             InventoryHelper.SuccessAlert("Success", "Product Edited");
         }
         Close = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Product Entry Fails:" + ex.ToString());
         //InventoryHelper.SimpleAlert("Warning", "Product Entry Fails:" + ex.ToString());
     }
 }