예제 #1
0
    protected void btn_Delete_Click(object sender, EventArgs e)
    {
        Panel_StatusError.Visible   = false;
        Panel_StatusSuccess.Visible = false;
        lblStatusError.Text         = "";
        lblStatusSuccess.Text       = "";

        WomenFashionEntities entity = new WomenFashionEntities();
        int SelectedItemID          = int.Parse(GridView_FashionItems.SelectedValue.ToString()); // selected value from grid


        Fashion_Item objFashion = new Fashion_Item {
            Fashion_item_Id = SelectedItemID
        };

        entity.Fashion_Item.Attach(objFashion);
        entity.Fashion_Item.Remove(objFashion);
        entity.SaveChanges();
        lblStatusSuccess.Text       = "Deleting Done SuccessFully";
        Panel_StatusSuccess.Visible = true;
        FillFashionGridView();
        Clear();
        ImgShow.Visible = false;
        Panel_FashionitemData.Visible = false;
    }
예제 #2
0
    protected void btn_Edit_Click(object sender, EventArgs e)
    {
        Panel_StatusError.Visible   = false;
        Panel_StatusSuccess.Visible = false;
        lblStatusError.Text         = "";
        lblStatusSuccess.Text       = "";

        WomenFashionEntities entity = new WomenFashionEntities();

        int SelectedItemID = int.Parse(GridView_FashionItems.SelectedValue.ToString());

        var SelectedFashionItem = (from tab in entity.Fashion_Item where (tab.Fashion_item_Id == SelectedItemID) select tab).FirstOrDefault();

        //ha5od l values l user 3amlha update w a7otha tany fl controls bt3ty 3shan a3ml save b3d kda
        SelectedFashionItem.Fashion_Type_Id  = int.Parse(ddl_FashionType.SelectedValue.ToString());
        SelectedFashionItem.BrandID          = int.Parse(ddl_Brand.SelectedValue.ToString());
        SelectedFashionItem.ColorId          = int.Parse(ddl_Color.SelectedValue.ToString());
        SelectedFashionItem.Item_Description = txtbox_Description.Text.Trim();
        SelectedFashionItem.Price            = double.Parse(txtbox_Price.Text);
        SelectedFashionItem.categoryid       = int.Parse(ddl_Rating.SelectedValue);

        if (FileUpload_images.HasFile != false)
        {
            string NewPath = "~/WebImages/" + FileUpload_images.FileName;
            string type    = NewPath.Substring(NewPath.LastIndexOf(".") + 1).ToLower();

            if (type == "jpeg".ToLower() || type == "png".ToLower() || type == "gif".ToLower() || type == "jpg".ToLower())
            {
                SelectedFashionItem.ImageURL = NewPath;
                FileUpload_images.SaveAs(Server.MapPath(NewPath));
            }
            else
            {
                lblStatusError.Text       = "File Extention Not Valid ! ";
                Panel_StatusError.Visible = true;
                return;
            }
        }

        //b3ml save lel values el gdeda
        entity.SaveChanges();
        ImgShow.ImageUrl            = SelectedFashionItem.ImageURL;
        ImgShow.Visible             = true;
        lblStatusSuccess.Text       = "Editing Done SuccessFully";
        Panel_StatusSuccess.Visible = true;
        // w b3den arg3 a3ml filling tany lel grid bl values l gdeda
        FillFashionGridView();
        Panel_FashionitemData.Visible = false;

        Clear();  // reset to The Whole page again ( refill Dropwon Lists , Clear textbox , etc.... )
    }
예제 #3
0
    //=====================================================
    //{ ddl_FashionType_SelectedIndexChanged } ->> da m3na eny awl ma adoos 3la l ddl bt3t l fashion type y7sl action
    //tab ana 3yzah y7sal eh ? --> 3yza awl ma a5tar noo3 l item el howa ya2ma clothes ya2ma makeup ya2ma accessories
    //yroo7 y3bele l ddl bt3t l brand based  3la l type el ana a5tro mn l ddl bt3t l fashion de
    //=====================================================


    protected void btn_add_Click(object sender, EventArgs e)
    {
        Panel_StatusError.Visible   = false;
        Panel_StatusSuccess.Visible = false;
        lblStatusError.Text         = "";
        lblStatusSuccess.Text       = "";


        //
        if (FileUpload_images.HasFile == false)
        {
            lblStatusError.Text       = "You Must Choose Image !";
            Panel_StatusError.Visible = true;
            return;
        }



        WomenFashionEntities entity = new WomenFashionEntities();

        Fashion_Item fashiontype_tbl = new Fashion_Item(); //object from table bs lessa fady wna h3mlo fill

        //bageb l values l howa da5laha

        fashiontype_tbl.Fashion_Type_Id = int.Parse(ddl_FashionType.SelectedValue.ToString());

        fashiontype_tbl.BrandID          = int.Parse(ddl_Brand.SelectedValue.ToString());
        fashiontype_tbl.ColorId          = int.Parse(ddl_Color.SelectedValue.ToString());
        fashiontype_tbl.Item_Description = txtbox_Description.Text.Trim();
        fashiontype_tbl.Price            = double.Parse(txtbox_Price.Text);
        fashiontype_tbl.categoryid       = int.Parse(ddl_Rating.SelectedValue);



        //IMAGE LOAD

        if (FileUpload_images.HasFile != false)// DA5LT SOORA
        {
            //lw da5l soora , fa ana ha create new path l hwa l path l mwgood 3ndy fl projec { folder esmo webimages } w ha7ot wrah esm l soora
            string NewPath = "~/WebImages/" + FileUpload_images.FileName;

            //hageeb l extension bta3 l soora l howa b3d l . w ashoof no3o
            string type = NewPath.Substring(NewPath.LastIndexOf(".") + 1).ToLower();

            if (type == "jpeg".ToLower() || type == "png".ToLower() || type == "gif".ToLower() || type == "jpg".ToLower())
            {
                //lw tmaam yb2a ha7ot el path da fl table
                fashiontype_tbl.ImageURL = NewPath;
                FileUpload_images.SaveAs(Server.MapPath(NewPath));
            }
            else
            {
                lblStatusError.Text       = "File Extention Not Valid ! ";
                Panel_StatusError.Visible = true;
                return;
            }
        }

        entity.Fashion_Item.Add(fashiontype_tbl);
        entity.SaveChanges();
        ImgShow.ImageUrl            = fashiontype_tbl.ImageURL;
        ImgShow.Visible             = true;
        lblStatusSuccess.Text       = "Adding Done SuccessFully";
        Panel_StatusSuccess.Visible = true;


        Clear();  // reset to The Whole page again ( refill Dropwon Lists , Clear textbox , etc.... )
    }