private void gridLeaveRegister_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         this.LeaveApplicationID = (int)(gridLeaveRegister.Rows[e.RowIndex].Cells["ApplicationID"].Value);
         TBL_MP_HR_LeaveApplication model = _ServiceLeaves.GetLeaveApplicationInfoDbRecord(this.LeaveApplicationID);
         if (model.FK_RequestTo == Program.CURR_USER.EmployeeID)
         {
             btnApproveReject.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
         }
         else
         {
             btnApproveReject.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "PageLeavesRegister::gridLeaveRegister_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
        private void gridLeaveApplications_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                ServiceLeaveApplication service = new ServiceLeaveApplication();
                this.SelectedLeaveAppliID = (int)(gridLeaveApplications.Rows[e.RowIndex].Cells["ApplicationID"].Value);
                TBL_MP_HR_LeaveApplication dbModel = service.GetLeaveApplicationInfoDbRecord(SelectedLeaveAppliID);

                if (dbModel.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_PENDING_ID)
                {
                    btnEditLeave.Enabled = btnDeleteLeave.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                }
                if (dbModel.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_APPROVED_ID)
                {
                    btnEditLeave.Enabled = btnDeleteLeave.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                }
                if (dbModel.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_REJECTED_ID)
                {
                    btnEditLeave.Enabled   = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnDeleteLeave.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "PageUserInfo::gridLeaveApplications_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                ServiceLeaveApplication    service = new ServiceLeaveApplication();
                TBL_MP_HR_LeaveApplication model   = service.GetLeaveApplicationInfoDbRecord(this.ApplicationID);
                if (model != null)
                {
                    model.RemarksApproval = txtApprovalRemarks.Text.Trim();
                    model.FK_ApprovedBy   = Program.CURR_USER.EmployeeID;
                    model.Approval_Date   = AppCommon.GetServerDateTime();
                    if (rbtnApproveLeave.Checked)
                    {
                        model.FK_UserList_ApprovalStatusID = service.LEAVE_STATUS_APPROVED_ID;
                    }
                    if (rbtnRejectLeave.Checked)
                    {
                        model.FK_UserList_ApprovalStatusID = service.LEAVE_STATUS_REJECTED_ID;
                    }

                    if (model.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_REJECTED_ID)
                    {
                        service.RejectAttendanceForLeave(ApplicationID);
                    }
                    service.UpdateLeaveApplicationInfo(model);
                    if (model.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_APPROVED_ID)
                    {
                        service.ApproveAttendanceForLeave(ApplicationID);
                    }

                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmApproveRejectLeave::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cursor = Cursors.Default;
        }
Exemple #4
0
        public void ScatterData()
        {
            ServiceLeaveApplication _service = new ServiceLeaveApplication();

            try
            {
                TBL_MP_HR_LeaveApplication model = _service.GetLeaveApplicationInfoDbRecord(this.LeaveApplicationID);
                if (model != null)
                {
                    txtLeaveApplicationNo.Text   = model.ApplicationNo;
                    dtLeaveApplicationDate.Value = model.ApplicationDate;

                    cboEmployees.SelectedItem     = ((List <SelectListItem>)cboEmployees.DataSource).Where(x => x.ID == model.FK_EmployeeID).FirstOrDefault();
                    cboRequestTo.SelectedItem     = ((List <SelectListItem>)cboRequestTo.DataSource).Where(x => x.ID == model.FK_RequestTo).FirstOrDefault();
                    cboLeaveFormType.SelectedItem = ((List <SelectListItem>)cboLeaveFormType.DataSource).Where(x => x.ID == model.FK_UserList_LeaveFormTypeID).FirstOrDefault();
                    this.SelectedLeavFormTypeID   = model.FK_UserList_LeaveFormTypeID;
                    int leaveFormID   = Program.LIST_DEFAULTS.Where(x => x.ID == (int)APP_DEFAULT_VALUES.LeaveFormTypeLeaveID).FirstOrDefault().DEFAULT_VALUE;
                    int outdoorFormID = Program.LIST_DEFAULTS.Where(x => x.ID == (int)APP_DEFAULT_VALUES.LeaveFormTypeOutDoorID).FirstOrDefault().DEFAULT_VALUE;

                    if (model.FK_UserList_LeaveFormTypeID == leaveFormID || model.FK_UserList_LeaveFormTypeID == outdoorFormID)
                    {
                        PopulateLeaveTypeDropdown();
                        cboLeaveType.SelectedItem = ((List <SelectListItem>)cboLeaveType.DataSource).Where(x => x.ID == model.fK_UsrLst_LeaveTypeID).FirstOrDefault();
                    }

                    dtFromDate.Value = model.FromDate;
                    dtToDate.Value   = model.ToDate;
                    dtFromTime.Value = model.FromTime.Value;
                    dtToTime.Value   = model.ToTime.Value;
                    txtRemarks.Text  = model.Remarks;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditLeaveApplication::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #5
0
        private void btnDeleteLeave_Click(object sender, EventArgs e)
        {
            try
            {
                // TBL_MP_HR_LeaveApplication model = new TBL_MP_HR_LeaveApplication();
                ServiceLeaveApplication service = new ServiceLeaveApplication();

                TBL_MP_HR_LeaveApplication dbModel = service.GetLeaveApplicationInfoDbRecord(SelectedLeaveAppliID);


                {
                    string       msg = "Are you sure to Delete selected leave Permanently";
                    DialogResult res = MessageBox.Show(msg, "Caution", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (res == DialogResult.Yes)
                    {
                        if (dbModel.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_PENDING_ID)
                        {
                            (new ServiceLeaveApplication()).DeleteEmployeeLeave(this.SelectedLeaveAppliID);
                            PopulateLeavesGrid();
                        }
                        else
                        {
                            msg = "Unable to delete  selected leave..";
                            MessageBox.Show(msg, "Caution", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "PageUserInfo::btnDeleteLeave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #6
0
        private void frmApproveRejectLeave_Load(object sender, EventArgs e)
        {
            try
            {
                ServiceLeaveApplication    service = new ServiceLeaveApplication();
                TBL_MP_HR_LeaveApplication model   = service.GetLeaveApplicationInfoDbRecord(this.ApplicationID);
                if (model != null)
                {
                    txtLeaveApplicationNo.Text   = model.ApplicationNo;
                    dtLeaveApplicationDate.Value = model.ApplicationDate;

                    txtLeaveDescription.Text  = string.Format("{0} {1}", model.TBL_MP_Master_Employee.EmployeeName, model.TBL_MP_Master_Employee.EmployeeCode);
                    txtLeaveDescription.Text += string.Format("\n{0}   From: {1}{2} To: {3}{4}",
                                                              model.TBL_MP_Admin_UserList.Admin_UserList_Desc.ToUpper(),
                                                              model.FromDate.ToString("ddMMMyy"), model.FromTime.Value.ToString("hh:mmtt"),
                                                              model.ToDate.ToString("ddMMMyy"), model.ToTime.Value.ToString("hh:mmtt"));
                    txtLeaveDescription.Text += string.Format("\n{0}", model.Remarks);
                    if (model.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_APPROVED_ID)
                    {
                        rbtnApproveLeave.Checked = true;
                    }
                    if (model.FK_UserList_ApprovalStatusID == service.LEAVE_STATUS_REJECTED_ID)
                    {
                        rbtnRejectLeave.Checked = true;
                    }

                    txtApprovalRemarks.Text = model.RemarksApproval;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmApproveRejectLeave::frmApproveRejectLeave_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            TBL_MP_HR_LeaveApplication model = null;

            ServiceLeaveApplication serviceLeaveApp = new ServiceLeaveApplication();

            try
            {
                if (!this.ValidateChildren())
                {
                    return;
                }
                if (this.LeaveApplicationID == 0)
                {
                    model = new TBL_MP_HR_LeaveApplication();
                }
                else
                {
                    model = serviceLeaveApp.GetLeaveApplicationInfoDbRecord(this.LeaveApplicationID);
                }

                #region GATHER DATA INTO MODEL FROM VIEW

                model.ApplicationNo               = txtLeaveApplicationNo.Text.Trim();
                model.ApplicationDate             = dtLeaveApplicationDate.Value;
                model.FK_EmployeeID               = ((SelectListItem)cboEmployees.SelectedItem).ID;
                model.FK_RequestTo                = ((SelectListItem)cboRequestTo.SelectedItem).ID;
                model.FK_UserList_LeaveFormTypeID = ((SelectListItem)cboLeaveFormType.SelectedItem).ID;
                model.PreparedBy = Program.CURR_USER.EmployeeID;
                if (cboLeaveType.SelectedItem != null)
                {
                    model.fK_UsrLst_LeaveTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID;
                }
                else
                {
                    model.fK_UsrLst_LeaveTypeID = 0;
                }

                model.FromDate       = new DateTime(dtFromDate.Value.Year, dtFromDate.Value.Month, dtFromDate.Value.Day);
                model.ToDate         = new DateTime(dtToDate.Value.Year, dtToDate.Value.Month, dtToDate.Value.Day);
                model.FromTime       = dtFromTime.Value;
                model.ToTime         = dtToTime.Value;
                model.Duration       = txtNoOfDays.Text.Trim();
                model.Remarks        = txtRemarks.Text.Trim();
                model.CreateDateTime = AppCommon.GetServerDateTime();

                #endregion
                if (this.LeaveApplicationID == 0)
                {
                    model.FK_YearID    = Program.CURR_USER.FinYearID;
                    model.FK_BranchID  = Program.CURR_USER.BranchID;
                    model.FK_CompanyID = Program.CURR_USER.CompanyID;

                    this.LeaveApplicationID = serviceLeaveApp.AddNewLeaveApplicationInfo(model);
                }
                else
                {
                    serviceLeaveApp.UpdateLeaveApplicationInfo(model);
                }

                // UPDATE ATTENDANCE AS PER LEAVE
                serviceLeaveApp.UpdateAttendanceForLeaveApplication(this.LeaveApplicationID);

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditLeaveApplication::btnOk_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }