Esempio n. 1
0
 protected override void AddNew()
 {
     this._leave            = new Book.Model.Leave();
     this._leave.LeaveId    = Guid.NewGuid().ToString();
     this._leave.LeaveDate  = DateTime.Now.Date;
     this._leave.LeaveRange = 0;
 }
Esempio n. 2
0
        //请假修改.需要得知会修改成的日期间隔.以便删除本身之外.删除原有
        public void Update(Model.Leave leave)
        {
            Validate(leave);

            //首先删除本条
            this.Delete(leave.LeaveId);
            //删除日期区间内所有
            if (Math.Truncate(leave.LeaveDateCount.Value) > 1)
            {
                DateTime startdate = leave.LeaveDate.Value;
                DateTime enddate   = leave.LeaveDate.Value.AddDays(double.Parse((leave.LeaveDateCount.Value - 1).ToString()));
                accessor.DeleteByDateRange(startdate, enddate, leave.EmployeeId);
            }


            this.Insert(leave);

            #region 原有修改方法
            //IList<Model.Leave> mLeaveList = this.SelectLeaveListbyEmp(leave.EmployeeId);
            //bool cando;
            ////获得假期列表
            //IList<Model.AnnualHoliday> holidaylist = new BL.AnnualHolidayManager().SelectBigThanDate(DateTime.Parse(DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-01")));
            //cando = holidaylist.Any(mel => mel.HolidayDate.Value.Date == leave.LeaveDate.Value.Date);
            //if (cando)
            //    throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveDate + "_IsHoliday");
            //cando = mLeaveList.Any(mle => mle.LeaveDate.Value.ToString("yyyy-MM-dd") == leave.LeaveDate.Value.ToString("yyyy-MM-dd") && mle.LeaveRange.Value == leave.LeaveRange.Value && mle.LeaveId != leave.LeaveId);
            //if (cando)
            //    throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveId + "_1");
            //accessor.Update(leave);
            #endregion
        }
Esempio n. 3
0
 protected override void MoveLast()
 {
     // if (this.action == "insert")
     {
         this._leave = this.leaveManamer.GetLastForEmployeeYear(_employee.EmployeeId, new DateTime(int.Parse(this.dateedit.Text.Substring(0, 4)), 1, 1));
     }
 }
Esempio n. 4
0
        private void band2()
        {
            _leave = this.bindingSource2.Current as Model.Leave;
            if (this._leave == null)
            {
                this.Refresh();
            }
            else
            {
                this.action = "view";

                //控件赋值
                // this.newChooseContorl1.EditValue = _employee;
                if ((global::Helper.DateTimeParse.DateTimeEquls(this._leave.LeaveDate, global::Helper.DateTimeParse.NullDate)) || (_leave.LeaveDate == new DateTime()))
                {
                    this.dateEditLeaveDateStart.EditValue = null;
                }
                else
                {
                    dateEditLeaveDateStart.DateTime = _leave.LeaveDate.Value;
                }

                cmbLeaveDayCount.SelectedIndex = _leave.LeaveRange.HasValue ? this._leave.LeaveRange.Value : 0;
                //this.calcLeaveCount.Value = decimal.Parse((this.cmbLeaveDayCount.SelectedIndex == 0 ? 1 : 0.5).ToString());
                lookUpEdit1.EditValue  = _leave.LeaveTypeId;
                memoEditLeaveDesc.Text = _leave.LeaveText;

                this.newChooseContorl1.ShowButton = true;
                this.newChooseContorl1.Enabled    = false;
                this.dateedit.Enabled             = true;
                //this.calcLeaveCount.Enabled = this._leave.LeaveRange > 2 ? true : false;
                base.Refresh();
            }
        }
Esempio n. 5
0
        public override void Refresh()
        {
            if (this._leave == null)
            {
                this.AddNew();
                this.action = "insert";
            }
            else
            {
                if (this.action == "view")
                {
                    this._leave = this.leaveManamer.Get(this._leave.LeaveId);
                }
            }

            this.newChooseContorl1.EditValue = _employee;
            if ((global::Helper.DateTimeParse.DateTimeEquls(this._leave.LeaveDate, global::Helper.DateTimeParse.NullDate)) || (_leave.LeaveDate == new DateTime()))
            {
                this.dateEditLeaveDateStart.EditValue = null;
            }
            else
            {
                dateEditLeaveDateStart.DateTime = _leave.LeaveDate.Value;
            }

            //默认终止日期为null
            this.dateEditLeaveDateEnd.EditValue = null;
            cmbLeaveDayCount.SelectedIndex      = _leave.LeaveRange.HasValue ? this._leave.LeaveRange.Value : 0;
            //this.calcLeaveCount.Value = decimal.Parse((this.cmbLeaveDayCount.SelectedIndex == 0 ? 1 : 0.5).ToString());
            lookUpEdit1.EditValue  = _leave.LeaveTypeId;
            memoEditLeaveDesc.Text = _leave.LeaveText;
            if (this.action != "update" && _employee != null)
            {
                _leaveList = this.leaveManamer.Getleavebyempidmonth(_employee.EmployeeId, int.Parse(this.dateedit.Text.Substring(0, 4)), null);
                this.bindingSource2.DataSource = _leaveList;
                int a = 0;
                for (a = 0; a < _leaveList.Count; a++)
                {
                    if (this._leave.LeaveId == _leaveList[a].LeaveId)
                    {
                        break;
                    }
                }
                this.bindingSource2.Position = a;
            }
            base.Refresh();

            if (this.bindingSource2.Current == null)
            {
                this.VisiblesLinks0();
            }
            this.newChooseContorl1.ShowButton = true;
            this.newChooseContorl1.Enabled    = false;
            this.dateedit.Enabled             = true;
            //this.calcLeaveCount.Enabled = this._leave.LeaveRange > 2 ? true : false;
            this.chkIsAll.Enabled = true;

            //this.bar1.ItemLinks[3].Visible = false;       //可以修改
        }
Esempio n. 6
0
        public async Task <string> UpdateLeave(int Id, Model.Leave _Leave)
        {
            string Status = string.Empty;
            var    Leave  = Mapper.Map <Model.Leave, Data.Leave>(_Leave);
            var    result = data.Put(Id, Leave);

            Status = result ? "Leave updated successfully." : "Failed to update Leave";
            return(Status);
        }
Esempio n. 7
0
        public async Task <string> InsertLeave(Model.Leave _Leave)
        {
            string Status = string.Empty;
            var    Leave  = Mapper.Map <Model.Leave, Data.Leave>(_Leave);
            var    result = data.Post(Leave);

            Status = result ? "Leave submitted successfully." : "Failed to submit Leave";
            return(Status);
        }
Esempio n. 8
0
 private void Validate(Model.Leave leave)
 {
     if (string.IsNullOrEmpty(leave.EmployeeId))
     {
         throw new Helper.RequireValueException(Model.Leave.PRO_EmployeeId);
     }
     if (string.IsNullOrEmpty(leave.LeaveTypeId))
     {
         throw new Helper.RequireValueException(Model.Leave.PRO_LeaveTypeId);
     }
 }
Esempio n. 9
0
 protected override void Delete()
 {
     if (this._leave == null)
     {
         return;
     }
     if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
     {
         return;
     }
     this.leaveManamer.Delete(this._leave);
     this._leave = this.leaveManamer.GetPrevForEmployeeYear(_employee.EmployeeId, this._leave.LeaveDate.Value);
 }
Esempio n. 10
0
 public void Delete(Model.Leave Leave)
 {
     try
     {
         BL.V.BeginTransaction();
         this.Delete(Leave.LeaveId);
         hrDatilyManager.ReCheck(Leave.LeaveDate.Value.Date, Leave.Employee);
         BL.V.CommitTransaction();
     }
     catch (Exception ex)
     {
         BL.V.RollbackTransaction();
         throw ex;
     }
 }
Esempio n. 11
0
        public void Insert(Model.Leave leave, IList <Model.Employee> empList)
        {
            Validate(leave);

            //for (int i = 0; i < a; i++)
            //{
            //    if (i > 0)
            //    {
            //        leave.LeaveId = Guid.NewGuid().ToString();
            //        leave.LeaveDate = leave.LeaveDate.Value.Date.AddDays(1);
            //    }
            //    leave.LeaveRange = 0;
            //    accessor.Insert(leave);
            //}
            //if (a < leave.LeaveDateCount.Value)
            //{
            //    leave.LeaveId = Guid.NewGuid().ToString();
            //    leave.LeaveDate = leave.LeaveDate.Value.Date.AddDays(1);
            //    leave.LeaveRange = 1;
            //    accessor.Insert(leave);
            //}

            IList <Model.Leave> mLeaveList;
            StringBuilder       sb = new StringBuilder();

            foreach (Model.Employee emp in empList)
            {
                sb.Append("'" + emp.EmployeeId + "',");
            }
            mLeaveList = this.SelectLeaveListbyEmp(sb.ToString().Substring(0, sb.ToString().Length - 1));

            //获得假期列表
            IList <Model.AnnualHoliday> holidaylist = new BL.AnnualHolidayManager().SelectBigThanDate(DateTime.Parse(DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-01")));

            bool cando;

            try
            {
                BL.V.BeginTransaction();
                Model.Leave model;
                int         flag = 0;

                decimal a = Math.Truncate(leave.LeaveDateCount.Value);

                foreach (Model.Employee emp in empList)
                {
                    if (a > 1)
                    {
                        for (int i = 0; i < a; i++)
                        {
                            cando = holidaylist.Any(mel => mel.HolidayDate.Value.Date == leave.LeaveDate.Value.AddDays(i).Date);
                            if (cando)
                            {
                                continue;
                            }
                            cando = mLeaveList.Any(mle => mle.LeaveDate.Value.ToString("yyyy-MM-dd") == leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") && mle.LeaveRange.Value == leave.LeaveRange.Value && mle.EmployeeId == emp.EmployeeId);
                            if (cando)
                            {
                                //continue;
                                throw new Helper.MessageValueException(emp.EmployeeName + " " + leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") + " 已有請假記錄,請查證。");
                            }
                            //if (hrDatilyManager.SelectByDateAndEmp(emp.EmployeeId, leave.LeaveDate.Value.AddDays(i)) != null && leave.LeaveRange == 0)
                            //    throw new Helper.MessageValueException(emp.EmployeeName + " " + leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") + " 已有出勤記錄,請查證。");

                            model                = new Book.Model.Leave();
                            model.EmployeeId     = emp.EmployeeId;
                            model.LeaveDate      = leave.LeaveDate.Value.Date.AddDays(i);
                            model.LeaveDateCount = leave.LeaveDateCount;
                            if (flag == 0)
                            {
                                model.LeaveId = leave.LeaveId;
                            }
                            else
                            {
                                model.LeaveId = Guid.NewGuid().ToString();
                            }
                            model.LeaveRange  = leave.LeaveRange;
                            model.LeaveText   = leave.LeaveText;
                            model.LeaveTypeId = leave.LeaveTypeId;
                            accessor.Insert(model);
                            //增加列表
                            //mLeaveList.Add(model);
                            if (DateTime.Now.Date > model.LeaveDate)
                            {
                                hrDatilyManager.ReCheck(leave.LeaveDate.Value.Date, leave.Employee);
                            }
                            flag = 1;
                        }
                    }
                    else
                    {
                        //cando = holidaylist.Any(mel => mel.HolidayDate.Value.Date == leave.LeaveDate.Value.Date);
                        //if (cando)
                        //    throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveDate + "_IsHoliday");
                        cando = mLeaveList.Any(mle => mle.LeaveDate.Value.ToString("yyyy-MM-dd") == leave.LeaveDate.Value.ToString("yyyy-MM-dd") && mle.LeaveRange.Value == leave.LeaveRange.Value && mle.EmployeeId == emp.EmployeeId);
                        if (cando)
                        {
                            //throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveId + "_1");
                            throw new Helper.MessageValueException(emp.EmployeeName + " " + leave.LeaveDate.Value.ToString("yyyy-MM-dd") + " 已有請假記錄,請查證。");
                        }
                        //if (hrDatilyManager.SelectByDateAndEmp(emp.EmployeeId, leave.LeaveDate.Value) != null && leave.LeaveRange == 0)
                        //    throw new Helper.MessageValueException(emp.EmployeeName + " " + leave.LeaveDate.Value.ToString("yyyy-MM-dd") + " 已有出勤記錄,請查證。");
                        model                = new Book.Model.Leave();
                        model.EmployeeId     = emp.EmployeeId;
                        model.LeaveDate      = leave.LeaveDate.Value.Date;
                        model.LeaveDateCount = leave.LeaveDateCount;
                        if (flag == 0)
                        {
                            model.LeaveId = leave.LeaveId;
                        }
                        else
                        {
                            model.LeaveId = Guid.NewGuid().ToString();
                        }
                        model.LeaveRange  = leave.LeaveRange;
                        model.LeaveText   = leave.LeaveText;
                        model.LeaveTypeId = leave.LeaveTypeId;
                        accessor.Insert(model);
                        //增加列表项
                        //mLeaveList.Add(model);
                        hrDatilyManager.ReCheck(leave.LeaveDate.Value.Date, leave.Employee);
                        flag = 1;
                    }
                }
                BL.V.CommitTransaction();
            }
            catch (Exception ex)
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
Esempio n. 12
0
        public void Insert(Model.Leave leave)
        {
            Validate(leave);
            Model.Leave model;
            int         flag = 0;

            decimal a = Math.Truncate(leave.LeaveDateCount.Value);

            IList <Model.Leave> mLeaveList = this.SelectLeaveListbyEmp("'" + leave.EmployeeId + "'");

            //获得假期列表
            IList <Model.AnnualHoliday> holidaylist = new BL.AnnualHolidayManager().SelectBigThanDate(leave.LeaveDate.Value);

            bool cando;

            #region 注释
            //decimal a = Math.Truncate(leave.LeaveDateCount.Value);
            //for (int i = 0; i < a; i++)
            //{
            //    if (i > 0)
            //    {
            //        leave.LeaveId = Guid.NewGuid().ToString();
            //        leave.LeaveDate = leave.LeaveDate.Value.Date.AddDays(1);
            //    }
            //    leave.LeaveRange = 0;
            //    accessor.Insert(leave);
            //}
            //if (a < leave.LeaveDateCount.Value)
            //{
            //    leave.LeaveId = Guid.NewGuid().ToString();
            //    leave.LeaveDate = leave.LeaveDate.Value.Date.AddDays(1);
            //    leave.LeaveRange = 1;
            //    accessor.Insert(leave);
            //}
            #endregion

            try
            {
                BL.V.BeginTransaction();
                if (a > 1)
                {
                    for (int i = 0; i < a; i++)
                    {
                        cando = holidaylist.Any(mel => mel.HolidayDate.Value.Date == leave.LeaveDate.Value.AddDays(i).Date);
                        if (cando)
                        {
                            continue;
                        }
                        cando = mLeaveList.Any(mle => mle.LeaveDate.Value.ToString("yyyy-MM-dd") == leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") && mle.LeaveRange.Value == leave.LeaveRange.Value);
                        if (cando)
                        {
                            //continue;
                            throw new Helper.MessageValueException(leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") + " 已有請假記錄,請查證。");
                        }
                        //Model.HrDailyEmployeeAttendInfo hr = hrDatilyManager.SelectByDateAndEmp(leave.EmployeeId,leave.LeaveDate.Value.AddDays(i));
                        //if (hrDatilyManager.SelectByDateAndEmp(leave.EmployeeId, leave.LeaveDate.Value.AddDays(i)) != null && leave.LeaveRange == 0)
                        //    throw new Helper.MessageValueException(leave.LeaveDate.Value.AddDays(i).ToString("yyyy-MM-dd") + " 已有出勤記錄,請查證。");
                        model                = new Book.Model.Leave();
                        model.EmployeeId     = leave.EmployeeId;
                        model.LeaveDate      = leave.LeaveDate.Value.Date.AddDays(i);
                        model.LeaveDateCount = leave.LeaveDateCount;
                        if (flag == 0)
                        {
                            model.LeaveId = leave.LeaveId;
                        }
                        else
                        {
                            model.LeaveId = Guid.NewGuid().ToString();
                        }
                        model.LeaveRange  = leave.LeaveRange;
                        model.LeaveText   = leave.LeaveText;
                        model.LeaveTypeId = leave.LeaveTypeId;
                        accessor.Insert(model);
                        //增加列表项
                        //mLeaveList.Add(model);
                        if (DateTime.Now.Date > model.LeaveDate)
                        {
                            hrDatilyManager.ReCheck(leave.LeaveDate.Value.Date, leave.Employee);
                        }
                        flag = 1;
                    }
                }
                else
                {
                    //cando = holidaylist.Any(mel => mel.HolidayDate.Value.Date == leave.LeaveDate.Value.Date);
                    //if (cando)
                    //    throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveDate + "_IsHoliday");
                    cando = mLeaveList.Any(mle => mle.LeaveDate.Value.ToString("yyyy-MM-dd") == leave.LeaveDate.Value.ToString("yyyy-MM-dd") && mle.LeaveRange.Value == leave.LeaveRange.Value);
                    if (cando)
                    {
                        //throw new Helper.InvalidValueException(Model.Leave.PRO_LeaveId + "_1");
                        throw new Helper.MessageValueException(leave.LeaveDate.Value.ToString("yyyy-MM-dd") + " 已有請假記錄,請查證。");
                    }
                    //if (hrDatilyManager.SelectByDateAndEmp(leave.EmployeeId, leave.LeaveDate.Value) != null && leave.LeaveRange == 0)
                    //    throw new Helper.MessageValueException(leave.LeaveDate.Value.ToString("yyyy-MM-dd") + " 已有出勤記錄,請查證。");
                    accessor.Insert(leave);
                    hrDatilyManager.ReCheck(leave.LeaveDate.Value.Date, leave.Employee);
                }
                BL.V.CommitTransaction();
            }
            catch (Exception ex)
            {
                BL.V.RollbackTransaction();
                throw ex;
            }
        }
Esempio n. 13
0
 public void Update(Model.Leave e)
 {
     this.Update <Model.Leave>(e);
 }
Esempio n. 14
0
 public void Insert(Model.Leave e)
 {
     this.Insert <Model.Leave>(e);
 }
Esempio n. 15
0
        public override void Refresh()
        {
            if (this._leave == null)
            {
                this.AddNew();
                this.action = "insert";
            }
            else
            {
                if (this.action == "view")
                {
                    this._leave = this.leaveManamer.Get(this._leave.LeaveId);
                }
            }

            this.newChooseContorl1.EditValue = _employee;
            if ((global::Helper.DateTimeParse.DateTimeEquls(this._leave.LeaveDate, global::Helper.DateTimeParse.NullDate)) || (_leave.LeaveDate == new DateTime()))
            {
                this.dateEditLeaveDateStart.EditValue = null;
            }
            else
            {
                dateEditLeaveDateStart.DateTime = _leave.LeaveDate.Value;
            }

            //默认终止日期为null
            this.dateEditLeaveDateEnd.EditValue = null;
            cmbLeaveDayCount.SelectedIndex      = _leave.LeaveRange.HasValue ? this._leave.LeaveRange.Value : 0;
            //this.calcLeaveCount.Value = decimal.Parse((this.cmbLeaveDayCount.SelectedIndex == 0 ? 1 : 0.5).ToString());
            lookUpEdit1.EditValue  = _leave.LeaveTypeId;
            memoEditLeaveDesc.Text = _leave.LeaveText;
            if (this.action != "update" && _employee != null)
            {
                _leaveList = this.leaveManamer.Getleavebyempidmonth(_employee.EmployeeId, int.Parse(this.dateedit.Text.Substring(0, 4)), null);
                this.bindingSource2.DataSource = _leaveList;
                int a = 0;
                for (a = 0; a < _leaveList.Count; a++)
                {
                    if (this._leave.LeaveId == _leaveList[a].LeaveId)
                    {
                        break;
                    }
                }
                this.bindingSource2.Position = a;
            }

            //清除员工选择
            (this.bs_Employees.DataSource as List <Model.Employee>).ForEach(d => { d.IsChecked = false; });
            this.grid_Employees.RefreshDataSource();
            //清除部门选择
            foreach (DevExpress.XtraEditors.Controls.CheckedListBoxItem item in this.chkCombox_Department.Properties.Items)
            {
                item.CheckState = CheckState.Unchecked;
            }

            base.Refresh();

            if (this.bindingSource2.Current == null)
            {
                this.VisiblesLinks0();
            }
            this.newChooseContorl1.ShowButton = true;
            this.newChooseContorl1.Enabled    = false;
            this.dateedit.Enabled             = true;
            this.dateedit.Properties.ReadOnly = false;
            this.checkEditAll.Checked         = false;
            //this.calcLeaveCount.Enabled = this._leave.LeaveRange > 2 ? true : false;
            //this.chkIsAll.Enabled = true;

            //this.bar1.ItemLinks[3].Visible = false;       //可以修改
        }