Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Student student = new Student();

            student.StudNo        = textBox1.Text;
            student.StudName      = textBox2.Text;
            student.StudSex       = radioButton1.Checked?'男':'女';
            student.StudBirthDate = dateTimePicker1.Value;
            student.StudMajor     = comboBox1.Text;
            student.StudIsMember  = checkBox1.Checked;
            if (pictureBox1.Image != null)
            {
                MemoryStream ms = new MemoryStream();
                pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                student.StudPic = ms.GetBuffer();
                ms.Close();
            }
            if (studentDAL.AddStudent(student) >= 0)
            {
                MessageBox.Show("添加成功!");
                Dispose();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
Exemple #2
0
 public void AddStudent(Student student)
 {
     try
     {
         // check Student code is exist
         var st = _context.Student.Where(item => item.StudentCode == student.StudentCode).SingleOrDefault();
         if (st == null)
         {
             student.Password = BCrypt.Net.BCrypt.HashPassword(student.Password);
             _studentDAL.AddStudent(student);
         }
         else
         {
             throw new Exception("Mã sinh viên đã tồn tại");
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("Mã sinh viên đã tồn tại"))
         {
             throw new Exception(ex.Message.ToString());
         }
         else
         {
             throw new Exception("Error from StudentBLL: " + ex.Message.ToString());
         }
     }
 }
Exemple #3
0
        public void Post(Student s)
        {
            bool done = StudentDAL.AddStudent(s);

            if (!done)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
        }
Exemple #4
0
 public static bool AddStudent(Student stu)
 {
     try
     {
         return(StudentDAL.AddStudent(stu));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #5
0
 public static int AddStdBusiness(StudentEntity entity)
 {
     if (entity.NAME != null &&
         entity.SURNAME != null &&
         entity.NUMBER != null &&
         entity.PASSWORD != null &&
         entity.PHOTO != null)
     {
         return(StudentDAL.AddStudent(entity));
     }
     return(-1);
 }
Exemple #6
0
        public IActionResult Add(string firstname, string lastname, double notefinale)
        {
            Student student = new Student();

            student.FirstName  = firstname;
            student.LastName   = lastname;
            student.NoteFinale = notefinale;

            studentDAL.AddStudent(student);

            return(RedirectToAction("Index"));
        }
Exemple #7
0
 public ActionResult NewStudent(StudentModel model)
 {
     if (ModelState.IsValid)
     {
         model.StudentImageAddress = "/Images/" + Guid.NewGuid() + ".jpg";
         model.StudentImageFile.SaveAs(Server.MapPath(model.StudentImageAddress));
         StudentDAL dal = new StudentDAL();
         int        id  = dal.AddStudent(model);
         ViewBag.msg = "Student Added : " + id;
         ModelState.Clear();
         ViewBag.cities = dal.GetCities();
         return(View());
     }
     else
     {
         StudentDAL dal = new StudentDAL();
         ViewBag.cities = dal.GetCities();
         return(View());
     }
 }
Exemple #8
0
 public int AddStudent(Student s)
 {
     return(dal.AddStudent(s));
 }
Exemple #9
0
 public int AddStudent()
 {
     return(StudentDAL.AddStudent(this));
 }
Exemple #10
0
    public void AddStudent(Student student)
    {
        StudentDAL dal = new StudentDAL();

        dal.AddStudent(student);
    }
Exemple #11
0
        /// <summary>
        /// Add new student record
        /// </summary>
        /// <param name="entity">Student entity</param>
        /// <returns>Student Id</returns>
        public int AddStudent(Student entity, int SchoolId)
        {
            StudentDAL dalObject = new StudentDAL();

            return(dalObject.AddStudent(entity, SchoolId));
        }