Esempio n. 1
0
        public ActionResult editAccount(AccountViewModel account)
        {
            if (!isLogin()) return RedirectToAction("login", "auth");
            User user = getCurrentUser();

            Account a = new Account()
            {
                Id=account.Id,
                Info=account.Info,
                Money=account.Money,
                State=account.State,
                Time=account.Time,
                Type=account.Type,
                UserId=account.UserId
            };
            Provider db = new Provider();
            db.updateAccount(a);

            int aid = account.Id;
            db.deleteAccountTagByAccount(aid);

            string[] tmp = account.Tag.Split(new char[] { ' ', ',', ',', ' ' });
            foreach (string t in tmp)
            {
                Tag tag = db.getTagsByName(t);
                if (tag == null)
                {
                    db.insertTag(new Tag() { Name = t, Count = 0, UserId = user.Id });
                    tag = new Tag();
                    tag.Id = (int)db.getDataRow("SELECT Id FROM Tag ORDER BY Id DESC")["Id"];
                }
                db.insertAccountTag(aid, tag.Id);
            }

            string content = "<td>" + (account.Type ? "收入" : "支出") + "</td><td>" + account.Money + "</td><td>" + account.Time.ToString("yyyy-MM-dd") + "</td><td>" + account.Info + "</td><td>" + account.Tag + "</td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_edit' onclick='showEditAccount(" + aid + ")'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_delete' onclick='showDeleteAccount(" + aid + ")'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>";

            return Content(content);
        }
Esempio n. 2
0
 public Account toAccount(DataRow data)
 {
     if (data == null) return null;
     Account account = new Account();
     account.Id = (int)data["Id"];
     account.Info = (string)data["Info"];
     account.Money = Convert.ToDouble(data["Money"]);
     account.State = (bool)data["State"];
     account.SubmitTime = (DateTime)data["SubmitTime"];
     account.Time = (DateTime)data["Time"];
     account.UserId = (int)data["UserId"];
     account.Type = (bool)data["Type"];
     return account;
 }
Esempio n. 3
0
 public void updateAccount(Account account)
 {
     executeNonQuery("UPDATE Account SET UserId=" + account.UserId + ", Money=" + account.Money
                                  + ", Time='" + account.Time + "', Info='" + account.Info + "', Type=" + (account.Type ? "1" : "0") + " WHERE Id=" + account.Id);
 }
Esempio n. 4
0
 public void insertAccount(Account account)
 {
     executeNonQuery("INSERT INTO Account (UserId, Money, Time, Info, State, SubmitTime, Type) VALUES ("
                                  + account.UserId + ", " + account.Money + ", '" + account.Time + "', '" + account.Info
                                  + "', 0, '" + account.SubmitTime + "', " + (account.Type ? "1" : "0") + ")");
 }