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

            strSql.Append("update STATE set ");
            strSql.Append("NAME=@NAME");
            strSql.Append(" where STATECODE=@STATECODE");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",      OleDbType.VarChar, 25),
                new OleDbParameter("@STATECODE", OleDbType.Integer, 4)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.STATECODE;

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

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

            strSql.Append("insert into STATE(");
            strSql.Append("NAME)");
            strSql.Append(" values (");
            strSql.Append("@NAME)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME", OleDbType.VarChar, 25)
            };
            parameters[0].Value = model.NAME;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AOC.Perf.Model.STATE DataRowToModel(DataRow row)
 {
     AOC.Perf.Model.STATE model = new AOC.Perf.Model.STATE();
     if (row != null)
     {
         if (row["STATECODE"] != null && row["STATECODE"].ToString() != "")
         {
             model.STATECODE = int.Parse(row["STATECODE"].ToString());
         }
         if (row["NAME"] != null)
         {
             model.NAME = row["NAME"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AOC.Perf.Model.STATE GetModel(int STATECODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select STATECODE,NAME from STATE ");
            strSql.Append(" where STATECODE=@STATECODE");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@STATECODE", OleDbType.Integer, 4)
            };
            parameters[0].Value = STATECODE;

            AOC.Perf.Model.STATE model = new AOC.Perf.Model.STATE();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

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