Beispiel #1
0
 public bool Add(Model.Student student, string password, out string message)
 {
     message = "";
     if (student.StuNo.Trim() == "")
     {
         message = "学号不可为空白";
         return(false);
     }
     if (student.StuName.Trim() == "")
     {
         message = "姓名不可为空白";
         return(false);
     }
     if (!Check.CheckYear(student.Grade.Trim()))
     {
         message = "请选择正确的年级";
         return(false);
     }
     if (student.Subject.Trim() == "")
     {
         message = "专业不可为空白";
         return(false);
     }
     if (student.College.Trim() == "")
     {
         message = "学院不可为空白";
         return(false);
     }
     if (!Check.CheckMobilePhone(student.Phone))
     {
         message = "请选择正确的手机号";
         return(false);
     }
     if (student.Living.Trim() == "")
     {
         message = "居住地不可为空白";
         return(false);
     }
     if (password.Trim() == "")
     {
         message = "默认密码不可空白";
         return(false);
     }
     DAL.Student model = new DAL.Student();
     if (model.CheckExist(student.StuNo.Trim()))
     {
         message = "该学生已被录入!!!";
         return(false);
     }
     message = "导入成功";
     model.Add(student);
     Model.StudentAccount account = new Model.StudentAccount();
     account.StuNo    = student.StuNo;
     account.Password = Encode.GenerateMD5(password);
     return(new DAL.StudentAccount().Add(account));
 }
Beispiel #2
0
 public bool Add(Model.Teacher teacher, string password, out string message)
 {
     message = "";
     if (teacher.TeacherNo.Trim() == "")
     {
         message = "学号不可为空白";
         return(false);
     }
     if (teacher.TeacherName.Trim() == "")
     {
         message = "姓名不可为空白";
         return(false);
     }
     if (teacher.Subject.Trim() == "")
     {
         message = "专业不可为空白";
         return(false);
     }
     if (teacher.College.Trim() == "")
     {
         message = "学院不可为空白";
         return(false);
     }
     if (teacher.Research.Trim() == "")
     {
         message = "研究方向不可为空白";
         return(false);
     }
     if (teacher.Brief.Trim() == "")
     {
         message = "详细情况不可为空白";
         return(false);
     }
     if (password.Trim() == "")
     {
         message = "默认密码不可空白";
         return(false);
     }
     DAL.Teacher model = new DAL.Teacher();
     if (model.CheckExist(teacher.TeacherNo.Trim()))
     {
         message = "该导师已被录入!!!";
         return(false);
     }
     message = "导入成功";
     model.Add(teacher);
     Model.TeacherAccount account = new Model.TeacherAccount();
     account.TeacherNo = teacher.TeacherNo;
     account.Password  = Encode.GenerateMD5(password);
     return(new DAL.TeacherAccount().Add(account));
 }