Esempio n. 1
0
 private void cboLeaveType_Validating(object sender, CancelEventArgs e)
 {
     try
     {
         ServiceLeaveApplication _service  = new ServiceLeaveApplication();
         SelectListItem          leaveForm = (SelectListItem)cboLeaveFormType.SelectedItem;
         if (leaveForm.ID == _service.LEAVE_TYPE_LEAVE_ID || leaveForm.ID == _service.LEAVE_TYPE_OUTDOOR_ID)
         {
             if (((SelectListItem)cboLeaveType.SelectedItem).ID == 0)
             {
                 errorProvider1.SetError(cboLeaveType, "Select Leave Type");
                 e.Cancel = true;
             }
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditLeaveApplication::cboLeaveType_Validating", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 3
0
 private void PopulateleaveTypeDropDown()
 {
     try
     {
         ServiceLeaveApplication service = new ServiceLeaveApplication();
         List <SelectListItem>   LST     = new List <SelectListItem>();
         LST.Add(new SelectListItem()
         {
             ID = 0, Description = "(Select)"
         });
         LST.AddRange(service.GetAllLeaveTypesForLeaveForm(service.LEAVE_TYPE_LEAVE_ID));
         cboLeaveType.DataSource    = LST;
         cboLeaveType.DisplayMember = "Description";
         cboLeaveType.ValueMember   = "Id";
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditEmployeeLeaveConfig::PopulateleaveTypeDropDown", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 4
0
        private void btnDetails_Click(object sender, EventArgs e)
        {
            try
            {
                ServiceLeaveApplication service = new ServiceLeaveApplication();
                //before invoking form pass employee and lave form type id
                frmAddEditLeaveApplication frm = new frmAddEditLeaveApplication();
                frm.EmployeeID = this.selectedOnSiteEmployeeID;
                switch (this.selectedAttendanceTYPE)
                {
                case ATTENDANCE_TYPE.LEAVE:
                    frm.SelectedLeavFormTypeID = service.LEAVE_TYPE_LEAVE_ID;
                    break;

                case ATTENDANCE_TYPE.OUT_DOOR:
                    frm.SelectedLeavFormTypeID = service.LEAVE_TYPE_OUTDOOR_ID;
                    break;
                }
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    OnSiteAttendanceModel model = new OnSiteAttendanceModel();
                    listOnSiteATTENDANCE.Add(model);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "PageDailyAttendance::btnDetails_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void PageLeavesRegister_Load(object sender, EventArgs e)
        {
            try
            {
                // STAR SERVICE WITH EVEN HANDLER
                _ServiceLeaves = new ServiceLeaveApplication();
                _ServiceLeaves.EmployeeRecordCompleted += _ServiceLeaves_EmployeeRecordCompleted;

                btnApproveReject.Visible = false;
                WhosWhoModel model = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == DB_FORM_IDs.LEAVE_APPLICATIONS).FirstOrDefault();
                if (model.CanApprove)
                {
                    btnApproveReject.Visible = true;
                }

                PopulateLavesGrid();
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "PageLeavesRegister::PageLeavesRegister_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
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;
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        private void cboLeaveType_SelectedValueChanged(object sender, EventArgs e)
        {
            ServiceLeaveApplication service = new ServiceLeaveApplication();

            try
            {
                DateTime inTime  = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0);
                DateTime outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0);
                lblLeaveBalanceInfo.Text = string.Empty;

                if (cboLeaveType.SelectedItem != null)
                {
                    this.SelectedLeaveTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID;
                    EmployeeID      = ((SelectListItem)cboEmployees.SelectedItem).ID;
                    btnSave.Enabled = true;
                    if (SelectedLeavFormTypeID == service.LEAVE_TYPE_LEAVE_ID)
                    {
                        LeaveBalanceModel model = service.GetLeaveBalanceModelOfEmployeeForYear(EmployeeID, Program.CURR_USER.FinYearID, SelectedLeaveTypeID);
                        if (model != null)
                        {
                            lblLeaveBalanceInfo.Text = string.Format("Allowed [{0}] Earned [{1}] Taken [{2}] Balance [{3}]", model.Allowed, model.Earned, model.Taken, model.Balance);
                            if (model.Balance <= 0)
                            {
                                btnSave.Enabled = false;
                            }
                        }


                        //  if (SelectedLeaveTypeID == service.LEAVE_TYPE_HALFDAY_ID)
                        //   {
                        //     double cntDays = 0.5;
                        //   txtNoOfDays.Text = cntDays.ToString();
                        // }
                    }
                    if (SelectedLeavFormTypeID == service.LEAVE_TYPE_OUTDOOR_ID)
                    {
                        inTime  = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0);
                        outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0);
                        int outDoorTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID;
                        if (outDoorTypeID == service.OUTDOOR_FULLSHIFT_ID)
                        {
                            inTime  = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0);
                            outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0);
                        }
                        if (outDoorTypeID == service.OUTDOOR_FIRST_HALF_ID)
                        {
                            inTime  = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0);
                            outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 13, 00, 0);
                        }
                        if (outDoorTypeID == service.OUTDOOR_SECOND_HALF_ID)
                        {
                            inTime  = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 13, 45, 0);
                            outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0);
                        }
                    }
                    dtFromTime.Value = inTime;
                    dtToTime.Value   = outTime;
                    txtNoOfDays.Text = AppCommon.GetTimeDuration(dtFromTime.Value, dtToTime.Value).Text;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditLeaveApplication::cboLeaveType_SelectedValueChanged", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 11
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);
            }
        }