Exemplo n.º 1
0
        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;
                }

            }
        }
Exemplo n.º 2
0
        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;
                }

            }
        }
Exemplo n.º 3
0
        protected void Button_submit_Click(object sender, EventArgs e)
        {
            if (!checkEmpty())
            {
                string userName = TextBox_userName.Text.Trim();
                string password = TextBox_password.Text.Trim();

                StaffBLL staffBLL = new StaffBLL();
                UserBLL userBLL = new UserBLL();
                User user = userBLL.getByUsername(userName);
                if (user != null)
                {
                    //取得加密后的密码
                    string encryptPWD = EncryptUtil.MD5Encrypt(password);

                    if (!user.Password.Equals(encryptPWD))
                    {
                        //密码不匹配的情况

                        checkPassword.ErrorMessage = "密码输入错误!";
                        checkPassword.IsValid = false;

                    }
                    else
                    {
                        Staff staff = staffBLL.getByUserId(user.Id);
                        if (staff != null && staff.Type.Equals("超级管理员"))
                        {

                            //用户检查通过的情况
                            AttendanceBLL attendBLL = new AttendanceBLL();
                            CourseTableBLL ctBLL = new CourseTableBLL();

                            string filter = "semester='" + GlobalVars.SEMESTER + "'";
                            DataTable dt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filter, null, false);

                            foreach (DataRow dr in dt.Rows)
                            {
                                attendBLL.deleteByCourseTableId(dr["ID"].ToString());
                            }

                            Response.Write("<script>alert('考勤初始化成功!');location.href='../mainPages/welcome.aspx';</script>");

                        }
                        else
                        {
                            checkUsername.ErrorMessage = "该用户没有权限!";
                            checkUsername.IsValid = false;
                        }

                    }
                }
                else
                {
                    checkUsername.ErrorMessage = "账号不存在!";
                    checkUsername.IsValid = false;
                }
            }
        }
Exemplo n.º 4
0
        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>");
            }
        }
Exemplo n.º 5
0
        protected void Button_submit_Click(object sender, EventArgs e)
        {
            if (!checkEmpty())
            {
                string userName = TextBox_userName.Text.Trim();
                string password = TextBox_password.Text.Trim();
                string userType = DropDownList_userType.SelectedValue;

                UserBLL userBLL = new UserBLL();
                User user = userBLL.getByUsername(userName);
                if (user != null)
                {
                    //取得加密后的密码
                    string encryptPWD = EncryptUtil.MD5Encrypt(password);

                    if (!user.Password.Equals(encryptPWD))
                    {
                        //密码不匹配的情况

                        checkPassword.ErrorMessage = "密码输入错误!";
                        checkPassword.IsValid = false;

                    }
                    else if (!user.Type.Equals("3-4") && !user.Type.Equals(userType))
                    {
                        //处理用户不是班长类型的情况

                        //用户类型不匹配的情况

                        checkUserType.ErrorMessage = "用户类型不匹配!";
                        checkUserType.IsValid = false;
                    }
                    else
                    {
                        if (user.Type.Equals("3-4"))
                        {
                            //处理用户类型是班长的情况

                            if (userType.Equals("3"))
                            {
                                user.Type = "3";
                            }
                            else if (userType.Equals("4"))
                            {
                                user.Type = "4";
                            }
                            else
                            {
                                //用户类型不匹配的情况

                                checkUserType.ErrorMessage = "用户类型不匹配!";
                                checkUserType.IsValid = false;
                                return;
                            }
                        }

                        //用户检查通过的情况

                        Session.Add("User", user);
                        Response.Redirect("~/mainPages/index.aspx");

                    }
                }
                else
                {
                    checkUsername.ErrorMessage = "账号不存在!";
                    checkUsername.IsValid = false;
                }
            }
        }