Beispiel #1
0
        protected void BtnGuncelle_Click(object sender, EventArgs e)
        {
            using (BakkalDB1Entities db = new BakkalDB1Entities())
            {
                int id     = int.Parse(Request.QueryString["ID"]);
                var result = db.Customers.Find(id);
                result.CustomerName    = TextBox1ad.Text;
                result.CustomerSurname = TextBoxsoyad.Text;
                result.Phone           = TextBoxtel.Text;
                result.Adress          = Textadres.Text;
                db.SaveChanges();

                Response.Redirect("Musteriler.aspx");
            }
        }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int id = int.Parse(Request.QueryString["ID"]);
         using (BakkalDB1Entities db = new BakkalDB1Entities())
         {
             var result = db.Customers.Find(id);
             TextBox1ad.Text   = result.CustomerName;
             TextBoxsoyad.Text = result.CustomerSurname;
             TextBoxtel.Text   = result.Phone;
             Textadres.Text    = result.Adress;
         }
     }
 }
        protected void BtnKaydet_Click(object sender, EventArgs e)
        {
            using (BakkalDB1Entities db = new BakkalDB1Entities())
            {
                Customer customer = new Customer();
                customer.CustomerName    = TextBox1ad.Text;
                customer.CustomerSurname = TextBoxsoyad.Text;
                customer.Phone           = TextBoxtel.Text;
                customer.Adress          = Textadres.Text;

                db.Customers.Add(customer);
                db.SaveChanges();

                Response.Redirect("Musteriler.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (BakkalDB1Entities db = new BakkalDB1Entities())
            {
                Repeater1.DataSource = db.Customers.ToList();
                Repeater1.DataBind();
            }

            if (Request.QueryString["ID"] != null)
            {
                int id = int.Parse(Request.QueryString["ID"]);
                using (BakkalDB1Entities db = new BakkalDB1Entities())
                {
                    var result = db.Customers.Find(id);
                    db.Customers.Remove(result);
                    db.SaveChanges();
                    Response.Redirect("Musteriler.aspx");
                }
            }
        }