private void btn_handle_Click(object sender, EventArgs e) { List <String> listError = new List <String>(); if (txt_dongia.Text == "" || txt_slmax.Text == "" || txt_slmin.Text == "" || txt_sltra.Text == "" || txt_tenHH.Text == "") { listError.Add("Trường không được rỗng"); } if (listError.Count == 0) { NhaCungCap ncc = (NhaCungCap)comb_ncc.SelectedItem; NhanVien ql = (NhanVien)comb_quanly.SelectedItem; LoaiHoang lh = (LoaiHoang)comb_loaihang.SelectedItem; bool rs = this.HangHoa == null?HangHoa_BUL.Them(txt_tenHH.Text, Convert.ToInt32(txt_slmax.Text), Convert.ToInt32(txt_slmin.Text), ncc.ID, ql.ID, lh.ID, Convert.ToDouble(txt_dongia.Text)) : HangHoa_BUL.ChinhSua(this.HangHoa.ID, txt_tenHH.Text, Convert.ToInt32(txt_slmax.Text), Convert.ToInt32(txt_slmin.Text), ncc.ID, ql.ID, lh.ID, Convert.ToDouble(txt_dongia.Text)); if (rs == true) { MessageSucess(); } else { MesageFaild(); } } else { MessageValidate(listError); } }
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 IntoDgv() { if (comb_filter.SelectedIndex == 0) { dtgv.DataSource = HangHoa_BUL.getDataTableDachSachMaQuanLi(this.NhanVien.ID.ToString()); } else if (comb_filter.SelectedIndex == 1) { dtgv.DataSource = HangHoa_BUL.getDataTableDachSachMaQuanLi(this.NhanVien.ID.ToString(), true); } }
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_comment() { DataTable table = new DataTable(); table.Columns.Add("ID", typeof(int)); table.Columns.Add("Tên Hàng Hóa", typeof(string)); //table.Columns.Add("Loại", typeof(string)); table.Columns.Add("Gia", typeof(double)); foreach (HangHoa hh in HangHoa_BUL.getList()) { table.Rows.Add(hh.ID, hh.TenHH, hh.DonGia); } dtgv_t1.DataSource = table; }
private void Load_HangHoa(int IDNCC) { DataTable table = new DataTable(); List <HangHoa> list = HangHoa_BUL.getHangHoaFilter1(this.NhanVien.ID, IDNCC); table.Columns.Add("ID", typeof(int)); table.Columns.Add("Tên Hàng", typeof(string)); table.Columns.Add("Số Lượng Còn", typeof(int)); table.Columns.Add("Số lượng nhập max", typeof(int)); table.Columns.Add("Số lượng hàng min", typeof(int)); foreach (HangHoa hh in list) { table.Rows.Add(hh.ID, hh.TenHH, hh.SoLuongTon, hh.NhapMax, hh.SLmin); } dtgv.DataSource = table; }
private void getDonHang() { List <HangHoa> list = HangHoa_BUL.DanhSachHangTra(((NhaCungCap)comb_NCC.Items[comb_NCC.SelectedIndex]).ID); if (list != null) { DataTable table = new DataTable(); table.Columns.Add("ID", typeof(int)); table.Columns.Add("Tên Hàng", typeof(string)); table.Columns.Add("Số lượng trả", typeof(int)); table.Columns.Add("Số lượng tồn", typeof(int)); foreach (HangHoa hh in list) { table.Rows.Add(hh.ID, hh.TenHH, hh.SoLuongTra, hh.SoLuongTon); } dtgv1.DataSource = table; } }
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); } } } }