public async Task <ActionResult <TypeAccount> > PostTypeAccount(TypeAccount typeAccount)
        {
            _context.typeAccount.Add(typeAccount);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTypeAccount", new { id = typeAccount.Id }, typeAccount));
        }
Ejemplo n.º 2
0
        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
            {
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 public Account(TypeAccount type, Customer customer, decimal balance, double IR)
 {
     this.Type         = type;
     this.Customer     = customer;
     this.InterestRate = IR;
     this.Balance      = balance;
 }
Ejemplo n.º 6
0
 public Account(TypeAccount typeAccount, double balance, double credit, string name)
 {
     TypeAccount = typeAccount;
     Balance     = balance;
     Credit      = credit;
     Name        = name;
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 11
0
 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"));
 }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        public ActionResult <TypeAccount> AddAccountType(TypeAccount addedAccount)
        {
            TypeAccount account = accountDAO.AddAccountType(addedAccount);

            if (account != null)
            {
                return(Ok(account));
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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;
            }
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        // 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));
        }
Ejemplo n.º 21
0
        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();
        }
Ejemplo n.º 22
0
        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); });
        }
Ejemplo n.º 24
0
        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)));
        }
Ejemplo n.º 25
0
        //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);
        }
Ejemplo n.º 26
0
        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;
            }
        }
Ejemplo n.º 27
0
        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)));
        }
Ejemplo n.º 28
0
        //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);
        }
Ejemplo n.º 29
0
 public async Task <TypeAccount> Update(TypeAccount entity)
 {
     return(await this._asyncRepository.UpdateAsync(entity));
 }
Ejemplo n.º 30
0
 public BankAccount(int balance, TypeAccount type)
 {
     this.numberAccount = NumberRnd();
     this.balance       = balance;
     this.type          = type;
 }
Ejemplo n.º 31
0
 public BankAccount(TypeAccount type)
 {
     this.numberAccount = NumberRnd();
     this.type          = type;
 }