protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        dt.Columns.Add("Item_Description");
        dt.Columns.Add("Fashion_item_Id");
        dt.Columns.Add("Fashion_Type_Name");
        dt.Columns.Add("BrandName");
        dt.Columns.Add("Price");

        if (Session["ShoppingCart"] != null)
        {
            dt = Session["ShoppingCart"] as DataTable;
            Label lbl_CartCount = this.Master.FindControl("lbl_cart") as Label;
            lbl_CartCount.Text = "( " + dt.Rows.Count.ToString() + " )";
        }

        if (!IsPostBack)
        {
            WomenFashionEntities entity = new WomenFashionEntities();
            var fitems = (from ob in entity.Fashion_Item
                          where (ob.Fashion_Type_Id == 2)
                          select new { ob.Fashion_item_Id, ob.Item_Description, ob.Color.ColorName, ob.ImageURL, ob.category.categoryhtml, ob.Price }).ToList();
            Repeater_Product.DataSource = fitems;
            Repeater_Product.DataBind();
        }
    }
    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;
    }
    private void FillFashionGridView()
    {
        //h3ml fill lel grid view be asamy columns mo3yna ana 3yzaha mn l table el esmo "Fashion_Item"
        //select new :: lma ba3oz a3mla selection le hagat mo3yna mn table msh el columns kolha y3ny
        WomenFashionEntities entity = new WomenFashionEntities();
        var AllObj = (from obj in entity.Fashion_Item select new { obj.Fashion_item_Id, obj.Fashion_Type.Fashion_Type_Name, obj.Price, obj.Brand.BrandName }).ToList();

        GridView_FashionItems.DataSource = AllObj;
        GridView_FashionItems.DataBind();
    }
Exemple #4
0
    protected void btn_search_Click(object sender, EventArgs e)
    {
        WomenFashionEntities entity = new WomenFashionEntities();

        //ana 3ayza a3ml select lel color mn l database
        string InputSearch = txt_Search.Value.Trim().ToString();

        var allobj = (from ob in entity.Fashion_Item where (ob.Color.ColorName.ToLower() == InputSearch.ToLower())
                      select new { ob.Item_Description, ob.Color.ColorName, ob.ImageURL, ob.category.categoryhtml, ob.Price }).ToList();

        Session["AllSearchData"] = allobj;
        Response.Redirect("../UserPages/Search.aspx");
    }
    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.... )
    }
Exemple #6
0
    //public static void Fill_Brand(DropDownList ddlBrand)
    //{
    //    WomenFashionEntities entity = new WomenFashionEntities();

    //    var brands = (from obj in entity.Brand select obj).ToList(); //obj de hatrg3le kolo

    //    ddlBrand.Items.Clear();
    //    ddlBrand.Items.Add(new ListItem("Select", "0"));

    //    foreach (var item in brands)
    //    {
    //        ddlBrand.Items.Add(new ListItem(item.BrandName.ToString(), item.BrandID.ToString()));
    //    }


    //}

    public static void Fill_Color(DropDownList ddlcolor)
    {
        WomenFashionEntities entity = new WomenFashionEntities();

        var colors = (from obj in entity.Color select obj).ToList(); //obj de hatrg3le kolo

        ddlcolor.Items.Clear();
        ddlcolor.Items.Add(new ListItem("Select", "0"));

        foreach (var item in colors)
        {
            ddlcolor.Items.Add(new ListItem(item.ColorName.ToString(), item.ColorID.ToString()));
        }
    }
    public static void Fill_FashionType(DropDownList ddlFashType)
    {
        WomenFashionEntities entity = new WomenFashionEntities();

        var fashiontype = (from obj in entity.Fashion_Type select obj).ToList(); //obj de hatrg3le kolo

        ddlFashType.Items.Clear();
        ddlFashType.Items.Add(new ListItem("Select", "0"));

        foreach (var item in fashiontype)
        {
            ddlFashType.Items.Add(new ListItem(item.Fashion_Type_Name.ToString(), item.Fashion_Type_Id.ToString()));
        }
    }
Exemple #8
0
    protected void ddl_FashionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        //hageeb el selected value fa lw howa e5tar mn l ddl bt3t l fashion msln clothes el hya el value bt3tha btsway 1
        int selectedfashtypeID = int.Parse(ddl_FashionType.SelectedValue.ToString());

        WomenFashionEntities entity = new WomenFashionEntities();
        //fa ana ha5od l 1 da b2a w aroo7 ageeb l brands bt3to mn db el mapped b number 1 de
        var brands = (from obj in entity.Brand where (obj.Fashion_Type_Id == selectedfashtypeID) select obj).ToList();

        ddl_Brand.Items.Clear();
        ddl_Brand.Items.Add(new ListItem("Select", "0"));

        foreach (var item in brands)
        {
            ddl_Brand.Items.Add(new ListItem(item.BrandName.ToString(), item.BrandID.ToString()));
        }
    }
Exemple #9
0
    public static void Fill_FashionType(DropDownList ddlFashType)
    {
        WomenFashionEntities entity = new WomenFashionEntities();

        // 3mlt select all from table el esmo fashion type
        var fashiontype = (from obj in entity.Fashion_Type select obj).ToList(); //obj de hatrg3le kolo

        ddlFashType.Items.Clear();
        ddlFashType.Items.Add(new ListItem("Select", "0"));

        //hroo7 a loop 3alehom w a7othom fl dropdownlist bt3ty
        // baruh aloop 3ala l cols l f table l fashion_type l fe l database w agbhum w ahutuhum f list b3d kda aloop 3alehum 3ashan ahutuhum f l ddl bt3tee 3ashan yzharulii
        foreach (var item in fashiontype)
        {
            // listitem de bt5od text w value , l text l 3yzah yzahar wl value bt3to l rakam bt3o ely mapped fl database
            ddlFashType.Items.Add(new ListItem(item.Fashion_Type_Name.ToString(), item.Fashion_Type_Id.ToString()));
        }
    }
    //GridView_FashionItems_SelectedIndexChanged --> lma adool 3la select fl grid y7sal eh ??
    //l mfrood yroo7 ygble l data kolha bt3t l row l ana 3mlto selection da
    protected void GridView_FashionItems_SelectedIndexChanged(object sender, EventArgs e)
    {
        Panel_StatusError.Visible   = false;
        Panel_StatusSuccess.Visible = false;
        lblStatusError.Text         = "";

        lblStatusSuccess.Text = "";
        WomenFashionEntities entity = new WomenFashionEntities();

        //gbt l id bta3 l selected item l ana a5trto 3shan howa da l haga l unique el a2dar ageeb beha l data ely m3ah
        int SelectedItemID = int.Parse(GridView_FashionItems.SelectedValue.ToString());

        //b3ml selection lel row kamel mn l database depends 3la l fashionID el ana a5trto mn el grid
        //SelectedFashionItem --> da hyrg3 be row kamel mn l db hygble y3ny shayel l columns
        var SelectedFashionItem = (from tab in entity.Fashion_Item where (tab.Fashion_item_Id == SelectedItemID) select tab).FirstOrDefault();

        //hbad2 b2a a7ot fl controls bt3ty el values el mwgooda mn SelectedFashionItem 3shan a2dar b3d kda a3ml edit 3aleha

        ddl_FashionType.SelectedValue = SelectedFashionItem.Fashion_Type_Id.Value.ToString();
        txtbox_Description.Text       = SelectedFashionItem.Item_Description.ToString();
        ImgShow.ImageUrl         = SelectedFashionItem.ImageURL.ToString();
        ddl_Color.SelectedValue  = SelectedFashionItem.ColorId.ToString();
        ddl_Rating.SelectedValue = SelectedFashionItem.categoryid.ToString();
        txtbox_Price.Text        = SelectedFashionItem.Price.ToString();

        //3shan l brands asln depends 3la fashionType ID el howa 1 aw 2 aw 3 el hya clothes wla make up wla accessories
        // fa l awl haroo7 a select l brands w a7otha fl ddl bt3t l brands
        var brands = (from obj in entity.Brand where (obj.Fashion_Type_Id == SelectedFashionItem.Fashion_Type_Id.Value) select obj).ToList();

        ddl_Brand.Items.Clear();
        ddl_Brand.Items.Add(new ListItem("Select", "0"));

        foreach (var item in brands)
        {
            ddl_Brand.Items.Add(new ListItem(item.BrandName.ToString(), item.BrandID.ToString()));
        }

        ddl_Brand.SelectedValue = SelectedFashionItem.BrandID.ToString();

        Panel_FashionitemData.Visible = true;
        //  ImgShow.Visible = true;
    }
    // el functions bt3t el cart

    protected void lnkbtn_AddToCart_Click(object sender, EventArgs e)
    {
        WomenFashionEntities entity = new WomenFashionEntities();

        RepeaterItem item = (sender as LinkButton).NamingContainer as RepeaterItem;
        int          selectedFashionItemID = int.Parse((item.FindControl("lbl_Fashion_item_Id") as Label).Text);

        var SelectItem = (from tab in entity.Fashion_Item where tab.Fashion_item_Id == selectedFashionItemID select tab).FirstOrDefault();


        DataTable dt = new DataTable();

        dt.Columns.Add("Item_Description");
        dt.Columns.Add("Fashion_item_Id");
        dt.Columns.Add("Fashion_Type_Name");
        dt.Columns.Add("BrandName");
        dt.Columns.Add("Price");

        if (Session["ShoppingCart"] != null)
        {
            dt = Session["ShoppingCart"] as DataTable;
        }


        DataRow dr = dt.NewRow();

        dr["Item_Description"]  = SelectItem.Item_Description;
        dr["Fashion_item_Id"]   = SelectItem.Fashion_item_Id;
        dr["Fashion_Type_Name"] = SelectItem.Brand.BrandName;
        dr["BrandName"]         = SelectItem.Fashion_Type.Fashion_Type_Name;
        dr["Price"]             = SelectItem.Price.Value;

        dt.Rows.Add(dr);
        Session["ShoppingCart"] = dt;


        Label lbl_CartCount = this.Master.FindControl("lbl_cart") as Label;

        lbl_CartCount.Text = "( " + dt.Rows.Count.ToString() + " )";
    }
Exemple #12
0
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        Lbl_status.Text = "";
        WomenFashionEntities entity = new WomenFashionEntities();

        String UserNm = txt_username.Text.Trim();
        String Pass   = txt_password.Text.Trim();
        //7aga shabh el variable (tab ) 3shan n2dar n access el columns el gowa el table
        var CheckIfFoundOrNot = (from tab in entity.Admin where (tab.UserName == UserNm && tab.Password == Pass) select tab).FirstOrDefault();


        if (CheckIfFoundOrNot != null) // If Matched
        {
            Session["UserName"] = UserNm;
            Response.Redirect("../AdminPages/Add.aspx");
        }
        else
        {
            txt_username.Text = "";
            txt_password.Text = "";
            Lbl_status.Text   = "InCorrect UserName or Password !";
        }
    }
    protected void ddl_FashionType_SelectedIndexChanged(object sender, EventArgs e)
    {
        Panel_StatusError.Visible   = false;
        Panel_StatusSuccess.Visible = false;
        lblStatusError.Text         = "";
        lblStatusSuccess.Text       = "";

        int selectedfashtypeID = int.Parse(ddl_FashionType.SelectedValue.ToString());

        WomenFashionEntities entity = new WomenFashionEntities();
        var brands = (from obj in entity.Brand where (obj.Fashion_Type_Id == selectedfashtypeID) select obj).ToList();

        ddl_Brand.Items.Clear();
        ddl_Brand.Items.Add(new ListItem("Select", "0"));

        foreach (var item in brands)
        {
            ddl_Brand.Items.Add(new ListItem(item.BrandName.ToString(), item.BrandID.ToString()));
        }


        ddl_Brand.Focus();
    }
Exemple #14
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.... )
    }