コード例 #1
0
ファイル: OrderDao.cs プロジェクト: LiuCpoechant/shop
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Shop.Model.Order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_order set ");
            strSql.Append("ordertime=@ordertime,");
            strSql.Append("orderstatus=@orderstatus,");
            strSql.Append("orderprice=@orderprice");
            strSql.Append(" where orderid=@orderid and uid=@uid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ordertime",   SqlDbType.DateTime),
                new SqlParameter("@orderstatus", SqlDbType.Int,        4),
                new SqlParameter("@orderprice",  SqlDbType.Float,      8),
                new SqlParameter("@orderid",     SqlDbType.VarChar,   16),
                new SqlParameter("@uid",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ordertime;
            parameters[1].Value = model.orderstatus;
            parameters[2].Value = model.orderprice;
            parameters[3].Value = model.orderid;
            parameters[4].Value = model.uid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: OrderDao.cs プロジェクト: LiuCpoechant/shop
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Shop.Model.Order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_order(");
            strSql.Append("orderid,uid,ordertime,orderstatus,orderprice)");
            strSql.Append(" values (");
            strSql.Append("@orderid,@uid,@ordertime,@orderstatus,@orderprice)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderid",     SqlDbType.VarChar,   16),
                new SqlParameter("@uid",         SqlDbType.Int,        4),
                new SqlParameter("@ordertime",   SqlDbType.DateTime),
                new SqlParameter("@orderstatus", SqlDbType.Int,        4),
                new SqlParameter("@orderprice",  SqlDbType.Float, 8)
            };
            parameters[0].Value = model.orderid;
            parameters[1].Value = model.uid;
            parameters[2].Value = model.ordertime;
            parameters[3].Value = model.orderstatus;
            parameters[4].Value = model.orderprice;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: OrderDao.cs プロジェクト: LiuCpoechant/shop
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Shop.Model.Order GetModel(string orderid, int uid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 orderid,uid,ordertime,orderstatus,orderprice from t_order ");
            strSql.Append(" where orderid=@orderid and uid=@uid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderid", SqlDbType.VarChar, 16),
                new SqlParameter("@uid",     SqlDbType.Int, 4)
            };
            parameters[0].Value = orderid;
            parameters[1].Value = uid;

            Shop.Model.Order model = new Shop.Model.Order();
            DataSet          ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: OrderDao.cs プロジェクト: LiuCpoechant/shop
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Shop.Model.Order DataRowToModel(DataRow row)
 {
     Shop.Model.Order model = new Shop.Model.Order();
     if (row != null)
     {
         if (row["orderid"] != null)
         {
             model.orderid = row["orderid"].ToString();
         }
         if (row["uid"] != null && row["uid"].ToString() != "")
         {
             model.uid = int.Parse(row["uid"].ToString());
         }
         if (row["ordertime"] != null && row["ordertime"].ToString() != "")
         {
             model.ordertime = DateTime.Parse(row["ordertime"].ToString());
         }
         if (row["orderstatus"] != null && row["orderstatus"].ToString() != "")
         {
             model.orderstatus = int.Parse(row["orderstatus"].ToString());
         }
         if (row["orderprice"] != null && row["orderprice"].ToString() != "")
         {
             model.orderprice = decimal.Parse(row["orderprice"].ToString());
         }
     }
     return(model);
 }
コード例 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// 批量更新订单状态
        public bool UpdateType(Shop.Model.Order model, string orderids)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_order set ");
            strSql.Append("orderstatus=@orderstatus,");
            strSql.Append(" where orderid in (" + orderids + ")");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderstatus", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.orderstatus;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }