Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public HeqiaoDaoshiCore.Model.ActiveQuantity DataRowToModel(DataRow row)
 {
     HeqiaoDaoshiCore.Model.ActiveQuantity model = new HeqiaoDaoshiCore.Model.ActiveQuantity();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["ActiveQuantityUUID"] != null && row["ActiveQuantityUUID"].ToString() != "")
         {
             model.ActiveQuantityUUID = new Guid(row["ActiveQuantityUUID"].ToString());
         }
         if (row["AddTime"] != null)
         {
             model.AddTime = row["AddTime"].ToString();
         }
         if (row["Num"] != null && row["Num"].ToString() != "")
         {
             model.Num = int.Parse(row["Num"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(HeqiaoDaoshiCore.Model.ActiveQuantity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ActiveQuantity(");
            strSql.Append("CreateTime,ActiveQuantityUUID,AddTime,Num,Type)");
            strSql.Append(" values (");
            strSql.Append("@CreateTime,@ActiveQuantityUUID,@AddTime,@Num,@Type)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@ActiveQuantityUUID", SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@AddTime",            SqlDbType.NVarChar,         50),
                new SqlParameter("@Num",                SqlDbType.Int,               4),
                new SqlParameter("@Type",               SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CreateTime;
            parameters[1].Value = Guid.NewGuid();
            parameters[2].Value = model.AddTime;
            parameters[3].Value = model.Num;
            parameters[4].Value = model.Type;

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

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

            strSql.Append("update ActiveQuantity set ");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Num=@Num,");
            strSql.Append("Type=@Type");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateTime",         SqlDbType.DateTime),
                new SqlParameter("@AddTime",            SqlDbType.NVarChar,        50),
                new SqlParameter("@Num",                SqlDbType.Int,              4),
                new SqlParameter("@Type",               SqlDbType.Int,              4),
                new SqlParameter("@ID",                 SqlDbType.Int,              4),
                new SqlParameter("@ActiveQuantityUUID", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = model.CreateTime;
            parameters[1].Value = model.AddTime;
            parameters[2].Value = model.Num;
            parameters[3].Value = model.Type;
            parameters[4].Value = model.ID;
            parameters[5].Value = model.ActiveQuantityUUID;

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

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

            strSql.Append("select  top 1 ID,CreateTime,ActiveQuantityUUID,AddTime,Num,Type from ActiveQuantity ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            HeqiaoDaoshiCore.Model.ActiveQuantity model = new HeqiaoDaoshiCore.Model.ActiveQuantity();
            DataSet ds = DbHelperSql.Query(strSql.ToString(), parameters);

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