protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { ClassBLL classBLL = new ClassBLL(); StudentBLL stuBLL = new StudentBLL(); UserBLL userBLL = new UserBLL(); string stuId = TextBox_stuId.Text.Trim(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string phone = TextBox_phone.Text.Trim(); string address = TextBox_address.Text.Trim(); string classID = DropDownList_class.SelectedValue; if (stuBLL.getByStuId(stuId) == null) { if (userBLL.getByUsername(stuId) == null) { #region 在用户表中创建新用户 User user = new User(); user.UserName = stuId; user.Password = EncryptUtil.MD5Encrypt("12345678"); user.Type = "4"; userBLL.save(user); #endregion Class clazz = classBLL.get(classID); clazz.StudCount = (Convert.ToInt32(clazz.StudCount) + 1).ToString(); classBLL.update(clazz); Student stu = new Student(); stu.StuId = stuId; stu.Name = name; stu.Gender = gender; stu.Birth = birth; stu.Phone = phone; stu.Address = address; stu.ClassID = classID; stu.UserID = userBLL.getByUsername(stuId).Id; stuBLL.save(stu); Response.Write("<script>alert('添加成功!');location.href='addStudent.aspx';</script>"); } else Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addStudent.aspx';</script>"); } else { checkStuId.ErrorMessage = "学号已存在!"; checkStuId.IsValid = false; } } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { TeacherBLL teachBLL = new TeacherBLL(); UserBLL userBLL = new UserBLL(); string teachId = TextBox_teachId.Text.Trim(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string title = DropDownList_title.SelectedValue; string phone = TextBox_phone.Text.Trim(); string email = TextBox_email.Text.Trim(); if (teachBLL.getByTeacherId(teachId) == null) { if (userBLL.getByUsername(teachId) == null) { #region 在用户表中创建新用户 User user = new User(); user.UserName = teachId; user.Password = EncryptUtil.MD5Encrypt("12345678"); user.Type = title.Equals("辅导员") ? "2" : "1"; userBLL.save(user); #endregion Teacher teacher = new Teacher(); teacher.TeacherId = teachId; teacher.Name = name; teacher.Gender = gender; teacher.Birth = birth; teacher.Title = title; teacher.Phone = phone; teacher.Email = email; teacher.UserID = userBLL.getByUsername(teachId).Id; teachBLL.save(teacher); Response.Write("<script>alert('添加成功!');location.href='addTeacher.aspx';</script>"); } else Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addTeacher.aspx';</script>"); } else { checkTeachId.ErrorMessage = "教师号已存在!"; checkTeachId.IsValid = false; } } }
protected void ImageButton_submit_Click(object sender, ImageClickEventArgs e) { if (check()) { StaffBLL staffBLL = new StaffBLL(); UserBLL userBLL = new UserBLL(); string username = TextBox_username.Text.Trim(); string name = TextBox_name.Text.Trim(); string gender = RadioButton_male.Checked ? "男" : "女"; string birth = DropDownList_yearPart1.SelectedValue + DropDownList_yearPart2.SelectedValue + DropDownList_yearPart3.SelectedValue + DropDownList_yearPart4.SelectedValue; birth += DropDownList_month.SelectedValue; string phone = TextBox_phone.Text.Trim(); string type = DropDownList_type.SelectedValue; if (userBLL.getByUsername(username) == null) { #region 在用户表中创建新用户 User user = new User(); user.UserName = username; user.Password = EncryptUtil.MD5Encrypt("12345678"); user.Type = type.Equals("考勤维护员") ? "6" : "5"; userBLL.save(user); #endregion Staff staff = new Staff(); staff.Name = name; staff.Gender = gender; staff.Birth = birth; staff.Phone = phone; staff.Type = type; staff.UserId = userBLL.getByUsername(username).Id; staffBLL.save(staff); Response.Write("<script>alert('添加成功!');location.href='addStaff.aspx';</script>"); } else Response.Write("<script>alert('添加失败,用户名已存在!');location.href='addStaff.aspx';</script>"); } }