private void btnThem_Click(object sender, EventArgs e)
        {
            ResetColor();
            if (!ValidateData())
            {
                return;
            }

            SanPham_DTO  sanPhamDaCo = lstSanPham.SingleOrDefault(item => item.TenSP == txtTenSP.Text.Trim());
            NhapHang_DTO phieuNhap   = new NhapHang_DTO();

            phieuNhap.TenSanPham = txtTenSP.Text.Trim();
            phieuNhap.Ma_SanPham = sanPhamDaCo == null ? 0 : sanPhamDaCo.MaSP;
            phieuNhap.Ma_NSX     = (int)cboNSX.SelectedValue;
            phieuNhap.Ma_NV      = (int)cboNhanVien.SelectedValue;
            phieuNhap.Ma_LoaiSP  = (int)cboLoaiSP.SelectedValue;
            phieuNhap.DonGia     = int.Parse(txtDonGia.Text);
            phieuNhap.SoLuong    = (int)numSoLuong.Value;
            phieuNhap.TenLoai    = cboLoaiSP.Text;
            phieuNhap.Ten_NV     = cboNhanVien.Text.Split('-')[0];
            phieuNhap.Ten_NSX    = cboNSX.Text;

            lstPhieuNhap.Add(phieuNhap);
            dgvPhieuNhap.DataSource = typeof(List <NhapHang_DTO>);
            dgvPhieuNhap.DataSource = lstPhieuNhap;
            EditDataGridView();
        }
Beispiel #2
0
 public List <NhapHang_DTO> LoadDanhSachPhieuNhap()
 {
     try
     {
         List <NhapHang_DTO> listNhapHang = new List <NhapHang_DTO>();
         DataTable           data         = DataProvider.Instance.ExecuteQuery("LoadToanBoPhieuNhap");
         foreach (DataRow item in data.Rows)
         {
             NhapHang_DTO nhapHang = new NhapHang_DTO(item);
             listNhapHang.Add(nhapHang);
         }
         return(listNhapHang);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }