Esempio n. 1
0
        private watchProduct CreatewatchProduct()
        {
            watchProduct watchproduct = new watchProduct();

            watchproduct.watchName        = txtNameP.Text;
            watchproduct.watchPrice       = Convert.ToInt32(txtPriceP.Text);
            watchproduct.watchProID       = Convert.ToInt32(ddlTypeP.SelectedValue);
            watchproduct.watchDescription = txtDescP.Text;
            watchproduct.watchImage       = ddlPicP.SelectedValue;

            return(watchproduct);
        }
Esempio n. 2
0
        public string InsertwatchProd(watchProduct watchproduct)
        {
            try
            {
                db_1525591_co5027_aziimEntities db = new db_1525591_co5027_aziimEntities();
                db.watchProducts.Add(watchproduct);
                db.SaveChanges();

                return(watchproduct.watchName + "was just added to your cart");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Esempio n. 3
0
 public watchProduct GetwatchProduct(int id)
 {
     try
     {
         using (db_1525591_co5027_aziimEntities db = new db_1525591_co5027_aziimEntities())
         {
             watchProduct watchproduct = db.watchProducts.Find(id);
             return(watchproduct);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 4
0
        private void FillPage(int id)
        {
            //retrieve product which are selected from database
            PwModel      pwmodel      = new PwModel();
            watchProduct watchproduct = pwmodel.GetwatchProduct(id);

            //Fill in textboxes
            txtDescP.Text  = watchproduct.watchDescription;
            txtNameP.Text  = watchproduct.watchName;
            txtPriceP.Text = watchproduct.watchPrice.ToString();

            //set ddl values
            ddlPicP.SelectedValue  = watchproduct.watchImage;
            ddlTypeP.SelectedValue = watchproduct.watchProID.ToString();
        }
Esempio n. 5
0
        public string DeletewatchProd(int id)
        {
            try
            {
                db_1525591_co5027_aziimEntities db = new db_1525591_co5027_aziimEntities();
                watchProduct watchproduct          = db.watchProducts.Find(id);

                db.watchProducts.Attach(watchproduct);
                db.watchProducts.Remove(watchproduct);
                db.SaveChanges();

                return(watchproduct.watchName + "was just removed");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
Esempio n. 6
0
        protected void btnSubmitP_Click(object sender, EventArgs e)
        {
            PwModel      pwmodel      = new PwModel();
            watchProduct watchproduct = CreatewatchProduct();

            //checking if the url contains id parameter
            if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                //id is exist thus update current row
                int id = Convert.ToInt32(Request.QueryString["id"]);
                lblResultP.Text = pwmodel.UpdatewatchProd(id, watchproduct);
            }
            else
            {
                //id is not exist thus create new row
                lblResultP.Text = pwmodel.InsertwatchProd(watchproduct);
            }
        }
Esempio n. 7
0
        public string UpdatewatchProd(int id, watchProduct watchproduct)
        {
            try
            {
                db_1525591_co5027_aziimEntities db = new db_1525591_co5027_aziimEntities();
                //take object from database
                watchProduct prod = db.watchProducts.Find(id);

                prod.watchName        = watchproduct.watchName;
                prod.watchPrice       = watchproduct.watchPrice;
                prod.watchProID       = watchproduct.watchProID;
                prod.watchDescription = watchproduct.watchDescription;
                prod.watchImage       = watchproduct.watchImage;

                db.SaveChanges();

                return(watchproduct.watchName + "was just updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }