示例#1
0
 public void CreateLeave()
 {
     using (HRMSDbContext hrmsDbContex = new HRMSDbContext())
     {
         Leave leave = new Leave()
         {
             Leavetype = LeaveType.Personal,
             StartTime = new DateTime(2015,6,30,8,0,0),
             EndTime = new DateTime(2015,6,30,17,0,0),
             Comment = "家裏有事"
         };
         hrmsDbContex.Leaves.Add(leave);
         hrmsDbContex.SaveChanges();
     }
 }
示例#2
0
        public ActionResult AssignLeave(Leave leave)
        {
            if (ModelState.IsValid == false)
            {
                return View(leave);
            }

            using (UnitOfWork unitwork = ServiceLocator.Current.GetInstance<UnitOfWork>())
            {
                var leaveRepository = ServiceLocator.Current.GetInstance<IRepository<Leave, long?>>();
                leaveRepository.SaveOrUpdate(leave);
                unitwork.SaveChanges();
            }

            return View(leave);
        }
        /// <summary>
        /// Inserts the or update.
        /// </summary>
        /// <param name="leave">The leave.</param>
        /// <returns>Leave result.</returns>
        /// <exception cref="System.ArgumentNullException">leave null</exception>
        public IList<LeaveResult> InsertOrUpdate(Leave leave)
        {
            if (leave == null)
            {
                throw new ArgumentNullException(LeaveConstant);
            }

            if (leave.LeaveId == default(int))
            {
                return this.unitOfWork.Context.AddLeave(leave.DeveloperIds, leave.Type, leave.DateRange, leave.RequestedByDeveloperId, leave.IsUnplanned, leave.Comment, (byte)leave.ApplicationType).ToList();
            }
            else
            {
                this.unitOfWork.Context.UpdateLeave(leave.LeaveId, Convert.ToInt32(leave.DeveloperIds, CultureInfo.CurrentCulture), leave.Type, leave.DateRange, leave.ModifiedByDeveloperId, leave.Comment);
                return null;
            }
        }
示例#4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Leave leave = new Leave
            {
                SystemCreated = DateTime.Now,
            };

            if (!string.IsNullOrEmpty(this.lblId.Text))
                leave = DateHelper.GetInstance().GetLeave(this.View_QueryResults, int.Parse(this.lblId.Text));

            leave.Date = this.leaveDate.Value;
            leave.Description = this.txtLeaveDescription.Text;
            leave.SystemUpdated = DateTime.Now;

            this.View_SaveRecord(leave);
            this.View_QueryRecords(null);
            this.WindowInputChanges(ModifierState.Save);
        }
示例#5
0
        /// <summary>
        /// Inserts the or update.
        /// </summary>
        /// <param name="leave">The leave.</param>
        /// <returns>Leave result.</returns>
        /// <exception cref="System.ArgumentNullException">leave null</exception>
        public IList<LeaveResult> InsertOrUpdate(Leave leave)
        {
            if (leave == null)
            {
                throw new ArgumentNullException(LeaveConst);
            }

            if (leave.ApplicationType == default(int))
            {
                leave.ApplicationType = ApplicationType.Website;
            }

            return this.leaveRepository.InsertOrUpdate(leave);
        }