Esempio n. 1
0
        private void BtnDelete_Click(int id)
        {
            using (var ctx = new Database1Entities())

            {
                var query = (from que in ctx.Employees where que.EmployeeID == id select que).FirstOrDefault();
                ctx.Employees.Remove(query);
                ctx.SaveChanges();
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
Esempio n. 2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (!Validation(TextBox4, TextBox5, Date1))
            {
                return;
            }

            using (var ctx = new Database1Entities())
            {
                int id    = int.Parse(LabelHide.Text);
                var query = (from quer in ctx.Employees where quer.EmployeeID == id select quer).FirstOrDefault();

                query.FirstName = TextBox4.Text;
                query.LastName  = TextBox5.Text;
                query.BirthDate = DateTime.ParseExact(Date1.Value, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

                ctx.SaveChanges();
            }
            Response.Redirect(Request.Url.AbsoluteUri);
        }