Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi_Model.T_Photo_Pay DataRowToModel(DataRow row)
 {
     WebApi_Model.T_Photo_Pay model = new WebApi_Model.T_Photo_Pay();
     if (row != null)
     {
         if (row["PayID"] != null && row["PayID"].ToString() != "")
         {
             model.PayID = int.Parse(row["PayID"].ToString());
         }
         if (row["PhotoCollectionID"] != null && row["PhotoCollectionID"].ToString() != "")
         {
             model.PhotoCollectionID = int.Parse(row["PhotoCollectionID"].ToString());
         }
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
         if (row["BuyDate"] != null && row["BuyDate"].ToString() != "")
         {
             model.BuyDate = DateTime.Parse(row["BuyDate"].ToString());
         }
         if (row["PayWay"] != null && row["PayWay"].ToString() != "")
         {
             model.PayWay = int.Parse(row["PayWay"].ToString());
         }
         if (row["PayValue"] != null && row["PayValue"].ToString() != "")
         {
             model.PayValue = int.Parse(row["PayValue"].ToString());
         }
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebApi_Model.T_Photo_Pay model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Photo_Pay(");
            strSql.Append("PhotoCollectionID,UID,BuyDate,PayWay,PayValue)");
            strSql.Append(" values (");
            strSql.Append("@PhotoCollectionID,@UID,@BuyDate,@PayWay,@PayValue)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PhotoCollectionID", SqlDbType.Int,       4),
                new SqlParameter("@UID",               SqlDbType.Int,       4),
                new SqlParameter("@BuyDate",           SqlDbType.DateTime),
                new SqlParameter("@PayWay",            SqlDbType.Int,       4),
                new SqlParameter("@PayValue",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.PhotoCollectionID;
            parameters[1].Value = model.UID;
            parameters[2].Value = model.BuyDate;
            parameters[3].Value = model.PayWay;
            parameters[4].Value = model.PayValue;

            object obj = DBHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebApi_Model.T_Photo_Pay model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Photo_Pay set ");
            strSql.Append("PhotoCollectionID=@PhotoCollectionID,");
            strSql.Append("UID=@UID,");
            strSql.Append("BuyDate=@BuyDate,");
            strSql.Append("PayWay=@PayWay,");
            strSql.Append("PayValue=@PayValue");
            strSql.Append(" where PayID=@PayID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PhotoCollectionID", SqlDbType.Int,       4),
                new SqlParameter("@UID",               SqlDbType.Int,       4),
                new SqlParameter("@BuyDate",           SqlDbType.DateTime),
                new SqlParameter("@PayWay",            SqlDbType.Int,       4),
                new SqlParameter("@PayValue",          SqlDbType.Int,       4),
                new SqlParameter("@PayID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.PhotoCollectionID;
            parameters[1].Value = model.UID;
            parameters[2].Value = model.BuyDate;
            parameters[3].Value = model.PayWay;
            parameters[4].Value = model.PayValue;
            parameters[5].Value = model.PayID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebApi_Model.T_Photo_Pay GetModel(int PayID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PayID,PhotoCollectionID,UID,BuyDate,PayWay,PayValue from T_Photo_Pay ");
            strSql.Append(" where PayID=@PayID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PayID", SqlDbType.Int, 4)
            };
            parameters[0].Value = PayID;

            WebApi_Model.T_Photo_Pay model = new WebApi_Model.T_Photo_Pay();
            DataSet ds = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }