public async Task <ActionResult <TypeAccount> > PostTypeAccount(TypeAccount typeAccount) { _context.typeAccount.Add(typeAccount); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeAccount", new { id = typeAccount.Id }, typeAccount)); }
private void txbNameAccount_TextChanged(object sender, EventArgs e) { try { if (dgvAccount.SelectedCells.Count > 0) { int id = (int)dgvAccount.SelectedCells[0].OwningRow.Cells["Type"].Value; TypeAccount typeaccount = TypeAccountDAO.Instance.GetTypeAccountById(id); cbTypeAccount.SelectedItem = typeaccount; int index = -1; int i = 0; foreach (TypeAccount item in cbTypeAccount.Items) { if (item.Id == typeaccount.Id) { index = i; break; } i++; } cbTypeAccount.SelectedIndex = index; } } catch { } }
private void txtUserName_TextChanged(object sender, EventArgs e) { string name = dtAccount.SelectedCells[0].OwningRow.Cells["nameTypeAccount"].Value.ToString(); TypeAccount type = TypeAccountDAO.Instance.GetTypeAccountByName(name); cmbType.SelectedIndex = cmbType.FindStringExact(type.NameTypeAccount); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] TypeAccount typeAccount) { if (id != typeAccount.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(typeAccount); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeAccountExists(typeAccount.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(typeAccount)); }
public Account(TypeAccount type, Customer customer, decimal balance, double IR) { this.Type = type; this.Customer = customer; this.InterestRate = IR; this.Balance = balance; }
public Account(TypeAccount typeAccount, double balance, double credit, string name) { TypeAccount = typeAccount; Balance = balance; Credit = credit; Name = name; }
public IActionResult OnPost() { IActionResult result = RedirectToPage(); Account account = repository.Validate(new Account { Correo = this.Correo, Password = this.Password }); if (account.Id > 0) { TypeAccount type = (TypeAccount)account.Type; switch (type) { case TypeAccount.STUDENT: result = RedirectToPage("Profile", "OnGet", account); break; case TypeAccount.ADMIN: result = RedirectToPage("EstudioSocioeconomico", "OnGet", account); break; case TypeAccount.EVALUATOR: result = RedirectToPage("Evaluatios"); break; } } return(result); }
public Account(TypeAccount typeAccount, double balance, double credit, string name) { this.TypeAccount = typeAccount; this.Balance = balance; this.Credit = credit; this.Name = name; }
public async Task <String> PutTypeAccount(int id, TypeAccount typeAccount) { if (id != typeAccount.Id) { return("0"); } _context.Entry(typeAccount).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeAccountExists(id)) { return("0"); } else { throw; } } return("{\"id\":" + id + ",\" stt\":\"" + typeAccount.Status + "\"}"); }
public Account(TypeAccount type, Customer customer, decimal balance, double IR) { this.Type = type; this.Customer = customer; this.InterestRate = IR; this.Balance = balance; }
public async Task <IActionResult> Create([Bind("Id,Name,Status")] TypeAccount typeAccount) { if (ModelState.IsValid) { _context.Add(typeAccount); await _context.SaveChangesAsync(); } TempData["result"] = "Thêm mới thành công"; return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,Name")] TypeAccount typeAccount) { if (ModelState.IsValid) { _context.Add(typeAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeAccount)); }
private Account AddAccount(Client client, TypeAccount type) { string accNumber = DateTime.Now.ToLongTimeString(); int newId = GetNewId(); Account acc = new Account() { Id = newId, Number = accNumber, TypeAccount = type, ClientId = client.Id }; _accounts.Add(acc); return(acc); }
public ActionResult <TypeAccount> AddAccountType(TypeAccount addedAccount) { TypeAccount account = accountDAO.AddAccountType(addedAccount); if (account != null) { return(Ok(account)); } else { return(NotFound()); } }
public List <TypeAccount> LoadlistAccount() { List <TypeAccount> typeAccount = new List <TypeAccount>(); string query = "select * from TypeAccount"; DataTable data = DataProvider.Instance.ExcuteQuery(query); foreach (DataRow item in data.Rows) { TypeAccount account = new TypeAccount(item); typeAccount.Add(account); } return(typeAccount); }
public TypeAccount GetTypeAccountById(int id) { TypeAccount typeaccount = null; string query = "select * from TypeAccount where id= " + id; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { typeaccount = new TypeAccount(item); return(typeaccount); } return(typeaccount); }
public List <TypeAccount> GetListTypeAccount() { List <TypeAccount> TypeAccountList = new List <TypeAccount>(); string query = "select * from TypeAccount"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { TypeAccount typeaccount = new TypeAccount(item); TypeAccountList.Add(typeaccount); } return(TypeAccountList); }
public void ActivateAccount(TypeAccount type) { switch (type) { case TypeAccount.FRIEND: if (this.Panels.Contains(_panelAccountPerso)) { this.Panels.Remove(_panelAccountPerso); } if (this.Panels.Contains(_panelAccountPro)) { this.Panels.Remove(_panelAccountPro); } if (!this.Panels.Contains(_panelAccountShared)) { this.Panels.Add(_panelAccountShared); } break; case TypeAccount.PERSONNAL: if (this.Panels.Contains(_panelAccountPro)) { this.Panels.Remove(_panelAccountPro); } if (this.Panels.Contains(_panelAccountShared)) { this.Panels.Remove(_panelAccountShared); } if (!this.Panels.Contains(_panelAccountPerso)) { this.Panels.Add(_panelAccountPerso); } break; case TypeAccount.PROFESSIONNAL: if (this.Panels.Contains(_panelAccountPerso)) { this.Panels.Remove(_panelAccountPerso); } if (this.Panels.Contains(_panelAccountShared)) { this.Panels.Remove(_panelAccountShared); } if (!this.Panels.Contains(_panelAccountPro)) { this.Panels.Add(_panelAccountPro); } break; } }
public List <TypeAccount> GetTypeAccount() { List <TypeAccount> tableList = new List <TypeAccount>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT DISTINCT CASE WHEN Type = 0 THEN N'Nhân viên' WHEN Type = 1 THEN N'Admin' END AS [Type] FROM dbo.Account"); foreach (DataRow item in data.Rows) { TypeAccount table = new TypeAccount(item); tableList.Add(table); } return(tableList); }
// GET: Admin/TypeAccounts public async Task <IActionResult> Index(int?id) { TypeAccount typeAccount = null; if (id != null) { typeAccount = await _context.typeAccount.FirstOrDefaultAsync(m => m.Id == id); } if (TempData["result"] != null) { ViewBag.SuccesMgs = TempData["result"]; } return(View(typeAccount)); }
private void Initialization() { Role AdminRole = new Role { Name = "Administrator" }; Role UserRole = new Role { Name = "User" }; Role ModRole = new Role { Name = "Moderator" }; TypeAccount TypeFiz = new TypeAccount { Name = "Физическое лицо" }; TypeAccount TypeUr = new TypeAccount { Name = "Юридическое лицо" }; Status StatusOpen = new Status { Name = "Открыта" }; Status StatusClose = new Status { Name = "Закрыта" }; Company CompanySibItPro = new Company { Name = "SibItProject", City = "Красноярск" }; Contract ContractSibItPro = new Contract { Uid = Guid.NewGuid(), CteateTime = DateTime.Now, Balance = 1000 }; Account Administrator = new Account { Login = "******", Password = HashMD5("Admin"), Role = AdminRole, Email = "*****@*****.**", Phone = "+79607522216", Name = "Сергей", SecondName = "Иванов", SurName = "Александнович", Company = CompanySibItPro, TypeAccount = TypeUr, Contract = ContractSibItPro }; _context.TypeAccounts.Add(TypeFiz); _context.TypeAccounts.Add(TypeUr); _context.Status.Add(StatusOpen); _context.Status.Add(StatusClose); _context.Roles.Add(AdminRole); _context.Roles.Add(ModRole); _context.Roles.Add(UserRole); _context.Accounts.Add(Administrator); _context.SaveChangesAsync(); }
public async Task <IActionResult> GetTypeAccountById(Int64 TypeAccountId) { TypeAccount Items = new TypeAccount(); try { Items = await _context.TypeAccount.Where(q => q.TypeAccountId == TypeAccountId).FirstOrDefaultAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(Items))); }
public MainViewModel() { var tmp = DataProvider.Ins.DB.QUYDINHs.Where(x => x.MAQD == 1).SingleOrDefault(); SettingWindowVM.LIMITED_IMPORT = tmp.NHAPTOITHIEU; SettingWindowVM.LIMITED_UNSTOCK = tmp.TONTOITHIEU; SettingWindowVM.MAXIMUM_CUSTOMERDUE = tmp.NOTOIDA; SettingWindowVM.MAXIMUM_IMPORT = tmp.NHAPTOIDA; LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { UpdatePromotionData(); Isloaded = true; p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginViewModel; if (loginVM.IsLogin) { DisplayName = LoginAccount.TENHIENTHI; TypeAccount = new TypeAccount(LoginAccount.LOAITK); TypeAccountDisplay = TypeAccount.Display; Image = LoginAccount.HINHANH; Img = ByteToImageConverter.Ins.LoadImage(Image); p.Show(); } else { p.Close(); } }); PressBtnBookMngCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenBookMngWindow(p); }); PressBtnAccountCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenAccountWindow(p); }); PressBtnBusinessCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenBusinesstWindow(p); }); PressBtnSettingCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenSettingWindow(p); }); PressBtnReportCommand = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenReportWindow(p); }); PressBtnStatisticCmd = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { OpenStatisticsWindow(p); }); LogOutCmd = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { LogOut(p); }); ExitCmd = new RelayCommand <Window>((p) => { return(p == null ? false : true); }, (p) => { Exit(p); }); }
public async Task <IActionResult> Delete([FromBody] TypeAccount _TypeAccount) { TypeAccount _TypeAccountq = new TypeAccount(); try { _TypeAccountq = _context.TypeAccount .Where(x => x.TypeAccountId == (Int64)_TypeAccount.TypeAccountId) .FirstOrDefault(); _context.TypeAccount.Remove(_TypeAccountq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_TypeAccountq))); }
//Adds a type to the user_favorited_types table. This method is called when you switch a checkbox on in the questionaire. public TypeAccount AddAccountType(TypeAccount account) { try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO user_favorited_types (user_id, type_id)" + " VALUES (@userId, @typeId)", conn); cmd.Parameters.AddWithValue("@userId", account.UserId); cmd.Parameters.AddWithValue("@typeId", account.TypeId); cmd.ExecuteNonQuery(); } } catch (SqlException) { throw; } return(account); }
private void txtAccountID_TextChanged(object sender, EventArgs e) { if (dgvAccount.SelectedCells.Count > 0) { int id = (int)dgvAccount.SelectedCells[0].OwningRow.Cells["Type"].Value; TypeAccount typeAccount = TypeAccountDAO.Intstance.GetCategoryAccountByID(id); int index = -1; int i = 0; foreach (TypeAccount item in cbbAccountType.Items) { if (item.ID == typeAccount.ID) { index = i; break; } i++; } cbbAccountType.SelectedIndex = index; } }
public async Task <ActionResult <TypeAccount> > Update([FromBody] TypeAccount _TypeAccount) { TypeAccount _TypeAccountq = _TypeAccount; try { _TypeAccountq = await(from c in _context.TypeAccount .Where(q => q.TypeAccountId == _TypeAccount.TypeAccountId) select c ).FirstOrDefaultAsync(); _context.Entry(_TypeAccountq).CurrentValues.SetValues((_TypeAccount)); //_context.Bank.Update(_Bankq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_TypeAccountq))); }
//BLOATERS: Long list parameters: More than three parameters //BLOATERS: Long method: More than three parameters //BLOATERS: Primitive Obsession: //Moving Features between Objects - Extract Class public static bool ChecksIfAvailable(int mountLoan, string account, TypeAccount typeAccount, DateTime endPaid, float feed) { bool accountExists = false; //Object-Orientation Abusers - Temporary Field float total = 0; float fby = 0; int years = 0; for (int i = 0; i < accounts.Length; i++) { if (string.Compare(accounts[i], account, true) == 0) { accountExists = true; // Simplifying Conditional Expressions:Remove Control Flag i = accounts.Length; } } int mountMaxToLoad = 0; if (accountExists) { // verify max loan according type account // Dispensables - Comments // Object - Orientation Abusers: Switch Statements // Simplifying Conditional Expressions - Decompose Conditional switch (typeAccount) { case TypeAccount.GOLD: mountMaxToLoad = 10000; break; case TypeAccount.SILVER: mountMaxToLoad = 5000; break; case TypeAccount.BRONZE: mountMaxToLoad = 1000; break; default: mountMaxToLoad = 500; break; } if (mountLoan < mountMaxToLoad) { //Dispensable-comments // get number of years years = endPaid.Year - DateTime.Today.Year; // feed by years fby = (feed * mountLoan) * years; total = fby + mountLoan; Console.WriteLine(Constants.LoanMessage, LoanStatus.Accepted.ToString(), account); Console.WriteLine(Constants.LoanDetail, account, total, years, feed); return(true); } else { //Dispensable: duplicate code Console.WriteLine(Constants.LoanMessage, LoanStatus.Denied.ToString(), account); return(false); } } Console.WriteLine(Constants.LoanMessage, LoanStatus.Denied.ToString(), account); return(false); }
public async Task <TypeAccount> Update(TypeAccount entity) { return(await this._asyncRepository.UpdateAsync(entity)); }
public BankAccount(int balance, TypeAccount type) { this.numberAccount = NumberRnd(); this.balance = balance; this.type = type; }
public BankAccount(TypeAccount type) { this.numberAccount = NumberRnd(); this.type = type; }