Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            MuonSachDTO muonSachDTO = new MuonSachDTO {
                MaMuon      = txtMaMuon.Text,
                SoThe       = txtMaThe.Text,
                MaNV        = frmDangNhap.MaNV,
                NgayMuon    = dtpNgayLap.Value,
                NgayPhaiTra = dtpNgayTra.Value,
                TrangThai   = true
            };

            List <CTMuonSachDTO> listCTMuon = new List <CTMuonSachDTO>();

            foreach (ListViewItem item in lsvSach.Items)
            {
                CTMuonSachDTO ct = new CTMuonSachDTO();
                ct.MaMuon    = txtMaMuon.Text;
                ct.MaSach    = item.Text;
                ct.SoLuong   = int.Parse(item.SubItems[2].Text);
                ct.TrangThai = true;
                ct.GiaSach   = 0;

                listCTMuon.Add(ct);
            }

            if (muonSachBUS.ThemMuonSach(muonSachDTO))
            {
                if (ctMuonBUS.ThemCTMuonSach(listCTMuon))
                {
                    MessageBox.Show(Constrant.ThemThanhCong, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(Constrant.ThemThatBai, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(Constrant.ThemThatBai, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public bool ThemMuonSach(MuonSachDTO muonSachDTO)
        {
            try
            {
                MuonSach muonSach = new MuonSach();
                muonSach.MaMuon      = muonSachDTO.MaMuon;
                muonSach.SoThe       = muonSachDTO.SoThe;
                muonSach.MaNV        = muonSachDTO.MaNV;
                muonSach.NgayMuon    = muonSachDTO.NgayMuon;
                muonSach.NgayPhaiTra = muonSachDTO.NgayPhaiTra;
                muonSach.TrangThai   = true;


                data.MuonSaches.Add(muonSach);

                data.SaveChanges();

                return(true);
            }catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 3
0
 public bool ThemMuonSach(MuonSachDTO muonSachDTO)
 {
     return(muonSachDAO.ThemMuonSach(muonSachDTO));
 }