Ejemplo n.º 1
0
        protected void btnProductAdd_Click(object sender, EventArgs e)
        {
            singlePicture = Request.Params["singlePicture"] != null ? Request.Params["singlePicture"].ToString() : String.Empty;
            Urun u = new Urun();

            u.PersonelId.Id    = 1;
            u.Ad               = txtUrunAd.Text;
            u.Barkod           = txtBarkod.Text;
            u.Fiyat            = Convert.ToDecimal(txtCost.Text);
            u.Stok             = Convert.ToInt16(txtStock.Text);
            u.AltKategoriId.Id = Convert.ToInt16(DropDownListSubCategory.SelectedItem.Value);
            u.Ozellikler       = txtFeatures.Text;
            u.RafId.Id         = Convert.ToInt16(DropDownListRaf.SelectedItem.Value);
            UrunDb udb = new UrunDb();

            try
            {
                udb.Insert(u);
            }
            catch (Exception hata)
            {
                Response.Write("<script LANGUAGE='JavaScript' >alert('" + hata.Message.ToString() + "')</script>");
            }

            UrunResim r = new UrunResim();

            r.Yol = "Images/" + singlePicture;
            UrunResimDb rdb = new UrunResimDb();

            try
            {
                rdb.Insert(r);
            }
            catch (Exception hata)
            {
                Response.Write("<script LANGUAGE='JavaScript' >alert('" + hata.Message.ToString() + "')</script>");
            }
            Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }
Ejemplo n.º 2
0
        protected void btnProductDelete_Click(object sender, EventArgs e)
        {
            Urun u = new Urun();

            u.Barkod = txtBarkod.Text;
            UrunDb    db        = new UrunDb();
            int       productID = db.GetProductID(u);
            UrunResim ur        = new UrunResim();

            ur.UrunId.Id = productID;
            UrunResimDb urdb = new UrunResimDb();

            try
            {
                urdb.Delete(ur);
                db.Delete(u);
            }
            catch (Exception hata)
            {
                Response.Write("<script LANGUAGE='JavaScript' >alert('" + hata.Message.ToString() + "')</script>");
            }
            Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
        }