private void loadDuLieu() { DataTable dt = NhaCungCapControl.layThongTin(MaNCC); txtTenCu.Text = dt.Rows[0]["TenNCC"].ToString(); txtDiaChiCu.Text = dt.Rows[0]["DiaChi"].ToString(); txtSDTCu.Text = dt.Rows[0]["SDT"].ToString(); }
private void loadDuLieu() { dgvDanhSach.Rows.Clear(); DataTable dt = NhaCungCapControl.layDanhSach(); for (int i = 0; i < dt.Rows.Count; ++i) { dgvDanhSach.Rows.Add(dt.Rows[i]["MaNCC"], dt.Rows[i]["TenNCC"], dt.Rows[i]["DiaChi"], dt.Rows[i]["SDT"]); } }
private void btnXacNhan_Click(object sender, EventArgs e) { string ten = txtTenMoi.Text; string diachi = txtDiaChiMoi.Text; string sdt = txtSDTMoi.Text; int ketqua = NhaCungCapControl.suaDuLieu(MaNCC, ten, diachi, sdt); if (ketqua > 0) { this.Close(); } }
private void btnThem_Click(object sender, EventArgs e) { string ten = txtTen.Text; string diachi = txtDiaChi.Text; string sdt = txtSDT.Text; if (kiemTraDuLieu(ten, diachi, sdt)) { int ketqua = NhaCungCapControl.themDuLieu(ten, diachi, sdt); if (ketqua > 0) { this.Close(); } } }
private void timKiem() { string value = txtTimKiem.Text; if (value.Length == 0) { loadDuLieu(); return; } dgvDanhSach.Rows.Clear(); DataTable dt = NhaCungCapControl.timKiem(value); for (int i = 0; i < dt.Rows.Count; ++i) { dgvDanhSach.Rows.Add(dt.Rows[i]["MaNCC"], dt.Rows[i]["TenNCC"], dt.Rows[i]["DiaChi"], dt.Rows[i]["SDT"]); } }
private void dgvDanhSach_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } int ma = Convert.ToInt32(dgvDanhSach.Rows[e.RowIndex].Cells["colMa"].Value.ToString()); if (e.ColumnIndex == dgvDanhSach.Columns["colSua"].Index) { frmSuaNCC frm = new frmSuaNCC(ma); frm.ShowDialog(); loadDuLieu(); } else if (e.ColumnIndex == dgvDanhSach.Columns["colXoa"].Index) { int ketqua = NhaCungCapControl.xoaDuLieu(ma); if (ketqua > 0) { loadDuLieu(); } } }