/// <summary>
 /// 修改
 /// </summary>
 /// <param name="model">修改对象</param>
 public int Update(Adctab  model)
 {
     string sql = "UPDATE adctab SET adcName = @AdcName, adcSex = @AdcSex, adcAge = @AdcAge, adcStatus = @AdcStatus WHERE 1=1  AND aid = @Aid";
     Command db = new Command();
     DbParameter[] ps = new DbParameter[5];
     ps[0] = db.CreateParameter("@AdcName", model.AdcName,DbType.AnsiString);
     ps[1] = db.CreateParameter("@AdcSex", model.AdcSex,DbType.AnsiStringFixedLength);
     ps[2] = db.CreateParameter("@AdcAge", model.AdcAge,DbType.Int32);
     ps[3] = db.CreateParameter("@AdcStatus", model.AdcStatus,DbType.Int32);
     ps[4] = db.CreateParameter("@Aid", model.Aid,DbType.Int32);
     
     return db.Update(sql,ps);
 }
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="model">新增信息</param>
 public int add(Adctab  model)
 {
     string sql = "INSERT INTO adctab (adcName, adcSex, adcAge, adcStatus) values (@AdcName, @AdcSex, @AdcAge, @AdcStatus)";
     Command db = new Command();
     DbParameter[] ps = new DbParameter[4];
     ps[0] = db.CreateParameter("@AdcName", model.AdcName,DbType.AnsiString);
     ps[1] = db.CreateParameter("@AdcSex", model.AdcSex,DbType.AnsiStringFixedLength);
     ps[2] = db.CreateParameter("@AdcAge", model.AdcAge,DbType.Int32);
     ps[3] = db.CreateParameter("@AdcStatus", model.AdcStatus,DbType.Int32);
     
     
     return Convert.ToInt32(db.Insert(sql,ps));
 }
        public new void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string jsonto=string.Empty;
            string type=context.Request["type"];
            #region 查询信息
            if (type == "List")
            {
                
                int pageindex = PageUtil.GetIntQs("pageindex");
                int pagesize = PageUtil.GetIntQs("pagesize");
                string jsonstr = PageUtil.UrlDecode(PageUtil.GetStringQs("json"));
                Adctab info = new Adctab();
                if (!string.IsNullOrEmpty(jsonstr))
                {
                    info = SerializeHelp.ScriptDeserialize<Adctab>(jsonstr);
                }
                int rowCount = 0;
                int Count = 0;
                DataTable dt = AdctabBll.Instance.GetPageList(pageindex, pagesize, out rowCount, info);
                Count = rowCount / pagesize;
                if (rowCount % pagesize != 0)
                {
                    Count += 1;
                }
                string json = dt.Rows.Count > 0 ? JsonHelp.ToJson(dt) : "\"\"";
                jsonto = string.Format("{0}\"o\":{1},\"j\":{2},\"c\":{3}{4}", "{", json, Count, rowCount, "}");
            }
            #endregion

            #region 插入信息
            else if (type == "insert")
            {
                string jsonstr = PageUtil.GetFormString("json","");
                Adctab info = new Adctab();
                if (!string.IsNullOrEmpty(jsonstr))
                {
                    info = SerializeHelp.ScriptDeserialize<Adctab>(jsonstr);
                }
                
                int i = AdctabBll.Instance.add(info);
                jsonto = "{\"o\":\"ok\"}";
            }
            #endregion

            context.Response.Write(jsonto);
        }
 /// <summary>
 /// 获取数据
 /// </summary>
 /// <param name="model">查询对象</param>
 public DataTable GetList(Adctab  model)
 {
     return Dal.GetList(model);
 }
 /// <summary>
 /// 获取分页数据
 /// </summary>
 /// <param name="pageindex">当前页</param>
 /// <param name="pagesize">分页大小</param>
 /// <param name="rowCount">输出总行数</param>
 /// <param name="model">查询对象</param>
 public  DataTable GetPageList(int pageindex, int pagesize, out int rowCount, Adctab  model)
 {
     return Dal.GetPageList(pageindex,pagesize,out rowCount,model);
    
 }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="model">修改对象</param>
 public int Update(Adctab  model)
 {
     return Dal.Update(model);
 }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model">新增信息</param>
        public int add(Adctab  model)
        {

            return Dal.add(model);
        }
 /// <summary>
 /// 获取行数据
 /// </summary>
 /// <param name="model">查询对象</param>
 public DataRow GetRow(Adctab  model)
 {
      return Dal.GetRow(model);
 }
 /// <summary>
 /// 获取行数据
 /// </summary>
 /// <param name="model">查询对象</param>
 public DataRow GetRow(Adctab  model)
 {
     string strwhere = " 1=1 ";
     
     Command db = new Command();
     DbCommand cmd = db.CreateCommand();
     
     #region -- 主键区 --
     
     if(model.Aid > 0)
     {
         
         strwhere += " and aid = @Aid";
         cmd.Parameters.Add(db.CreateParameter("@Aid", model.Aid,DbType.Int32));
         
     }
     #endregion
     
     #region -- 数字区 --
     if(model.AdcAge > 0)
     {
         strwhere += " and adcAge = @AdcAge";
         cmd.Parameters.Add(db.CreateParameter("@AdcAge", model.AdcAge,DbType.Int32));
     }
     
     if(model.AdcStatus > 0)
     {
         strwhere += " and adcStatus = @AdcStatus";
         cmd.Parameters.Add(db.CreateParameter("@AdcStatus", model.AdcStatus,DbType.Int32));
     }
     
     
     #endregion
     
     #region -- 字符区 --
     if(!string.IsNullOrEmpty(model.AdcName))
     {
         strwhere += " and adcName = @AdcName";
         cmd.Parameters.Add(db.CreateParameter("@AdcName", model.AdcName,DbType.AnsiString));
     }
     if(!string.IsNullOrEmpty(model.AdcSex))
     {
         strwhere += " and adcSex = @AdcSex";
         cmd.Parameters.Add(db.CreateParameter("@AdcSex", model.AdcSex,DbType.AnsiStringFixedLength));
     }
     #endregion
     
     string sql = String.Format("SELECT {0} FROM adctab where {1} {2}", SelectedFields,strwhere, OrderBy);
     cmd.CommandText = sql;
     return db.GetRow(cmd);
     
 }
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">分页大小</param>
        /// <param name="rowCount">输出总行数</param>
        /// <param name="model">查询对象</param>
        public  DataTable GetPageList(int pageindex, int pagesize, out int rowCount, Adctab  model)
        {
            string strwhere = " 1=1 ";
            
            Command db = new Command();
            DbCommand cmd = db.CreateCommand();
            
            #region -- 主键区 --
            
            if(model.Aid > 0)
            {
                
                strwhere += " and aid = @Aid";
                cmd.Parameters.Add(db.CreateParameter("@Aid", model.Aid,DbType.Int32));
                
            }
            #endregion
            
            #region -- 数字区 --
            if(model.AdcAge > 0)
            {
                strwhere += " and adcAge = @AdcAge";
                cmd.Parameters.Add(db.CreateParameter("@AdcAge", model.AdcAge,DbType.Int32));
            }
            
            if(model.AdcStatus > 0)
            {
                strwhere += " and adcStatus = @AdcStatus";
                cmd.Parameters.Add(db.CreateParameter("@AdcStatus", model.AdcStatus,DbType.Int32));
            }
            
            
            #endregion
            
            #region -- 字符区 --
            if(!string.IsNullOrEmpty(model.AdcName))
            {
                strwhere += " and adcName like  @AdcName+'%'";
                cmd.Parameters.Add(db.CreateParameter("@AdcName", model.AdcName,DbType.AnsiString));
            }
            if(!string.IsNullOrEmpty(model.AdcSex))
            {
                strwhere += " and adcSex = @AdcSex";
                cmd.Parameters.Add(db.CreateParameter("@AdcSex", model.AdcSex,DbType.AnsiStringFixedLength));
            }
            #endregion

            string sql = String.Format("SELECT {0} FROM adctab where {1} {2}", SelectedFields,strwhere, OrderBy);
            string countSql = "SELECT COUNT(*) FROM adctab where " + strwhere;
            cmd.CommandText = countSql;
            rowCount = Convert.ToInt32(db.GetVar(cmd));

            ISqlText sqlPage = SqlFactory.CreateSqlDialect();
            string sqlPageText = sqlPage.GetPageSqlText(sql, pagesize, pageindex, "aid");
            
			cmd.CommandText = sqlPageText;
            return db.Select(cmd);
           
        }