private void btnTimChiTietHoaDon_Click(object sender, EventArgs e) { if (txtMaHoaDonCT.Text != "") { BULChiTietHoaDon bul = new BULChiTietHoaDon(); dgvChiTiet.DataSource = bul.layChiTietHoaDonTheoMa(txtMaHoaDonCT.Text); } }
private void btnChiTiet_Click(object sender, EventArgs e) { BULChiTietHoaDon bul = new BULChiTietHoaDon(); dgvChiTiet.DataSource = bul.layChiTietHoaDonTheoMa(""); dgvChiTiet.Columns[0].HeaderText = "Mã hàng"; dgvChiTiet.Columns[1].HeaderText = "Mã hóa đơn"; dgvChiTiet.Columns[2].HeaderText = "Số lượng"; dgvChiTiet.Columns[3].HeaderText = "Thành tiền"; tiHang.Visible = false; tiHoaDon.Visible = false; tiKhachHang.Visible = false; tiLoaiHang.Visible = false; tiLoaiKhachHang.Visible = false; tiNCC.Visible = false; tiNhanVien.Visible = false; tiChiTietHoaDon.Visible = true; }
private void btnTaoHoaDon_Click(object sender, EventArgs e) { try { BULHoaDon bulhd = new BULHoaDon(); bulhd.themHoaDon(new HoaDon(1, DateTime.Now.ToShortDateString(), int.Parse(txtMaKhachHang.Text), int.Parse(txtMaNhanVien.Text))); BULChiTietHoaDon bulct = new BULChiTietHoaDon(); for (int i = 0; i < dgvGio.RowCount - 1; i++) { ChiTietHoaDon cthd = new ChiTietHoaDon(int.Parse(dgvGio.Rows[i].Cells[0].Value + ""), bulhd.layHoaDonVuaThem(), int.Parse(dgvGio.Rows[i].Cells[3].Value + ""), int.Parse(dgvGio.Rows[i].Cells[4].Value + "")); bulct.themChiTietHoaDon(cthd); } MessageBox.Show("Tạo hóa đơn thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); frmST.hienDanhSachHoaDon(); this.Close(); } catch (Exception ex) { MessageBox.Show("Có lỗi xảy ra, xem lại dữ liệu hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnXoa_Click(object sender, EventArgs e) { BULChiTietHoaDon bulChiTiet = new BULChiTietHoaDon(); if (bulChiTiet.coHang(txtMaHang.Text)) { MessageBox.Show("Có dữ liệu khác đang chứa hàng này", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { try { BULHang bul = new BULHang(); bul.xoaHang(new Hang(int.Parse(txtMaHang.Text))); frmST.hienDanhSachHang(); MessageBox.Show("Xóa thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("Thao tác thất bạt, dữ liệu sai", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }