private void ChiTietHoaDon_Load(object sender, EventArgs e) { HoaDon.model.Load load = new model.Load(); DataTable dt = new DataTable(); if (check == 2) { DataTable dtHoaDonNhapHang = load.LoadHoaDonNhapHangTheoMaHoaDon(ID); string ThoiGian = dtHoaDonNhapHang.Rows[0][1].ToString(); // string ViTri = dtHoaDon.Rows[0][2].ToString(); // string Khach = dtHoaDon.Rows[0][13].ToString(); // string MaKhach = dtHoaDon.Rows[0][12].ToString(); int ThanhToan = Convert.ToInt32(dtHoaDonNhapHang.Rows[0][2].ToString()); dt = load.LoadChiTietHoaDonNhapHang(ID); lblNgay.Text = ThoiGian; lblBan.Visible = false; lblKhachHang.Visible = false; lblTongTien.Text = ThanhToan.ToString(); } else if(check ==1) { DataTable dtHoaDon = load.LoadHoaDonTheoMaHoaDon(ID); string ThoiGian = dtHoaDon.Rows[0][1].ToString(); string ViTri = dtHoaDon.Rows[0][11].ToString(); string Khach = dtHoaDon.Rows[0][13].ToString(); string MaKhach = dtHoaDon.Rows[0][12].ToString(); int ThanhToan = Convert.ToInt32( dtHoaDon.Rows[0][8].ToString()); dt = load.LoadChiTietHoaDonTheoMaHoaDon(ID); lblNgay.Text = ThoiGian; lblBan.Text = ViTri; lblKhachHang.Text = Khach; lblTongTien.Text = ThanhToan.ToString(); if (MaKhach!=""&& Convert.ToInt32(MaKhach)!=0) { MaKhachHang = Convert.ToInt32(MaKhach); groupPanel1.Visible = true; BanHang.Model.Load load1 = new BanHang.Model.Load(); DataTable dtKhach = load1.LoadKhachHangTheoMaKhach(MaKhachHang); labelXSDT.Text = dtKhach.Rows[0][2].ToString(); richTextBoxExDiaChi.Text = dtKhach.Rows[0][1].ToString(); } } dgvChiTietHoaDon.DataSource = dt; dgvChiTietHoaDon.AllowUserToResizeRows = false; for (int i = 0; i < dt.Rows.Count; i++) { dgvChiTietHoaDon.Rows[i].Cells["ST"].Value = i + 1; } }
private void ListKhachHang_Load(object sender, EventArgs e) { BanHang.Model.Load load = new BanHang.Model.Load(); DataTable dt = load.LoadKhachHang(); dataGridViewXListKhachHang.DataSource = dt; dataGridViewXListKhachHang.Columns[1].Visible = false; for (int i = 0; i < dataGridViewXListKhachHang.Rows.Count; i++) { dataGridViewXListKhachHang.Rows[i].Cells["STT1"].Value = i + 1; } }
private void buttonX1_Click(object sender, EventArgs e) { try { int MaKhuVuc = Convert.ToInt32(comboTree1.SelectedValue.ToString()); BanHang.Model.Load load = new BanHang.Model.Load(); DataTable dt = load.LoadHoaDonChuaThanhToanTheoMaKhuVuc(MaKhuVuc); if (dt.Rows.Count == 0) { BanHang.Model.Delete delete = new Model.Delete(); delete.DeleteKhuVuc(MaKhuVuc); this.Close(); } else { MessageBox.Show("Vẫn còn bàn chưa thanh toán, không thể xóa"); } } catch (Exception) { } }