예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MSCD.Model.Config model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update b_Config set ");
            strSql.Append("name=@name,");
            strSql.Append("info=@info");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name", SqlDbType.VarChar,  50),
                new SqlParameter("@info", SqlDbType.VarChar),
                new SqlParameter("@id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.info;
            parameters[2].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MSCD.Model.Config model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into b_Config(");
            strSql.Append("name,info)");
            strSql.Append(" values (");
            strSql.Append("@name,@info)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name", SqlDbType.VarChar, 50),
                new SqlParameter("@info", SqlDbType.VarChar)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.info;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.Config DataRowToModel(DataRow row)
 {
     MSCD.Model.Config model = new MSCD.Model.Config();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["info"] != null)
         {
             model.info = row["info"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
파일: Config.cs 프로젝트: zfc317/mscd
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.Config DataRowToModel(DataRow row)
 {
     MSCD.Model.Config model = new MSCD.Model.Config();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["info"] != null)
         {
             model.info = row["info"].ToString();
         }
     }
     return model;
 }
예제 #5
0
        /// </summary>
        public MSCD.Model.Config GetModel(string configName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,info from b_Config ");
            strSql.Append(" where name=@configName");
            SqlParameter[] parameters =
            {
                new SqlParameter("@configName", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = configName;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
파일: Config.cs 프로젝트: zfc317/mscd
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MSCD.Model.Config model)
 {
     return(dal.Update(model));
 }
예제 #7
0
파일: Config.cs 프로젝트: zfc317/mscd
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MSCD.Model.Config model)
 {
     return(dal.Add(model));
 }
예제 #8
0
파일: Config.cs 프로젝트: zfc317/mscd
        /// </summary>
        public MSCD.Model.Config GetModel(string configName)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,name,info from b_Config ");
            strSql.Append(" where name=@configName");
            SqlParameter[] parameters = {
                    new SqlParameter("@configName", SqlDbType.VarChar,50)
            };
            parameters[0].Value = configName;

            MSCD.Model.Config model = new MSCD.Model.Config();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }