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(); } }
public static DoiTacQuangCao TimLoaiHang(int ID) { DoiTacQuangCao lh = null; using (PTTKHTEntities context = new PTTKHTEntities()) { var v = context.DoiTacQuangCaos.SingleOrDefault(b => b.ID == ID); if (v is DoiTacQuangCao) { lh = (DoiTacQuangCao)v; } } return(lh); }
public static bool Them(string TenDoiTac) { bool rs = false; using (PTTKHTEntities context = new PTTKHTEntities()) { DoiTacQuangCao a = new DoiTacQuangCao() { TenDoiTac = TenDoiTac }; context.DoiTacQuangCaos.Add(a); var created = context.SaveChanges(); if (created > 0) { rs = true; } } return(rs); }
public fr_QuanLy_DoiTacQuanCao(DoiTacQuangCao dtqc) { InitializeComponent(); this.DoiTacQuangCao = dtqc; }