private void btnChuyen_Click(object sender, EventArgs e) { HangHoa hh = hangBLL.GetHangHoaByID(dgvHangHoa.SelectedRows[0].Cells[0].Value.ToString()); hh.SoLuong = nmSoLuong.Value; donNhapHang.AddHangHoa(hh); ShowDanhSachHangHoa(); txtTotalPrice.Text = donNhapHang.TongTien.ToString(); nmSoLuong.Value = 1; }
private void ShowInfoDonNhapHang(DonNhapHang donNhapHang) { txtMaHD.Text = donNhapHang.MaDNH; nhaCungCap = nhacungcapBLL.GetNhaCungCapByID(donNhapHang.MaNCC); txtTenNCC.Text = nhaCungCap.Ten; txtNgayLap.Text = donNhapHang.NgayLap.ToString(); txtSDT.Text = nhaCungCap.SoDienThoai; txtDiaChi.Text = nhaCungCap.DiaChi; txtEmail.Text = nhaCungCap.Email; dgvCTDNH.Rows.Clear(); dgvCTDNH.Refresh(); foreach (HangHoa hh in donNhapHang.DSHangHoa) { DataGridViewRow row = (DataGridViewRow)dgvCTDNH.Rows[0].Clone(); row.Cells[0].Value = hh.MaHH; row.Cells[3].Value = hh.GiaGoc; row.Cells[4].Value = hh.SoLuong; int thanhtien = hh.GiaGoc * hh.SoLuong; row.Cells[5].Value = thanhtien.ToString(); HangHoa hh2 = hangBLL.GetHangHoaByID(hh.MaHH); row.Cells[1].Value = hh2.TenHH; row.Cells[2].Value = hh2.LoaiHang; dgvCTDNH.Rows.Add(row); } lblTotalPrice.Text = donNhapHang.TongTien.ToString(); lblDaTra.Text = donNhapHang.DaTra.ToString(); lblConLai.Text = donNhapHang.ConLai.ToString(); }
private void btnChuyen_Click(object sender, EventArgs e) { HangHoa hh = hangBLL.GetHangHoaByID(dgvHangHoa.SelectedRows[0].Cells[0].Value.ToString()); if (hh.SoLuong < 1) { MessageBox.Show("Số lượng không đủ"); txtSoLuong.Text = "1"; } else { hh.SoLuong = 1; hoaDon.AddHangHoa(hh); ShowDanhSachHangHoa(); txtTotalPrice.Text = hoaDon.TongTien.ToString(); } }
private void frmHangHoa_Load(object sender, EventArgs e) { dgHangHoa.DataSource = hhBLL.LoadDanhSachHH(true); cboLoaiHang.DataSource = lhBLL.LoadAll(); cboLoaiHang.DisplayMember = "TenLoai"; cboLoaiHang.ValueMember = "ID"; cboLoaiHang.SelectedIndex = -1; cboLoaiTim.DataSource = lhBLL.LoadAll(); cboLoaiTim.DisplayMember = "TenLoai"; cboLoaiTim.ValueMember = "ID"; cboLoaiTim.SelectedIndex = -1; if (dgHangHoa.Rows.Count > 0) { string id = dgHangHoa.Rows[0].Cells[0].Value.ToString(); HangHoa hh = hhBLL.GetHangHoaByID(id); ShowInfoHang(hh); } }
private void ShowInfoHoaDon(HoaDon hoaDon) { txtMaHD.Text = hoaDon.MaHD; khachHang = khachhangBLL.GetKhachHangByID(hoaDon.MaKH); txtTenKH.Text = khachHang.Ten; txtNgayLap.Text = hoaDon.NgayLap.ToString(); txtSDT.Text = khachHang.SoDienThoai; txtDiaChi.Text = khachHang.DiaChi; txtEmail.Text = khachHang.Email; dgvCTHD.Rows.Clear(); dgvCTHD.Refresh(); foreach (HangHoa hh in hoaDon.DSHangHoa) { DataGridViewRow row = (DataGridViewRow)dgvCTHD.Rows[0].Clone(); row.Cells[0].Value = hh.MaHH; row.Cells[3].Value = hh.GiaBan; row.Cells[4].Value = hh.SoLuong; int thanhtien = hh.GiaBan * hh.SoLuong; row.Cells[5].Value = thanhtien.ToString(); HangHoa hh2 = hangBLL.GetHangHoaByID(hh.MaHH); row.Cells[1].Value = hh2.TenHH; row.Cells[2].Value = hh2.LoaiHang; dgvCTHD.Rows.Add(row); } lblTotalPrice.Text = hoaDon.TongTien.ToString(); lblDaTra.Text = hoaDon.DaTra.ToString(); lblConLai.Text = hoaDon.ConLai.ToString(); if (hoaDon.ConLai > 0) { btnCapNhatCongNo.Enabled = true; } else { btnCapNhatCongNo.Enabled = false; } }