예제 #1
0
        // find all get List<PurviewTable>
        public List<PurviewTable> findAll_List(string dbName)
        {
            string sql = "select * from purviewtable";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);

            OleDbDataReader reader = cmd.ExecuteReader();
            List<PurviewTable> list = new List<PurviewTable>();
            while (reader.Read()) {
                PurviewTable bean = new PurviewTable();

                bean.Id = reader.GetInt32(0);
                bean.Dept_userid = reader.GetInt32(1);
                bean.Dept_table = reader.GetString(2);
                bean.Purview = reader.GetInt32(3);

                list.Add(bean);
            }

            // close the con
            closeAll(con,cmd,reader);

            if (list.Count <= 0)
            {
                return null;
            }

            return list;
        }
예제 #2
0
        // add
        public void add(string dbName,PurviewTable form)
        {
            string sql = "insert into purviewtable(dept_userid,dept_table,purview) values(@dept_userid,@dept_table,@purview)";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter[] param = {new OleDbParameter("@dept_userid",form.Dept_userid),new OleDbParameter("@dept_table",form.Dept_table),
                                     new OleDbParameter("@purview",form.Purview)};
            cmd.Parameters.AddRange(param);

            cmd.ExecuteNonQuery();

            // close the con
            closeAll(con,cmd,null);
        }
예제 #3
0
        // load by id
        public PurviewTable load(string dbName,int id)
        {
            string sql = "select * from purviewtable where id=@id";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter param = new OleDbParameter("@id",id);
            cmd.Parameters.Add(param);

            OleDbDataReader reader = cmd.ExecuteReader();
            PurviewTable bean = null;
            if (reader.Read()) {
                bean = new PurviewTable();

                bean.Id = reader.GetInt32(0);
                bean.Dept_userid = reader.GetInt32(1);
                bean.Dept_table = reader.GetString(2);
                bean.Purview = reader.GetInt32(3);
            }

            // close the con
            closeAll(con, cmd, null);

            return bean;
        }
예제 #4
0
        // update
        public void update(string dbName,PurviewTable form)
        {
            string sql = "update purviewtable set dept_userid=@dept_userid,dept_table=@dept_table,purview=@purview where id=@id";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter[] param = {new OleDbParameter("@dept_userid",form.Dept_userid),new OleDbParameter("@dept_table",form.Dept_table),
                                     new OleDbParameter("@purview",form.Purview),new OleDbParameter("@id",form.Id)};
            cmd.Parameters.AddRange(param);

            cmd.ExecuteNonQuery();

            // close the con
            closeAll(con, cmd, null);
        }
예제 #5
0
        // load  by dept_userid
        public List<PurviewTable> loadByUserid(string dbName,int dept_userid)
        {
            string sql = "select * from purviewtable where dept_userid=@dept_userid";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql,con);
            OleDbParameter param = new OleDbParameter("@dept_userid", dept_userid);
            cmd.Parameters.Add(param);

            OleDbDataReader reader = cmd.ExecuteReader();
            List<PurviewTable> list = new List<PurviewTable>();
            while (reader.Read())
            {
                PurviewTable bean = new PurviewTable();

                bean.Id = reader.GetInt32(0);
                bean.Dept_userid = reader.GetInt32(1);
                bean.Dept_table = reader.GetString(2);
                bean.Purview = reader.GetInt32(3);

                list.Add(bean);
            }

            // close the con
            closeAll(con, cmd, reader);

            if (list.Count() <= 0) {
                return null;
            }

            return list;
        }