private void btnOK_Click(object sender, EventArgs e) { if (txtMaNhaCC.Text != "" || txtDCNhaCC.Text != "" || txtSDTNhaCC.Text != "" || txtTenNhaCC.Text != "") { tb_NhaCungCapDBO obj = new tb_NhaCungCapDBO(); obj.MaNhaCungCap = txtMaNhaCC.Text; obj.TenNhaCungCap = txtTenNhaCC.Text; obj.SDT = txtSDTNhaCC.Text; obj.DiaChi = txtDCNhaCC.Text; if (flag == "them") { if (tb_NhaCungCapBLL.kiemTraTonTai(obj.MaNhaCungCap) == 1) { MessageBox.Show("Thông Báo Đã tồn tại!"); } else { tb_NhaCungCapBLL.them(obj); MessageBox.Show("Thêm thành công!"); this.Dispose(); } } else if (flag == "sua") { tb_NhaCungCapBLL.sua(obj); MessageBox.Show("Sửa thành công!"); this.Dispose(); } } }
public static void sua(tb_NhaCungCapDBO obj) { tb_NhaCungCapDAL.sua(obj); }
public static void them(tb_NhaCungCapDBO obj) { tb_NhaCungCapDAL.them(obj); }
public static void sua(tb_NhaCungCapDBO obj) { Unility.ExcuteSQL(string.Format("UPDATE tb_NhaCungCap SET TenNhaCungCap = N'{1}' ,DiaChi = N'{2}',SDT = N'{3}' WHERE MaNhaCungCap = N'{0}'", obj.MaNhaCungCap, obj.TenNhaCungCap, obj.DiaChi, obj.SDT)); }
public static void them(tb_NhaCungCapDBO obj) { Unility.ExcuteSQL(string.Format("INSERT INTO tb_NhaCungCap (MaNhaCungCap ,TenNhaCungCap ,DiaChi ,SDT) VALUES(N'{0}',N'{1}',N'{2}',N'{3}')", obj.MaNhaCungCap, obj.TenNhaCungCap, obj.DiaChi, obj.SDT)); }