예제 #1
0
 /// <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));
 }
예제 #2
0
 /// <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);
 }
예제 #3
0
        /// <summary>
        /// 删除单条记录
        /// </summary>
        /// <param name="obj">对象</param>
        public int Delete(object obj)
        {

            string sql = "DELETE adctab WHERE 1=1  AND aid = @Aid";
            Command db = new Command();
            DbParameter[] ps = new DbParameter[1];
            
            ps[0] = db.CreateParameter("@Aid", obj,DbType.Int32);
            
            return db.Delete(sql,ps);
        }
예제 #4
0
 /// <summary>
 /// 获取数据总数
 /// </summary>
 public int GetRowCount()
 {
     string strwhere = " 1=1 ";
     
     Command db = new Command();
     string sql = "SELECT COUNT(*) FROM adctab where " + strwhere;
     return Convert.ToInt32(db.GetVar(sql));
 }
예제 #5
0
 /// <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);
     
 }
예제 #6
0
        /// <summary>
        /// 获取全部数据
        /// </summary>
        public DataTable GetAllList()
        {
             string strwhere = " 1=1 ";
            
            Command db = new Command();

            string sql = String.Format("SELECT {0} FROM adctab where {1} {2}", SelectedFields,strwhere, OrderBy);
            return db.Select(sql);
        }
예제 #7
0
        /// <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);
           
        }
예제 #8
0
        /// <summary>
        /// 删除多条记录【批量】
        /// </summary>
        /// <param name="array">数组</param>
        public int Delete(ArrayList array)
        {
            
            if (array == null || array.Count == 0)
                throw new ArgumentNullException("array");
            string sql = string.Format("DELETE adctab  where aid in({0})", StringHelp.Join(array));
            Command db = new Command();

            return db.Delete(sql);
        }