private void btnUpdate_Click(object sender, RoutedEventArgs e) { try { if (status == "UReleasing") { if (iDept == "Financing") { wpfFReleasing frm = new wpfFReleasing(); frm.status = "UReleasing"; frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } else { wpfMReleasing frm = new wpfMReleasing(); frm.status = "UReleasing"; frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } } else if (status == "Holding") { using (var ctx = new finalContext()) { //var dts = ctx.FPaymentInfo.Where(x => x.LoanID == lId && x.PaymentStatus == "Pending").First(); if (DateTime.Today.Date > Convert.ToDateTime(lblEDt.Content) || DateTime.Today.Date < Convert.ToDateTime(lblSDt.Content)) { System.Windows.MessageBox.Show("Unable to hold next cheque", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } /*MessageBoxResult mr = System.Windows.MessageBox.Show("You sure?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (mr == MessageBoxResult.Yes) { var dts = ctx.FPaymentInfo.Where(x => x.LoanID == lId && (x.PaymentStatus == "Pending" || x.PaymentStatus == "On Hold")).First(); double hFee = dts.Amount * (dts.Loan.Service.Holding / 100); hFee = Convert.ToDouble(hFee.ToString("N2")); HeldCheque hc = new HeldCheque { DateHeld = DateTime.Today.Date, LoanID = lId, NewPaymentDate = dts.PaymentDate.AddDays(7), OriginalPaymentDate = dts.PaymentDate, PaymentNumber = dts.PaymentNumber, HoldingFee = hFee }; dts.PaymentDate = dts.PaymentDate.AddDays(7); dts.PaymentStatus = "On Hold"; ctx.HeldCheques.Add(hc); ctx.SaveChanges(); reset(); System.Windows.MessageBox.Show("Okay"); }*/ wpfCheckout frm = new wpfCheckout(); frm.lId = lId; frm.UserID = UserID; frm.status = "Holding"; frm.ShowDialog(); } } else if (status == "Adjustment") { wpfPaymentAdjustment frm = new wpfPaymentAdjustment(); frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } else if (status == "Restructure") { wpfLoanRestructure frm = new wpfLoanRestructure(); frm.lId = lId; frm.UserID = UserID; this.Close(); frm.ShowDialog(); } } catch (Exception ex) { System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
private void btnApprove_Click(object sender, RoutedEventArgs e) { try { if (status == "Approval" || status == "UApproval" || status=="Renewal Approval") { using (var ctx = new finalContext()) { var lon = ctx.Loans.Find(lId); if (status != "Renewal Approval") { var ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && (x.Status == "Applied" || x.Status == "Released" || x.Status == "Approved") && x.LoanID != lon.LoanID).Count(); if (ctr > 0) { System.Windows.MessageBox.Show("Client cannot have more than one(1) Loan application/Loan", "Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && (x.Status == "Closed Account" || x.Status == "Under Collection")).Count(); if (ctr > 0) { System.Windows.MessageBox.Show("Client has bad record due to Closed Account/Unpaid Balance. Unable to process loan.", "Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } ctr = ctx.Loans.Where(x => x.ClientID == lon.ClientID && x.Status == "Released" && x.Service.Department != lon.Service.Department).Count(); if (ctr > 0) { System.Windows.MessageBox.Show("Client has an existing loan on other department", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } } wpfLoanApproval frm = new wpfLoanApproval(); frm.status = status; frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } else if (status == "Releasing" || status == "Renewal") { String iDept = ""; using (var ctx = new finalContext()) { var ln = ctx.Loans.Find(lId); iDept = ln.Service.Department; } if (iDept == "Financing") { wpfFReleasing frm = new wpfFReleasing(); frm.status = status; frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } else { wpfMReleasing frm = new wpfMReleasing(); frm.status = status; frm.UserID = UserID; frm.lId = lId; this.Close(); frm.ShowDialog(); } } } catch (Exception ex) { System.Windows.MessageBox.Show("Runtime Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } }