Esempio n. 1
0
        protected void itemGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int        itemid       = Convert.ToInt32(itemGrid.DataKeys[e.RowIndex].Value.ToString());
            TextBox    itemname     = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_iname");
            TextBox    description  = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_editidescr");
            FileUpload fu_itemimage = (FileUpload)itemGrid.Rows[e.RowIndex].FindControl("fu_iimage");
            TextBox    catagoryid   = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_cid");
            TextBox    billedrate   = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_billedrate");
            TextBox    quantity     = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_qty");
            TextBox    netrate      = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_netrate");

            //check whether the image is valid or not
            bool isImageValid = checkPhoto(fu_itemimage, Int32.Parse(catagoryid.Text), itemid);

            if (isImageValid)
            {
                //save updated values in database
                BusinessEntitiesBS.ItemEntities.ItemObj UpdateItemObj = new BusinessEntitiesBS.ItemEntities.ItemObj();
                UpdateItemObj.itemName     = itemname.Text;
                UpdateItemObj.itemDesc     = description.Text;
                UpdateItemObj.itemCatagory = Int32.Parse(catagoryid.Text);
                UpdateItemObj.itemBR       = float.Parse(billedrate.Text);
                UpdateItemObj.itemQty      = Int32.Parse(quantity.Text);
                UpdateItemObj.itemNR       = float.Parse(netrate.Text);

                IAdmin UpdateItems = new AdminItems();
                int    updated     = UpdateItems.UpdateItems(UpdateItemObj, itemid);
                if (updated != -1)
                {
                    lbl_status.Text    = "Updated Successfully";
                    itemGrid.EditIndex = -1;
                    if (txt_itemname.Text == "Enter Item Name/Id")
                    {
                        int grpCatId = Int32.Parse(ddl_catagory.SelectedValue.ToString());
                        getItems(grpCatId);
                    }
                    else
                    {
                        searchDT(txt_itemname.Text);
                    }
                }
                else
                {
                    lbl_status.Text = "Error Occured.. Row Not Updated";
                }
            }
            else
            {
                lbl_status.Text = "Selected file is not an image or it is greater than 1mb";
            }
        }
Esempio n. 2
0
        protected void itemGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int          itemid          = Convert.ToInt32(itemGrid.DataKeys[e.RowIndex].Value.ToString());
            TextBox      itemname        = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_iname");
            TextBox      description     = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_editidescr");
            FileUpload   fu_itemimage    = (FileUpload)itemGrid.Rows[e.RowIndex].FindControl("fu_iimage");
            TextBox      catagoryid      = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_cid");
            TextBox      billedrate      = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_billedrate");
            TextBox      quantity        = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_qty");
            TextBox      netrate         = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_netrate");
            CheckBox     cb_actvsts      = (CheckBox)itemGrid.Rows[e.RowIndex].FindControl("cb_actvstsedit");
            CheckBox     cb_featuredflag = (CheckBox)itemGrid.Rows[e.RowIndex].FindControl("cb_fflagedit");
            TextBox      txt_itemtype    = (TextBox)itemGrid.Rows[e.RowIndex].FindControl("txt_type");
            DropDownList ddl_SubCatId    = (DropDownList)itemGrid.Rows[e.RowIndex].FindControl("ddl_subcatid");
            DropDownList ddl_merchantId  = (DropDownList)itemGrid.Rows[e.RowIndex].FindControl("ddl_merchantId");

            //check whether the image is valid or not
            bool isImageValid = checkPhoto(fu_itemimage, Int32.Parse(catagoryid.Text), itemid);

            if (isImageValid)
            {
                //save updated values in database
                BusinessEntitiesBS.ItemEntities.ItemObj UpdateItemObj = new BusinessEntitiesBS.ItemEntities.ItemObj();
                UpdateItemObj.itemName     = itemname.Text;
                UpdateItemObj.itemDesc     = description.Text;
                UpdateItemObj.itemCatagory = Int32.Parse(catagoryid.Text);
                UpdateItemObj.itemBR       = float.Parse(billedrate.Text);
                UpdateItemObj.itemQty      = Int32.Parse(quantity.Text);
                UpdateItemObj.itemNR       = float.Parse(netrate.Text);
                UpdateItemObj.itemStatus   = cb_actvsts.Checked;
                UpdateItemObj.featuredFlag = cb_featuredflag.Checked;
                UpdateItemObj.itemType     = txt_itemtype.Text;
                UpdateItemObj.itemSubCatId = Int32.Parse(ddl_SubCatId.SelectedValue);
                UpdateItemObj.merchantId   = Int32.Parse(ddl_merchantId.SelectedValue);

                IAdmin UpdateItems = new AdminItems();
                int    updated     = UpdateItems.UpdateItems(UpdateItemObj, itemid);
                if (updated != -1)
                {
                    lbl_status.Text = HardCodedValues.BuddaResource.UpdateSuccess;
                    ClearCache();
                    itemGrid.EditIndex = -1;
                    int grpCatId = Int32.Parse(ddl_catagory.SelectedValue.ToString());
                    if (txt_itemname.Text == "")
                    {
                        getItems(grpCatId);
                    }
                    else
                    {
                        searchDT(txt_itemname.Text, grpCatId);
                    }
                }
                else
                {
                    lbl_status.Text = HardCodedValues.BuddaResource.UpdateFail;
                }
            }
            else
            {
                lbl_status.Text = HardCodedValues.BuddaResource.ImageError;
            }
        }