private void AddButton_OnClick(object sender, RoutedEventArgs e) { using (var db = new BankingContext()) { try { if (VornameTextBox.Text == "" || NachnameTextBox.Text == "" || AdresseTextBox.Text == "" || PlzTextBox.Text == "" || OrtTextBox.Text == "" || DatenschutzCheckbox.IsChecked == false) { throw new IsEmptyException(); } var plz = Convert.ToInt32(PlzTextBox.Text); var datenschutz = DatenschutzCheckbox.IsChecked == true; db.Add(new Kunde.Kunde(VornameTextBox.Text, NachnameTextBox.Text, AdresseTextBox.Text, plz, OrtTextBox.Text, TelefonNummerTextBox.Text, datenschutz)); //TODO:Ueberpruefung ob bereits ein Kunde mit den Werten vorhanden ist db.SaveChanges(); MessageBox.Show("Kunde angelegt!"); } catch (IsEmptyException) { MessageBox.Show("Alle Felder müssen ausgefüllt sein!"); } finally { db.Dispose(); } } }
public bool IsCodeValid(string code, out string message) { var result = false; message = string.Empty; try { using (var context = new BankingContext()) { var pRecord = context.RecoverPasswords.FirstOrDefault(a => a.RecoveryCode == code); if (pRecord == null) { message = "Invalid password reset link"; } else { if (pRecord.ExpiryTime < DateTime.Now) { message = "Password expiry link has expired. Please do Forgot Password again"; } else { message = "Success"; result = true; } } } } catch (Exception ex) { message = ex.Message; } return(result); }
public DbInitializer(BankingContext context) { _context = context; _context.Database.EnsureCreated(); if (context.Customers.Any()) { return; } int n = 100; for (int i = 1; i < n; i++) { var newCustomer = new Customer { FirstName = "Name" + i, LastName = "Ape" + i, DocumentNumber = i.ToString().PadLeft(9, '0'), IsActive = true, Password = "******" + i, Id_Rol = 1, User = "******" + i }; _context.Customers.Add(newCustomer); _context.BankAccounts.Add(new BankAccount { CustomerId = newCustomer.Id, Customer = newCustomer, Balance = 100, IsLocked = false, Number = i.ToString().PadLeft(9, '0') }); } //_context.BankAccounts.Add(new BankAccount { Customer = newCustomer, Balance = 1500, IsLocked = false, Number = "123-456-001" }); //_context.BankAccounts.Add(new BankAccount { Customer = newCustomer, Balance = 1800, IsLocked = false, Number = "123-456-002" }); _context.Roles.Add(new Role { Id = 1, IsActive = true, Role_Name = "Cliente" }); _context.SaveChanges(); }
public ReturnObjValueBackEnd InsertSaveMoney(SoTietKiem objInsert) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); string maxId = ""; maxId = (from c in ctx.SoTietKiem select c.MaSTK).Max(); if (!string.IsNullOrEmpty(maxId)) { int maxCurrent = Convert.ToInt16(maxId.Substring(3, maxId.Length - 2)); int maxNext = maxCurrent + 1; string mastkaddnew = maxNext.ToString().PadLeft(4, '0'); objInsert.MaSTK = "STK" + mastkaddnew; } else { objInsert.MaSTK = "STK0001"; } ctx.SoTietKiem.Add(objInsert); ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd DeleteCustomer(List <string> lstKH) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); List <KhachHang> lstKhachHang = new List <KhachHang>(); for (int i = 0; i < lstKH.Count; i++) { lstKhachHang.Add(new KhachHang { MaKH = lstKH[i] }); ctx.Entry(lstKhachHang[i]).State = System.Data.Entity.EntityState.Deleted; } ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
private async Task ExecuteBillPays(CancellationToken cancellationToken) { try { using (var scope = _services.CreateScope()) { var context = new BankingContext( scope.ServiceProvider .GetRequiredService <DbContextOptions <BankingContext> >()); var now = DateTime.UtcNow; var billPaysQ = context.BillPay.Where(x => x.ScheduleDate > now - interval && x.ScheduleDate <= now); var billPays = await billPaysQ.ToListAsync(); foreach (var billPay in billPays) { string errMsg; if (billPay.ExecuteBillPay(out errMsg)) { await context.SaveChangesAsync(); _logger.LogInformation($"Executed BillPay {billPay.BillPayID}"); } else { _logger.LogError($"BillPay {billPay.BillPayID}({billPay.ScheduleDateLocal}) execution failed. {errMsg}"); } } } } catch (Exception e) { DateTime now = DateTime.Now; _logger.LogError(0, e, "An exception occured when executing bill pays"); } }
public void DeleteUser(List <string> lstID) { try { var ctx = new BankingContext(); MSTUSER userModel = new MSTUSER(); for (int i = 0; i < lstID.Count; i++) { var query = from user in ctx.MstUser where user.USERID.Equals(lstID[i]) select user; if (query.ToList().Count > 0) { userModel = query.ToList()[0]; } userModel.DELETE_YMD = DateTime.Now; UpdateUser(userModel); } } catch (Exception ex) { throw ex; } }
public ReturnObjValueBackEnd DeleteUser(List <string> lstID) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); MSTUSER userModel = new MSTUSER(); for (int i = 0; i < lstID.Count; i++) { var query = from user in ctx.MstUser where user.USERID.Equals(lstID[i]) select user; if (query.ToList().Count > 0) { userModel = query.ToList()[0]; } userModel.DELETE_YMD = DateTime.Now; UpdateUser(userModel); } retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd InsertStaff(NhanVien staff) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { string maxId = ""; var ctx = new BankingContext(); maxId = (from c in ctx.NhanVien select c.MaNV).Max(); if (!string.IsNullOrEmpty(maxId)) { int maxCurrent = Convert.ToInt16(maxId.Substring(2, maxId.Length - 2)); int maxNext = maxCurrent + 1; string manv = maxNext.ToString().PadLeft(4, '0'); staff.MaNV = "NV" + manv; } else { staff.MaNV = "NV0001"; } ctx.NhanVien.Add(staff); ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd DeleteStaff(List <string> lstMaNV) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); List <NhanVien> lstNV = new List <NhanVien>(); for (int i = 0; i < lstMaNV.Count; i++) { lstNV.Add(new NhanVien { MaNV = lstMaNV[i] }); ctx.Entry(lstNV[i]).State = System.Data.Entity.EntityState.Deleted; } ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd DeleteBanking(List <string> lstID) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); List <CreditManagement.Models.NganHang> lst = new List <CreditManagement.Models.NganHang>(); for (int i = 0; i < lstID.Count; i++) { lst.Add(new CreditManagement.Models.NganHang { MaNH = lstID[i] }); ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted; } ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd SearchAllBanking() { List <CreditManagement.Models.NganHang> lst = new List <CreditManagement.Models.NganHang>(); retObjValueBackEnd = new ReturnObjValueBackEnd(); try { using (var context = new BankingContext()) { lst = context.NganHang.ToList(); } retObjValueBackEnd.Success = true; retObjValueBackEnd.Data = lst.ToArray(); return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public DealDetail ShowDataToScreen() { string maKH = null; DealDetail model = new DealDetail(); maKH = HttpContext.Current.Session["MAKH"].ToString(); using (var context = new BankingContext()) { var kh = context.KhachHang .Where(b => b.MaKH == maKH) .FirstOrDefault(); model.TenKH = kh.TenKH; } model.ChiTietGD = GetDealDetail(); model.ChuyenKhoanModel = DataChuyenKhoan(maKH); model.RutTienModel = DataRutTien(maKH); using (var context = new BankingContext()) { model.dsNganHang = context.ChiNhanhNganHang.ToList(); } return(model); }
public ReturnObjValueBackEnd DeleteDealDetail(List <ChiTietGiaoDich> lstID) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); List <ChiTietGiaoDich> lst = new List <ChiTietGiaoDich>(); for (int i = 0; i < lstID.Count; i++) { lst.Add(new ChiTietGiaoDich { MaKH = lstID[i].MaKH, NgayGD = lstID[i].NgayGD }); ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted; } ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public ReturnObjValueBackEnd SearchAllAccount() { List <TaiKhoan> lst = new List <TaiKhoan>(); retObjValueBackEnd = new ReturnObjValueBackEnd(); try { using (var context = new BankingContext()) { lst = context.TaiKhoan.ToList(); } retObjValueBackEnd.Success = true; retObjValueBackEnd.Data = lst.ToArray(); return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
/// <summary> /// Lấy thông tin nhân viên dựa vào useris và password /// </summary> /// <param name="userId">user id</param> /// <param name="pass">password</param> /// <returns></returns> public NhanVien CheckLogin(string userId, string pass) { NhanVien lstTTNhanVien = new NhanVien(); try { using (var ct = new BankingContext()) { var query = from user in ct.MstUser join nv in ct.NhanVien on user.USERID equals nv.MaNV where user.USERID.Equals(userId) && user.PASSWD.Equals(pass) select nv; if (query.ToList().Count > 0) { lstTTNhanVien = query.ToList()[0]; } } return(lstTTNhanVien); } catch (Exception ex) { return(null); throw ex; } }
/// <summary> /// Lấy thông tin nhân viên dựa vào useris và password /// </summary> /// <param name="userId">user id</param> /// <param name="pass">password</param> /// <returns></returns> public ReturnObjValueBackEnd CheckLogin(string userId, string pass) { NhanVien lstTTNhanVien = new NhanVien(); retObjValueBackEnd = new ReturnObjValueBackEnd(); try { using (var ct = new BankingContext()) { var query = from user in ct.MstUser join nv in ct.NhanVien on user.USERID equals nv.MaNV where user.USERID.Equals(userId) && user.PASSWD.Equals(pass) select nv; if (query.ToList().Count > 0) { lstTTNhanVien = query.ToList()[0]; } } retObjValueBackEnd.Success = true; retObjValueBackEnd.Data = lstTTNhanVien; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public UnitOfWork(BankingContext dbContext) { _context = dbContext; Customers = new CustomerRepository(_context); BankAccounts = new BankAccountRepository(_context); Transactions = new TransactionRepository(_context); }
public List <Transaction> Transactions() { var result = new List <Transaction>(); var currentuser = HttpContext.Current.User.Identity.Name; try { using (var db = new BankingContext()) { var userid = db.Customers.FirstOrDefault(a => a.Email == currentuser).Id; var currendusername = db.Customers.FirstOrDefault(a => a.Email == currentuser).FirstName; var totalrecords = db.Transactions.Where(a => a.CustomerId == userid || a.ReceiverName == currendusername).ToList().Count(); result = db.Transactions.Where(a => a.CustomerId == userid || a.ReceiverName == currendusername).OrderBy(a => a.Id).Skip(totalrecords - 10).Take(10).ToList(); var paged = result.Skip(3).Take(3).ToList(); //var list = db.Customers.ToList(); //var paged = list.Skip((2 - 1) * 10).Take(10).ToList(); //var betterPaged = db.Customers.Skip(10).Take(10).ToList(); } } catch (Exception ex) { } return(result); }
public string GetCurrentUserName(string currentusername) { using (var db = new BankingContext()) { return(db.Customers.FirstOrDefault(a => a.Email == currentusername)?.FirstName); } }
public string GetCustomerAccountNumber(long accountNumber) { using (var db = new BankingContext()) { return(db.Customers.FirstOrDefault(a => a.AccountNumber == accountNumber)?.FirstName); } }
public ReturnObjValueBackEnd DeleteAccount(List <TaiKhoan> lstID) { retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); List <TaiKhoan> lst = new List <TaiKhoan>(); for (int i = 0; i < lstID.Count; i++) { lst.Add(new TaiKhoan { MaKH = lstID[i].MaKH, MaNV = lstID[i].MaNV, MaCN = lstID[i].MaCN }); ctx.Entry(lst[i]).State = System.Data.Entity.EntityState.Deleted; } ctx.SaveChanges(); retObjValueBackEnd.Success = true; return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public List <Tab01Model> GetDealDetail() { string ds = ""; BankingContext ct = new BankingContext(); List <Tab01Model> model = new List <Tab01Model>(); var query = from ctgd in ct.ChiTietGiaoDich join kh in ct.KhachHang on ctgd.MaKH equals kh.MaKH join nv in ct.NhanVien on ctgd.MaNV equals nv.MaNV join cnnh in ct.ChiNhanhNganHang on ctgd.MaCNNH equals cnnh.MaCN select new { MaGD = ctgd.MaGD, NgayGD = ctgd.NgayGD, NhanVien = nv.TenNV, CNGD = cnnh.TenCN, SoTien = ctgd.SoTienGD }; DataTable dt = LINQToDataTable(query); model = (from rw in dt.AsEnumerable() select new Tab01Model() { MaGD = rw["MaGD"].ToString(), NgayGD = Convert.ToString(rw["NgayGD"]), TenNV = Convert.ToString(rw["NhanVien"]), TenCN = Convert.ToString(rw["CNGD"]), SoTienGD = Convert.ToString(rw["SoTien"]) }).ToList(); return(model); }
public ReturnObjValueBackEnd SearchBankBranchesByCondition(ChiNhanhNganHang sc) { List <ChiNhanhNganHang> lst = new List <ChiNhanhNganHang>(); retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); var query = from ct in ctx.ChiNhanhNganHang select ct; if (sc != null) { if (sc.MaCN != null) { query = query.Where(p => p.MaCN.Equals(sc.MaCN)); } if (sc.LoaiCN != null) { query = query.Where(p => p.LoaiCN.Equals(sc.LoaiCN)); } if (sc.DTNoiBo != null) { query = query.Where(p => p.DTNoiBo.Equals(sc.DTNoiBo)); } if (sc.TenCN != null) { query = query.Where(p => p.TenCN.Contains(sc.TenCN)); } if (sc.DiaChi != null) { query = query.Where(p => p.DiaChi.Contains(sc.DiaChi)); } if (sc.LoaiNH != null) { query = query.Where(p => p.LoaiNH.Equals(sc.LoaiNH)); } } lst = query.ToList(); retObjValueBackEnd.Success = true; retObjValueBackEnd.Data = lst.ToArray(); return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
public AccountController(BankingContext context, ILogger <AccountController> logger, IHostingEnvironment env, IRabbitMqClient rabbitMqClient) { _context = context; _logger = logger; _env = env; _rabbitMqClient = rabbitMqClient; }
//ToRemove added because of wcf ef loading error public string GetRoleName(int userId) { using (var context = new BankingContext()) { var user = context.User.Include("Role").SingleOrDefault(us => us.Id == userId); return(user.Role.Name); }; }
public ReturnObjValueBackEnd SearchCustomerByCondition(KhachHang sc) { List <KhachHang> lstKhachhang = new List <KhachHang>(); retObjValueBackEnd = new ReturnObjValueBackEnd(); try { var ctx = new BankingContext(); var query = from ct in ctx.KhachHang select ct; if (sc != null) { if (sc.MaKH != null) { query = query.Where(p => p.MaKH.Equals(sc.MaKH)); } if (sc.cmnd != null) { query = query.Where(p => p.cmnd.Equals(sc.cmnd)); } if (sc.TenKH != null) { query = query.Where(p => p.TenKH.Contains(sc.TenKH)); } if (sc.SoDienThoai != null) { query = query.Where(p => p.SoDienThoai.Equals(sc.SoDienThoai)); } if (sc.NgaySinh != null) { query = query.Where(p => p.NgaySinh.Equals(sc.NgaySinh)); } if (sc.GioiTinh != null) { query = query.Where(p => p.GioiTinh.Equals(sc.GioiTinh)); } } lstKhachhang = query.ToList(); retObjValueBackEnd.Success = true; retObjValueBackEnd.Data = lstKhachhang.ToArray(); return(retObjValueBackEnd); } catch (Exception ex) { retObjValueBackEnd.Success = false; retObjValueBackEnd.Message = ex.ToString(); return(retObjValueBackEnd); throw ex; } }
private void DeleteButton_OnClick(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Wollen Sie dieses Konto wirklich Löschen ?", "Löschen", MessageBoxButton.YesNo); var error = false; switch (result) { case MessageBoxResult.Yes: using (var db = new BankingContext()) { var kontoList = db.KontoSet.Where(s => s.KontoNummer == KontoNummerTextbox.Text); foreach (var giro in kontoList) { if (Crypto.DecryptPin(giro.Pin) == PinTextbox.Password) { var transactionlist = db.TransaktionsSet .Where(s => s.Empfaenger == KontoNummerTextbox.Text) .ToList(); foreach (var transaction in transactionlist) { db.TransaktionsSet.Remove(transaction); } db.Remove(giro); error = false; } else { MessageBox.Show("Pin Falsch!"); error = true; break; } } //TODO: Fehler im Löschprotokoll Beheben FOREIGN-Key kann nicht gelöscht werden solange objekt noch besteht (Transaktionen werden deswegen nicht gelöscht sonderen besitzen keinen key mehr) try { db.SaveChanges(); } catch (Exception) { MessageBox.Show("Currently not working :D ! I work on a fix for this."); } } if (error == false) { MessageBox.Show("Gelöscht!!"); ResetForm(); } break; case MessageBoxResult.No: ResetForm(); break; } }
public BranchRepository(BankingContext bankingContext) { if (bankingContext == null) { throw new ArgumentNullException(nameof(bankingContext)); } _bankingContext = bankingContext; }
public List <SoTietKiem> SearchSaveMoneyByCondition(SoTietKiem sc) { List <SoTietKiem> lst = new List <SoTietKiem>(); try { var ctx = new BankingContext(); var query = from ct in ctx.SoTietKiem select ct; if (sc != null) { if (sc.MaSTK != null) { query = query.Where(p => p.MaSTK.Equals(sc.MaSTK)); } if (sc.MaKH != null) { query = query.Where(p => p.MaKH.Equals(sc.MaKH)); } if (sc.NgayTao != null) { query = query.Where(p => p.NgayTao.Equals(sc.NgayTao)); } if (sc.NgayHuy != null) { query = query.Where(p => p.NgayHuy.Equals(sc.NgayHuy)); } if (sc.MaNV != null) { query = query.Where(p => p.MaNV.Equals(sc.MaNV)); } if (sc.MaCN != null) { query = query.Where(p => p.MaCN.Equals(sc.MaCN)); } if (sc.LoaiTK != null) { query = query.Where(p => p.LoaiTK.Equals(sc.LoaiTK)); } if (sc.SoTien != null) { query = query.Where(p => p.SoTien.Equals(sc.SoTien)); } } lst = query.ToList(); return(lst); } catch (Exception ex) { throw ex; } }