public vLoanRequestApplication GetLoanRequestViewDbRecord(int LoanReqID) { vLoanRequestApplication model = null; try { model = _dbContext.vLoanRequestApplications.Where(x => x.PK_LoanRequestID == LoanReqID).FirstOrDefault(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "ServiceLoanRequest::GetLoanRequestViewDbRecord", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
private void frmApproveRejectLoanRequest_Load(object sender, EventArgs e) { // try getting edmx again for view try { ServiceLoanRequest service = new ServiceLoanRequest(); vLoanRequestApplication model = service.GetLoanRequestViewDbRecord(this.LoanRequestID); if (model != null) { txtLoanRequestNo.Text = string.Format("{0} dt. {1}", model.LoanRequestNo, model.LoanRequestDate.Value.ToString("dd MMM yy")); dtApprovalDate.Value = (DateTime)model.LoanRequestDate; txtLoanRequestDescription.Text = model.EmployeeName; txtLoanRequestDescription.Text += string.Format("\nAmount: {0:0.00}\nRemarks: {1}", model.RequestedLoanAmount, model.Remarks); if (model.ApprovalStatus == service.REQUEST_STATUS_APPROVED_ID) { rbtnApproveLoanRequest.Checked = true; } if (model.ApprovalStatus == service.REQUEST_STATUS_REJECTED_ID) { rbtnRejectLoanRequest.Checked = true; } txtApprovedAmount.Text = model.ApprovedAmount.ToString(); txtApprovalRemarks.Text = model.RemarksApproved; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmApproveRejectLoanRequest::frmApproveRejectLoanRequest_Load", MessageBoxButtons.OK, MessageBoxIcon.Error); } }