Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(UserBuyOrder model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update UserBuyOrder set ");

            strSql.Append(" Email = @Email , ");
            strSql.Append(" ShenFenID = @ShenFenID , ");
            strSql.Append(" OrderNo = @OrderNo , ");
            strSql.Append(" UserID = @UserID , ");
            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" EditDate = @EditDate , ");
            strSql.Append(" OrderStatus = @OrderStatus , ");
            strSql.Append(" UserName = @UserName , ");
            strSql.Append(" Mobile = @Mobile , ");
            strSql.Append(" Address = @Address  ");
            strSql.Append(" where ID=@ID ");

            SqlParameter[] parameters = {
                        new SqlParameter("@ID", SqlDbType.Int,4) ,
                        new SqlParameter("@Email", SqlDbType.NChar,30) ,
                        new SqlParameter("@ShenFenID", SqlDbType.NChar,30) ,
                        new SqlParameter("@OrderNo", SqlDbType.VarChar,255) ,
                        new SqlParameter("@UserID", SqlDbType.Int,4) ,
                        new SqlParameter("@CreateDate", SqlDbType.DateTime) ,
                        new SqlParameter("@EditDate", SqlDbType.DateTime) ,
                        new SqlParameter("@OrderStatus", SqlDbType.Int,4) ,
                        new SqlParameter("@UserName", SqlDbType.NChar,50) ,
                        new SqlParameter("@Mobile", SqlDbType.NChar,20) ,
                        new SqlParameter("@Address", SqlDbType.NChar,50)

            };

            parameters[0].Value = model.ID;
            parameters[1].Value = model.Email;
            parameters[2].Value = model.ShenFenID;
            parameters[3].Value = model.OrderNo;
            parameters[4].Value = model.UserID;
            parameters[5].Value = model.CreateDate;
            parameters[6].Value = DateTime.Now;
            parameters[7].Value = (int)model.OrderStatus;
            parameters[8].Value = model.UserName;
            parameters[9].Value = model.Mobile;
            parameters[10].Value = model.Address;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据当前用户ID得到一个对象实体
        /// </summary>
        public UserBuyOrder GetModelByUserId(int userId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID, OrderNo, UserID,OrderStatus, CreateDate, EditDate  ");
            strSql.Append("  from UserBuyOrder ");
            strSql.Append(" where UserID=@UserID");
            SqlParameter[] parameters = {
                    new SqlParameter("@UserID", SqlDbType.Int,4)
            };
            parameters[0].Value = userId;

            UserBuyOrder model = new UserBuyOrder();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.OrderNo = ds.Tables[0].Rows[0]["OrderNo"].ToString();
                if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(ds.Tables[0].Rows[0]["EditDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderStatus"].ToString() != "")
                {
                    model.OrderStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), ds.Tables[0].Rows[0]["OrderStatus"].ToString(), false);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<UserBuyOrder> GetUserBuyOrdersList(string strWhere)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select * ");
     strSql.Append(" FROM UserBuyOrder ");
     if (strWhere.Trim() != "")
     {
         strSql.Append(" where " + strWhere);
     }
     DataSet ds = DbHelperSQL.Query(strSql.ToString());
     List<UserBuyOrder> userBuyOrders = new List<UserBuyOrder>();
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         UserBuyOrder model = new UserBuyOrder();
         if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
         {
             model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
         }
         model.OrderNo = ds.Tables[0].Rows[0]["OrderNo"].ToString();
         if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
         {
             model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
         }
         if (ds.Tables[0].Rows[0]["EditDate"].ToString() != "")
         {
             model.EditDate = DateTime.Parse(ds.Tables[0].Rows[0]["EditDate"].ToString());
         }
         if (ds.Tables[0].Rows[0]["OrderStatus"].ToString() != "")
         {
             model.OrderStatus =
                 (OrderStatus)
                     Enum.Parse(typeof(OrderStatus), ds.Tables[0].Rows[0]["OrderStatus"].ToString(), false);
         }
         userBuyOrders.Add(model);
     }
     return userBuyOrders;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public UserBuyOrder GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID, Email, ShenFenID, OrderNo, UserID, CreateDate, EditDate, OrderStatus, UserName, Mobile, Address  ");
            strSql.Append("  from UserBuyOrder ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            UserBuyOrder model = new UserBuyOrder();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.Email = ds.Tables[0].Rows[0]["Email"].ToString();
                model.ShenFenID = ds.Tables[0].Rows[0]["ShenFenID"].ToString();
                model.OrderNo = ds.Tables[0].Rows[0]["OrderNo"].ToString();
                if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(ds.Tables[0].Rows[0]["EditDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderStatus"].ToString() != "")
                {
                    model.OrderStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), ds.Tables[0].Rows[0]["OrderStatus"].ToString());
                }
                model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                model.Mobile = ds.Tables[0].Rows[0]["Mobile"].ToString();
                model.Address = ds.Tables[0].Rows[0]["Address"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }