public List <ReaderCate> getReaderCateList()
        {
            List <ReaderCate> list = new List <ReaderCate>();
            String            sql  = String.Format("select " +
                                                   "Id,Name,LimitBooksCount,LimitDays,ReBorrowTimes,ReBorrowDays,Discount " +
                                                   "from ReaderCate"
                                                   );

            try
            {
                using (DbDataReader reader = conn.execReader(sql))
                {
                    while (reader.Read())
                    {
                        ReaderCate rc = new ReaderCate();
                        rc.Id              = Convert.ToInt32(reader[0]);
                        rc.Name            = reader[1].ToString();
                        rc.LimitBooksCount = Convert.ToInt32(reader[2]);
                        rc.LimitDays       = Convert.ToInt32(reader[3]);
                        rc.ReBorrowTimes   = Convert.ToInt32(reader[4]);
                        rc.ReBorrowDays    = Convert.ToInt32(reader[5]);
                        rc.Discount        = Convert.ToDouble(reader[6]);
                        list.Add(rc);
                    }
                }
            }
            catch (DbException)
            {
            }

            return(list);
        }
        public List <ReaderCate> findReaderCate(String attr, String value)
        {
            List <ReaderCate> list = new List <ReaderCate>();
            String            sql  = String.Format("select Id, Name, LimitBooksCount, LimitDays, ReBorrowTimes, ReBorrowDays from ReaderCate where {0} like '%{1}%'",
                                                   attr, value);

            try
            {
                using (DbDataReader reader = conn.execReader(sql))
                {
                    while (reader.Read())
                    {
                        ReaderCate rc = new ReaderCate();
                        rc.Id              = Convert.ToInt32(reader[0]);
                        rc.Name            = reader[1].ToString();
                        rc.LimitBooksCount = Convert.ToInt32(reader[2]);
                        rc.LimitDays       = Convert.ToInt32(reader[3]);
                        rc.ReBorrowTimes   = Convert.ToInt32(reader[4]);
                        rc.ReBorrowDays    = Convert.ToInt32(reader[5]);
                        rc.Discount        = Convert.ToDouble(reader[6]);
                        list.Add(rc);
                    }
                }
            }
            catch (DbException)
            {
                //输出日志
            }
            return(list);
        }
Esempio n. 3
0
        public bool delReaderCate(ReaderCate cate)
        {
            bool ret = user.readerRights.delReaderCate(cate);

            if (true == ret)
            {
                String val = cate.Name;
                log.write("删除读者角色", val, user.code);
            }
            return(ret);
        }
        public int getReaderCateCount(ReaderCate cate)
        {
            int    ret = 0;
            String sql = String.Format("Select count(*) from Readers where CateId = {0}", cate.Id);

            try
            {
                ret = int.Parse(conn.execScalar(sql).ToString());
            }
            catch (DbException)
            {
                ret = -1;
            }
            return(ret);
        }
        public bool delReaderCate(ReaderCate cate)
        {
            String sql = String.Format("delete from ReaderCate where Id='{0}'", cate.Id);
            int    ret = 0;

            try
            {
                ret = conn.execNonSQL(sql);
                if (ret == 1)
                {
                    return(true);
                }
            }
            catch (DbException)
            {
                return(false);
            }

            return(false);
        }
        public bool addReaderCate(ReaderCate cate)
        {
            String sql = String.Format("insert into ReaderCate values(null,'{0}',{1},{2},{3},{4},{5})",
                                       cate.Name, cate.LimitBooksCount, cate.LimitDays, cate.ReBorrowTimes, cate.ReBorrowDays, cate.Discount);
            int ret = 0;

            try
            {
                ret = conn.execNonSQL(sql);
                if (ret == 1)
                {
                    return(true);
                }
            }
            catch (DbException)
            {
                return(false);
            }

            return(false);
        }
        private ReaderCate getReaderCate(int cateId)
        {
            String sql = String.Format("select " +
                                       "Id,Name,LimitBooksCount,LimitDays,ReBorrowTimes,ReBorrowDays,Discount " +
                                       "from ReaderCate where Id = {0}",
                                       cateId);

            DbDataReader reader = conn.execReader(sql);
            ReaderCate   rc     = new ReaderCate();

            if (reader.Read())
            {
                rc.Id              = Convert.ToInt32(reader[0]);
                rc.Name            = reader[1].ToString();
                rc.LimitBooksCount = Convert.ToInt32(reader[2]);
                rc.LimitDays       = Convert.ToInt32(reader[3]);
                rc.ReBorrowTimes   = Convert.ToInt32(reader[4]);
                rc.ReBorrowDays    = Convert.ToInt32(reader[5]);
                rc.Discount        = Convert.ToDouble(reader[6]);
            }
            return(rc);
        }
        public bool addBorrow(Book b, Reader r, User u)
        {
            int        ret        = 0;
            ReaderCate rc         = r.Cate;
            DateTime   ReturnDate = DateTime.Now;

            ReturnDate = ReturnDate.AddDays(rc.LimitDays);
            String sql = String.Format("insert into BorrowRecord " +
                                       "values(null, '{0}', '{1}', Date('now','+8 hour'), '{2}', 0, {3}, '{4}', null)",
                                       b.Id,
                                       r.Id,
                                       ReturnDate.ToString("yyyy-MM-dd"),
                                       rc.ReBorrowTimes,
                                       u.id);

            ret = conn.execNonSQL(sql);
            if (ret == 1)
            {
                return(true);
            }

            return(false);
        }
        public bool upReaderCate(ReaderCate cate)
        {
            String sql = String.Format("Update ReaderCate set Name='{0}'," +
                                       "LimitBooksCount={1},LimitDays = {2},ReBorrowTimes={3},ReBorrowDays ={4},Discount = {6} " +
                                       "where Id={5}",
                                       cate.Name, cate.LimitBooksCount, cate.LimitDays, cate.ReBorrowTimes, cate.ReBorrowDays, cate.Id, cate.Discount);
            int ret = 0;

            try
            {
                ret = conn.execNonSQL(sql);
                if (ret == 1)
                {
                    return(true);
                }
            }
            catch (DbException)
            {
                return(false);
            }

            return(false);
        }
Esempio n. 10
0
 public int getReaderCateCount(ReaderCate cate)
 {
     return(user.readerRights.getReaderCateCount(cate));
 }