Example #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (RaborContext db = new RaborContext())
     {
         Rabor app = new Rabor()
         {
             ID_oboryd     = int.Parse(DropDownList1.Text),
             ID_vid_rabot  = int.Parse(DropDownList2.Text),
             Data_polychen = DateTime.Parse(TextBox1.Text),
             Data_vipolnen = DateTime.Parse(TextBox2.Text)
         };
         db.Rabor.Add(app);
         db.SaveChanges();
     }
     Response.Redirect("WebForm1.aspx");
 }
Example #2
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     using (RaborContext db = new RaborContext())
     {
         foreach (GridViewRow rowInGrid in GridView1.Rows)
         {
             CheckBox checkBox = (CheckBox)rowInGrid.FindControl("CheckBox1");
             if (checkBox != null && checkBox.Checked)
             {
                 int   id    = int.Parse(GridView1.Rows[rowInGrid.RowIndex].Cells[1].Text);
                 Rabor delId = db.Rabor.Where(s => s.Id == id).FirstOrDefault();
                 if (delId != null)
                 {
                     db.Rabor.Remove(delId);
                     db.SaveChanges();
                 }
             }
         }
         Response.Redirect("WebForm1.aspx");
     }
 }