Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Tc.Model.TcConfig model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TcConfig set ");
            strSql.Append("Ename=@Ename,");
            strSql.Append("Name=@Name,");
            strSql.Append("Types=@Types,");
            strSql.Append("Content=@Content");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.NVarChar, 200),
                new SqlParameter("@Name",    SqlDbType.NVarChar, 200),
                new SqlParameter("@Types",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Content", SqlDbType.NText),
                new SqlParameter("@ID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Ename;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Types;
            parameters[3].Value = model.Content;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tc.Model.TcConfig model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TcConfig(");
            strSql.Append("Ename,Name,Types,Content)");
            strSql.Append(" values (");
            strSql.Append("@Ename,@Name,@Types,@Content)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.NVarChar, 200),
                new SqlParameter("@Name",    SqlDbType.NVarChar, 200),
                new SqlParameter("@Types",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Content", SqlDbType.NText)
            };
            parameters[0].Value = model.Ename;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Types;
            parameters[3].Value = model.Content;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Tc.Model.TcConfig DataRowToModel(DataRow row)
 {
     Tc.Model.TcConfig model = new Tc.Model.TcConfig();
     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["Types"] != null)
         {
             model.Types = row["Types"].ToString();
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tc.Model.TcConfig model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TcConfig(");
            strSql.Append("Ename,Name,Types,Content)");
            strSql.Append(" values (");
            strSql.Append("@Ename,@Name,@Types,@Content)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ename",   SqlDbType.VarChar, 255),
                new SqlParameter("@Name",    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.Types;
            parameters[3].Value = model.Content;

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

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

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

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

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