示例#1
0
        public IHttpActionResult UpdateEmployeeLeave()
        {
            try
            {
                using (MaxMasterDbEntities db = new MaxMasterDbEntities())
                {
                    var form = HttpContext.Current.Request.Form;

                    LeaveRecord leave = new LeaveRecord();
                    leave.EmpId     = form.Get("empId");
                    leave.LeaveDate = Convert.ToDateTime(form.Get("leaveDate"));
                    leave.UpdatedBy = User.Identity.GetUserId();
                    leave.LeaveType = form.Get("leaveType");

                    db.LeaveRecords.Add(leave);
                    db.SaveChanges();
                    return(Ok());
                }
            }
            catch (Exception ex)
            {
                new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace);
                return(Content(HttpStatusCode.InternalServerError, "An errorr occured, please try again later"));
            }
        }
示例#2
0
        /// <summary>
        /// 進行要顯示資料的初始化
        /// </summary>
        private async Task Init()
        {
            #region 假別清單項目初始化
            假別清單.Clear();
            假別清單.Add("請選擇");
            假別清單.Add("特休假");
            假別清單.Add("事假");
            假別清單.Add("病假");
            #endregion

            await foo請假紀錄Repository.Read();

            if (string.IsNullOrEmpty(fooID) == true)
            {
                請假紀錄項目 = new 請假紀錄項目ViewModel();
                點選假別   = 假別清單[0];
            }
            else
            {
                foo請假紀錄 = await MainHelper.請假紀錄Manager.LookupAsync(fooID);

                //foo請假紀錄項目 = foo請假紀錄Repository.請假紀錄.FirstOrDefault(x => x.ID == fooID);
                if (foo請假紀錄 == null)
                {
                    請假紀錄項目 = new 請假紀錄項目ViewModel();
                    點選假別   = 假別清單[0];
                }
                else
                {
                    請假紀錄項目 = new 請假紀錄項目ViewModel
                    {
                        ID    = foo請假紀錄.Id,
                        假別    = foo請假紀錄.假別,
                        申請人   = foo請假紀錄.申請人,
                        職務代理人 = foo請假紀錄.職務代理人,
                        請假日期  = foo請假紀錄.請假日期,
                        請假時數  = foo請假紀錄.請假時數,
                        請假理由  = foo請假紀錄.請假理由,
                        開始時間  = foo請假紀錄.開始時間,
                    };

                    var fooObj = 假別清單.FirstOrDefault(x => x == 請假紀錄項目.假別);
                    if (fooObj != null)
                    {
                        點選假別 = fooObj;
                    }
                    else
                    {
                        點選假別 = 假別清單[0];
                    }
                }
            }
        }
 /// <summary>
 /// 新增一筆紀錄
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public async Task InsertAsync(LeaveRecord item)
 {
     await 請假紀錄Table.InsertAsync(item);
 }
 /// <summary>
 /// 進行記錄更新
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public async Task UpdateAsync(LeaveRecord item)
 {
     await 請假紀錄Table.UpdateAsync(item);
 }
 /// <summary>
 /// 刪除這筆紀錄
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public async Task DeleteAsync(LeaveRecord item)
 {
     await 請假紀錄Table.DeleteAsync(item);
 }
示例#6
0
        public 我要請假記錄修改PageViewModel(INavigationService navigationService, IEventAggregator eventAggregator,
                                     IPageDialogService dialogService)
        {
            //
            #region 相依性服務注入的物件

            _dialogService     = dialogService;
            _eventAggregator   = eventAggregator;
            _navigationService = navigationService;
            #endregion

            #region 頁面中綁定的命令
            刪除按鈕Command = new DelegateCommand(async() =>
            {
                var fooAnswer = await _dialogService.DisplayAlertAsync("警告", "您確定刪除這筆請假記錄", "確定", "取消");
                if (fooAnswer == true)
                {
                    foo請假紀錄 = await MainHelper.請假紀錄Manager.LookupAsync(請假紀錄項目.ID);
                    if (foo請假紀錄 != null)
                    {
                        await MainHelper.請假紀錄Manager.DeleteAsync(foo請假紀錄);
                    }
                    await _navigationService.GoBackAsync();
                }
            });
            儲存按鈕Command = new DelegateCommand(async() =>
            {
                var fooCheck = await Check資料完整性();
                if (fooCheck == false)
                {
                    return;
                }

                if (新增或修改 == 新增或修改Enum.新增)
                {
                    foo請假紀錄 = new LeaveRecord
                    {
                        假別    = 點選假別,
                        申請人   = 請假紀錄項目.申請人,
                        職務代理人 = 請假紀錄項目.職務代理人,
                        請假日期  = 請假紀錄項目.請假日期,
                        請假時數  = 請假紀錄項目.請假時數,
                        請假理由  = 請假紀錄項目.請假理由,
                        開始時間  = 請假紀錄項目.開始時間,
                    };
                    await MainHelper.請假紀錄Manager.InsertAsync(foo請假紀錄);

                    await _navigationService.GoBackAsync();
                }
                else
                {
                    foo請假紀錄 = await MainHelper.請假紀錄Manager.LookupAsync(請假紀錄項目.ID);
                    if (foo請假紀錄 != null)
                    {
                        foo請假紀錄.假別    = 點選假別;
                        foo請假紀錄.申請人   = 請假紀錄項目.申請人;
                        foo請假紀錄.職務代理人 = 請假紀錄項目.職務代理人;
                        foo請假紀錄.請假日期  = 請假紀錄項目.請假日期;
                        foo請假紀錄.請假時數  = 請假紀錄項目.請假時數;
                        foo請假紀錄.請假理由  = 請假紀錄項目.請假理由;
                        foo請假紀錄.開始時間  = 請假紀錄項目.開始時間;
                        await MainHelper.請假紀錄Manager.UpdateAsync(foo請假紀錄);
                    }
                    else
                    {
                        return;
                    }

                    await _navigationService.GoBackAsync();
                }

                await _navigationService.GoBackAsync();
            });

            取消按鈕Command = new DelegateCommand(async() =>
            {
                var fooAnswer = await _dialogService.DisplayAlertAsync("警告", "您確定取消這筆請假記錄", "確定", "取消");
                if (fooAnswer == true)
                {
                    await _navigationService.GoBackAsync();
                }
            });
            #endregion
        }