bool ktkc(string maqt) { quantri cv = tv.quantris.Where(t => t.maqt == maqt).FirstOrDefault(); if (cv != null) { return(true); } else { return(false); } }
public int xoamod(string maqt) { if (maqt != null) { quantri delete = tv.quantris.Where(t => t.maqt.Equals(maqt)).SingleOrDefault(); tv.quantris.DeleteOnSubmit(delete); tv.SubmitChanges(); return(1); } else { return(0); } }
public int themmod(quantri qt) { try { if (ktkc(qt.maqt) == false) { tv.quantris.InsertOnSubmit(qt); } tv.SubmitChanges(); return(1); } catch { return(0); } }
private void them_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string tenqt = Ten.Text; string diachi = DiaChi.Text; string sdt = Sdt.Text; quantri qt = new quantri(); qt.tenqt = tenqt; qt.diachi = diachi; qt.sdt = sdt; qt.maqt = ""; int kq = qtbll.themmod(qt); if (kq == 1) { MessageBox.Show("Thêm thành công"); this.Close(); } else { MessageBox.Show("Nhập lại"); } }