/// <summary>
        /// 分页绑定数据
        /// </summary>
        /// <param name="currentPage">要显示的当前页码数</param>
        private void BindPagedEmployees(int pageIndex)
        {
            string             employeeName = txtEmployeeName.Text;
            string             userName     = txtUserName.Text;
            EmployeeStatusType status       = (EmployeeStatusType)Convert.ToInt32(rblStatus.SelectedValue);
            int             totalResults;   // 返回的员工总行数
            List <Employee> results = BLLStaff.SearchPagedEmployees(employeeName, userName, status,
                                                                    pageSize, pageIndex, out totalResults);
            int totalPages = totalResults / pageSize + (totalResults % pageSize == 0 ? 0 : 1); // 计算总分页数

            if (totalPages == 0)                                                               // 如果没有返回记录
            {
                divNoResults.Visible = true;
                divResults.Visible   = false;
            }
            else
            {
                divNoResults.Visible = false;
                divResults.Visible   = true;

                lblTotalResults.Text = totalResults.ToString();     // 显示总行数
                lblTotalPages.Text   = totalPages.ToString();       // 显示总分页数
                lblCurrentPage.Text  = pageIndex.ToString();        // 显示当前页码数
            }

            repEmployees.DataSource = results;
            repEmployees.DataBind();
        }
Exemple #2
0
        private void BindEmployees()
        {
            List <Employee> list = BLLStaff.GetUnApprovedEmployees();

            repAccounts.DataSource = list;
            repAccounts.DataBind();
        }
 private void BindDepartments()
 {
     ddlDepartments.DataSource     = BLLStaff.GetAllDepartments();
     ddlDepartments.DataTextField  = "DepartmentName";
     ddlDepartments.DataValueField = "DepartmentID";
     ddlDepartments.DataBind();
 }
Exemple #4
0
        protected void gvDepartments_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int         deptID            = Convert.ToInt32(e.Keys[0]);                      // 获取被编辑的行所对应Department的编号。需在GridView中预先设置DataKeyNames
            GridViewRow gvr               = gvDepartments.Rows[e.RowIndex];                  // 获取当前被编辑的行
            TextBox     txtDepartmentName = gvr.FindControl("txtDepartmentName") as TextBox; // 找到部门名称编辑框
            string      newName           = txtDepartmentName.Text;

            Department department = new Department();

            department.DepartmentID   = deptID;
            department.DepartmentName = newName;

            StaffOpResult result = BLLStaff.UpdateDepartment(department);
            string        script;

            if (result == StaffOpResult.Duplicate)
            {
                script = "<script type='text/javascript'>alert('部门:" + newName + " 已经存在!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "duplicate", script);
                e.Cancel = true;                        // 不再执行后续操作,回到编辑状态
            }
            else
            {
                script = "<script type='text/javascript'>alert('部门修改成功!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "success", script);

                gvDepartments.EditIndex = -1;           // 退出编辑状态
                BindDepartments();
            }
        }
Exemple #5
0
        private void BindDepartments()
        {
            List <Department> list = BLLStaff.GetAllDepartments();

            gvDepartments.DataSource = list;
            gvDepartments.DataBind();
        }
Exemple #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string   meetingName          = txtMeetingName.Text;
            int      numberofParticipants = Convert.ToInt32(txtNumberofParticipants.Text);
            DateTime start       = DateTime.Parse(txtStartDate.Text + " " + txtStartTime.Text);
            DateTime end         = DateTime.Parse(txtEndDate.Text + " " + txtEndTime.Text);
            int      roomID      = Convert.ToInt32(ddlRooms.SelectedValue);
            string   description = txtDescription.Text;

            string script;

            if (start >= end)           // 检查结束时间是否大于起始时间
            {
                script = "<script type='text/javascript'>alert('会议结束时间必须大于起始时间');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "dateerror", script);
                return;
            }

            Meeting meeting = new Meeting();

            meeting.MeetingName          = meetingName;
            meeting.NumberofParticipants = numberofParticipants;
            meeting.StartTime            = start;
            meeting.EndTime        = end;
            meeting.Description    = description;
            meeting.Room           = BLLRoom.GetRoomByID(roomID);
            meeting.Reservationist = BLLStaff.GetEmployeeforLoggedInUser();
            meeting.Status         = MeetingStatus.Normal;

            meeting.Participants = new List <Employee>();
            foreach (ListItem item in lbSelectedEmployees.Items)
            {
                int employeeID = Convert.ToInt32(item.Value);
                meeting.Participants.Add(new Employee {
                    EmployeeID = employeeID
                });
            }

            MeetingOpResults result = BLLMeeting.ReserveMeeting(meeting);

            script = string.Format("<script>alert('会议预订成功!');window.location.href='MyReservations.aspx';</script>");
            switch (result)
            {
            case MeetingOpResults.NotEnoughCapacity:
                script = string.Format("<script>alert('所选会议室容量为{0},无法容纳{1}人');</script>",
                                       meeting.Room.Capacity, meeting.NumberofParticipants);
                break;

            case MeetingOpResults.ReservationTooLate:
                script = string.Format("<script>alert('距会议开始时间{0}已不足30分钟,请推迟时间');</script>",
                                       meeting.StartTime.ToString("HH:mm"));
                break;

            case MeetingOpResults.RoomScheduleNotAvailable:
                script = string.Format("<script>alert('该会议室已被预订,请更改时间或重新选择会议室');</script>");
                break;
            }
            Page.ClientScript.RegisterStartupScript(this.GetType(), "result", script);
        }
        private void BindReservations()
        {
            Employee       reservationist = BLLStaff.GetEmployeeforLoggedInUser();
            List <Meeting> list           = BLLMeeting.GetReservationsByReservationistID(reservationist.EmployeeID);

            repReservations.DataSource = list;
            repReservations.DataBind();
        }
        private void BindMeetings()
        {
            Employee       employee = BLLStaff.GetEmployeeforLoggedInUser();
            List <Meeting> list     = BLLMeeting.GetMeetingsForEmployee(employee.EmployeeID);

            repReservations.DataSource = list;
            repReservations.DataBind();
        }
Exemple #9
0
        protected void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e)
        {
            int             departmentID = Convert.ToInt32(ddlDepartments.SelectedValue);
            List <Employee> list         = BLLStaff.GetEmployeesByDepartment(departmentID);

            lbEmployees.DataSource     = list;
            lbEmployees.DataTextField  = "EmployeeName";
            lbEmployees.DataValueField = "EmployeeID";
            lbEmployees.DataBind();
        }
        protected void repEmployees_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "CloseAccount")
            {
                int    employeeID  = Convert.ToInt32(e.CommandArgument);
                Label  lblUserName = e.Item.FindControl("lblUserName") as Label;
                string userName    = lblUserName.Text;

                BLLStaff.CloseAccount(employeeID, userName);

                BindPagedEmployees(1);
            }
        }
Exemple #11
0
        protected void repAccounts_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int    employeeID  = Convert.ToInt32(e.CommandArgument);
            Label  lblUserName = e.Item.FindControl("lblUserName") as Label;
            string userName    = lblUserName.Text;

            if (e.CommandName == "Approve")
            {
                BLLStaff.ApproveEmployee(employeeID, userName);
            }
            else if (e.CommandName == "Delete")
            {
                BLLStaff.DeleteEmployee(employeeID, userName);
            }
            BindEmployees();
        }
Exemple #12
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string        oldPassword = txtOrigin.Text;
            string        newPassword = txtNew.Text;
            StaffOpResult result      = BLLStaff.ChangePassword(oldPassword, newPassword);
            string        script      = "";

            if (result == StaffOpResult.PasswordIncorrect)
            {
                script = "<script type='text/javascript'>alert('原始密码错误!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "error", script);
            }
            else
            {
                script = "<script type='text/javascript'>alert('密码修改成功!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "success", script);
            }
        }
Exemple #13
0
        protected void gvDepartments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int           deptID = Convert.ToInt32(e.Keys[0]);
            StaffOpResult result = BLLStaff.DeleteDepartment(deptID);
            string        script;

            if (result == StaffOpResult.DependanceExists)
            {
                script = "<script type='text/javascript'>alert('该部门下仍有员工,不能删除!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "duplicate", script);
                e.Cancel = true;
            }
            else
            {
                script = "<script type='text/javascript'>alert('部门删除成功!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "success", script);
                BindDepartments();
            }
        }
Exemple #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string        departmentName = txtDepartmentName.Text;
            StaffOpResult result         = BLLStaff.AddDepartment(departmentName);
            string        script;

            if (result == StaffOpResult.Duplicate)
            {
                script = "<script type='text/javascript'>alert('部门:" + departmentName + " 已经存在!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "duplicate", script);
            }
            else
            {
                BindDepartments();                  // 重新绑定以显示新增部门数据
                txtDepartmentName.Text = "";
                script = "<script type='text/javascript'>alert('部门:" + departmentName + " 添加成功!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "success", script);
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string employeeName = txtEmployeeName.Text;
            string userName     = txtUserName.Text;
            string password     = txtPassword.Text;
            string email        = txtEmail.Text;
            string phone        = txtPhone.Text;

            Employee employee = new Employee();

            employee.EmployeeName = employeeName;
            employee.UserName     = userName;
            employee.Password     = password;
            employee.Phone        = phone;
            employee.Email        = email;
            Department department = new Department();

            department.DepartmentID    = Convert.ToInt32(ddlDepartments.SelectedValue);
            department.DepartmentName  = ddlDepartments.SelectedItem.Text;
            employee.RelatedDepartment = department;
            employee.Status            = EmployeeStatusType.Inactive;

            StaffOpResult result = BLLStaff.Register(employee);

            if (result == StaffOpResult.Duplicate)
            {
                lblResult.Text = "用户名或电子邮件已经存在,请修改!";
            }
            else if (result == StaffOpResult.UserCreateError)
            {
                lblResult.Text = "创建用户账号失败,请联系管理员!";
            }
            else
            {
                txtEmployeeName.Text         = "";
                txtUserName.Text             = "";
                txtPhone.Text                = "";
                txtEmail.Text                = "";
                ddlDepartments.SelectedIndex = 0;
                lblResult.Text               = "注册成功!";
            }
        }