Ejemplo n.º 1
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     using (dbconection db = new dbconection())
     {
         Grade grade = new Grade();
         grade.Name      = txtname.Text;
         grade.TeacherId = Convert.ToInt32(cmbteacher.SelectedValue);
         db.Grades.Add(grade);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        private void btndelete_Click(object sender, EventArgs e)
        {
            int?id = GetId();

            using (dbconection database = new dbconection())
            {
                Teacher teacher = database.Teachers.Find(id);
                database.Teachers.Remove(teacher);
                database.SaveChanges();
            }
            CleanTxt();
            GetTeachers();
        }
Ejemplo n.º 3
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     using (dbconection db = new dbconection())
     {
         Teacher teacher = new Teacher();
         teacher.Name     = txtname.Text;
         teacher.LastName = txtlastname.Text;
         teacher.Gender   = cmbgender.Text;
         db.Teachers.Add(teacher);
         db.SaveChanges();
         CleanTxt();
     }
     GetTeachers();
 }
Ejemplo n.º 4
0
        private void btnedit_Click(object sender, EventArgs e)
        {
            int?id = GetId();

            using (dbconection database = new dbconection())
            {
                Teacher teacher = null;
                teacher          = database.Teachers.Find(id);
                teacher.Name     = txtname.Text;
                teacher.LastName = txtlastname.Text;
                teacher.Gender   = cmbgender.Text;
                database.Entry(teacher).State = System.Data.Entity.EntityState.Modified;
                database.SaveChanges();
            }
            GetTeachers();
        }