Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Articel_Words model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Articel_Words set ");
            strSql.Append("WordPattern=@WordPattern,");
            strSql.Append("IsForbid=@IsForbid,");
            strSql.Append("IsMod=@IsMod,");
            strSql.Append("ReplaceWord=@ReplaceWord");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WordPattern", SqlDbType.NVarChar, 50),
                new SqlParameter("@IsForbid",    SqlDbType.Bit,       1),
                new SqlParameter("@IsMod",       SqlDbType.Bit,       1),
                new SqlParameter("@ReplaceWord", SqlDbType.NVarChar, 50),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.WordPattern;
            parameters[1].Value = model.IsForbid;
            parameters[2].Value = model.IsMod;
            parameters[3].Value = model.ReplaceWord;
            parameters[4].Value = model.Id;

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

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

            strSql.Append("insert into Articel_Words(");
            strSql.Append("WordPattern,IsForbid,IsMod,ReplaceWord)");
            strSql.Append(" values (");
            strSql.Append("@WordPattern,@IsForbid,@IsMod,@ReplaceWord)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WordPattern", SqlDbType.NVarChar, 50),
                new SqlParameter("@IsForbid",    SqlDbType.Bit,       1),
                new SqlParameter("@IsMod",       SqlDbType.Bit,       1),
                new SqlParameter("@ReplaceWord", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.WordPattern;
            parameters[1].Value = model.IsForbid;
            parameters[2].Value = model.IsMod;
            parameters[3].Value = model.ReplaceWord;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Articel_Words DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Articel_Words model = new Maticsoft.Model.Articel_Words();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["WordPattern"] != null)
         {
             model.WordPattern = row["WordPattern"].ToString();
         }
         if (row["IsForbid"] != null && row["IsForbid"].ToString() != "")
         {
             if ((row["IsForbid"].ToString() == "1") || (row["IsForbid"].ToString().ToLower() == "true"))
             {
                 model.IsForbid = true;
             }
             else
             {
                 model.IsForbid = false;
             }
         }
         if (row["IsMod"] != null && row["IsMod"].ToString() != "")
         {
             if ((row["IsMod"].ToString() == "1") || (row["IsMod"].ToString().ToLower() == "true"))
             {
                 model.IsMod = true;
             }
             else
             {
                 model.IsMod = false;
             }
         }
         if (row["ReplaceWord"] != null)
         {
             model.ReplaceWord = row["ReplaceWord"].ToString();
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Articel_Words GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,WordPattern,IsForbid,IsMod,ReplaceWord from Articel_Words ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

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