예제 #1
0
        public List <HRLeave> FindByWhereForMgr(HRLeave vo, string mgrDeptId, string mgrEmpId)
        {
            string whereSql = "";

            if (!EmptyUtils.EmptyStr(vo.Id))
            {
                whereSql += " and id=@Id";
            }
            if (vo.Status > 0)
            {
                whereSql += " and Status=@Status";
            }
            if (!EmptyUtils.EmptyStr(vo.EmpId))
            {
                whereSql += " and EMP_ID=@EmpId";
            }

            string sql = "SELECT * FROM HR_LEAVE WHERE EMP_ID != @MgrEmpId ";

            sql = sql += whereSql;
            sql = sql += " AND EMP_ID IN (SELECT EMP_ID FROM HR_EMPLOYEE WHERE DEPT_ID = @mgrDeptId) ";

            return(conn.Query <HRLeave>(sql, new
            {
                Id = vo.Id,
                Status = vo.Status,
                EmpId = vo.EmpId,
                MgrEmpId = mgrDeptId,
                mgrDeptId = mgrDeptId
            }).ToList());
        }
예제 #2
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            if (!validateInput())
            {
                return;
            }

            if (dao.FindByDate(dtStartDate.Text).Count > 0)
            {
                MessageBoxEx.Show(this, dtStartDate.Text + "已经请过假了,请选择其他日期");
                return;
            }

            HRLeave vo = new HRLeave();

            vo.Id        = UidUtils.GGuidPrefix();
            vo.EmpId     = GlobalInfo.loginEmp.Id;
            vo.Cause     = txtCause.Text;
            vo.Type      = !EmptyUtils.EmptyObj(cboLeaveType.SelectedValue) ? int.Parse(cboLeaveType.SelectedValue.ToString()) : -1;
            vo.LeaveDay  = int.Parse(txtLeaveDay.Text);
            vo.LeaveDate = dtStartDate.Text;
            vo.Status    = 1;// 提交申请
            dao.Add(vo);

            DialogResult ret = MessageBoxEx.Show(this, "请假提交成功");

            Close();
        }
예제 #3
0
        public List <HRLeave> FindByWhereForAdmin(HRLeave vo)
        {
            string whereSql = "";

            if (!EmptyUtils.EmptyStr(vo.Id))
            {
                whereSql += " and id=@Id";
            }
            if (vo.Status > 0)
            {
                whereSql += " and Status=@Status";
            }
            if (!EmptyUtils.EmptyStr(vo.EmpId))
            {
                whereSql += " and EMP_ID=@EmpId";
            }

            string sql = "SELECT * FROM HR_LEAVE WHERE 1=1 ";

            sql = sql += whereSql;
            sql = sql += " AND EMP_ID IN(SELECT EMP_ID FROM HR_USER WHERE USER_TYPE = 2)";

            return(conn.Query <HRLeave>(sql, new
            {
                Id = vo.Id,
                Status = vo.Status,
                EmpId = vo.EmpId
            }).ToList());
        }
        /// <summary>
        /// 输入转VO
        /// </summary>
        /// <returns></returns>
        private HRLeave InputToVo()
        {
            HRLeave vo = new HRLeave();

            vo.Id      = txtId.Text;
            vo.EmpId   = !EmptyUtils.EmptyObj(cboEmp.SelectedValue) ? cboEmp.SelectedValue.ToString() : "";
            vo.EmpName = !EmptyUtils.EmptyObj(cboEmp.SelectedValue) ? ((HREmployee)cboEmp.SelectedItem).Name : "";
            vo.Status  = !EmptyUtils.EmptyObj(cboStatus.SelectedValue) ? int.Parse(cboStatus.SelectedValue.ToString()) : -1;
            return(vo);
        }
        private void btnFail_Click(object sender, EventArgs e)
        {
            if (grid.CurrentRow.Index >= 0)
            {
                HRLeave vo = list[grid.CurrentRow.Index];
                dao.Update(vo.Id, 3); // 通过

                initData();
            }
        }
예제 #6
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <returns></returns>
 public int Update(HRLeave vo)
 {
     //return conn.Execute(@"update HR_LEAVE SET NAME=@Name,CREATE_TIME=@CreateTime WHERE id = @Id",
     //    new
     //    {
     //        Id = vo.Id,
     //        Name = vo.Name,
     //        CreateTime = vo.CreateTime
     //    });
     return(0);
 }
예제 #7
0
        // 新增
        public int Add(HRLeave vo)
        {
            int ret = conn.Execute(@"insert HR_LEAVE(ID,EMP_ID,TYPE,LEAVE_DATE,LEAVE_DAY,CAUSE,STATUS) values (@Id,@EmpId,@Type, @LeaveDate, @LeaveDay,@Cause,@Status)",
                                   new[] { new { Id        = vo.Id,
                                                 EmpId     = vo.EmpId,
                                                 Type      = vo.Type,
                                                 LeaveDate = vo.LeaveDate,
                                                 LeaveDay  = vo.LeaveDay,
                                                 Cause     = vo.Cause,
                                                 Status    = vo.Status } });

            Console.WriteLine(string.Format("插入数据库成功{0}", ret));

            return(ret);
        }
        private void grid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            HRLeave vo = list[e.RowIndex];

            if (vo.Status == 1)
            {
                btnPass.Enabled = true;
                btnFail.Enabled = true;
            }
            else
            {
                btnPass.Enabled = false;
                btnFail.Enabled = false;
            }
        }
        private void btnFind_Click(object sender, EventArgs e)
        {
            HRLeave vo = InputToVo();

            if (GlobalInfo.loginUser.UserType == GlobalInfo.ADMIN)
            {
                list = dao.FindByWhereForAdmin(vo);
                var bindingList = new BindingList <HRLeave>(list);
                listSource      = new BindingSource(bindingList, null);
                grid.DataSource = listSource;
            }
            else if (GlobalInfo.loginUser.UserType == GlobalInfo.DEPT_MGR)
            {
                list = dao.FindByWhereForMgr(vo, GlobalInfo.loginEmp.DeptId, GlobalInfo.loginEmp.Id);
                var bindingList = new BindingList <HRLeave>(list);
                listSource      = new BindingSource(bindingList, null);
                grid.DataSource = listSource;
            }
        }