Пример #1
0
        public ActionResult RechargeMoney(RechargeMoney model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            string updateBy = AccountInfo.GetUserName(Request);
            string username = model.Username;
            int amountOfMoney = 0;
            if (!string.IsNullOrEmpty(model.AmountOfMoney.ToString()))
            {
                amountOfMoney = model.AmountOfMoney;
            }
            string transactionContent = "Nạp tiền";
            DateTime date = DateTime.Now;
            int transactionType = 2;
            UserInfoDetailTableAdapter userInfoAdapter = new UserInfoDetailTableAdapter();
            DataTable userInfoDataTable = userInfoAdapter.GetDataByUsername(username);

            if (userInfoDataTable.Rows.Count != 1)
            {
                ModelState.AddModelError("", "Tên đăng nhập không tồn tại.");
                return View(model);
            }
            TransactionHistoryTableAdapter transactionAdapter = new TransactionHistoryTableAdapter();
            try
            {
                string transactionID = transactionAdapter.RechargeMoneyScalar(username, transactionType, amountOfMoney, transactionContent, null, false, date, updateBy, date).ToString();
                int id = int.Parse(transactionID);
                XmlSync.SaveTransactionHistoryXml(id, username, transactionType, amountOfMoney, transactionContent, null, false, date, updateBy, date, null);
                Session["rechargeMoney"] = "Giao dịch thành công!";
            }
            catch (Exception ex)
            {
                Log.ErrorLog(ex.Message);
                Session["rechargeMoney"] = "Giao dịch thất bại!";
            }

            return RedirectToAction("RechargeMoney", "Transaction");
        }
Пример #2
0
        public ActionResult EditUser(string username)
        {
            UserTypeTableAdapter userTypeAdapter = new UserTypeTableAdapter();
            DataTable userTypeDT = userTypeAdapter.GetData();

            List<SelectListItem> items = new List<SelectListItem>();
            foreach (DataRow row in userTypeDT.Rows)
            {
                items.Add(new SelectListItem { Text = row["TypeName"].ToString(), Value = row["TypeShortName"].ToString() });
            }
            ViewData["UserType"] = items;

            EditUserModel userInfo = new EditUserModel();
            UserInfoDetailTableAdapter userinfoAdapter = new UserInfoDetailTableAdapter();
            DataTable userinfoDataTable = userinfoAdapter.GetDataByUsername(username);

            try
            {
                userInfo.Username = username;
                userInfo.Name = userinfoDataTable.Rows[0]["Name"].ToString();
                userInfo.UserTypeID = (string)userinfoDataTable.Rows[0]["TypeShortName"];
                userInfo.Email = userinfoDataTable.Rows[0]["Email"].ToString();
                userInfo.Role = (int)userinfoDataTable.Rows[0]["Role"];
                userInfo.isActive = (bool)userinfoDataTable.Rows[0]["IsActive"];

                return View(userInfo);
            }
            catch (Exception ex)
            {
                Log.ErrorLog(ex.Message);
                return RedirectToAction("Error", "Error");
            }
        }
Пример #3
0
        public ActionResult UserInfo()
        {
            string username = AccountInfo.GetUserName(Request);

            UserinfoModel userinfo = new UserinfoModel();
            DataTable userInfoDataTable = new DataTable();
            UserInfoDetailTableAdapter userInfoDetailAdapter = new UserInfoDetailTableAdapter();
            UserInfoTableAdapter userInfoAdapter = new UserInfoTableAdapter();
            userInfoDataTable = userInfoAdapter.GetDataByUsername(username);
            string userTypeName = null;
            string email = null;
            if (!string.IsNullOrEmpty(userInfoDataTable.Rows[0]["TypeShortName"].ToString()))
            {
                userInfoDataTable = userInfoDetailAdapter.GetDataByUsername(username);
                userTypeName = (string)userInfoDataTable.Rows[0]["TypeName"];
                email = userInfoDataTable.Rows[0]["Email"].ToString();
            }
            else
            {
                AccountTableAdapter accountAdapter = new AccountTableAdapter();
                DataTable accountDataTable = new DataTable();
                accountDataTable = accountAdapter.GetDataByUsername(username);
                email = accountDataTable.Rows[0]["Email"].ToString();
            }
            DateTime date = DateTime.Parse(userInfoDataTable.Rows[0]["LastUpdatedMoney"].ToString());
            int amountOfMoney = (int)userInfoDataTable.Rows[0]["AmountOfMoney"];

            TransactionHistoryTableAdapter transactionAdapter = new TransactionHistoryTableAdapter();
            int? money = transactionAdapter.GetCurrentMoney(username, date);
            if (money == null)
            {
                money = 0;
            }

            amountOfMoney += money.Value;

            userinfo.Username = username;
            userinfo.Name = userInfoDataTable.Rows[0]["Name"].ToString();
            userinfo.TypeName = userTypeName;
            userinfo.Email = email;
            userinfo.AmountOfMoney = amountOfMoney;

            return View(userinfo);
        }
Пример #4
0
        public ActionResult DetailUser(string username)
        {
            UserinfoModel userinfo = new UserinfoModel();
            UserInfoDetailTableAdapter userinfoAdapter = new UserInfoDetailTableAdapter();
            DataTable userinfoDataTable = userinfoAdapter.GetDataByUsername(username);
            DateTime date = DateTime.Parse(userinfoDataTable.Rows[0]["LastUpdatedMoney"].ToString());
            int amountOfMoney = (int)userinfoDataTable.Rows[0]["AmountOfMoney"];

            TransactionHistoryTableAdapter transactionAdapter = new TransactionHistoryTableAdapter();
            int? money = transactionAdapter.GetCurrentMoney(username, date);
            if (money == null)
            {
                money = 0;
            }

            amountOfMoney += money.Value;

            userinfo.Username = username;
            userinfo.Name = userinfoDataTable.Rows[0]["Name"].ToString();
            userinfo.TypeName = (string)userinfoDataTable.Rows[0]["TypeName"];
            userinfo.Email = userinfoDataTable.Rows[0]["Email"].ToString();
            userinfo.AmountOfMoney = amountOfMoney;
            userinfo.Role = (int)userinfoDataTable.Rows[0]["Role"];

            return View(userinfo);
        }