コード例 #1
0
        public List <book> GetBookByobj(bookSearch bs, int page = 1)
        {
            int RecordsPerPage = 10;

            using (CTyPHSachEntities db = new CTyPHSachEntities())
            {
                var book = (from b in db.Books
                            where (bs.ten == null || b.bookName.Contains(bs.ten)) &&
                            b.status != 2 &&
                            (bs.mota == null || b.description.Contains(bs.mota)) &&
                            (bs.id_danhmuc == null || b.CategoryID == bs.id_danhmuc.Value) &&
                            (bs.ma == null || b.BookID == bs.ma.Value) &&
                            (bs.id_nxb == null || b.PublisherID == bs.id_nxb.Value) &&
                            (bs.gianhap == null || b.receiptPrice >= bs.gianhap.Value) &&
                            (bs.gianhapden == null || b.receiptPrice <= bs.gianhapden.Value) &&
                            (bs.giaxuat == null || b.price >= bs.giaxuat.Value) &&
                            (bs.giaxuatden == null || b.price <= bs.giaxuatden.Value)


                            select new book()
                {
                    ma = b.BookID,
                    ten = b.bookName,
                    gianhap = b.receiptPrice,
                    giaxuat = b.price,
                    sl = b.amount,
                    id_nxb = b.PublisherID,
                    id_danhmuc = b.CategoryID,
                    nhaxb = (from c in db.Publishers
                             where c.PublisherID == b.PublisherID
                             select new nxb()
                    {
                        id = c.PublisherID,
                        name = c.publisherName
                    }).FirstOrDefault(),
                    cat = (from d in db.Categories
                           where d.CategoryID == d.CategoryID
                           select new category()
                    {
                        id = d.CategoryID,
                        name = d.CategoryName
                    }).FirstOrDefault()
                }).OrderBy(x => x.ten).Skip((page - 1) * RecordsPerPage).Take(RecordsPerPage).ToList();
                return(book);
            }
        }
コード例 #2
0
        public void loadSachformsearch(bookSearch bs, int page = 1)
        {
            tb_trang.Text = "1";
            DataTable table = new DataTable();
            int       stt   = 0;

            table.Columns.Add("STT", typeof(int));
            table.Columns.Add("Ma", typeof(int));
            table.Columns.Add("Tên", typeof(string));
            table.Columns.Add("Số Lượng", typeof(int));
            table.Columns.Add("Giá nhập", typeof(decimal));
            table.Columns.Add("Giá xuất", typeof(decimal));
            table.Columns.Add("NXB", typeof(string));
            table.Columns.Add("Danh mục", typeof(string));
            var books = SachService.GetBookByobj(bs, page);

            foreach (var item in books)
            {
                stt++;
                table.Rows.Add(stt, item.ma, item.ten, item.sl, item.gianhap, item.giaxuat, item.nhaxb.name, item.cat.name);
            }
            dgv_sach.DataSource = table;
        }
コード例 #3
0
        public ActionResult Sach(bookSearch bk)
        {
            var sach = SachService.GetBookByobj(bk);

            return(PartialView(sach));
        }
コード例 #4
0
 public ActionResult Create(bookSearch bk)
 {
     loadnxb();
     return(View());
 }
コード例 #5
0
        private void bt_timkiem_Click(object sender, EventArgs e)
        {
            bookSearch bs = new bookSearch();

            if (tb_ten.TextLength > 0)
            {
                bs.ten = tb_ten.Text;
            }

            if (tb_ma.TextLength > 0)
            {
                try
                {
                    bs.ma = Convert.ToInt16(tb_ma.Text.Trim());
                }
                catch (Exception ex)
                {
                }
            }
            try
            {
                bs.gianhap    = Convert.ToDecimal(tb_gianhap.Text.Trim());
                bs.giaxuat    = Convert.ToDecimal(tb_giaxuat.Text.Trim());
                bs.gianhapden = Convert.ToDecimal(tb_gianhapden.Text.Trim());
                bs.giaxuatden = Convert.ToDecimal(tb_giaxuatden.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            try
            {
                bs.gianhap    = Convert.ToDecimal(tb_gianhap.Text.Trim());
                bs.giaxuat    = Convert.ToDecimal(tb_giaxuat.Text.Trim());
                bs.gianhapden = Convert.ToDecimal(tb_gianhapden.Text.Trim());
                bs.giaxuatden = Convert.ToDecimal(tb_giaxuatden.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            try
            {
                bs.gianhap = Convert.ToDecimal(tb_gianhap.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            try
            {
                bs.giaxuat = Convert.ToDecimal(tb_giaxuat.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            try
            {
                bs.gianhapden = Convert.ToDecimal(tb_gianhapden.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            try
            {
                bs.giaxuatden = Convert.ToDecimal(tb_giaxuatden.Text.Trim());
            }
            catch (Exception ex)
            {
            }
            if (tb_mota.TextLength > 0)
            {
                bs.mota = tb_mota.Text;
            }
            bs.id_danhmuc = Convert.ToInt16(cb_danhmuc.SelectedValue);
            bs.id_nxb     = Convert.ToInt16(cb_nhaxb.SelectedValue);

            loadSachformsearch(bs);
        }
コード例 #6
0
 public static List <book> GetBookByobj(bookSearch bs, int page = 1)
 {
     return(repository.GetBookByobj(bs, page));
 }