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

                User user = userBLL.get(staff.UserId);
                if (!user.UserName.Equals(username) || !staff.Type.Equals(type))
                {
                    user.UserName = username;
                    user.Type = type.Equals("考勤维护员") ? "6" : "5";
                    userBLL.update(user);
                }

                staff.Name = name;
                staff.Gender = gender;
                staff.Birth = birth;
                staff.Phone = phone;
                staff.Type = type;
                staffBLL.update(staff);

                Response.Write("<script>alert('修改成功!');location.href='showStaffs.aspx';</script>");

            }
        }
Exemplo n.º 2
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.º 3
0
        protected void ImageButton_delete_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imageButton = sender as ImageButton;

            string id = imageButton.CommandArgument;

            StaffBLL staffBLL = new StaffBLL();
            UserBLL userBLL = new UserBLL();

            Staff staff = staffBLL.get(id);
            User user = userBLL.get(staff.UserId);

            staffBLL.delete(staff);
            userBLL.delete(user);

            Response.Write("<script>alert('删除成功!');location.href='showStaffs.aspx';</script>");
        }
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
        public static void SaveListStaffsOfGroup(int groupId, List <Assignment> assignments)
        {
            // List of staff in group
            var staffsInGroup   = StaffBLL.ListStaffsInGroup(groupId);
            var staffsInGroupId = staffsInGroup.Select(s => s.Id).ToList();

            var removeStaffsList = new List <Assignment>();

            foreach (var staffId in staffsInGroupId)
            {
                removeStaffsList.Add(
                    new Assignment
                {
                    StaffId = staffId,
                    GroupId = groupId
                });
            }

            AssignmentDAL.RemoveRange(removeStaffsList);
            AssignmentDAL.AddRange(assignments);
        }
Exemplo n.º 6
0
        private void bind()
        {
            string id = Request.QueryString["id"].ToString();

            StaffBLL staffBLL = new StaffBLL();
            staff = staffBLL.get(id);

            UserBLL userBLL = new UserBLL();
            User user = userBLL.get(staff.UserId);

            TextBox_username.Text = user.UserName;
            TextBox_name.Text = staff.Name;
            if (staff.Gender.Equals("女")) RadioButton_female.Checked = true;
            PageUtil.bindDropDownList(DropDownList_yearPart1, staff.Birth[0].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart2, staff.Birth[1].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart3, staff.Birth[2].ToString());
            PageUtil.bindDropDownList(DropDownList_yearPart4, staff.Birth[3].ToString());
            PageUtil.bindDropDownList(DropDownList_month, staff.Birth.Substring(4, 2));
            TextBox_phone.Text = staff.Phone;
            PageUtil.bindDropDownList(DropDownList_type, staff.Type);
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["User"] != null)
                {
                    string username = "";

                    User user = Session["User"] as User;
                    int type = Convert.ToInt32(user.Type);
                    switch (type)
                    {
                        case 1:
                            username = new TeacherBLL().getByUserId(user.Id).Name;
                            break;
                        case 2:
                            username = new TeacherBLL().getByUserId(user.Id).Name;
                            break;
                        case 3:
                            username = new StudentBLL().getByUserId(user.Id).Name;
                            break;
                        case 4:
                            username = new StudentBLL().getByUserId(user.Id).Name;
                            break;
                        case 5:
                            username = new StaffBLL().getByUserId(user.Id).Name;
                            break;
                        case 6:
                            username = new StaffBLL().getByUserId(user.Id).Name;
                            break;
                    }

                    Label_username.Text = username;
                }
            }
        }