Ejemplo 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);
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
     }
 }
Ejemplo 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();
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }