private void btnGenerateLeaveConfigurationForEmployees_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { txtProgress.Text = string.Empty; tbl_Acct_Financial_Year currYear = (new ServiceMASTERS()).GetFinancialYearDbRecordByID(this.SelectedFinYearID); ServiceLeaveConfiguration configuration = new ServiceLeaveConfiguration(); configuration.OnEmployeeLeaveConfigurationCompleted += Configuration_OnEmployeeLeaveConfigurationCompleted; configuration.GenerateEmployeeLeaveConfigurationsForFinYear(currYear.FK_CompanyID, currYear.FK_BranchID, currYear.PK_ID); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageFinYear::btnGenerateLeaveConfigurationForEmployees_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
private void btnSave_Click(object sender, EventArgs e) { TBL_MP_HR_LeaveConfiguration model = null; ServiceLeaveConfiguration serviceLeave = new ServiceLeaveConfiguration(); try { string strSalaryHeadIDs = string.Empty; string strSalaryHeadNames = string.Empty; if (!this.ValidateChildren()) { return; } if (this.LeaveID == 0) { model = new TBL_MP_HR_LeaveConfiguration(); } else { model = serviceLeave.GetLeaveInfoDbRecord(this.LeaveID); } #region GATHER DATA INTO MODEL FROM VIEW model.FK_LeaveTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID; model.MaxDaysAllow = decimal.Parse(txtMaxDaysallow.Text.Trim()); model.CarryForwardLeave = chkLeaveCarryForward.Checked; model.CarryForwardLimitDays = decimal.Parse(txtLimitDays.Text.Trim()); model.ApplicableInProbation = chkApplicableProbationPeriod.Checked; model.LeaveEnchashable = chkLeaveEncashable.Checked; model.IsActive = chkIsActive.Checked; model.FK_BranchID = ((SelectListItem)cboBranch.SelectedItem).ID; model.FK_FinYearID = ((SelectListItem)cboYear.SelectedItem).ID; #endregion #region PREPARE SALARY HEADS STRING if (chkLeaveEncashable.Checked) { foreach (DataGridViewRow mRow in gridAllounces.Rows) { if ((bool)mRow.Cells["IsActive"].Value == true) { strSalaryHeadIDs += mRow.Cells["ID"].Value.ToString() + ", "; strSalaryHeadNames += mRow.Cells["Description"].Value.ToString() + ", "; } } } #endregion if (strSalaryHeadIDs.Trim() != string.Empty) { model.EncashableSalaryHeadIDs = strSalaryHeadIDs.Trim().TrimEnd(','); } else { model.EncashableSalaryHeadIDs = null; } if (strSalaryHeadNames.Trim() != string.Empty) { model.EncashableSalaryHeadNames = strSalaryHeadNames.Trim().TrimEnd(','); } else { model.EncashableSalaryHeadNames = null; } if (this.LeaveID == 0) { this.LeaveID = serviceLeave.AddNewLeaveConfiguration(model); } else { serviceLeave.UpdateLeaveConfiguration(model); } 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, "frmAddEditLeaveConfiguration::btnOk_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }