Exemplo n.º 1
0
 public Form1()
 {
     try
     {
         Alumno al = new Alumno
         {
             Dni        = "234234234",
             Nombre     = "Daniel",
             Apellidos  = "Madirfal",
             Edad       = 28,
             Guid       = Guid.NewGuid(),
             Nacieminto = DateTime.Parse("14/11/1990"),
             Registro   = DateTime.Now,
         };
         StudentJson <Alumno> stu = new StudentJson <Alumno>();
         IStudentBL           bl  = new StudentBL(stu);
         bl.Add(al);
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         throw;
     }
     InitializeComponent();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            StudentBL stBl         = new StudentBL();
            Student   studenttest  = new Student(1, "Nom", 50);
            Student   studenttest2 = new Student(2, "Nom2", 5);

            List <Student> stlist = new List <Student>();

            stlist.Add(studenttest);
            stlist.Add(studenttest2);

            stBl.Add <Student>("test1", studenttest);
            stBl.Add <Student>("test1", studenttest2);

            stBl.Add <List <Student> >("test2", stlist);

            Console.WriteLine(stBl.Read <Student>("test1").Name);
            Console.ReadKey();
        }
 public ActionResult Add_student(Student ob)
 {
     ModelState.Remove("ID");
     if (ModelState.IsValid)
     {
         StudentBL.Add(ob);
         return(RedirectToAction("students"));
     }
     else
     {
         return(View());
     }
 }
Exemplo n.º 4
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (rdoAddStudent.Checked == false && rdoDeleteStudent.Checked == false && rdoEditStudent.Checked == false)
                {
                    MessageBox.Show("Please select an specific action", "Missing Information");
                    return;
                }
                StudentBL studentBL = new StudentBL();
                if (rdoAddStudent.Checked)
                {
                    Student student = new Student();
                    PopulateSudentObject(student);
                    if (studentBL.Add(student))
                    {
                        int studentId = studentBL.GetLastID();
                        MessageBox.Show($"New Student Created:" +
                                        $" \n Student ID: {studentBL.GetLastID()}");
                    }
                }
                else
                {
                    PopulateSudentObject();

                    if (rdoEditStudent.Checked)
                    {
                        if (studentBL.Edit(student))
                        {
                            MessageBox.Show("Updated SuccessFully");
                        }
                    }

                    if (rdoDeleteStudent.Checked)
                    {
                        if (studentBL.Remove(student.ID))
                        {
                            MessageBox.Show("Deleted SuccessFully");
                        }
                    }
                }

                ResetFields();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }