public ActionResult ChangePassword(Tbl_Account model)
        {
            using (var Db = new ProjectWebEntities())
            {
                try
                {
                    string oldPass = Request.Form["OldPassword"] ?? "";
                    if (Check_Login(model.UserName, oldPass))
                    {
                        string key = GlobalVariables.Cus_Key;
                        if (model.UserName == "BeeAdmin")
                        {
                            key = GlobalVariables.Bee_Key;
                        }
                        var account = Db.Tbl_Account.FirstOrDefault(p => p.UserName == model.UserName);

                        model.Password          = Md5.VT_Encrypt(key, model.Password);
                        account.Password        = model.Password;
                        Db.Entry(account).State = EntityState.Modified;
                        Db.SaveChanges();
                    }
                    else
                    {
                        return(View(model));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("An Error Happened! ", ex);
                }
                return(RedirectToAction("Index", "Login"));
            }
        }
Beispiel #2
0
        public static Account MapFrom(this Tbl_Account account)
        {
            var openingBalance = account.OpeningBalance;
            var totalRevenue   = account.Tbl_Transaction.Where(x => x.TransactionType == (int)TransactionType.Income).Sum(x => x.Amount);
            var totalExpense   = account.Tbl_Transaction.Where(x => x.TransactionType == (int)TransactionType.Expense).Sum(x => x.Amount);

            return(new Account
            {
                Id = account.Id,
                AccountName = account.AccountName,
                Number = account.Number,
                IBANNumber = account.IBANNumber,
                CurrencyId = account.CurrencyId,
                CurrencyName = account.Tbl_Currency?.Name ?? string.Empty,
                OpeningBalance = (openingBalance + totalRevenue) - totalExpense,
                BankName = account.BankName,
                BankPhone = account.BankPhone,
                BankAddress = account.BankAddress,
                DefaultAccount = account.DefaultAccount,
                IsEnabled = account.IsEnabled,
                Created_At = account.Created_At,
                Updated_At = account.Updated_At,
                CurrencySymbol = account.Tbl_Currency?.Symbol ?? string.Empty,
                SymbolPosition = account.Tbl_Currency?.SymbolPosition ?? string.Empty
            });
        }
Beispiel #3
0
        /// <summary>
        /// 创建新的 Tbl_Account 对象。
        /// </summary>
        /// <param name="id">Id 的初始值。</param>
        /// <param name="name">Name 的初始值。</param>
        /// <param name="zoneId">ZoneId 的初始值。</param>
        /// <param name="activeCode">ActiveCode 的初始值。</param>
        public static Tbl_Account CreateTbl_Account(int id, string name, int zoneId, string activeCode)
        {
            Tbl_Account tbl_Account = new Tbl_Account();

            tbl_Account.Id         = id;
            tbl_Account.Name       = name;
            tbl_Account.ZoneId     = zoneId;
            tbl_Account.ActiveCode = activeCode;
            return(tbl_Account);
        }
        public async Task <ActionResult> Index(Tbl_Account model, string returnUrl)
        {
            if (ModelState.IsValid && Check_Login(model.UserName, model.Password))
            {
                SetAuthCookie(model.UserName, true, null);
                return(RedirectToLocal(returnUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng.");
            TempData["Fail"] = "fail";
            return(View(model));
        }
Beispiel #5
0
        public ActionResult Create(FormCollection form)
        {
            using (var Db = new ProjectWebEntities())
            {
                var user = new Tbl_Account();
                try
                {
                    user.UserName = form["username"];
                    if (checkInvaild(user.UserName))
                    {
                        ViewBag.Message =
                            MessageHelper.GetWarningMessage("Tên tài khoản đã tồn tại, vui lòng chọn tên tài khoản khác");
                        SetGroupCheckbox(null);
                        return(View(user));
                    }


                    string pass = form["pass"];;
                    user.Password = Md5.VT_Encrypt(GlobalVariables.Cus_Key, pass);
                    user.Email    = form["email"];
                    user.IsUse    = true;

                    if (form["chkGroups"] != null)
                    {
                        string[] arrayGroup = form["chkGroups"].Split(',');
                        if (user.Tbl_Group == null)
                        {
                            user.Tbl_Group = new List <Tbl_Group>();
                        }
                        foreach (string grId in arrayGroup)
                        {
                            int groupId = Convert.ToInt32(grId);
                            var group   = Db.Tbl_Group.SingleOrDefault(w => w.Id == groupId);
                            user.Tbl_Group.Add(group);
                        }
                    }
                    Db.Tbl_Account.Add(user);
                    Db.SaveChanges();

                    //SendEmailPassword
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    logger.Error("An Error Happened! ", ex);
                }
                SetGroupCheckbox(user.Tbl_Group);
                return(RedirectToAction("Index", "Account"));
            }
        }
        public Tbl_Account Post(Tbl_Account account)
        {
            UnitOfWork  uo              = null;
            Tbl_Account accountToSave   = null;
            bool        editingRequired = true;

            try
            {
                uo            = new UnitOfWork("CCATDBEntities");
                accountToSave = uo.AccountRepository.GetById(account.AccountNumber);
                if (accountToSave == null)
                {
                    accountToSave          = new Tbl_Account();
                    accountToSave.AgencyId = (account.AgencyId == null) ? uo.Repository <Tbl_Agency>().GetAll().Where(r => r.Name == account.Tbl_Agency.Name).SingleOrDefault().AgencyId:account.AgencyId;
                    editingRequired        = false;
                }
                accountToSave.AccountNumber       = account.AccountNumber;
                accountToSave.Address             = account.Address;
                accountToSave.Address2            = account.Address2;
                accountToSave.City                = account.City;
                accountToSave.DebtCurrentBalance  = account.DebtCurrentBalance;
                accountToSave.DebtPurchaseBalance = account.DebtPurchaseBalance;
                accountToSave.FirstName           = account.FirstName;
                accountToSave.HomePhone           = account.HomePhone;
                accountToSave.LastFourSSN         = account.LastFourSSN;
                accountToSave.LastName            = account.LastName;
                accountToSave.MobilePhone         = account.MobilePhone;
                accountToSave.StateId             = account.StateId;
                accountToSave.WorkPhone           = account.WorkPhone;
                accountToSave.Zip = account.Zip;

                if (editingRequired)
                {
                    uo.Repository <Tbl_Account>().Update(accountToSave);
                }
                else
                {
                    uo.Repository <Tbl_Account>().Add(accountToSave);
                }
                uo.Save();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(account);
        }
 private void PopulateDebtInfo(Tbl_Account account, Tbl_ComplaintMain complaint)
 {
     complaint.Tbl_Account.AccountNumber       = account.AccountNumber;
     complaint.Tbl_Account.FirstName           = account.FirstName;
     complaint.Tbl_Account.LastName            = account.LastName;
     complaint.Tbl_Account.Address             = account.Address;
     complaint.Tbl_Account.City                = account.City;
     complaint.Tbl_Account.StateId             = account.StateId;
     complaint.Tbl_Account.Zip                 = account.Zip;
     complaint.Tbl_Account.LastFourSSN         = account.LastFourSSN;
     complaint.Tbl_Account.MobilePhone         = account.MobilePhone;
     complaint.Tbl_Account.HomePhone           = account.HomePhone;
     complaint.Tbl_Account.WorkPhone           = account.WorkPhone;
     complaint.Tbl_Account.DebtCurrentBalance  = account.DebtCurrentBalance;
     complaint.Tbl_Account.DebtPurchaseBalance = account.DebtPurchaseBalance;
     complaint.Tbl_Account.CreditorName        = account.CreditorName;
 }
Beispiel #8
0
 public ActionResult destroyAccount([DataSourceRequest] DataSourceRequest request, Tbl_Account model)
 {
     using (var Db = new ProjectWebEntities())
     {
         try
         {
             var u = Db.Tbl_Account.SingleOrDefault(w => w.Id == model.Id);
             Db.Tbl_Account.Remove(u);
             Db.SaveChanges();
         }
         catch (Exception ex)
         {
             logger.Error("An Error Happened! ", ex);
         }
         return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
     }
 }
        public int Add(AccountDTO data)
        {
            try
            {
                var Context = new DB_SYSBANKEntities();
                var STM     = new Tbl_Statement();
                var TRS     = new Tbl_Transaction();
                var oi      = new Tbl_Account();
                oi.User_ID      = data.User_ID;
                oi.IBAN         = data.IBAN;
                oi.TotalBalance = data.TotalBalance;
                oi.UpdateDate   = data.UpdateDate;
                oi.UpdateBy     = data.UpdateBy;
                oi.IsActive     = data.IsActive;
                if (data.TotalBalance != 0 && data.TotalBalance != null)
                {
                    STM.IBANTo     = data.IBAN;
                    STM.FullMoney  = data.TotalBalance;
                    STM.Fee        = data.TotalBalance * Convert.ToDecimal(0.01);
                    STM.Deposit    = data.TotalBalance - STM.Fee;
                    STM.Channel    = "Website";
                    STM.CreateDate = DateTime.Now;
                    string ReqNo = Guid.NewGuid().ToString();
                    STM.Req_No = ReqNo;

                    TRS.IBAN        = data.IBAN;
                    TRS.FullMoney   = data.TotalBalance;
                    TRS.Fee         = data.TotalBalance * Convert.ToDecimal(0.01);
                    TRS.Deposit     = data.TotalBalance - STM.Fee;
                    TRS.Balance     = STM.Deposit;
                    TRS.PrevBalance = 0;
                    TRS.CreateDate  = DateTime.Now;
                    TRS.Req_No      = ReqNo;

                    oi.TotalBalance = data.TotalBalance - STM.Fee;
                }

                Context.Tbl_Account.Add(oi);
                if (data.TotalBalance != 0 && data.TotalBalance != null)
                {
                    Context.Tbl_Statement.Add(STM);
                    Context.Tbl_Transaction.Add(TRS);
                }
                int result = Context.SaveChanges();

                return(result);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    var _Name = eve.Entry.Entity.GetType().Name;
                    var State = eve.Entry.State;
                    foreach (var ve in eve.ValidationErrors)
                    {
                        var pName = ve.PropertyName;
                        var Msg   = ve.ErrorMessage;
                    }
                }
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #10
0
 /// <summary>
 /// 架构中不存在 Tbl_Account 的注释。
 /// </summary>
 public void AddToTbl_Account(Tbl_Account tbl_Account)
 {
     base.AddObject("Tbl_Account", tbl_Account);
 }
Beispiel #11
0
        public int Add(StatementDTO data)
        {
            try
            {
                string ReqNo   = Guid.NewGuid().ToString();
                var    Context = new DB_SYSBANKEntities();
                var    oi      = new Tbl_Statement();
                oi.IBANFrom  = data.IBANFrom;
                oi.IBANTo    = data.IBANTo;
                oi.FullMoney = data.FullMoney;
                oi.Fee       = data.Fee;
                oi.Deposit   = data.Deposit;
                oi.Withdraw  = data.Withdraw;

                oi.Channel    = data.Channel;
                oi.CreateDate = data.CreateDate;
                oi.CreateBy   = data.CreateBy;
                oi.Req_No     = ReqNo;
                Context.Tbl_Statement.Add(oi);


                var oiAcc  = new Tbl_Account();
                var TRST   = new Tbl_Transaction();
                var TRS    = new Tbl_Transaction();
                var oiAcc2 = new Tbl_Account();
                if (data.IBANFrom != null)
                {
                    TRS.IBAN        = data.IBANFrom;
                    TRS.FullMoney   = data.FullMoney;
                    TRS.Withdraw    = data.FullMoney;
                    TRS.PrevBalance = data.PrevBalanceFrom;
                    TRS.Balance     = TRS.PrevBalance - TRS.FullMoney;
                    TRS.CreateDate  = DateTime.Now;
                    TRS.CreateBy    = data.CreateBy;
                    TRS.Req_No      = ReqNo;
                    Context.Tbl_Transaction.Add(TRS);
                    oiAcc2 = Context.Tbl_Account.FirstOrDefault(i => i.IBAN == data.IBANFrom);
                    if (oiAcc2 != null)
                    {
                        if (oiAcc2.TotalBalance != null)
                        {
                            oiAcc2.TotalBalance = oiAcc2.TotalBalance - TRS.FullMoney;
                        }
                        else
                        {
                            oiAcc2.TotalBalance = TRS.FullMoney;
                        }
                        oiAcc2.UpdateBy   = data.CreateBy;
                        oiAcc2.UpdateDate = DateTime.Now;
                    }
                }

                if (data.IBANTo != null)
                {
                    TRST.IBAN        = data.IBANTo;
                    TRST.FullMoney   = data.FullMoney;
                    TRST.Fee         = data.FullMoney * Convert.ToDecimal(0.01);
                    TRST.Deposit     = data.FullMoney - TRST.Fee;
                    TRST.PrevBalance = data.PrevBalanceTo;
                    TRST.Balance     = TRST.PrevBalance + TRST.Deposit;
                    TRST.CreateBy    = data.CreateBy;
                    TRST.CreateDate  = DateTime.Now;
                    TRST.Req_No      = ReqNo;
                    Context.Tbl_Transaction.Add(TRST);
                    oiAcc = Context.Tbl_Account.FirstOrDefault(i => i.IBAN == data.IBANTo);
                    if (oiAcc != null)
                    {
                        if (oiAcc.TotalBalance != null)
                        {
                            oiAcc.TotalBalance = oiAcc.TotalBalance + TRST.Deposit;
                        }
                        else
                        {
                            oiAcc.TotalBalance = TRST.Deposit;
                        }
                        oiAcc.UpdateBy   = data.CreateBy;
                        oiAcc.UpdateDate = DateTime.Now;
                    }
                }



                int result = Context.SaveChanges();
                return(result);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    var _Name = eve.Entry.Entity.GetType().Name;
                    var State = eve.Entry.State;
                    foreach (var ve in eve.ValidationErrors)
                    {
                        var pName = ve.PropertyName;
                        var Msg   = ve.ErrorMessage;
                    }
                }
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }