public ActionResult Details(int?id, int page = 1, int pageSize = 10, string search = null)
        {
            if (id == null)
            {
                putErrorMessage("Đường dẫn không chính xác");
                return(RedirectToAction("TheoDoi"));
            }
            ViewBag.cultureInfo = CultureInfo;
            var nxb = NhaXuatBanManager.find((int)id);

            if (nxb == null)
            {
                putErrorMessage("Không tìm thấy Nhà xuất bản");
                return(RedirectToAction("TheoDoi"));
            }
            ViewBag.currentNXB = nxb;
            var DMCongNo = nxb.CongNo;

            if (!String.IsNullOrEmpty(search))
            {
                DMCongNo          = CongNoNXBManager.filter(search, DMCongNo);
                ViewBag.SearchKey = search;
            }
            ViewBag.tongSoLuongNo = DMCongNo.Sum(cn => cn.SoLuong);
            ViewBag.tongTienNo    = DMCongNo.Sum(cn => cn.ThanhTien);
            var models = DMCongNo.ToPagedList(page, pageSize);

            setAlertMessage();
            return(View(models));
        }
 public ActionResult Create(NhaXuatBan model, FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             var result = NhaXuatBanManager.add(model);
             if (result != 0)
             {
                 putSuccessMessage("Thêm thành công");
                 return(RedirectToAction("Details", new { id = result }));
             }
             else
             {
                 putErrorMessage("Thêm không thành công");
             }
         }
         else
         {
             putModelStateFailErrors(ModelState);
         }
         setAlertMessage();
         return(View(model));
     }
     catch (Exception ex)
     {
         putErrorMessage(ex.Message);
         return(RedirectToAction("Create"));
     }
 }
 private void btnLoc_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(txbLoc.Text))
     {
         gdvDMNXB.DataSource = NhaXuatBanManager.filter(txbLoc.Text, _DMNXB);
     }
 }
 private void txbLoc_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         gdvDMNXB.DataSource = NhaXuatBanManager.filter(txbLoc.Text, _DMNXB);
     }
 }
示例#5
0
 private void LoadNXB()
 {
     _DMNXB               = NhaXuatBanManager.getAll();
     cmbNXB.DataSource    = _DMNXB;
     cmbNXB.DisplayMember = nameof(NhaXuatBanManager.Properties.TenNXB);
     cmbNXB.ValueMember   = nameof(NhaXuatBanManager.Properties.MaSoNXB);
 }
 public ActionResult Edit(NhaXuatBan model, FormCollection collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (NhaXuatBanManager.edit(model))
             {
                 putSuccessMessage("Cập nhật thành công");
                 return(RedirectToAction("Details", new { id = model.MaSoNXB }));
             }
             else
             {
                 putErrorMessage("Cập nhật không thành công");
             }
         }
         else
         {
             putModelStateFailErrors(ModelState);
         }
         return(RedirectToAction("Edit", new { id = model.MaSoNXB }));
     }
     catch (Exception ex)
     {
         putErrorMessage(ex.Message);
         return(RedirectToAction("Edit", new { id = model.MaSoNXB }));
     }
 }
        //Khi Chọn Thêm
        private void btnThem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn thêm nhà xuất bản", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (!txbTenNXB.Text.Equals("") && !txbDiaChi.Text.Equals("") && !txbSoDienThoai.Text.Equals("") && !txbSoTaiKhoan.Text.Equals(""))
                {
                    NhaXuatBan nxb = new NhaXuatBan();
                    nxb.TenNXB      = txbTenNXB.Text.ToString();
                    nxb.DiaChi      = txbDiaChi.Text.ToString();
                    nxb.SoDienThoai = txbSoDienThoai.Text.ToString();
                    nxb.SoTaiKhoan  = txbSoTaiKhoan.Text.ToString();
                    nxb.NganHang    = txbNganHang.Text.ToString();

                    if (NhaXuatBanManager.add(nxb) != 0)
                    {
                        MessageBox.Show("Đã thêm nhà xuất bản thành công");
                    }
                    else
                    {
                        MessageBox.Show("Không thêm được");
                    }
                }
                else
                {
                    MessageBox.Show("Bạn cần nhập đầy đủ thuông tin");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
示例#8
0
 private void LoadDSNXB()
 {
     _DSNXB = NhaXuatBanManager.getAll();
     cmbNhaXuatBan.DataSource    = _DSNXB;
     cmbNhaXuatBan.DisplayMember = "TenNXB";
     cmbNhaXuatBan.ValueMember   = "MaSoNXB";
 }
示例#9
0
 // GET: PhieuNhap/Create
 public ActionResult Create(int?masonxb)
 {
     if (masonxb != null)
     {
         var nxb = NhaXuatBanManager.find((int)masonxb);
         if (nxb == null || nxb.TrangThai == 0)
         {
             putErrorMessage("Không tìm thấy Nhà xuát bản");
             return(RedirectToAction("Create"));
         }
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.currentNXB  = nxb;
         ViewBag.DMSach      = new SelectList(nxb.Sach,
                                              nameof(SachManager.Properties.MaSoSach),
                                              nameof(SachManager.Properties.TenSach), "");
         if (_phieu == null)
         {
             _phieu = new PhieuNhap();
         }
         _phieu.MaSoNXB = nxb.MaSoNXB;
         _phieu.NXB     = nxb;
         _phieu.NgayLap = DateTime.Now;
         setAlertMessage();
         return(View(_phieu));
     }
     else
     {
         ViewBag.DMNXB = new SelectList(NhaXuatBanManager.getAllAlive(),
                                        nameof(NhaXuatBanManager.Properties.MaSoNXB),
                                        nameof(NhaXuatBanManager.Properties.TenNXB), "");
         _phieu = new PhieuNhap();
         setAlertMessage();
         return(View());
     }
 }
 private void cmbNXB_SelectionChangeCommitted(object sender, EventArgs e)
 {
     _currentNXB     = NhaXuatBanManager.find(int.Parse(cmbNXB.SelectedValue.ToString()));
     txbMaSoNXB.Text = _currentNXB.MaSoNXB + "";
     loadSach();
     cmbNXB.Enabled = false;
 }
        //Khi CHọn xóa NXB
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn xóa nhà xuất bản", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (!txbMaSoNXB.Text.Equals(""))
                {
                    if (NhaXuatBanManager.delete(int.Parse(txbMaSoNXB.Text.ToString())))
                    {
                        MessageBox.Show("Đã xóa thành công");
                        loadNXB();
                    }
                    else
                    {
                        MessageBox.Show("Không xóa được");
                    }
                }
                else
                {
                    MessageBox.Show("Chưa nhập mã nhà xuất bản cần xóa");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
        //Khi Cập nhật thông tin NXB
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn cập nhật nhà xuất bản", "Thông báo", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (!txbMaSoNXB.Text.Equals("") && !txbTenNXB.Text.Equals("") && !txbSoTaiKhoan.Text.Equals("") && !txbSoDienThoai.Text.Equals(""))
                {
                    _currentNXB.TenNXB      = txbTenNXB.Text.ToString();
                    _currentNXB.DiaChi      = txbDiaChi.Text.ToString();
                    _currentNXB.SoDienThoai = txbSoDienThoai.Text.ToString();
                    _currentNXB.SoTaiKhoan  = txbSoTaiKhoan.Text.ToString();
                    _currentNXB.NganHang    = txbNganHang.Text.ToString();

                    if (NhaXuatBanManager.edit(_currentNXB))
                    {
                        MessageBox.Show("Đã sửa thành công");
                        loadNXB();
                    }
                    else
                    {
                        MessageBox.Show("Không sửa được");
                    }
                }
                else
                {
                    MessageBox.Show("Bạn phải nhập đủ thông tin nhà xuất bản");
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
示例#13
0
        // GET: Sach/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                putErrorMessage("Đường dẫn không chính xác");
                return(RedirectToAction("Index"));
            }
            var model = SachManager.find((int)id);

            if (model == null || model.TrangThai == 0)
            {
                putErrorMessage("Không tìm thấy");
                return(RedirectToAction("Index"));
            }
            //Combobox Nhà xuất bản
            ViewBag.DMNXB = new SelectList(NhaXuatBanManager.getAllAlive(),
                                           nameof(NhaXuatBanManager.Properties.MaSoNXB),
                                           nameof(NhaXuatBanManager.Properties.TenNXB), "");
            //Combobox lĩnh vực
            ViewBag.DMLinhVuc = new SelectList(LinhVucManager.getAllALive(),
                                               nameof(LinhVucManager.Properties.MaSoLinhVuc),
                                               nameof(LinhVucManager.Properties.TenLinhVuc), "");
            if (model.HinhAnh != null)
            {
                ViewBag.imgSrc = ImagesHelper.ImageToDataBase64String(model.HinhAnhTypeImage);
            }
            setAlertMessage();
            return(View(model));
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         var model = NhaXuatBanManager.find((int)id);
         if (model == null)
         {
             putErrorMessage("Không tìm thấy");
             return(RedirectToAction("Index"));
         }
         if (model.delete())
         {
             putSuccessMessage("Xóa thành công");
             return(RedirectToAction("Index"));
         }
         else
         {
             putErrorMessage("Xóa không thành công");
         }
         return(RedirectToAction("Delete", new { id }));
     }
     catch (Exception ex)
     {
         putErrorMessage(ex.Message);
         return(RedirectToAction("Delete", new { id }));
     }
 }
示例#15
0
 private void cmbNhaXuatBan_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (cmbNhaXuatBan.SelectedIndex != -1)
     {
         NhaXuatBan nxb = NhaXuatBanManager.find(int.Parse(cmbNhaXuatBan.SelectedValue.ToString()));
         _DMSach = nxb.Sach;
         cmbNhaXuatBan.Enabled = false;
     }
 }
示例#16
0
 //Khi Load Form
 private void frmThemSach_Load(object sender, EventArgs e)
 {
     //Load tất cả lĩnh vực
     _DMLinhVuc            = LinhVucManager.getAll();
     cmbLinhVuc.DataSource = _DMLinhVuc;
     //Load tất cả nhà xuất bản
     _DMNXB            = NhaXuatBanManager.getAll();
     cmbNXB.DataSource = _DMNXB;
 }
        public void loadNXB()
        {
            _DMNXB = NhaXuatBanManager.getAllAlive()
                     .Where(nxb => nxb.tongTienNoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 &&
                            nxb.tinhTongSoLuongNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 &&
                            nxb.tongTienNhapThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();
            gdvDMNXB.DataSource = _DMNXB;

            _tongTienNo         = _DMNXB.Sum(nxb => nxb.TongTienNoThang);
            _tongTienNhap       = _DMNXB.Sum(nxb => nxb.TongTienNhapTheoThang);
            lbTongConNo.Text    = String.Format(_cultureInfo, "{0:c}", _tongTienNo);
            lbTongTienSach.Text = String.Format(_cultureInfo, "{0:c}", _tongTienNhap);
            lbTongDaChi.Text    = String.Format(_cultureInfo, "{0:c}", _tongTienNhap - _tongTienNo);
        }
 public ActionResult DoanhThu(DateTime?startDate,
                              DateTime?endDate,
                              int dlpage         = 1,
                              int dlpageSize     = 10,
                              int nxbpage        = 1,
                              int nxbpageSize    = 10,
                              string searchDaiLy = null,
                              string searchNXB   = null)
 {
     if (startDate != null && endDate != null)
     {
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.startDate   = startDate;
         ViewBag.endDate     = endDate;
         List <DaiLy> DMDaily = DaiLyManager.getAllAlive()
                                .Where(dl => dl.tinhTongTienThanhToanTheoThang(
                                           ((DateTime)startDate).Month,
                                           ((DateTime)startDate).Year,
                                           ((DateTime)endDate).Month,
                                           ((DateTime)endDate).Year) > 0).ToList();
         ViewBag.tongTienThu = DMDaily.Sum(s => s.TongTienThanhToanTheoThang);
         if (!String.IsNullOrEmpty(searchDaiLy))
         {
             DMDaily = DaiLyManager.filter(searchDaiLy, DMDaily);
             ViewBag.SearchKeyDaiLy = searchDaiLy;
         }
         List <NhaXuatBan> DMNXB = NhaXuatBanManager.getAllAlive()
                                   .Where(nxb => nxb.tinhTongTienThanhToanTheoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0).ToList();
         ViewBag.tongTienChi = DMNXB.Sum(s => s.TongTienThanhToanTheoThang);
         if (!String.IsNullOrEmpty(searchNXB))
         {
             DMNXB = NhaXuatBanManager.filter(searchNXB, DMNXB);
             ViewBag.SearchKeyNXB = searchNXB;
         }
         ViewBag.tongCongDaiLy          = DMDaily.Sum(dl => dl.TongTienThanhToan);
         ViewBag.tongCongDaiLyTheoThang = DMDaily.Sum(dl => dl.TongTienThanhToanTheoThang);
         ViewBag.tongCongNXB            = DMNXB.Sum(nxb => nxb.TongTienThanhToan);
         ViewBag.tongCongNXBTheoThang   = DMNXB.Sum(nxb => nxb.TongTienThanhToanTheoThang);
         ViewBag.DaiLymodels            = DMDaily.ToPagedList(dlpage, dlpageSize);
         ViewBag.NXBmodels = DMNXB.ToPagedList(nxbpage, nxbpageSize);
         setAlertMessage();
         return(View());
     }
     setAlertMessage();
     return(View());
 }
示例#19
0
        // GET: Sach/Create
        public ActionResult Create()
        {
            var model = new Sach();

            //Combobox nhà xuất bản
            ViewBag.DMNXB = new SelectList(NhaXuatBanManager.getAllAlive(),
                                           nameof(NhaXuatBanManager.Properties.MaSoNXB),
                                           nameof(NhaXuatBanManager.Properties.TenNXB), "");
            //Combobox lĩnh vực
            ViewBag.DMLinhVuc = new SelectList(LinhVucManager.getAllALive(),
                                               nameof(LinhVucManager.Properties.MaSoLinhVuc),
                                               nameof(LinhVucManager.Properties.TenLinhVuc), "");
            setAlertMessage();
            return(View(model));
        }
        private void LoadTT()
        {
            _DSDaiLy = DaiLyManager.getAllAlive()
                       .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();
            gdvDaiLy.DataSource = _DSDaiLy;
            lbTongThu.Text      = _DSDaiLy.Sum(s => s.TongTienThanhToanTheoThang) + "";
            int tongthu = int.Parse(lbTongThu.Text.ToString());

            _DSNXB = NhaXuatBanManager.getAllAlive()
                     .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList();
            gdvNXB.DataSource = _DSNXB;
            lbTongChi.Text    = _DSNXB.Sum(s => s.TongTienThanhToanTheoThang) + "";
            int tongchi = int.Parse(lbTongChi.Text.ToString());

            lbLoiNhuan.Text = tongthu - tongchi + "";
        }
        // GET: NhaXuatBan/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                putErrorMessage("Đường dẫn không chính xác");
                return(RedirectToAction("Index"));
            }
            var model = NhaXuatBanManager.find((int)id);

            if (model == null)
            {
                putErrorMessage("Không tìm thấy");
                return(RedirectToAction("Index"));
            }
            setAlertMessage();
            return(View(model));
        }
        // GET: NhaXuatBan
        public ActionResult Index(int page = 1, int pageSize = 10, string search = null)
        {
            List <NhaXuatBan> DMNXB = null;

            if (!String.IsNullOrEmpty(search))
            {
                DMNXB             = NhaXuatBanManager.filter(search);
                ViewBag.searchKey = search;
            }
            else
            {
                DMNXB = NhaXuatBanManager.getAllAlive();
            }
            var models = DMNXB.ToPagedList(page, pageSize);

            setAlertMessage();
            return(View(models));
        }
        public ViewResult BlankEditorRow(int masonxb, int masosach = 0)
        {
            var nxb     = NhaXuatBanManager.find((int)masonxb);
            var chitiet = new ChiTietHoaDonNXB();

            if (masosach != 0)
            {
                chitiet.MaSoSach = (int)masosach;
                if (_hoadon.ChiTiet.Contains(chitiet))
                {
                    return(null);
                }
            }
            else
            {
                var founded = false;
                foreach (Sach s in nxb.Sach.Where(s => s.CongNoNXB.Count > 0).ToList())
                {
                    chitiet.MaSoSach = s.MaSoSach;
                    chitiet.Sach     = s;
                    if (_hoadon.ChiTiet.Contains(chitiet))
                    {
                        continue;
                    }
                    founded = true;
                    break;
                }
                if (!founded)
                {
                    return(null);
                }
            }
            ViewBag.currentNXB  = nxb;
            ViewBag.cultureInfo = CultureInfo;
            ViewBag.DMSach      = new SelectList(nxb.Sach,
                                                 nameof(SachManager.Properties.MaSoSach),
                                                 nameof(SachManager.Properties.TenSach), "");
            chitiet.SoLuong = 1;
            chitiet.DonGia  = chitiet.Sach.GiaNhap;
            _hoadon.addDetail(chitiet);
            return(View("ChiTietEditorRow", chitiet));
        }
 public ActionResult TheoDoi(DateTime?startDate, DateTime?endDate, int page = 1, int pageSize = 10, string search = null)
 {
     if (startDate != null && endDate != null)
     {
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.startDate   = startDate;
         ViewBag.endDate     = endDate;
         List <NhaXuatBan> DMNXB = NhaXuatBanManager.getAllAlive()
                                   .Where(nxb => nxb.tinhTongSoLuongNoTheoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0 &&
                                          nxb.tongTienNoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0 &&
                                          nxb.tongTienNhapThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0).ToList();
         if (!String.IsNullOrEmpty(search))
         {
             DMNXB             = NhaXuatBanManager.filter(search, DMNXB);
             ViewBag.SearchKey = search;
         }
         ViewBag.tongTienNhap  = DMNXB.Sum(nxb => nxb.TongTienNhapTheoThang);
         ViewBag.tongSoLuongNo = DMNXB.Sum(nxb => nxb.TongSoLuongNoTheoThang);
         ViewBag.tongTienNo    = DMNXB.Sum(s => s.TongTienNoThang);
         var models = DMNXB.ToPagedList(page, pageSize);
         setAlertMessage();
         return(View(models));
     }
     setAlertMessage();
     return(View());
 }
        public FileStreamResult DoanhThu(DateTime startDate, DateTime endDate)
        {
            List <DaiLy> DMDaily = DaiLyManager.getAllAlive()
                                   .Where(dl => dl.tinhTongTienThanhToanTheoThang(
                                              ((DateTime)startDate).Month,
                                              ((DateTime)startDate).Year,
                                              ((DateTime)endDate).Month,
                                              ((DateTime)endDate).Year) > 0).ToList();
            List <NhaXuatBan> DMNXB = NhaXuatBanManager.getAllAlive()
                                      .Where(nxb => nxb.tinhTongTienThanhToanTheoThang(
                                                 ((DateTime)startDate).Month,
                                                 ((DateTime)startDate).Year,
                                                 ((DateTime)endDate).Month,
                                                 ((DateTime)endDate).Year) > 0).ToList();
            var printer = new PrintHelper();

            printer.FileName   = "report.pdf";
            printer.FolderPath = "D://";
            printer.Title      = "Thống kê doanh thu";
            var info = new MemoryStream(printer.printDoanhThu(DMDaily, DMNXB, startDate, endDate));

            return(new FileStreamResult(info, "application/pdf"));
        }
 // GET: PhieuNhap/ThanhToan
 public ActionResult ThanhToan(int?masonxb)
 {
     if (masonxb != null)
     {
         var nxb = NhaXuatBanManager.find((int)masonxb);
         if (nxb == null || nxb.TrangThai == 0)
         {
             putErrorMessage("Không tìm thấy nhà xuất bản");
             return(RedirectToAction("ThanhToan"));
         }
         ViewBag.cultureInfo = CultureInfo;
         ViewBag.currentNXB  = nxb;
         ViewBag.DMSach      = new SelectList(nxb.Sach.Where(s => s.CongNoNXB.Count > 0).ToList(),
                                              nameof(SachManager.Properties.MaSoSach),
                                              nameof(SachManager.Properties.TenSach), "");
         if (_hoadon == null)
         {
             _hoadon = new HoaDonNXB();
         }
         _hoadon.MaSoNXB = nxb.MaSoNXB;
         _hoadon.NXB     = nxb;
         _hoadon.NgayLap = DateTime.Now;
         setAlertMessage();
         return(View(_hoadon));
     }
     else
     {
         ViewBag.DMNXB = new SelectList(NhaXuatBanManager.getAllAlive()
                                        .Where(nxb => nxb.TongTienNo > 0).ToList(),
                                        nameof(NhaXuatBanManager.Properties.MaSoNXB),
                                        nameof(NhaXuatBanManager.Properties.TenNXB), "");
         _hoadon = new HoaDonNXB();
         setAlertMessage();
         return(View());
     }
 }
 /// <summary>
 /// Load danh sách NXB và đưa lên giao diện
 /// </summary>
 public void loadNXB()
 {
     _DMNXB = NhaXuatBanManager.getAllAlive();
     gdvDMNXB.DataSource = _DMNXB;
 }
示例#28
0
 public bool delete()
 {
     this.TrangThai = 0;
     return(NhaXuatBanManager.edit(this));
 }