Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Tc.Model.TcDanye model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TcDanye set ");
            strSql.Append("Ename=@Ename,");
            strSql.Append("Name=@Name,");
            strSql.Append("Tupian=@Tupian,");
            strSql.Append("Fenlei=@Fenlei,");
            strSql.Append("Url=@Url,");
            strSql.Append("Types=@Types,");
            strSql.Append("Content=@Content");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.VarChar, 255),
                new SqlParameter("@Name",    SqlDbType.VarChar, 255),
                new SqlParameter("@Tupian",  SqlDbType.VarChar, 255),
                new SqlParameter("@Fenlei",  SqlDbType.Int,       4),
                new SqlParameter("@Url",     SqlDbType.VarChar, 255),
                new SqlParameter("@Types",   SqlDbType.VarChar, 255),
                new SqlParameter("@Content", SqlDbType.VarChar,   0),
                new SqlParameter("@ID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Ename;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Tupian;
            parameters[3].Value = model.Fenlei;
            parameters[4].Value = model.Url;
            parameters[5].Value = model.Types;
            parameters[6].Value = model.Content;
            parameters[7].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Tc.Model.TcDanye DataRowToModel(DataRow row)
 {
     Tc.Model.TcDanye model = new Tc.Model.TcDanye();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Ename"] != null)
         {
             model.Ename = row["Ename"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Tupian"] != null)
         {
             model.Tupian = row["Tupian"].ToString();
         }
         if (row["Fenlei"] != null && row["Fenlei"].ToString() != "")
         {
             model.Fenlei = int.Parse(row["Fenlei"].ToString());
         }
         if (row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
         if (row["Types"] != null)
         {
             model.Types = row["Types"].ToString();
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
     }
     return(model);
 }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tc.Model.TcDanye model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TcDanye(");
            strSql.Append("Ename,Types,Name,Url,Tupian,Fenlei,Content)");
            strSql.Append(" values (");
            strSql.Append("@Ename,@Types,@Name,@Url,@Tupian,@Fenlei,@Content)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.NVarChar, 200),
                new SqlParameter("@Types",   SqlDbType.NVarChar, 200),
                new SqlParameter("@Name",    SqlDbType.NVarChar, 200),
                new SqlParameter("@Url",     SqlDbType.NVarChar, 200),
                new SqlParameter("@Tupian",  SqlDbType.NVarChar, 200),
                new SqlParameter("@Fenlei",  SqlDbType.Int,        4),
                new SqlParameter("@Content", SqlDbType.NText)
            };
            parameters[0].Value = model.Ename;
            parameters[1].Value = model.Types;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Url;
            parameters[4].Value = model.Tupian;
            parameters[5].Value = model.Fenlei;
            parameters[6].Value = model.Content;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tc.Model.TcDanye model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TcDanye(");
            strSql.Append("Ename,Name,Tupian,Fenlei,Url,Types,Content)");
            strSql.Append(" values (");
            strSql.Append("@Ename,@Name,@Tupian,@Fenlei,@Url,@Types,@Content)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.VarChar, 255),
                new SqlParameter("@Name",    SqlDbType.VarChar, 255),
                new SqlParameter("@Tupian",  SqlDbType.VarChar, 255),
                new SqlParameter("@Fenlei",  SqlDbType.Int,       4),
                new SqlParameter("@Url",     SqlDbType.VarChar, 255),
                new SqlParameter("@Types",   SqlDbType.VarChar, 255),
                new SqlParameter("@Content", SqlDbType.VarChar, 0)
            };
            parameters[0].Value = model.Ename;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Tupian;
            parameters[3].Value = model.Fenlei;
            parameters[4].Value = model.Url;
            parameters[5].Value = model.Types;
            parameters[6].Value = model.Content;

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

            if (rows > 0)
            {
                return(GetMaxId());
            }
            else
            {
                return(0);
            }
        }
Exemple #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tc.Model.TcDanye GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,Ename,Name,Tupian,Fenlei,Url,Types,Content from TcDanye ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Tc.Model.TcDanye model = new Tc.Model.TcDanye();
            DataSet          ds    = DbHelper.Query(strSql.ToString(), parameters);

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