private void btnReserve_Click(object sender, EventArgs e) { try { LoanBL loanBL = new LoanBL(s, r); loanBL.Validation(); if (loanBL.Errors.Count == 0) { ResourceBL resourceBL = new ResourceBL(); if (resourceBL.changeReservation(r.ResourceId, s.StudentId, Convert.ToInt32(chkIsReserved.Checked))) { MessageBox.Show("Reserve changed!"); } GetResourceAndPopulate(r.ResourceId); } else { string msg = ""; foreach (ValidationError error in loanBL.Errors) { msg += error.Description + Environment.NewLine; } MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult LoanEntry(Loan objLoan) { LoanBL objLoanBL = new LoanBL(); try { if (ModelState.IsValid) { int IsRowAffected = objLoanBL.CreateLoan(objLoan); if (IsRowAffected > 0) { ViewBag.Message = "Save Succesfully"; } else { ViewBag.Message = "Save Failed"; } } } catch (Exception ex) { ViewBag.error = ("Error : " + ex.Message); } var model = new Loan { BankNameList = objLoanBL.GetBankNameforLoan() }; return(View(model)); }
private void button1_Click(object sender, EventArgs e) { LoanBL loanBL = new LoanBL(s, r); loanBL.Validation(); if (loanBL.Errors.Count == 0) { loans.Add(new LoanLookUp() { StudendId = txtStudentId.Text, ResourceId = Convert.ToInt32(txtResourceIdEntry.Text), CheckOutDate = DateTime.Now, }); dgvList.DataSource = null; dgvList.DataSource = loans; DatagridViewSetting(); } else { string msg = ""; foreach (ValidationError error in loanBL.Errors) { msg += error.Description + Environment.NewLine; } MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public JsonResult GetBankNameByTruncationNumber(string TruncationNumber) { LoanBL objLoanBL = new LoanBL(); var data = objLoanBL.GetBankNameByTruncationNumber(TruncationNumber); return(Json(data, JsonRequestBehavior.AllowGet)); }
private void btnConfirmReturn_Click(object sender, EventArgs e) { try { ResourceBL rebl = new ResourceBL(); LoanBL loBL = new LoanBL(); int count = 0; foreach (Resource r in resourcestoreturn) { if (rebl.UpdateResource2(r) && loBL.UpdateLoan(loanstoupdate[count].LoanId, loanstoupdate[count].LoanStatusId)) { count++; if (resourcestoreturn.IndexOf(r) == resourcestoreturn.Count - 1) { MessageBox.Show("Resources were returned."); } } else { MessageBox.Show("There was a problem"); } } ClearData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static List <UserDTO> GetUsersList() { var sumPayThisMonth = 0; List <UserDTO> userList = new List <UserDTO> (); List <AlertsUsers> alertsUsers = new List <AlertsUsers> (); using (SuperGmachEntities db = new SuperGmachEntities()) { foreach (User u in db.Users) { UserDTO user = Userconvert.DALtoDTO(u); //cheac if the user Proper else add alret if (user.Management_status.Id != "Proper") { AlertsUsers alert = new AlertsUsers() { UserId = user.Id_user, Alret = " סטטוס ניהול לחבר " + user.Last_name + " " + user.First_name + " " + user.Management_status.Name + " סיבת הסטטוס " + user.Status_reason }; alertsUsers.Add(alert); } /// cheack if the user have active loan Loan loan = db.Loans.FirstOrDefault(l => l.UserId == u.UserId && l.NameManagement_status != "performed"); if (loan != null) { var thisMonth = DateTime.Now.Month; List <Repayments> repayments = db.Repayments.Where(r => r.LoanId == loan.LoanId && r.NameStatus != "performed").ToList(); List <Repayments> pastRepayments = repayments.Where(r => r.Date.Month < thisMonth && r.Date.Month != thisMonth).ToList(); foreach (var repayment in pastRepayments) { sumPayThisMonth += repayment.Amount; } if (pastRepayments.ToArray().Length > 0) { // user.payThisMonth = ":החזר הלוואה מחודשים קודמים שטרם החזרו" + sumPayThisMonth.ToString (); AlertsUsers alert = new AlertsUsers() { UserId = user.Id_user, Alret = " יש החזרים מחודשים קודמים שלא שולמו לחבר " + user.Last_name + " " + user.First_name }; alertsUsers.Add(alert); } Repayments repaymentThisMonth = repayments.FirstOrDefault(r => r.Date.Month == thisMonth); if (repaymentThisMonth != null) { // user.payThisMonth += " :תשלום פררעון לחודש זה" + repaymentThisMonth.Amount.ToString (); sumPayThisMonth += repaymentThisMonth.Amount; } } user.Loans = loan != null?LoanBL.Balance(loan.LoanId) : 0; User_in_fund rachelLea = db.UserInFunds.FirstOrDefault(uf => u.UserId == uf.UserId && uf.FundId == "rachelLea"); user.RachelLea = rachelLea != null ? (int)rachelLea.balance : 0; // Repayment repayment=db.Repayments.Where(r=>r. userList.Add(user); } } return(userList); }
public JsonResult AutoCompleteTruncationNumber(string term) { LoanBL objLoanBL = new LoanBL(); List <String> result = new List <String>(); result = objLoanBL.GetAllTruncationNumber().Where(x => x.TransactionNumber.ToString().StartsWith(term)).Select(y => y.TransactionNumber.ToString()).Distinct().ToList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult LoanPaid() { LoanBL objLoanBL = new LoanBL(); List <Loan> bankName = objLoanBL.GetBankNameforLoan(); ViewBag.bankName = bankName; return(View()); }
public ActionResult Create(LoanBusinessEntity loanBusinessEntity) { loanBusinessEntity.Id = -1; string str = "Success"; LoanBL loanBL = new LoanBL(); bool status = loanBL.Create(loanBusinessEntity); return(Json(str, JsonRequestBehavior.AllowGet)); }
// GET: Accounts/Loan public ActionResult LoanEntry() { LoanBL objLoanBL = new LoanBL(); var model = new Loan { BankNameList = objLoanBL.GetBankNameforLoan() }; return(View(model)); }
private void Controller_ResourcePassed(object sender, EventArgs e) { LoanBL bl = new LoanBL(); Models.Loan l = bl.RetrieveLoanByResource((Resource)sender); loan = l; BindStudent(loan.Student); BindResources(l.Resource); BindDates(); SetState(2); }
public ActionResult LAccount(string accountType, string loanamount) { var userID = this.User.FindFirstValue(ClaimTypes.NameIdentifier); LoanAccount la = new LoanBL().Create(loanamount, userID); _db.LoanAccounts.Add(la); _db.SaveChanges(); ViewBag.Message = "Congratulations! Your loan account has been created!"; return(View("Confirmed")); }
private void btnProceed_Click(object sender, EventArgs e) { try { LoanBL bl = new LoanBL(); MessageBox.Show(bl.CreateLoan(PopulateLoan())); Controller.CloseFrom(this); } catch (LoanCreateException ex) { MessageBox.Show("Loan did not pass validation: " + ex.Message); } }
public ActionResult SearchLoan() { LoanBL loanBL = new LoanBL(); IList <LoanBusinessEntity> loans = loanBL.GetLoans(); List <LoanBusinessEntity> loansnew = new List <LoanBusinessEntity>(); foreach (LoanBusinessEntity loan in loans) { LoanBusinessEntity ob = GetCustName(loan); loansnew.Add(ob); } return(Json(loansnew, JsonRequestBehavior.AllowGet)); }
//---------------- Action performed when grid view selection changed --------------------------- private void dgvLoanApplications_SelectionChanged(object sender, EventArgs e) { string loanId, status; DataSet dsLoanDetails = null; if (dgvLoanApplications.SelectedCells.Count > 0) { int selectedrowindex = dgvLoanApplications.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dgvLoanApplications.Rows[selectedrowindex]; loanId = Convert.ToString(selectedRow.Cells["loanId"].Value); dsLoanDetails = LoanBL.GetLoanDetails(loanId); if (dsLoanDetails.Tables[0].Rows.Count > 0) { try { Object[] Data = null; Data = dsLoanDetails.Tables[0].Rows[0].ItemArray; textBoxCustomerId.Text = Data[0].ToString(); textBoxAccountNumber.Text = Data[1].ToString(); textBoxName.Text = Data[2].ToString(); textBoxAddress.Text = Data[9].ToString(); textBoxLoanAmount.Text = Data[16].ToString(); textBoxLoanType.Text = Data[15].ToString(); textBoxLoanId.Text = Data[13].ToString(); textBoxGuarantor.Text = Data[20].ToString(); txtTerm.Text = Data[18].ToString(); textBoxRateofInterest.Text = Data[17].ToString(); textBoxDate.Text = Data[22].ToString().Substring(0, 9); status = Data[21].ToString(); comboBoxStatus.Text = status; if (status == "Submitted") { comboBoxStatus.Items.Clear(); comboBoxStatus.Items.Add("Approved"); comboBoxStatus.Items.Add("Rejected"); } else { comboBoxStatus.Items.Clear(); } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } } } }
//----------------- Action for Customer Id change ------------------------- private void textBoxcustomerid_TextChanged(object sender, EventArgs e) { Customer customerObj = null; try { customerObj = LoanBL.GetCustomerById(textBoxCustomerId.Text); if (customerObj != null) { textBoxName.Text = customerObj.CustomerName; textBoxAccountNumber.Text = customerObj.AccountNumber; } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
private void btnResouceSearch_Click(object sender, EventArgs e) { try { if (txtResourceID.Text == string.Empty) { MessageBox.Show("Search cannot be empty.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { string ResourceId = txtResourceID.Text; StudentBL stuBl = new StudentBL(); List <Student> stuList = new List <Student>(); stu = stuBl.GetStudentByResourceId(ResourceId); stuList.Add(stu); dgvStudentInfo.DataSource = stuList; dgvStudentInfo.Columns["ProgramId"].Visible = false; dgvStudentInfo.Columns["Address"].Visible = false; dgvStudentInfo.Columns["City"].Visible = false; dgvStudentInfo.Columns["PhoneNumber"].Visible = false; dgvStudentInfo.Columns["TimeStamp"].Visible = false; dgvStudentInfo.Columns["PostalCode"].Visible = false; LoanBL loBl = new LoanBL(); List <Loan> loanList = new List <Loan>(); //change indexes to column name loanList = loBl.GetLoan(dgvStudentInfo.Rows[0].Cells["StudentId"].Value.ToString()); dgvLoanInfo.DataSource = loanList; dgvLoanInfo.Columns[0].Visible = false; dgvLoanInfo.Columns[1].Visible = false; dgvLoanInfo.Columns[5].Visible = false; dgvLoanInfo.Columns[6].Visible = false; dgvLoanInfo.Columns[9].Visible = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult LoanAc(Loan_Account_Entites le) { if (Session["user"] != null) { LoanBL lb = new LoanBL(); int res = lb.LoanAc(le); if (res > 0) { ViewData["a"] = "Your Loan Sucessfull"; } else { ViewData["a"] = "INValid CustomerDetails"; } return(View()); } else { return(RedirectToAction("Login")); } }
public ActionResult LoanTrans(Loan_Transcation_Entites le) { if (Session["user"] != null) { LoanBL lb = new LoanBL(); int res = lb.LoanTrans(le); if (res > 0) { ViewData["a"] = "Paid Emi Sucessfull"; } else { ViewData["a"] = "INValid CustomerDetails"; } return(View()); } else { return(RedirectToAction("Login")); } }
//---------------- Action for Status Combo Box selection change --------------------------- private void comboBoxStatus_SelectedIndexChanged(object sender, EventArgs e) { int output = 0; ComboBox comboBox = (ComboBox)sender; string loanId = textBoxLoanId.Text; string status = (string)comboBox.SelectedItem; output = LoanBL.UpdateLoanStatus(loanId, status); if (output > 0) { LoadLoanApplications(); lblLoanMessage.ForeColor = Color.Green; lblLoanMessage.Text = "Status Updated Successfully."; } else { lblLoanMessage.ForeColor = Color.Red; lblLoanMessage.Text = "Failed! Please Try Again."; } }
private void btnConfirmSelection_Click(object sender, EventArgs e) { try { ResourceBL rebl = new ResourceBL(); LoanBL loBL = new LoanBL(); int counter = 0; foreach (Resource r in resourcestoborrow) { if (loBL.CreateLoan(PopulateLoanObject(r, counter), r) && rebl.UpdateResource(r.ResourceId)) { LoanBL loBl = new LoanBL(); List <Loan> loanList = new List <Loan>(); loanList = loBl.GetLoan(dtvStudentInfo.Rows[0].Cells["StudentId"].Value.ToString()); dtgStudentLoanInfo.DataSource = loanList; if (resourcestoborrow.IndexOf(r) == resourcestoborrow.Count - 1) { MessageBox.Show("Resources were borrowed."); } } else { string msg = string.Empty; foreach (ValidationError error in loBL.Errors) { msg += error.Description + Environment.NewLine; } loBL.Errors.Clear(); MessageBox.Show(msg); } } ClearData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//---------------- Action for Search TextBox text change --------------------------- private void textBoxSearch_TextChanged(object sender, EventArgs e) { DataSet dsLoans = null; try { string nameLike = textBoxSearch.Text; dsLoans = LoanBL.GetLoansLike(nameLike, searchOption); if (dsLoans != null) { dgvLoanApplications.DataSource = dsLoans.Tables[0]; } else { lblLoanMessage.ForeColor = Color.Red; lblLoanMessage.Text = "No History Available!"; } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
//---------------- Load Loan Details form --------------------------- private void LoadLoanApplications() { DataSet dsLoans = null; try { dsLoans = LoanBL.GetBasicLoanDetails(); if (dsLoans != null) { dgvLoanApplications.DataSource = dsLoans.Tables[0]; } else { lblLoanMessage.ForeColor = Color.Red; lblLoanMessage.Text = "No Students Available!"; } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
public ActionResult LoanPaid(Loan objLoan) { try { LoanBL objLoanBL = new LoanBL(); int IsRowAffected = objLoanBL.PaidLoan(objLoan); if (IsRowAffected > 0) { ViewBag.Message = "Save Succesfully"; } else { ViewBag.Message = "Save Failed"; } List <Loan> bankName = objLoanBL.GetBankNameforLoan(); ViewBag.bankName = bankName; } catch (Exception ex) { ViewBag.error = ("Error : " + ex.Message); } return(View()); }
private void lstSearchResult_SelectedIndexChanged(object sender, EventArgs e) { try { string studentId = lstSearchResult.SelectedValue.ToString(); StudentBL stuBl = new StudentBL(); List <Student> stuList = new List <Student>(); stu = stuBl.GetStudent(studentId); stuList.Add(stu); dtvStudentInfo.DataSource = stuList; LoanBL loBl = new LoanBL(); List <Loan> loanList = new List <Loan>(); loanList = loBl.GetLoan(studentId); dtgStudentLoanInfo.DataSource = loanList; dtvStudentInfo.Columns[0].Visible = false; dtgStudentLoanInfo.Columns[0].Visible = false; dtgStudentLoanInfo.Columns[1].Visible = false; dtgStudentLoanInfo.Columns[5].Visible = false; dtgStudentLoanInfo.Columns[6].Visible = false; dtgStudentLoanInfo.Columns[9].Visible = false; dtvStudentInfo.Columns["ProgramId"].Visible = false; dtvStudentInfo.Columns["Address"].Visible = false; dtvStudentInfo.Columns["City"].Visible = false; dtvStudentInfo.Columns["PhoneNumber"].Visible = false; dtvStudentInfo.Columns["TimeStamp"].Visible = false; dtvStudentInfo.Columns["PostalCode"].Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//---------------- Action for submit button --------------------------- private void buttonsubmit_Click(object sender, EventArgs e) { Loan loanObj = null; int output = 0; try { loanObj = new Loan(); loanObj.LoanId = LoanBL.GetNewLoanId(); loanObj.CustomerId = textBoxCustomerId.Text; loanObj.LoanType = comboBoxLoanType.Text; loanObj.LoanAmount = Convert.ToDouble(textBoxLoanAmount.Text); loanObj.InterestRate = 0.1; loanObj.Term = Convert.ToInt32(textBoxTerm.Text); loanObj.NetAmount = loanObj.LoanAmount * (1 + loanObj.InterestRate); loanObj.GuarantorName = textBoxGuarantor.Text; loanObj.Status = "Submitted"; DateTime today = DateTime.Today; loanObj.Date = today.ToString(); output = LoanBL.InsertLoanDetails(loanObj); if (output > 0) { lblLoanMessage.Text = "Loan Applied Successfully!"; } else { lblLoanMessage.Text = "Failed! Please Try Again."; } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
private void btnCheckout_Click(object sender, EventArgs e) { try { loan.StudentId = txtStudentId.Text; loan.ResourceId = Convert.ToInt32(txtResourceIdEntry.Text); loan.CheckOutDate = DateTime.Now; LoanBL loanBL = new LoanBL(); if (r.IsReserved != true && r.ResourceStatus.ToString() == "Available") { MessageBox.Show($"StudendID: {txtStudentId.Text}\n" + $"ResourceID: {txtResourceIdEntry.Text}\n" + $"CheckOut Date: {loan.CheckOutDate}\n" + $"Due Date: {loan.DueDate}"); if (loanBL.ResourceTransaction(loan.StudentId, loan.ResourceId, loan.CheckOutDate, loan.DueDate)) { MessageBox.Show("Transaction worked!"); } else { MessageBox.Show("Transaction Falied!"); } ListsBL listsBL = new ListsBL(); dgvCurrentLoans.DataSource = listsBL.GetLoans(s.StudentId); } else { MessageBox.Show("Resource is not available!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public LoanRepo(TestDbContext ctx) { _context = ctx; loanBL = new LoanBL(); }
public static ListUsers GetUsersList() { var sumPayThisMonth = 0; // List<UserDTO> userList = new List<UserDTO> (); ListUsers userList = new ListUsers(); using (SuperGmachEntities db = new SuperGmachEntities()) { foreach (User u in db.Users) { UserDTO user = Userconvert.DALtoDTO(u); //cheac if the user Proper else add alret if (user.Management_status.Id != "Proper") { AlertsUsers alert = new AlertsUsers() { UserId = user.Id_user, Alret = " סטטוס ניהול לחבר " + user.Last_name + " " + user.First_name + " " + user.Management_status.Name + " סיבת הסטטוס " + user.Status_reason }; userList.alertsUsers.Add(alert); } /// cheack if the user have active loan Loan loan = db.Loans.FirstOrDefault(l => l.UserId == u.UserId && l.NameStatus != "performed"); if (loan != null) { var today = DateTime.Now; var thisMonth = DateTime.Now.Month; List <Repayments> repayments = db.Repayments.Where(r => r.LoanId == loan.LoanId && r.NameStatus != "performed").ToList(); List <Repayments> pastRepayments = repayments.Where(r => r.Date < today && r.Date != today).ToList(); foreach (var repayment in pastRepayments) { sumPayThisMonth += repayment.Amount; } if (pastRepayments.ToArray().Length > 0) { // user.payThisMonth = ":החזר הלוואה מחודשים קודמים שטרם החזרו" + sumPayThisMonth.ToString (); AlertsUsers alert = new AlertsUsers() { UserId = user.Id_user, Alret = " יש החזרים מחודשים קודמים שלא שולמו לחבר " + user.Last_name + " " + user.First_name }; userList.alertsUsers.Add(alert); } Repayments repaymentThisMonth = repayments.FirstOrDefault(r => r.Date.Month == thisMonth); if (repaymentThisMonth != null) { // user.payThisMonth += " :תשלום פררעון לחודש זה" + repaymentThisMonth.Amount.ToString (); sumPayThisMonth += repaymentThisMonth.Amount; } } if (loan != null) { switch (loan.NameManagement_status) { case "Invalid": user.Loans = " לא תקין " + LoanBL.Balance(loan.LoanId).ToString(); break; case "Unauthorized": user.Loans = "לא מאושר"; break; case "Proper": user.Loans = loan.NameStatus == "active" ? ("-" + LoanBL.Balance(loan.LoanId).ToString()) : "ממתין לאישור"; break; case "Approved": user.Loans = loan.NameStatus == "future" ? loan.Amount.ToString() + " עתידי" : loan.Amount.ToString() + "מאושר "; break; } } // user.Loans = loan != IChangeTracking null ? LoanBL.Balance (loan.LoanId) : 0; User_in_fund rachelLea = db.UserInFunds.FirstOrDefault(uf => u.UserId == uf.UserId && uf.FundId == "2"); user.RachelLea = rachelLea != null ? (int)rachelLea.balance : 0; // Repayment repayment=db.Repayments.Where(r=>r. userList.Users.Add(user); } } return(userList); }
private void btnCheckout_Click(object sender, EventArgs e) { try { if (Form_Validation() != string.Empty) { MessageBox.Show(Form_Validation(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (loans.Count != 0) { foreach (LoanLookUp loan in loans.ToList()) { GetResource(loan.ResourceId); LoanBL loanBL = new LoanBL(s, r); if (loanBL.Errors.Count == 0) { loan.StudendId = s.StudentId; loan.ResourceId = r.ResourceId; loan.CheckOutDate = DateTime.Now; //Check Studend Status and overdueBalance if (loanBL.ResourceTransaction(loan.CheckOutDate, loan.DueDate)) { DeleteLoans(loan.ResourceId); if (loans.Count == 0) { dgvList.DataSource = null; MessageBox.Show("Checkout worked!"); } txtResourceStatus.Text = r.ResourceStatus.ToString(); } } else { string msg = ""; foreach (ValidationError error in loanBL.Errors) { msg += error.Description + Environment.NewLine; } MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } ListsBL listsBL = new ListsBL(); showDGV(listsBL.GetLoans(s.StudentId)); } else { MessageBox.Show("please add resources first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }