Ejemplo n.º 1
0
        private BootProduct CreateProduct()
        {
            BootProduct product = new BootProduct();

            product.ShoeName    = Nametxt.Text;
            product.Price       = Convert.ToInt32(Pricetxt.Text);
            product.ShoeType    = Convert.ToInt32(TypeDropDown.SelectedValue);
            product.Description = Desctxt.Text;
            product.Image       = ImageDropDown.SelectedValue;

            return(product);
        }
Ejemplo n.º 2
0
 public BootProduct GetProducts(int id)
 {
     try
     {
         using (db_1525596_co5027Entities db = new db_1525596_co5027Entities())
         {
             BootProduct product = db.BootProducts.Find(id);
             return(product);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public string InsertProduct(BootProduct product)
        {
            try
            {
                db_1525596_co5027Entities db = new db_1525596_co5027Entities();
                db.BootProducts.Add(product);
                db.SaveChanges();

                return(product.ShoeName + " Inserted Successfull");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Ejemplo n.º 4
0
        private void Fillpage(int id)
        {
            //get selected details  from database
            ShoeModel   shoeModel = new ShoeModel();
            BootProduct product   = shoeModel.GetProducts(id);

            //Fill the text
            Desctxt.Text  = product.Description;
            Nametxt.Text  = product.ShoeName;
            Pricetxt.Text = product.Price.ToString();

            //set the value of dropdown
            ImageDropDown.SelectedValue = product.Image;
            TypeDropDown.SelectedValue  = product.ShoeType.ToString();
        }
Ejemplo n.º 5
0
        public string DeleteProduct(int id)
        {
            try
            {
                db_1525596_co5027Entities db = new db_1525596_co5027Entities();
                BootProduct product          = db.BootProducts.Find(id);

                db.BootProducts.Attach(product);
                db.BootProducts.Remove(product);
                db.SaveChanges();

                return(product.ShoeName + "Deleted Successfull");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Ejemplo n.º 6
0
        protected void Submitbtn_Click(object sender, EventArgs e)
        {
            ShoeModel   bootProduct = new ShoeModel();
            BootProduct product     = CreateProduct();

            //checck if there is an id on the websitename
            if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                //there is an id
                int id = Convert.ToInt32(Request.QueryString["id"]);
                ResultLabel.Text = bootProduct.UpdateProduct(id, product);
            }
            else
            {
                //no id
                ResultLabel.Text = bootProduct.InsertProduct(product);
            }
        }
Ejemplo n.º 7
0
        public string UpdateProduct(int id, BootProduct product)
        {
            try
            {
                db_1525596_co5027Entities db = new db_1525596_co5027Entities();
                //get the info from the db
                BootProduct p = db.BootProducts.Find(id);

                p.ShoeName    = product.ShoeName;
                p.Price       = product.Price;
                p.ShoeType    = product.ShoeType;
                p.Description = product.Description;
                p.Image       = product.Image;

                db.SaveChanges();
                return(product.ShoeName + " Updated Successfull");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }