示例#1
0
        private void approveBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var empPtoInfo = (EmployeePtoInfo)leaveRequestsBindingSource.Current;

            if (empPtoInfo != null)
            {
                var result = ViewHelper.ShowConfirmDialog("Are you sure to approve this leave request.");
                if (result == DialogResult.Yes)
                {
                    //do the calculation and affect the transaction table.
                    try
                    {
                        LeaveCalculationHelper.ApproveLeaveRequest(empPtoInfo.EmployeeId, empPtoInfo.NumDays, Convert.ToDateTime(empPtoInfo.From));
                        var pto = _proxy.Context.EmployeePtoes.FirstOrDefault(p => p.PtoId == empPtoInfo.PtoId);
                        pto.Status = EmployeePto.StatusApproved;
                        _proxy.Save();
                        RefreshList();
                    }
                    catch (Exception exception)
                    {
                        ViewHelper.ShowErrorMessage("Error occured while calculating the leave.", exception);
                    }
                }
            }
            else
            {
                ViewHelper.ShowErrorMessage("You must first select a leave request to approve.");
            }
        }
示例#2
0
        private void calculateLeaveBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            var result = ViewHelper.ShowConfirmDialog("Are you sure you want to calculate current leave value for all employees.");

            if (result == DialogResult.Yes)
            {
                try
                {
                    LeaveCalculationHelper.CalculateLeaveForAll();
                    ViewHelper.ShowSuccessMessage("Leave calculation completed successfuly.");
                }
                catch (Exception exception)
                {
                    ViewHelper.ShowErrorMessage("Error has occured during leave calculation.", exception);
                }
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     employeeBindingSource.EndEdit();
     try
     {
         LeaveCalculationHelper.AddInitialLeave(empList);
         ViewHelper.ShowSuccessMessage("Leave Configuration has successfully completed.");
         this.Close();
     }
     catch (ApplicationException appException)
     {
         ViewHelper.ShowErrorMessage(appException.Message);
     }
     catch (Exception exception)
     {
         ViewHelper.ShowErrorMessage("Error has occured while calculating leave.", exception);
     }
 }