Esempio n. 1
0
 //update product info function
 public void SaveUpdate(int index)
 {
     try
     {
         BL.Inventory inventory  = new BL.Inventory();
         var          ctrl       = GVProducts.Rows[index].FindControl("fileImgSave");
         var          fileUpload = (FileUpload)ctrl;
         var          img        = fileUpload.PostedFile.FileName;
         string       image      = img;
         string       imgFile    = Path.GetFileName(image);
         string       folderPath = Server.MapPath("~/Images/");
         fileUpload.SaveAs(folderPath + Path.GetFileName(fileUpload.FileName));
         string name = (GVProducts.Rows[index].FindControl("txtName") as TextBox).Text.Trim();
         var    selectedCategoryStr = (GVProducts.Rows[index].FindControl("txtCategory") as TextBox).Text.Trim();
         int    selectedCategory    = int.Parse(selectedCategoryStr);
         var    AmntAvStr           = (GVProducts.Rows[index].FindControl("txtAmountAvailable") as TextBox).Text.Trim();
         int    AmountAvailable     = int.Parse(AmntAvStr);
         var    priceString         = (GVProducts.Rows[index].FindControl("txtPrice") as TextBox).Text.Trim();
         int    price    = int.Parse(priceString);
         string type     = (GVProducts.Rows[index].FindControl("txtType") as TextBox).Text.Trim();
         string platform = (GVProducts.Rows[index].FindControl("txtPlatform") as TextBox).Text.Trim();
         string desc     = (GVProducts.Rows[index].FindControl("txtDescription") as TextBox).Text.Trim();
         inventory.BLUpdateProduct(index, GVProducts, name, selectedCategory, type, platform, AmountAvailable, price, desc, image);
         GVProducts.EditIndex = -1;
         if (lblSuccess.Visible)
         {
             lblSuccess.Visible = false;
         }
         populateGV();
         populateDDL();
     }
     catch
     {
         lblSuccess.Visible = true;
         lblSuccess.Text    = "Error With Updating! Ensure Data Is In Correct Format And All Data Is Filled Out!";
     }
 }