private void IntoDataTodtgv() { if (comb_danhmuc.SelectedIndex == 0) { dtgv.DataSource = LoaiHang_BUL.getDataTable(txt_search.Text); } else if (comb_danhmuc.SelectedIndex == 1) { dtgv.DataSource = HangHoa_BUL.getDataTable(txt_search.Text); } else if (comb_danhmuc.SelectedIndex == 2) { dtgv.DataSource = KhachHang_BUL.getDataTable(txt_search.Text); } else if (comb_danhmuc.SelectedIndex == 3) { dtgv.DataSource = NhaCungCap_BUL.getDataTable(txt_search.Text); } else if (comb_danhmuc.SelectedIndex == 4) { dtgv.DataSource = NhanVien_BUL.getDataTable(txt_search.Text); } else if (comb_danhmuc.SelectedIndex == 5) { dtgv.DataSource = DoiTacQuangCao_BUL.getDataTable(txt_search.Text); } }
private void btn_sua_Click(object sender, EventArgs e) { Form fr_lh = null; if (comb_danhmuc.SelectedIndex == 0) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); LoaiHoang lh = LoaiHang_BUL.TimLoaiHang(ID); fr_lh = new fr_QuanLy_LoaiHang(lh); } else if (comb_danhmuc.SelectedIndex == 1) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); HangHoa hh = HangHoa_BUL.TimLoaiHang(ID); fr_lh = new fr_QuanLy_HangHoa(hh); } else if (comb_danhmuc.SelectedIndex == 2) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); KhachHang hh = KhachHang_BUL.TimKhachHang(ID); fr_lh = new fr_QuanLy_KhachHang(hh); } else if (comb_danhmuc.SelectedIndex == 3) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); NhaCungCap hh = NhaCungCap_BUL.TimNCC(ID); fr_lh = new fr_QuanLy_NhaCungCap(hh); } else if (comb_danhmuc.SelectedIndex == 4) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); NhanVien hh = NhanVien_BUL.TimNhanVien(ID); fr_lh = new fr_QuanLy_NhanVien(hh); } else if (comb_danhmuc.SelectedIndex == 5) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); DoiTacQuangCao hh = DoiTacQuangCao_BUL.TimLoaiHang(ID); fr_lh = new fr_QuanLy_DoiTacQuanCao(hh); } if (fr_lh != null) { fr_lh.FormClosing += Frm2_Closing; fr_lh.ShowDialog(); resetAfterHandle(); } }
private void init() { List <LoaiHoang> listLoaihang = LoaiHang_BUL.getList(); comb_loaihang.DataSource = listLoaihang; comb_loaihang.DisplayMember = "TenLoai"; List <NhanVien> listQuanLy = NhanVien_BUL.getListNhanVien(); comb_quanly.DataSource = listQuanLy; comb_quanly.DisplayMember = "HoTen"; List <NhaCungCap> listNCC = NhaCungCap_BUL.getList(); comb_ncc.DataSource = listNCC; comb_ncc.DisplayMember = "TenNCC"; txt_sltra.Enabled = false; txt_sltra.Text = "0"; }
private void btn_them_Click(object sender, EventArgs e) { if (txtTen.Text != "") { bool rs = this.LoaiHoang == null?LoaiHang_BUL.Them(txtTen.Text) : LoaiHang_BUL.ChinhSua(this.LoaiHoang.ID, txtTen.Text); if (rs == true) { MessageSucess(); } else { MesageFaild(); } } else { MessageValidate(new string[] { "Tên loại hàng" }); } }
private void btn_xoa_Click(object sender, EventArgs e) { int pos = dtgv.CurrentRow.Index; int ID = Convert.ToInt32(dtgv.Rows[pos].Cells[0].Value); DialogResult dialogResult = MessageBox.Show("Bạn chắc chắn muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (comb_danhmuc.SelectedIndex == 0) { if (LoaiHang_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (comb_danhmuc.SelectedIndex == 1) { if (HangHoa_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (comb_danhmuc.SelectedIndex == 2) { if (KhachHang_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (comb_danhmuc.SelectedIndex == 3) { if (NhaCungCap_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (comb_danhmuc.SelectedIndex == 4) { if (NhanVien_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (comb_danhmuc.SelectedIndex == 5) { if (DoiTacQuangCao_BUL.Xoa(ID)) { MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); IntoDataTodtgv(); } else { MessageBox.Show("Thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }