/// <summary> /// Apply business method. /// </summary> /// <param name="Account">A Account value.</param> /// <returns>Returns a Account object.</returns> public Account Apply(Account Account) { Account.Status = AccountStatuses.Pending; Account.DateSubmitted = DateTime.Now; Account.IsCompleted = false; AccountStatusLog log = CreateLog(Account); // Data access component declarations. var AccountDAC = new AccountDAL(); var AccountStatusLogDAC = new AccountStatusLogDAL(); // Check for overlapping Accounts. if (AccountDAC.IsOverlap(Account)) { throw new ApplicationException("Date range is overlapping with another Account."); } using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { // Step 1 - Calling Create on AccountDAC. AccountDAC.Create(Account); // Step 2 - Calling Create on AccountStatusLogDAC. log.AccountID = Account.AccountID; AccountStatusLogDAC.Create(log); ts.Complete(); } return Account; }
public ActionResult Login(FormCollection f) { string email = f["txtEmail"]; string password = f["txtPassword"]; if (email == null && password == null) { return(View()); } AccountDAL accountDal = new AccountDAL(); User_Account u_account = accountDal.checkLogin(email, password); if (u_account == null) { ViewBag.Message = "Your Email or Password is INCORRECT!!!"; } else { Session["USER"] = u_account; Product_CartDAL productCartDal = new Product_CartDAL(); List <Product_Cart> productCarts = productCartDal.getProductCartsByEmail(u_account.Email); foreach (var item in productCarts) { u_account.Product_Cart.Add(item); } DateTime birthday = (DateTime)u_account.Birthday; Session["USER"] = u_account; Session["DATE"] = birthday.Day.ToString(); Session["MONTH"] = birthday.Month.ToString(); Session["YEAR"] = birthday.Year.ToString(); Session["GENDER"] = u_account.Gender; addToCart(); return(RedirectToAction("ViewCart", "Cart")); } return(View()); }
private void btnSearch_Click(object sender, EventArgs e) { if (txtSearch.Text.Length != 0) { if (Account.GetAccountByUsername(txtSearch.Text.Trim()).Count > 0) { dataGridView1.DataSource = null; dataGridView1.DataSource = AccountDAL.GetAccountByUsername(txtSearch.Text.Trim()); } else { MessageBox.Show("Không tìm thấy danh mục"); Refresh(); } } else { MessageBox.Show("Điền danh mục cần tìm!"); Refresh(); txtSearch.Focus(); } }
protected bool CanLogin() { var accountDAL = new AccountDAL(); if (txtUserName.Text == string.Empty || txtPassWord.Text == string.Empty) { MessageBox.Show("UserName or PassWord is invalid"); return(false); } var isLogin = accountDAL.IsGetAccountByUserNameAndPassWord(txtUserName.Text, txtPassWord.Text); if (!isLogin) { MessageBox.Show("UserName or PassWord is wrong"); return(false); } else { return(true); } }
/// <summary> /// Stores all transaction records to Transactions collection. /// </summary> /// <param name="accountID">Uniquely generated account ID.</param> /// <param name="amount">Amount to be transacted.</param> /// <param name="type">Type of transaction such as credit, debit.</param> /// <param name="mode">Mode of transaction such as cheque or withdrawal slip.</param> /// <param name="chequeNumber">Cheque number if mode of transaction is cheque and null in case of withdrawal slip.</param> /// <returns>Determinates whether the transactions are stored.</returns> public override bool StoreTransactionRecord(Guid accountID, double amount, TypeOfTranscation type, ModeOfTransaction mode, string chequeNumber) { try { //// retrieving customerID based on account No AccountDAL accountDAL = new AccountDAL(); List <Account> accounts = accountDAL.DeserializeFromJSON("AccountData.txt"); string customerID = "00000000000000";// dummy initialization to avoid warnings foreach (Account account in accounts) { if (account.AccountID == accountID) { customerID = account.CustomerID.ToString(); } } DateTime time = DateTime.Now; Guid TransactionID = Guid.NewGuid(); Transaction transaction = new Transaction(); transaction.AccountID = accountID; transaction.Type = type; transaction.Amount = amount; transaction.TransactionID = TransactionID; transaction.DateOfTransaction = time; transaction.Mode = mode; transaction.ChequeNumber = chequeNumber; List <Transaction> TransactionsRecords = DeserializeFromJSON(filepath); TransactionsRecords.Add(transaction); return(SerializeIntoJSON(TransactionsRecords, filepath)); } catch (PecuniaException) { throw new StoreTransactionException("Transaction not stored."); } }
private void btnLogin_Click(object sender, EventArgs e) { AccountDAL accDAL = new AccountDAL(); Account acc = new Account(); acc.UserName = txtUser.Text; acc.PassWord = accDAL.encodeMD5(txtPassword.Text); DataTable data = accDAL.GetAccount(); // lọc từ datatable dong có username = username người dùng nhập string filterExpression = string.Format("UserName='******'", acc.UserName); DataRow[] rows = data.Select(filterExpression); if (rows.Length != 0) { if (rows[0].ItemArray[1].ToString() == acc.PassWord) { this.Hide(); int PhanQuyen = Convert.ToInt32(rows[0].ItemArray[2].ToString()); MainFrame mf = new MainFrame(PhanQuyen, acc.UserName, acc.PassWord); mf.ShowDialog(); // this.Show(); } else { MessageBox.Show("mật khẩu của bạn bị sai", "Lỗi đăng nhâp"); } } else { MessageBox.Show("tài khoản không tồn tại", "Lỗi đăng nhâp"); } }
private void btnDoiMK_Click(object sender, EventArgs e) { AccountDAL accDAl = new AccountDAL(); string oldpass = accDAl.encodeMD5(txtOldPass.Text); string newPass = accDAl.encodeMD5(txtNewPass.Text); // if (MessageBox.Show("Bạn có thật sự muốn đôi mật khẩu ?", "Thông báo", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) // { if (acc.Password == oldpass && newPass != "") { this.Hide(); AccountDAL accDAL = new AccountDAL(); accDAL.doiMatKhau(acc.Usename, oldpass, newPass); acc.Password = newPass; } else { MessageBox.Show("Nhập không đúng mật khẩu", "Lỗi "); } // } }
public void transfer(string fromAccountNo, string toAccountNo, string transferMoneyStr) { AccountDAL accountDAL = new AccountDAL(); TransferRecordDAL transferRecordDAL = new TransferRecordDAL(); Account fromAccount = accountDAL.FindByAccountNo(fromAccountNo); Account toAccount = accountDAL.FindByAccountNo(toAccountNo); if (fromAccount == null) { throw new ArgumentException("转出账户不存在!"); } if (toAccount == null) { throw new ArgumentException("转入账户不存在!"); } if (!decimal.TryParse(transferMoneyStr, out decimal transferMoney)) { throw new ArgumentException("金额输入错误!"); } if (fromAccount.Balance - transferMoney < 0) { throw new ArgumentException("转出账户余额不够!"); } fromAccount.Balance -= transferMoney; toAccount.Balance += transferMoney; TransferRecord transferRecord = new TransferRecord { FromAccountId = fromAccount.Id, ToAccountId = toAccount.Id, TransferMoney = transferMoney, TransferDate = DateTime.Now, Id = Guid.NewGuid() }; accountDAL.Save(fromAccount); accountDAL.Save(toAccount); transferRecordDAL.Add(transferRecord); }
/// <summary> /// Debit type of transaction with mode of transaction as withdrawal slip. /// </summary> /// <param name="accountID">Uniquely generated account ID.</param> /// <param name="amount">Amount to be debited.</param> /// <returns>Determinates whether the amount is debited by withdrawal slip.</returns> public async Task <bool> DebitTransactionByWithdrawalSlipBL(Guid accountID, double amount) { bool transactionWithdrawal = false; try { AccountDAL accountnoexist = new AccountDAL(); if ((amount <= 50000) && (amount > 0) && accountnoexist.AccountIDExists(accountID) == true) { await Task.Run(() => { TransactionDAL transactionDAL = new TransactionDAL(); transactionDAL.DebitTransactionByWithdrawalSlipDAL(accountID, amount); transactionWithdrawal = true; }); } return(transactionWithdrawal); } catch (PecuniaException ex) { throw new InsufficientBalanceException(ex.Message); } }
public void Deposit(int customerId, int accountId, double amount) { try { // check if customerid matches account's customerid var customerAccounts = AccountDAL.GetCustomerAccounts(customerId); Account acc = customerAccounts.SingleOrDefault(x => x.Id == accountId); if (acc.AccountType == "Checking" || acc.AccountType == "Business") { acc.Amount += amount; CreateTransaction(new Transaction(accountId, amount, "Deposit")); } else { Console.WriteLine("Cannot deposit into this account."); } } catch (Exception ex) { Console.WriteLine("Cannot find account of that id"); } }
// Delete Check public bool CanDelete(User user, int givenAccountID) { bool deletePossible = false; if (user.GoodStanding) { AccountDAL accountDAL = new AccountDAL(); var account = accountDAL.GetAccountDAL(user, givenAccountID); if (account.CurrentBalance > 0) { deletePossible = true; return(deletePossible); } else { return(deletePossible); } } else { return(deletePossible); } }
public ActionResult SetPassword(SetPasswordViewModel model) { var qs = Request.UrlReferrer.Query; var parsed = HttpUtility.ParseQueryString(qs); var userId = parsed["userID"]; string name = parsed["name"]; string email = parsed["email"]; if (String.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(email)) { ModelState.AddModelError("", BusinessConstants.UserNotFound); return(View()); } if (ModelState.IsValid && AccountDAL.SetPasswordForUser(model, name, email)) { ViewBag.Status = true; ModelState.Clear(); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// 开设真实账户,录入信息到数据库 /// </summary> /// <param name="account">用户基础信息</param> /// <param name="profe">开户者职业信息</param> /// <param name="personalInfo">个人信息</param> /// <param name="tradingInfo">从事交易信息</param> /// <returns>返回录入结果</returns> public int ApplyForLiveAccount(Account account, ProfessionInfo profe, PersonalInformation personalInfo) { try { //个人信息 personalInfo = new PersonalInformationDAL().AddPersonalInformation(personalInfo); if (personalInfo == null) { return(0); } profe.PersonalInformationId = personalInfo.InformationId; //雇主信息 profe = new ProfessionInfoDAL().AddProfessionInfo(profe); if (profe == null) { return(0); } //基础信息 account.InformationId = profe.ProfessionInfoId; account = new AccountDAL().AddAccount(account); if (account == null) { return(0); } return(account.AccountId); } catch (Exception) { return(0); } }
public ActionResult Register(FormCollection f) { string email = f["txtEmail"]; string password = f["txtPassword"]; string fullName = f["txtFullname"]; string bDate = f["slBirthDay"]; string bMonth = f["slbirthMonth"]; string bYear = f["slbirthYear"]; string gender = f["slGender"]; string address = f["txtAddress"]; bool poli = (f["cbPoli"] == "on") ? true : false; string s = bYear + "-" + bMonth + "-" + bDate; AccountDAL accountDal = new AccountDAL(); bool checkExist = accountDal.checkExist(email); if (checkExist == false) { DateTime bd = Convert.ToDateTime(s); DateTime today = DateTime.Today; User_Account u_account = new User_Account { Email = email, Password = password, Full_Name = fullName, Birthday = bd, Gender = gender, Address = address, Cancel_Amount = 0, created_Date = today }; accountDal.registerAccount(email, password, fullName, bd, gender, address, today); Session["USER"] = u_account; Session["DATE"] = bDate; Session["MONTH"] = bMonth; Session["YEAR"] = bYear; Session["GENDER"] = gender; return(RedirectToAction("Index", "Home")); } else { Session["ERROR"] = "Your Email is existed!!!"; return(RedirectToAction("Login", "Login")); } }
public JsonResult GetRights(string xmlData) { List <List <string> > listarray = new List <List <string> >(); AccountDAL objAccount = new AccountDAL(); try { DataTable dt = objAccount.getRight(xmlData).Tables[0]; List <String> columnlist = (from dc in dt.Columns.Cast <DataColumn>() select dc.ColumnName).ToList(); listarray.Add(columnlist); foreach (string clmnName in columnlist) { List <String> itm = new List <String>(); itm.Add(clmnName); itm.Add(dt.Rows[0][clmnName].ToString()); listarray.Add(itm); } //List<String> columnlist = (from dc in dt.Columns.Cast<DataColumn>() // select dc.ColumnName).ToList(); //listarray.Add(columnlist); //foreach (DataRow dr in dt.Rows) //{ // List<String> jst = dr.ItemArray.Select(o => o.ToString()).ToList(); // listarray.Add(jst); //} } catch (Exception ex) { Utility.ReportError("HomeController :GetRights :: ", ex, xmlData); } return(Json(listarray)); }
public bool ValidateRedHawkToken(string redHawkTokenUsername, string redHawkTokenPassword) { EncryptDecrypt encryptDecrypt = new EncryptDecrypt(); LoginModel loginModel = new LoginModel(); IEnumerable <LoginModel> tempLogin; if (!string.IsNullOrEmpty(redHawkTokenUsername)) { loginModel.UserName = redHawkTokenUsername; } else { return(false); } if (!string.IsNullOrEmpty(redHawkTokenPassword)) { loginModel.Password = encryptDecrypt.Decrypt(redHawkTokenPassword); } else { return(false); } AccountDAL accountDAL = new AccountDAL(); tempLogin = accountDAL.ValidateUser(loginModel); if (tempLogin.Count() > 0) { return(true); } else { return(false); } }
public ActionResult ForgotPassword(ForgotPasswordViewModel model) { try { if (!ModelState.IsValid) { return(View()); } if (AccountDAL.CheckforUser(model)) { return(RedirectToAction("SetPassword", "manage", new { @name = model.UserName, @email = model.Email })); } else { ModelState.AddModelError("", BusinessConstants.UserNotFound); return(View()); } } catch (Exception ex) { ModelState.AddModelError("", BusinessConstants.contactAdmin); return(View()); } }
private async void SignInButtonClicked(object sender, EventArgs e) { if (IsValid()) { UserDto userDto = new UserDto { User = new UserModel { Email = _usernameEntry.Text.Trim(), Password = _passwordEntry.Text.Trim() } }; AccountDAL accountDAL = new AccountDAL(); accountDAL.ValidateUser(userDto); if (userDto.ErrCode == Enums.ErrorCode.OK) { App.Current.MainPage = new ListPage(); } else { await DisplayAlert("Academy", userDto.ErrCode.ToString(), "Cancel"); } } }
/// <summary> /// Credit type of transaction with mode of transaction as withdrawal slip. /// </summary> /// <param name="accountID">Uniquely generated account ID.</param> /// <param name="amount">Amount to be credited.</param> /// <returns>Determinates whether the amount is credited by withdrawal slip.</returns> public async Task <bool> CreditTransactionByDepositSlipBL(Guid accountID, double amount) { bool transactionWithdrawal = false; try { AccountDAL accountnoexist = new AccountDAL(); if (accountnoexist.AccountIDExists(accountID) == true && (amount <= 50000) && (amount > 0)) { await Task.Run(() => { TransactionDAL transactionDAL = new TransactionDAL(); transactionDAL.CreditTransactionByDepositSlipDAL(accountID, amount); transactionWithdrawal = true; }); } return(transactionWithdrawal); } catch (PecuniaException ex) { throw new CreditSlipException(ex.Message); } }
public static bool Validate(string username, string password) { return(AccountDAL.Validate(username, password)); }
public static bool update(int id, string password) { return(AccountDAL.update(id, password)); }
public static bool Insert(int id, string name, string city, string email, string password, string mob) { return(AccountDAL.Insert(id, name, city, email, password, mob)); }
public CheckingsController(ApplicationDbContext context, IHttpContextAccessor contextAccessor) { string uid = contextAccessor.HttpContext.User.Identity.Name; DAL = new AccountDAL(context, uid); }
public void Delete(int id) { AccountDAL dalObject = new AccountDAL(); dalObject.Delete(id); }
public void Edit(Account entity) { AccountDAL dalObject = new AccountDAL(); dalObject.Edit(entity); }
public void Add(Account entity) { AccountDAL dalObject = new AccountDAL(); dalObject.Add(entity); }
public void Add(Account entity, int schoolId) { AccountDAL dalObject = new AccountDAL(); dalObject.Add(entity, schoolId); }
// UPDATE // Withdraw Check public bool CanWithdraw(User user, int givenAccountID, double withdrawAmount) { bool withdrawPossible; AccountDAL accountDAL = new AccountDAL(); var account = accountDAL.GetAccountDAL(user, givenAccountID); double remainingBalance = account.CurrentBalance - withdrawAmount; switch (account.AccountType) { case "Checking Account": if (remainingBalance > 0) { withdrawPossible = true; } else { withdrawPossible = false; } break; case "Business Account": if (remainingBalance > 0) { withdrawPossible = true; } else { BusinessAccount biz = (BusinessAccount)account; if (biz.IsOverdraft) { withdrawPossible = false; } else { withdrawPossible = true; } } break; case "Loan Account": LoanAccount loan = (LoanAccount)account; if (withdrawAmount > loan.MaximumWithdrawal) { withdrawPossible = false; } else { if (remainingBalance > loan.MaximumBalance) { withdrawPossible = true; } else { withdrawPossible = false; } } break; case "Term Deposit": if (remainingBalance > 0) { withdrawPossible = true; } else { withdrawPossible = false; } break; default: withdrawPossible = false; Console.WriteLine("Type not detected. Major Failure!"); break; } return(withdrawPossible); }
private void UpdateStatus(Account Account) { AccountStatusLog log = CreateLog(Account); // Data access component declarations. var AccountDAC = new AccountDAL(); var AccountStatusLogDAC = new AccountStatusLogDAL(); using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { // Step 1 - Calling UpdateById on AccountDAC. AccountDAC.UpdateStatus(Account); // Step 2 - Calling Create on AccountStatusLogDAC. AccountStatusLogDAC.Create(log); ts.Complete(); } }
//Create public void CreateAccountBL(User user, IAccount account) { AccountDAL accountDAL = new AccountDAL(); accountDAL.CreateAccountDAL(user, account); }
public void PayLoanInstallment(int customerId, int accountId, double amount) { var customerAccounts = AccountDAL.GetCustomerAccounts(customerId); Account acc = customerAccounts.SingleOrDefault(x => x.Id == accountId); }
/// <summary> /// ListAccountsByEmployee business method. /// </summary> /// <param name="startRowIndex">A startRowIndex value.</param> /// <param name="maximumRows">A maximumRows value.</param> /// <param name="sortExpression">A sortExpression value.</param> /// <param name="employee">A employee value.</param> /// <param name="category">A category value.</param> /// <param name="status">A status value.</param> /// <returns>Returns a List<Account> object.</returns> public List<Account> ListAccountsByEmployee(int maximumRows, int startRowIndex, string sortExpression, string employee, AccountCategories? category, AccountStatuses? status, out int totalRowCount) { List<Account> result = default(List<Account>); if (string.IsNullOrWhiteSpace(sortExpression)) sortExpression = "DateSubmitted DESC"; // Data access component declarations. var AccountDAC = new AccountDAL(); // Step 1 - Calling Select on AccountDAC. result = AccountDAC.Select(maximumRows, startRowIndex, sortExpression, employee, category, status); // Step 2 - Get count. totalRowCount = AccountDAC.Count(employee, category, status); return result; }
public void CreateAccount(Account account) { AccountDAL.CreateAccount(account); }
/// <summary> /// GetAccountById business method. /// </summary> /// <param name="AccountID">A AccountID value.</param> /// <returns>Returns a Account object.</returns> public Account GetAccountById(long AccountID) { Account result = default(Account); // Data access component declarations. var AccountDAC = new AccountDAL(); // Step 1 - Calling SelectById on AccountDAC. result = AccountDAC.SelectById(AccountID); return result; }