예제 #1
0
        /// <summary>
        /// 修改排序.
        /// </summary>
        /// <param name="orderString">id字符串,逗号隔开的.</param>
        /// <returns></returns>
        public static KeyvalM OrderBy(string orderString)
        {
            KeyvalM data = new KeyvalM();

            if (string.IsNullOrWhiteSpace(orderString))
            {
                data.ErrorMsg = "排序参数不能为空!";
                return(data);
            }
            string[]  order = orderString.Split(',');
            string    sql   = @"UPDATE Keyval SET orderby=@orderby WHERE id=@id";
            SQLServer db    = new SQLServer();

            db.BeginTransaction();
            for (int i = 0; i < order.Length; i++)
            {
                int re = db.ExecuteNoQuery(sql, i + 1, order[i]);
                if (re == -999)
                {
                    db.RollBackTransaction();
                    data.ErrorMsg = AlertMsg.数据库错误.ToString();
                    return(data);
                }
            }
            if (db.CommitTransaction() == false)
            {
                data.ErrorMsg = AlertMsg.数据库错误.ToString();
                return(data);
            }
            data.ErrorCode = 200;
            // 更新缓存
            CacheRefresh();
            return(data);
        }
예제 #2
0
        /// <summary>
        /// 更新总值
        /// </summary>
        /// <param name="para"></param>
        public static void UpdateVal(AssetM para)
        {
            para.ErrorCode = 305;
            SQLServer db  = new SQLServer();
            string    del = @"delete totalday where totaldate=@totaldate";
            string    sql = @"insert into totalday(id,value,totaldate,ctime)";

            db.BeginTransaction();
            if (db.ExecuteNoQuery(del, para.TotalDate, 1) < 0 ||
                db.Insert <AssetM>(sql, para) != 1)
            {
                db.RollBackTransaction();
                para.ErrorMsg = AlertMsg.数据库错误.ToString();
                return;
            }
            if (db.CommitTransaction())
            {
                para.ErrorCode = 200;
                return;
            }
            para.ErrorMsg = AlertMsg.数据库错误.ToString();
        }