public void ScatterData() { ServiceLoanDisbursement _service = new ServiceLoanDisbursement(); try { TBL_MP_HR_LoanDisbursement model = _service.GetLoanDisbursementInfoDbRecord(this.SelectedLoanDisbursementID); if (model != null) { dtLoanDisbursementDate.Value = model.DisbursementDate; cboLoanRequests.SelectedItem = ((List <SelectListItem>)cboLoanRequests.DataSource).Where(x => x.ID == model.FK_LoanRequestID).FirstOrDefault(); txtLoanAmount.Text = string.Format("{0:0.00}", model.LoanAmount); txtInterestRate.Text = string.Format("{0:0.00}", model.InterestRate); txttotalEMI.Text = model.NoOfInstallment.ToString(); TxtEMIAmount.Text = string.Format("{0:0.00}", model.InstallmentAmount); dtDeductionFromDate.Value = model.InstallmentStartDate; cboPreparedBy.SelectedItem = ((List <SelectListItem>)cboPreparedBy.DataSource).Where(x => x.ID == model.FK_PreparedBy).FirstOrDefault(); cboRequestTo.SelectedItem = ((List <SelectListItem>)cboRequestTo.DataSource).Where(x => x.ID == model.FK_ApprovedBy).FirstOrDefault(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditLoanDisbursement::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gridLoanDisbursement_RowEnter(object sender, DataGridViewCellEventArgs e) { try { this.SelectedLoanDisbursementID = (int)gridLoanDisbursement.Rows[e.RowIndex].Cells["DisbursementID"].Value; ServiceLoanDisbursement service = new ServiceLoanDisbursement(); TBL_MP_HR_LoanDisbursement model = service.GetLoanDisbursementInfoDbRecord(this.SelectedLoanDisbursementID); if (model.ApprovalStatus == service.LOAN_DISBURSEMENT_STATUS_PENDING_ID) { btnApproveDisbursement.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True; } else { btnApproveDisbursement.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, "PageLoanDisbursement::gridLoanDisbursement_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnApproveDisbursement_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { string strMessage = "Are You sure to Approve Selected Loan"; if (MessageBox.Show(strMessage, "Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ServiceLoanDisbursement service = new ServiceLoanDisbursement(); TBL_MP_HR_LoanDisbursement model = service.GetLoanDisbursementInfoDbRecord(this.SelectedLoanDisbursementID); model.ApprovalStatus = service.LOAN_DISBURSEMENT_APPROVED_ID; model.FK_ApprovedBy = Program.CURR_USER.EmployeeID; service.UpdateLoanDisbursement(model); PopulateLoanDisbursmentGrid(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "PageLoanDisbursement::btnApproveDisbursement_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
public bool DeleteLoanDisbursement(int loanDisburseID) { bool result = false; try { TBL_MP_HR_LoanDisbursement model = _dbContext.TBL_MP_HR_LoanDisbursement.Where(x => x.PK_LoanDisbursementID == loanDisburseID).FirstOrDefault(); if (model != null) { model.IsDeleted = true; //model.DeletedBy = deletedBy; // model.DeleteDatetime = AppCommon.GetServerDateTime(); _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, "ServiceLoanDisbursement::DeleteLoanDisbursement", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public TBL_MP_HR_LoanDisbursement GetLoanDisbursementInfoDbRecord(int LoanDisbursementID) { TBL_MP_HR_LoanDisbursement model = null; try { model = _dbContext.TBL_MP_HR_LoanDisbursement.Where(x => x.PK_LoanDisbursementID == LoanDisbursementID).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanDisbursement ::GetLoanDisbursementInfoDbRecord", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
public bool UpdateLoanDisbursement(TBL_MP_HR_LoanDisbursement model) { bool result = false; try { TBL_MP_HR_LoanDisbursement dbModel = _dbContext.TBL_MP_HR_LoanDisbursement.Where(x => x.PK_LoanDisbursementID == model.PK_LoanDisbursementID).FirstOrDefault(); if (dbModel != null) { dbModel.FK_EmployeeID = model.FK_EmployeeID; dbModel.DisbursementDate = model.DisbursementDate; dbModel.LoanAmount = model.LoanAmount; dbModel.InterestRate = model.InterestRate; dbModel.NoOfInstallment = model.NoOfInstallment; dbModel.InstallmentAmount = model.InstallmentAmount; dbModel.InstallmentStartDate = model.InstallmentStartDate; dbModel.FK_PreparedBy = model.FK_PreparedBy; dbModel.FK_ApprovedBy = model.FK_ApprovedBy; dbModel.FK_LoanRequestID = model.FK_LoanRequestID; dbModel.Remarks = model.Remarks; _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, "ServiceLoanDisbursement::UpdateLoanDisbursement", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private void btnDeleteLoan_Click(object sender, EventArgs e) { try { ServiceLoanDisbursement service = new ServiceLoanDisbursement(); TBL_MP_HR_LoanDisbursement dbModel = service.GetLoanDisbursementInfoDbRecord(SelectedLoanDisbursementID); { string msg = "Are you sure to Delete selected Loan disbursement Permanently"; DialogResult res = MessageBox.Show(msg, "Caution", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { if (dbModel.ApprovalStatus == service.LOAN_DISBURSEMENT_STATUS_PENDING_ID) { (new ServiceLoanDisbursement()).DeleteLoanDisbursement(this.SelectedLoanDisbursementID); PopulateLoanDisbursmentGrid(); } else { msg = "Unable to delete selected Loan disbursement 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, "PageLoanDisbursement::btnDeleteLoan_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int AddNewLoanDisbursement(TBL_MP_HR_LoanDisbursement model) { int newID = 0; try { model.IsClosed = false; model.IsDeleted = false; model.ApprovalStatus = LOAN_DISBURSEMENT_STATUS_PENDING_ID; _dbContext.TBL_MP_HR_LoanDisbursement.Add(model); _dbContext.SaveChanges(); newID = model.PK_LoanDisbursementID; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanDisbursement::AddNewLoanDisbursement", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newID); }
private void btnSave_Click(object sender, EventArgs e) { errorProvider1.Clear(); TBL_MP_HR_LoanDisbursement model = null; ServiceLoanDisbursement service = new ServiceLoanDisbursement(); try { if (!this.ValidateChildren()) { return; } if (this.SelectedLoanDisbursementID == 0) { model = new TBL_MP_HR_LoanDisbursement(); } else { model = service.GetLoanDisbursementInfoDbRecord(this.SelectedLoanDisbursementID); } #region GATHER DATA INTO MODEL FROM VIEW model.DisbursementDate = dtLoanDisbursementDate.Value; model.FK_LoanRequestID = ((SelectListItem)cboLoanRequests.SelectedItem).ID; model.FK_EmployeeID = this.EmployeeID; model.LoanAmount = decimal.Parse(txtLoanAmount.Text.Trim()); model.InterestRate = decimal.Parse(txtInterestRate.Text.Trim()); model.NoOfInstallment = int.Parse(txttotalEMI.Text.Trim()); model.InstallmentAmount = decimal.Parse(TxtEMIAmount.Text.Trim()); model.InstallmentStartDate = dtDeductionFromDate.Value; model.FK_PreparedBy = ((SelectListItem)cboPreparedBy.SelectedItem).ID; model.FK_ApprovedBy = ((SelectListItem)cboRequestTo.SelectedItem).ID; model.Remarks = txtRemarks.Text.Trim(); #endregion if (this.SelectedLoanDisbursementID == 0) { model.FK_YearID = Program.CURR_USER.FinYearID; model.FK_BranchID = Program.CURR_USER.BranchID; model.FK_CompanyID = Program.CURR_USER.CompanyID; this.SelectedLoanDisbursementID = service.AddNewLoanDisbursement(model); } else { service.UpdateLoanDisbursement(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, "frmAddEditLoanDisbursement::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }