Ejemplo n.º 1
0
 /// <summary>
 /// 删除员工
 /// </summary>
 /// <param name="nStaffId"></param>
 /// <param name="nOpStaffId">操作员工编码</param>
 /// <param name="strOpStaffName">操作员工姓名</param>
 /// <param name="strErrText">出错信息</param>
 /// <returns>成功返回True,否则返回False</returns>
 public bool DeleteStaff(long nStaffId, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     try
     {
         using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
         {
             using (StaffDAO dao = new StaffDAO())
             {
                 if (!dao.DeleteStaff(nStaffId, nOpStaffId, strOpStaffName, out strErrText))
                 {
                     return(false);
                 }
             }
             transScope.Complete();
         }
         return(true);
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return(false);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取除指定员工及其所有下属之外的员工记录
        /// </summary>
        /// <param name="nStaffId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <Staff> LoadStaffsExcludeSelfAndSubordinates(long nStaffId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <Staff> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StaffDAO dao = new StaffDAO())
                    {
                        dataResult = dao.LoadStaffsExcludeSelfAndSubordinates(nStaffId, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["login"] != "Admin")
         {
             Response.Redirect(String.Format("{0}?ReturnUrl={1}", "DangNhap.aspx", Request.RawUrl));
         }
         else
         {
             StaffDAO dao = new StaffDAO();
             if (dao.getStaffByUserID(Session["ID"].ToString()) == null)
             {
                 welcome.InnerText = "Xin chào null";
             }
             else
             {
                 String name = dao.getStaffByUserID(Session["ID"].ToString()).StaffName;
                 welcome.InnerText = "Xin chào " + name + "!";
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void LoadStaff()
        {
            StaffDAO d   = new StaffDAO();
            DataSet  set = d.GetAllStaff();

            tablePost = set.Tables[0];
            gridCtrlPost.DataSource = tablePost;
            //DataRow newRow;
            //foreach (DataRow r in set.Tables[0].Rows)
            //{
            //    newRow = tablePost.NewRow();
            //    newRow["Name"] = r["Name"];
            //    newRow["StaffNumber"] = r["StaffNumber"];
            //    newRow["Sex"] = r["Sex"];
            //    newRow["Birthday"] = r["Birthday"];
            //    newRow["Phone"] = r["Phone"];
            //    newRow["IdCard"] = r["IdCard"];
            //    newRow["BankCard"] = r["BankCard"];
            //    tablePost.Rows.Add(newRow);
            //}

            //gridCtrlPost.DataSource = tablePost;
        }
Ejemplo n.º 5
0
        private void btnStaffAdd_Click(object sender, RoutedEventArgs e)
        {
            StaffDAO sd = new StaffDAO();

            DTO.Entity.Staff staff = new DTO.Entity.Staff
            {
                Name       = txtFullName.Text,
                Address    = txtAddress.Text,
                Email      = txtEmail.Text,
                Permission = cbxPermission.SelectedIndex,
                Username   = txtUsername.Text,
                Password   = txtPassword.Password
            };
            if (new StaffDAO().Add(staff))
            {
                grdStaff.ItemsSource = new StaffDAO().GetAll();
                MessageBox.Show("Thêm người dùng thành công!!!");
            }
            else
            {
                MessageBox.Show("Thêm người dùng không thành công!!!");
            }
        }
Ejemplo n.º 6
0
 public ActionResult Index(mDangNhap model)
 {
     if (ModelState.IsValid)
     {
         int result = new StaffDAO().CheckLogin(model.userId, Encryption.GetSHA512(model.password));
         if (result == -2)
         {
             //User ID không tồn tại
             ModelState.AddModelError("", "Mã nhân viên không tồn tại!");
         }
         else if (result == -1)
         {
             //Sai mật khẩu
             ModelState.AddModelError("", "Sai mật khẩu!");
         }
         else if (result == 0)
         {
             //Tài khoản bị khóa
             ModelState.AddModelError("", "Tài khoản bị khóa. Vui lòng liên hệ quản lý!");
         }
         else if (result == 1)
         {
             //Đăng nhập thành công
             //Lưu session
             var staff        = new StaffDAO().getByID(model.userId);
             var staffSession = new StaffLogin();
             staffSession.UserId   = staff.UserID;
             staffSession.UserType = staff.TypeUser;
             staffSession.FullName = staff.FullName;
             staffSession.Image    = staff.Image;
             Session.Add(CommonConstants.STAFF_SESSION, staffSession);
             //Chuyển về trang chủ
             return(RedirectToAction("Index", "TrangChu"));
         }
     }
     return(View());
 }
Ejemplo n.º 7
0
 public StaffViewer()
 {
     _staffDAO = new StaffDAO();
 }
Ejemplo n.º 8
0
 void LoadStaffIntoComboBox(ComboBox cbo)
 {
     cbo.DataSource    = StaffDAO.GetStaff();
     cbo.DisplayMember = "ID";
     cbo.ValueMember   = "ID";
 }
Ejemplo n.º 9
0
        public JsonResult Login(string username, string password, int type = 0)
        {
            if (type == 0)
            {
                StudentDAO dao = new StudentDAO();

                int status = dao.Login(username, Encryptor.MD5Hash(password));
                if (status == 1)
                {
                    var student = dao.Get(username);
                    var user    = new User();
                    user.Username = student.Id;
                    user.Avatar   = student.Avatar;
                    user.FullName = student.FullName;
                    user.Gender   = student.Gender;

                    Session[Constants.USER] = user;

                    return(Json(new
                    {
                        status = status,
                        data = student
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = status
                    }));
                }
            }
            else if (type == 1)
            {
                StaffDAO dao = new StaffDAO();

                int status = dao.Login(username, Encryptor.MD5Hash(password));
                if (status == 1)
                {
                    var staff = dao.Get(username);
                    var user  = new User();
                    user.Username = staff.Id;
                    user.Avatar   = staff.Avatar;
                    user.FullName = staff.FullName;
                    user.Gender   = staff.Gender;

                    Session[Constants.ADMIN] = user;

                    return(Json(new
                    {
                        status = status,
                        data = staff
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = status
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = -1
                }));
            }
        }
Ejemplo n.º 10
0
        private void repositoryItemButtonEditSave_Click(object sender, EventArgs e)
        {
            DataRowView r = (DataRowView)gridView.GetRow(gridView.FocusedRowHandle);
            StaffBean   b = new StaffBean();

            try
            {
                b.Id = Convert.ToInt32(r["StaffId"].ToString());
            }
            catch
            {
                MessageBox.Show("出现错误", "信息提示", MessageBoxButtons.OK);
                return;
            }


            b.StaffNumber = r["StaffNumber"].ToString();

            string level = r["PostLevel"].ToString();

            DataRow[] matches = tabPost.Select("Level='" + level + "'");
            if (matches.Length == 0)
            {
                return;
            }
            try
            {
                b.Post.Id = Convert.ToInt32((matches[0]["Id"].ToString()));
            }
            catch
            {
                MessageBox.Show("请选择岗位层级", "信息提示", MessageBoxButtons.OK);
                return;
            }


            level   = r["PerformanceLevel"].ToString();
            matches = tabPerformance.Select("Level='" + level + "'");
            if (matches.Length == 0)
            {
                MessageBox.Show("请选择绩效层级", "信息提示", MessageBoxButtons.OK);
                return;
            }
            try
            {
                b.Performance.Id = Convert.ToInt32((matches[0]["Id"].ToString()));
            }
            catch
            {
                MessageBox.Show("请选择绩效层级", "信息提示", MessageBoxButtons.OK);
                return;
            }

            level   = r["BenefitLevel"].ToString();
            matches = tabBenefit.Select("Level='" + level + "'");
            if (matches.Length == 0)
            {
                MessageBox.Show("请选择效益层级", "信息提示", MessageBoxButtons.OK);
                return;
            }
            try
            {
                b.Benefit.Id = Convert.ToInt32((matches[0]["Id"].ToString()));
            }
            catch
            {
                MessageBox.Show("请选择效益层级", "信息提示", MessageBoxButtons.OK);
                return;
            }
            b.AttendanceSalary = 0;
            b.SenioritySalary  = 0;
            try
            {
                b.AttendanceSalary = Convert.ToInt32((r["AttendanceSalary"].ToString()));
                b.SenioritySalary  = Convert.ToInt32((r["SenioritySalary"].ToString()));
            }
            catch {}

            if (DialogResult.OK != MessageBox.Show("是否保存修改", "信息提示", MessageBoxButtons.OKCancel))
            {
                return;
            }

            StaffDAO d = new StaffDAO();

            d.UpdateStaffSalary(b);
        }
Ejemplo n.º 11
0
 void LoadStaffList()
 {
     staffList.DataSource = StaffDAO.GetListStaff();
 }
Ejemplo n.º 12
0
 public static Staff getByID(int id)
 {
     return(StaffDAO.getByID(id));
 }