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("添加失败!"); } }
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()); } } }
public void Post(Student s) { bool done = StudentDAL.AddStudent(s); if (!done) { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public static bool AddStudent(Student stu) { try { return(StudentDAL.AddStudent(stu)); } catch (Exception) { throw; } }
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); }
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")); }
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()); } }
public int AddStudent(Student s) { return(dal.AddStudent(s)); }
public int AddStudent() { return(StudentDAL.AddStudent(this)); }
public void AddStudent(Student student) { StudentDAL dal = new StudentDAL(); dal.AddStudent(student); }
/// <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)); }