コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(HeqiaoDaoshiCore.Model.Luxian model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Luxian(");
            strSql.Append("CreateTime,LuxianUUID,Name,Phone,Introduction,Address,Price,Picture,State,IsDelete,Cover,Addpeople,AddTime,Count,ytype,PlayType)");
            strSql.Append(" values (");
            strSql.Append("@CreateTime,@LuxianUUID,@Name,@Phone,@Introduction,@Address,@Price,@Picture,@State,@IsDelete,@Cover,@Addpeople,@AddTime,@Count,@ytype,@PlayType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@LuxianUUID",   SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@Name",         SqlDbType.NVarChar,         255),
                new SqlParameter("@Phone",        SqlDbType.NVarChar,          -1),
                new SqlParameter("@Introduction", SqlDbType.NVarChar,          -1),
                new SqlParameter("@Address",      SqlDbType.NVarChar,          -1),
                new SqlParameter("@Price",        SqlDbType.NVarChar,          -1),
                new SqlParameter("@Picture",      SqlDbType.NVarChar,          -1),
                new SqlParameter("@State",        SqlDbType.Int,                4),
                new SqlParameter("@IsDelete",     SqlDbType.Int,                4),
                new SqlParameter("@Cover",        SqlDbType.VarChar,          255),
                new SqlParameter("@Addpeople",    SqlDbType.NVarChar,         255),
                new SqlParameter("@AddTime",      SqlDbType.NVarChar,         255),
                new SqlParameter("@Count",        SqlDbType.Int,                4),
                new SqlParameter("@ytype",        SqlDbType.NVarChar,         255),
                new SqlParameter("@PlayType",     SqlDbType.NVarChar, 255)
            };
            parameters[0].Value  = model.CreateTime;
            parameters[1].Value  = Guid.NewGuid();
            parameters[2].Value  = model.Name;
            parameters[3].Value  = model.Phone;
            parameters[4].Value  = model.Introduction;
            parameters[5].Value  = model.Address;
            parameters[6].Value  = model.Price;
            parameters[7].Value  = model.Picture;
            parameters[8].Value  = model.State;
            parameters[9].Value  = model.IsDelete;
            parameters[10].Value = model.Cover;
            parameters[11].Value = model.Addpeople;
            parameters[12].Value = model.AddTime;
            parameters[13].Value = model.Count;
            parameters[14].Value = model.ytype;
            parameters[15].Value = model.PlayType;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HeqiaoDaoshiCore.Model.Luxian GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,CreateTime,LuxianUUID,Name,Phone,Introduction,Address,Price,Picture,State,IsDelete,Cover,Addpeople,AddTime,Count,ytype,PlayType from Luxian ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HeqiaoDaoshiCore.Model.Luxian model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Luxian set ");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("Name=@Name,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("Introduction=@Introduction,");
            strSql.Append("Address=@Address,");
            strSql.Append("Price=@Price,");
            strSql.Append("Picture=@Picture,");
            strSql.Append("State=@State,");
            strSql.Append("IsDelete=@IsDelete,");
            strSql.Append("Cover=@Cover,");
            strSql.Append("Addpeople=@Addpeople,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Count=@Count,");
            strSql.Append("ytype=@ytype,");
            strSql.Append("PlayType=@PlayType");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@Name",         SqlDbType.NVarChar,         255),
                new SqlParameter("@Phone",        SqlDbType.NVarChar,          -1),
                new SqlParameter("@Introduction", SqlDbType.NVarChar,          -1),
                new SqlParameter("@Address",      SqlDbType.NVarChar,          -1),
                new SqlParameter("@Price",        SqlDbType.NVarChar,          -1),
                new SqlParameter("@Picture",      SqlDbType.NVarChar,          -1),
                new SqlParameter("@State",        SqlDbType.Int,                4),
                new SqlParameter("@IsDelete",     SqlDbType.Int,                4),
                new SqlParameter("@Cover",        SqlDbType.VarChar,          255),
                new SqlParameter("@Addpeople",    SqlDbType.NVarChar,         255),
                new SqlParameter("@AddTime",      SqlDbType.NVarChar,         255),
                new SqlParameter("@Count",        SqlDbType.Int,                4),
                new SqlParameter("@ytype",        SqlDbType.NVarChar,         255),
                new SqlParameter("@PlayType",     SqlDbType.NVarChar,         255),
                new SqlParameter("@ID",           SqlDbType.Int,                4),
                new SqlParameter("@LuxianUUID",   SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value  = model.CreateTime;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.Phone;
            parameters[3].Value  = model.Introduction;
            parameters[4].Value  = model.Address;
            parameters[5].Value  = model.Price;
            parameters[6].Value  = model.Picture;
            parameters[7].Value  = model.State;
            parameters[8].Value  = model.IsDelete;
            parameters[9].Value  = model.Cover;
            parameters[10].Value = model.Addpeople;
            parameters[11].Value = model.AddTime;
            parameters[12].Value = model.Count;
            parameters[13].Value = model.ytype;
            parameters[14].Value = model.PlayType;
            parameters[15].Value = model.ID;
            parameters[16].Value = model.LuxianUUID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public HeqiaoDaoshiCore.Model.Luxian DataRowToModel(DataRow row)
 {
     HeqiaoDaoshiCore.Model.Luxian model = new HeqiaoDaoshiCore.Model.Luxian();
     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["LuxianUUID"] != null && row["LuxianUUID"].ToString() != "")
         {
             model.LuxianUUID = new Guid(row["LuxianUUID"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Phone"] != null)
         {
             model.Phone = row["Phone"].ToString();
         }
         if (row["Introduction"] != null)
         {
             model.Introduction = row["Introduction"].ToString();
         }
         if (row["Address"] != null)
         {
             model.Address = row["Address"].ToString();
         }
         if (row["Price"] != null)
         {
             model.Price = row["Price"].ToString();
         }
         if (row["Picture"] != null)
         {
             model.Picture = row["Picture"].ToString();
         }
         if (row["State"] != null && row["State"].ToString() != "")
         {
             model.State = int.Parse(row["State"].ToString());
         }
         if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
         {
             model.IsDelete = int.Parse(row["IsDelete"].ToString());
         }
         if (row["Cover"] != null)
         {
             model.Cover = row["Cover"].ToString();
         }
         if (row["Addpeople"] != null)
         {
             model.Addpeople = row["Addpeople"].ToString();
         }
         if (row["AddTime"] != null)
         {
             model.AddTime = row["AddTime"].ToString();
         }
         if (row["Count"] != null && row["Count"].ToString() != "")
         {
             model.Count = int.Parse(row["Count"].ToString());
         }
         if (row["ytype"] != null)
         {
             model.ytype = row["ytype"].ToString();
         }
         if (row["PlayType"] != null)
         {
             model.PlayType = row["PlayType"].ToString();
         }
     }
     return(model);
 }