private void cboLoanRequests_SelectedValueChanged(object sender, EventArgs e) { try { if (cboLoanRequests.SelectedItem != null) { SelectListItem selLoan = (SelectListItem)cboLoanRequests.SelectedItem; if (selLoan.ID > 0) { TBL_MP_HR_LoanRequestApplication loan = (new ServiceLoanRequest()).GetLoanRequestInfoDbRecord(selLoan.ID); if (loan != null) { this.EmployeeID = loan.FK_EmployeeID; txtEmployeeInfo.Text = (new ServiceEmployee()).GetEmployeeCompleteDescription(this.EmployeeID); txtLoanAmount.Text = string.Format("{0:0.00}", loan.RequestedLoanAmount); } } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditLoanDisbursement::cboLoanRequests_SelectedValueChanged", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ScatterData() { ServiceLoanRequest _service = new ServiceLoanRequest(); try { TBL_MP_HR_LoanRequestApplication model = _service.GetLoanRequestInfoDbRecord(this.LoanRequestID); if (model != null) { txtLoanRequestNo.Text = model.LoanRequestNo; dtLoanRequestDate.Value = model.LoanRequestDate; 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.RequestTo).FirstOrDefault(); txtRemarks.Text = model.Remarks; txtRequestedLoanAmount.Text = model.RequestedLoanAmount.ToString(); if (model.ProposedDisbursementDate != null) { dtDisbursementDate.Value = (DateTime)model.ProposedDisbursementDate; } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditLoanRequest::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int AddNewLoanRequest(TBL_MP_HR_LoanRequestApplication model) { int newID = 0; try { model.LoanRequestNo = this.GenerateNewLoanRequestNumber(model.FK_YearID, model.FK_BranchID, model.FK_CompanyID); model.ApprovalStatus = REQUEST_STATUS_PENDING_ID; model.IsDeleted = false; model.ApprovalDate = null; model.FK_ApprovedBy = null; model.RemarksApproved = string.Empty; _dbContext.TBL_MP_HR_LoanRequestApplication.Add(model); _dbContext.SaveChanges(); newID = model.pk_LoanRequestID; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::AddNewLoanRequest", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newID); }
private void btnSave_Click(object sender, EventArgs e) { errorProvider1.Clear(); TBL_MP_HR_LoanRequestApplication model = null; ServiceLoanRequest service = new ServiceLoanRequest(); try { if (!this.ValidateChildren()) { return; } if (this.LoanRequestID == 0) { model = new TBL_MP_HR_LoanRequestApplication(); } else { model = service.GetLoanRequestInfoDbRecord(this.LoanRequestID); } #region GATHER DATA INTO MODEL FROM VIEW model.LoanRequestNo = txtLoanRequestNo.Text.Trim(); model.LoanRequestDate = dtLoanRequestDate.Value; model.ProposedDisbursementDate = dtDisbursementDate.Value; model.FK_EmployeeID = ((SelectListItem)cboEmployees.SelectedItem).ID; model.RequestTo = ((SelectListItem)cboRequestTo.SelectedItem).ID; model.RequestedLoanAmount = decimal.Parse(txtRequestedLoanAmount.Text.Trim()); model.Remarks = txtRemarks.Text.Trim(); #endregion if (this.LoanRequestID == 0) { model.FK_YearID = Program.CURR_USER.FinYearID; model.FK_BranchID = Program.CURR_USER.BranchID; model.FK_CompanyID = Program.CURR_USER.CompanyID; this.LoanRequestID = service.AddNewLoanRequest(model); } else { service.UpdateLoanRequest(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, "frmAddEditLoanRequest::btnOk_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool UpdateLoanRequest(TBL_MP_HR_LoanRequestApplication model) { bool result = false; try { TBL_MP_HR_LoanRequestApplication dbModel = _dbContext.TBL_MP_HR_LoanRequestApplication.Where(x => x.pk_LoanRequestID == model.pk_LoanRequestID).FirstOrDefault(); if (dbModel != null) { dbModel.FK_EmployeeID = model.FK_EmployeeID; dbModel.RequestTo = model.RequestTo; dbModel.LoanRequestDate = model.LoanRequestDate; dbModel.ProposedDisbursementDate = model.ProposedDisbursementDate; dbModel.RequestedLoanAmount = model.RequestedLoanAmount; dbModel.Remarks = model.Remarks; dbModel.ApprovalDate = model.ApprovalDate; dbModel.ApprovalStatus = model.ApprovalStatus; dbModel.ApprovedAmount = model.ApprovedAmount; dbModel.FK_ApprovedBy = model.FK_ApprovedBy; dbModel.FK_BranchID = model.FK_BranchID; dbModel.FK_CompanyID = model.FK_CompanyID; dbModel.FK_YearID = model.FK_YearID; dbModel.IsDeleted = model.IsDeleted; dbModel.RemarksApproved = model.RemarksApproved; dbModel.RequestTo = model.RequestTo; _dbContext.SaveChanges(); result = true; } else { MessageBox.Show("Unable to Locate this Record in Database", "ERROR"); return(false); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::UpdateLoanRequest", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public TBL_MP_HR_LoanRequestApplication GetLoanRequestInfoDbRecord(int LoanRequestID) { TBL_MP_HR_LoanRequestApplication model = null; try { model = _dbContext.TBL_MP_HR_LoanRequestApplication.Where(x => x.pk_LoanRequestID == LoanRequestID).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest" + "::GetLoanRequestInfoDbRecord", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
private void btnSave_Click(object sender, EventArgs e) { try { errorProvider1.Clear(); if (!this.ValidateChildren()) { return; } ServiceLoanRequest service = new ServiceLoanRequest(); TBL_MP_HR_LoanRequestApplication model = service.GetLoanRequestInfoDbRecord(this.LoanRequestID); if (model != null) { model.RemarksApproved = txtApprovalRemarks.Text.Trim(); model.FK_ApprovedBy = Program.CURR_USER.EmployeeID; if (rbtnApproveLoanRequest.Checked) { model.ApprovalStatus = service.REQUEST_STATUS_APPROVED_ID; } if (rbtnRejectLoanRequest.Checked) { model.ApprovalStatus = service.REQUEST_STATUS_REJECTED_ID; } model.ApprovalDate = dtApprovalDate.Value; model.ApprovedAmount = decimal.Parse(txtApprovedAmount.Text.Trim()); // put validation on this service.UpdateLoanRequest(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, "frmApproveRejectLoanRequest::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool DeleteLoanRequest(int LoanID) { bool result = false; try { TBL_MP_HR_LoanRequestApplication model = _dbContext.TBL_MP_HR_LoanRequestApplication.Where(x => x.pk_LoanRequestID == LoanID).FirstOrDefault(); model.IsDeleted = true; _dbContext.SaveChanges(); result = true; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::DeleteLoanRequest", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void btnDeleteLoanRequest_Click(object sender, EventArgs e) { try { ServiceLoanRequest service = new ServiceLoanRequest(); TBL_MP_HR_LoanRequestApplication dbModel = service.GetLoanRequestInfoDbRecord(SelectedLoanRequestID); { string msg = "Are you sure to Delete selected Loan request Permanently"; DialogResult res = MessageBox.Show(msg, "Caution", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { if (dbModel.ApprovalStatus == service.REQUEST_STATUS_PENDING_ID) { (new ServiceLoanRequest()).DeleteLoanRequest(this.SelectedLoanRequestID); PopulateLoanRequestGrid(); } else { msg = "Unable to delete selected Loan request.."; 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, "PageMyAdvanceRequests::btnDeleteAdvanceRequests_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int GetLoanRequestApplicationStatus(int applicationID) { int statusID = 0; try { TBL_MP_HR_LoanRequestApplication model = _dbContext.TBL_MP_HR_LoanRequestApplication.Where(x => x.pk_LoanRequestID == applicationID).FirstOrDefault(); if (model != null) { statusID = (int)model.ApprovalStatus; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::GetLoanRequestApplicationStatus", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(statusID); }
private void gridLoanRegister_RowEnter(object sender, DataGridViewCellEventArgs e) { try { ServiceLoanRequest service = new ServiceLoanRequest(); this.LoanRequestID = (int)(gridLoanRequestRegister.Rows[e.RowIndex].Cells["PK_LoanRequestID"].Value); TBL_MP_HR_LoanRequestApplication model = service.GetLoanRequestInfoDbRecord(this.LoanRequestID); //if (AppCommon.GetServerDateTime() < model.RequestDate) // btnApproveReject.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True; //else // btnApproveReject.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageLoanRequestRegister::gridLoanRegister_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string GenerateNewLoanRequestNumber(int currFinYear, int currBrachID, int companyID) { string keyCode = string.Empty; int intPreviousYearCount = 0; int cnt; string strNumber; string strQuery = string.Empty; try { // 0123 TBL_MP_Admin_VoucherNoSetup objAdvanceSetup = (from xx in _dbContext.TBL_MP_Admin_VoucherNoSetup where xx.fk_FormID == (int)DB_FORM_IDs.LOAN_REQUEST && xx.Fk_YearID == currFinYear && xx.Fk_BranchID == currBrachID select xx).FirstOrDefault(); if (objAdvanceSetup == null) { string strMessage = "Unable to locate Voucher No. setup for the selected Financial Year or Branch"; MessageBox.Show(strMessage, "Caution", MessageBoxButtons.OK, MessageBoxIcon.Error); return(string.Empty); } strQuery = string.Format("SELECT count(*) FROM TBL_MP_HR_LoanRequestApplication WHERE FK_YearID={0} AND FK_BranchID={1} AND FK_CompanyID={2}", currFinYear, currBrachID, companyID); cnt = _dbContext.Database.SqlQuery <int>(strQuery).FirstOrDefault(); // IF NO. CONTINUED FROM PREVIOUS YEAR GENERATE NEXT NUMBER BY REFEREING PREVIOUS YEAR MAX. NUMBER if (objAdvanceSetup.Is_NoContinuedNextYear) { TBL_MP_Admin_VoucherNoSetup objVoucherSetupPrevYear = (from xx in _dbContext.TBL_MP_Admin_VoucherNoSetup where xx.fk_FormID == (int)DB_FORM_IDs.LOAN_REQUEST && xx.Fk_YearID == currFinYear - 1 && xx.Fk_BranchID == currBrachID select xx).FirstOrDefault(); TBL_MP_HR_LoanRequestApplication lastLeavePrevYear = (from xx in _dbContext.TBL_MP_HR_LoanRequestApplication where xx.FK_YearID == currFinYear - 1 && xx.FK_BranchID == currBrachID && xx.FK_CompanyID == companyID orderby xx.LoanRequestDate descending select xx).FirstOrDefault(); if (lastLeavePrevYear != null) { string lstnumber = lastLeavePrevYear.LoanRequestNo.Replace(objVoucherSetupPrevYear.NoPrefix, "").Replace(objVoucherSetupPrevYear.NoPostfix, "").Replace(objVoucherSetupPrevYear.NoSeperator, ""); intPreviousYearCount = int.Parse(lstnumber); } else { intPreviousYearCount = 1; } cnt += intPreviousYearCount; } else { cnt += (int)objAdvanceSetup.NoStartingFrom; } strNumber = cnt.ToString().PadLeft(objAdvanceSetup.NoPad, '0'); //0083 keyCode += objAdvanceSetup.NoPrefix + objAdvanceSetup.NoSeperator + strNumber + objAdvanceSetup.NoSeperator + objAdvanceSetup.NoPostfix; // XL/SO/0083/2018-19 } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::GenerateNewLoanRequestNumber", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(keyCode); }