/// <summary> /// insert a record into table MATHANG- increament number of MATHANG /// </summary> /// <param name="tenhang"></param> /// <param name="tendvt"></param> /// <param name="dongia"></param> /// <returns></returns> public bool InsertMATHANG(string tenhang, int madvt, int dongia) { using (QLDLEntities db = new QLDLEntities()) { MATHANG mh = new MATHANG(); mh.TENHANG = tenhang; mh.MADVT = madvt; mh.DONGIA = dongia; db.MATHANGs.Add(mh); db.SaveChanges(); return(true); } }
/// <summary> /// delete a record into table MATHANG - descreament number of MATHANG /// </summary> /// <param name="mamh"></param> /// <returns></returns> public bool DeleteMATHANG(int mamh) { using (QLDLEntities db = new QLDLEntities()) { if (db.CTPXes.Where(p => p.MAHANG == mamh).Count() <= 0) { MATHANG mh = db.MATHANGs.Where(p => p.MAHANG == mamh).Single(); db.MATHANGs.Remove(mh); db.SaveChanges(); return(true); } return(false); } }