예제 #1
0
        public bool _NhapSach(NhapSachDTO nhapSachDTO)
        {
            try
            {
                NhapSach nhapSach = new NhapSach();
                nhapSach.MaNhap    = nhapSachDTO.MaNhap;
                nhapSach.MaNV      = nhapSachDTO.MaNV;
                nhapSach.NgayNhap  = nhapSachDTO.NgayNhap;
                nhapSach.ThanhTien = 0;
                nhapSach.TrangThai = true;
                data.NhapSaches.Add(nhapSach);
                data.SaveChanges();


                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #2
0
 public bool NhapSach(NhapSachDTO nhapSachDTO)
 {
     return(nhapSachDAL._NhapSach(nhapSachDTO));
 }
예제 #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            NhapSachDTO nhapSachDTO = new NhapSachDTO {
                MaNhap    = txtMaNhap.Text,
                MaNV      = frmDangNhap.MaNV,
                NgayNhap  = DateTime.Now,
                ThanhTien = 0,
                TrangThai = true
            };


            CTNhapSachDTO cTNhapSachDTO = new CTNhapSachDTO {
                MaNhap  = txtMaNhap.Text,
                MaSach  = txtMaSach.Text,
                SoLuong = int.Parse(txtSoLuong.Text),
                DonGia  = int.Parse(txtGiaTien.Text)
            };



            if (rdoNhapMoi.Checked)
            {
                SachDTO sachDTO = new SachDTO();
                sachDTO.MaSach        = txtMaSach.Text;
                sachDTO.TenSach       = txtSach.Text;
                sachDTO.MaDauSach     = cbbDauSach.SelectedValue.ToString();
                sachDTO.TenTacGia     = txtTacGia.Text;
                sachDTO.TenNhaXuatBan = txtNXB.Text;
                sachDTO.NamXuatBan    = int.Parse(txtNamXB.Text);
                sachDTO.DonGia        = int.Parse(txtGiaTien.Text);
                sachDTO.TrangThai     = true;

                if (chkSachHiem.Checked)
                {
                    sachDTO.SachHiem = true;
                }
                else
                {
                    sachDTO.SachHiem = false;
                }
                sachDTO.SoLuong = int.Parse(txtSoLuong.Text);

                if (sachBUS.ThemSachMoi(sachDTO) && nhapSachBUS.NhapSach(nhapSachDTO) && cTNhapSachBUS.ThemCTNhapSach(cTNhapSachDTO))
                {
                    MessageBox.Show(Constrant.ThemThanhCong, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmNhapSach_Load(sender, e);
                }
                else
                {
                    MessageBox.Show(Constrant.ThemThatBai, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (rdoNhapThem.Checked)
            {
                if (sachBUS.NhapThemSachCu(txtMaSach.Text, int.Parse(txtSoLuong.Text)) && nhapSachBUS.NhapSach(nhapSachDTO) && cTNhapSachBUS.ThemCTNhapSach(cTNhapSachDTO))
                {
                    MessageBox.Show(Constrant.ThemThanhCong, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmNhapSach_Load(sender, e);
                }
                else
                {
                    MessageBox.Show(Constrant.ThemThatBai, Constrant.ThongBao, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }