コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AOC.Perf.Model.CITY model)
        {
            StringBuilder strSql = new StringBuilder();

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

            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.CITY model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CITY(");
            strSql.Append("NAME,STATECODE)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@STATECODE)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",      OleDbType.VarChar, 20),
                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);
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AOC.Perf.Model.CITY DataRowToModel(DataRow row)
 {
     AOC.Perf.Model.CITY model = new AOC.Perf.Model.CITY();
     if (row != null)
     {
         if (row["CITYCODE"] != null && row["CITYCODE"].ToString() != "")
         {
             model.CITYCODE = int.Parse(row["CITYCODE"].ToString());
         }
         if (row["NAME"] != null)
         {
             model.NAME = row["NAME"].ToString();
         }
         if (row["STATECODE"] != null && row["STATECODE"].ToString() != "")
         {
             model.STATECODE = int.Parse(row["STATECODE"].ToString());
         }
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AOC.Perf.Model.CITY GetModel(int CITYCODE)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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