Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         using (var context = new ShyjuDB())
         {
             var res = context.p_GetStudentAge(2).FirstOrDefault();
             MessageBox.Show(res.Value.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
 // GET: Student
 public ActionResult Students()
 {
     using (var context = new ShyjuDB())
     {
         var res      = context.p_GetStudent(0);
         var students = from s in res
                        where s.SchoolId != 2
                        select new SudentDTO
         {
             Id      = s.Id,
             Name    = s.Name,
             Address = s.Address,
             DOB     = s.DOB
         };
         return(View(students.ToList()));
     }
 }
Пример #3
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         Student student = new Student
         {
             SchoolId = 5,
             Name     = "Test student",
             DOB      = DateTime.Now,
             Address  = "Bangalore"
         };
         using (var context = new ShyjuDB())
         {
             context.Students.Add(student);
             context.SaveChanges();
         }
         MessageBox.Show("New student created.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #4
0
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         using (var context = new ShyjuDB())
         {
             var res      = context.p_GetStudent(0).ToList();
             var students = from s in res
                            where s.SchoolId != 2
                            select new SudentDTO
             {
                 Id      = s.Id,
                 Name    = s.Name,
                 Address = s.Address,
                 DOB     = s.DOB
             };
             DataBind(students.ToList());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }