void HuyNhap(HoaDonNhap_DTO hd_nhap) { HoaDonNhap_BUS hd_bus = new HoaDonNhap_BUS(); if (hd_bus.Huy(hd_nhap.id, int.Parse(txtTongTien.Text))) { LoadHDNhap(); MessageBox.Show("Hủy Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } txtMaNCC.Enabled = true; btnHuyHoaDon.Enabled = false; btnNhapKho.Enabled = false; }
private void frmHoaDonNhap_Load(object sender, EventArgs e) { HoaDonNhap_BUS hDN_BUS = new HoaDonNhap_BUS(); dsHoaDonNhap = hDN_BUS.LayDanhSach(); dataGridViewHoaDonNhap.DataSource = dsHoaDonNhap; dataGridViewHoaDonNhap.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewHoaDonNhap.Columns["MAHDN"].HeaderText = "Mã Hoá Nhập"; dataGridViewHoaDonNhap.Columns["MANV"].HeaderText = "Mã Nhân Viên Lập Hoá Đơn"; dataGridViewHoaDonNhap.Columns["NGAYMUA"].HeaderText = "Ngày Lập Hoá Đơn"; dataGridViewHoaDonNhap.Columns["MANCC"].HeaderText = "Mã Khách Hàng"; dataGridViewHoaDonNhap.Columns["TONGTIEN"].HeaderText = "Tổng Tiền"; dataGridViewHoaDonNhap.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; }
void NhapKho(HoaDonNhap_DTO hd_nhap) { HienThiHoaDonNhap_BUS hthdnhap_bus = new HienThiHoaDonNhap_BUS(); List <HienThiHoaDonNhap_DTO> listHTHD = hthdnhap_bus.LayDanhSachTheoIDHoaDonNhap(hd_nhap.id); BangSize_BUS size_bus = new BangSize_BUS(); foreach (HienThiHoaDonNhap_DTO item in listHTHD) { size_bus.CapNhatKho(item.idGiay, item.size, item.soLuong, item.donGia); } HoaDonNhap_BUS hd_bus = new HoaDonNhap_BUS(); if (hd_bus.NhapKho(hd_nhap.id, int.Parse(txtTongTien.Text))) { LoadHDNhap(); MessageBox.Show("Thanh Toán Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } txtMaNCC.Enabled = true; btnHuyHoaDon.Enabled = false; btnNhapKho.Enabled = false; }
private void btnThemSP_Click(object sender, EventArgs e) { if (txtTenGiay.Text != "") { txtMaNCC.Enabled = false; HoaDonNhap_BUS hdnhap_bus = new HoaDonNhap_BUS(); ChiTietHoaDonNhap_BUS cthdnhap_bus = new ChiTietHoaDonNhap_BUS(); HoaDonNhap_DTO hd_nhap = new HoaDonNhap_DTO(); hd_nhap = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text); if (hd_nhap.id == -1) { HoaDonNhap_DTO hdnhap_moi = new HoaDonNhap_DTO(-1, BienToanCuc.nvDangNhap.idNhanVien, txtMaNCC.Text, DateTime.Now, 0, 0); if (hdnhap_bus.Them(hdnhap_moi)) { ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hdnhap_bus.LastID(), idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text)); cthdnhap_bus.Them(cthd_nhap); HienThiCTHoaDonNhap(hdnhap_bus.LastID()); lvHoaDon.Tag = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text); LoadHDNhap(); } } else { ChiTietHoaDonNhap_DTO cthd_nhap = new ChiTietHoaDonNhap_DTO(hd_nhap.id, idGiay, cbSize.Text, int.Parse(txtSoLuongNhap.Text), int.Parse(txtGiaNhap.Text)); cthdnhap_bus.Them(cthd_nhap); HienThiCTHoaDonNhap(hd_nhap.id); lvHoaDon.Tag = hd_nhap; LoadHDNhap(); } ResetSP(); } else { MessageBox.Show("Vui lòng chọn sản phẩm !!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void HienThiCTHoaDonNhap(int idHoaDonNhap) { lvHoaDon.Items.Clear(); HoaDonNhap_BUS hdnhap_bus = new HoaDonNhap_BUS(); HienThiHoaDonNhap_BUS hthdnhap_bus = new HienThiHoaDonNhap_BUS(); List <HienThiHoaDonNhap_DTO> listHTHD = new List <HienThiHoaDonNhap_DTO>(); listHTHD = hthdnhap_bus.LayDanhSachTheoIDHoaDonNhap(idHoaDonNhap); int tongTien = 0; foreach (HienThiHoaDonNhap_DTO item in listHTHD) { ListViewItem lvItem = new ListViewItem(item.tenGiay); lvItem.SubItems.Add(item.size); lvItem.SubItems.Add(item.soLuong.ToString()); lvItem.SubItems.Add(item.donGia.ToString()); lvItem.SubItems.Add(item.thanhTien.ToString()); tongTien = tongTien + item.thanhTien; lvHoaDon.Items.Add(lvItem); } txtTongTien.Text = tongTien.ToString(); hdnhap_bus.CapNhatTien(idHoaDonNhap, tongTien); }
void LoadHDNhap() { if (txtMaNCC.Text != "") { HoaDonNhap_BUS hdnhap_bus = new HoaDonNhap_BUS(); HoaDonNhap_DTO hd_nhap = new HoaDonNhap_DTO(); hd_nhap = hdnhap_bus.LayHoaDonChuaNhapTheoMaNCC(txtMaNCC.Text); lvHoaDon.Tag = hd_nhap; if (hd_nhap.id == -1) { lvHoaDon.Items.Clear(); btnHuyHoaDon.Enabled = false; btnNhapKho.Enabled = false; txtTongTien.Text = "0"; } else { btnHuyHoaDon.Enabled = true; btnNhapKho.Enabled = true; HienThiCTHoaDonNhap(hd_nhap.id); txtTongTien.Text = hd_nhap.tongTien.ToString(); } } }