public void delete_LoaiHangHoa(string ma) { LoaiHangHoa hh = lhh.LoaiHangHoas.Where(t => t.maLoaiHH == ma).FirstOrDefault(); lhh.LoaiHangHoas.DeleteOnSubmit(hh); lhh.SubmitChanges(); }
public void SuaLoaiHangHoa(string ma, string ten) { LoaiHangHoa hh = lhh.LoaiHangHoas.Where(t => t.maLoaiHH == ma).FirstOrDefault(); hh.maLoaiHH = ma; hh.tenLoaiHH = ten; lhh.SubmitChanges(); }
public void insert_LoaiHangHoa(string makh, string tekh) { LoaiHangHoa hh = new LoaiHangHoa(); hh.maLoaiHH = makh; hh.tenLoaiHH = tekh; lhh.LoaiHangHoas.InsertOnSubmit(hh); lhh.SubmitChanges(); }
public string getMALOAILast() { List <LoaiHangHoa> a = lhh.LoaiHangHoas.ToList(); if (a.Count == 0)// neu chua co nhan vien nao { return(""); } //da co ma nhan vien LoaiHangHoa b = lhh.LoaiHangHoas.ToList().OrderByDescending(t => t.maLoaiHH).First(); return(b.maLoaiHH); }
public bool delete(String id) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = (from item in db.LoaiHangHoas where item.MaLoaiHangHoa == id select item).SingleOrDefault(); db.LoaiHangHoas.Remove(loaiHangHoa); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool insert(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Add(loaiHangHoa); if (db.SaveChanges() > 0) { return(true); } return(false); } }
public bool update(DTO_LoaiHangHoa obj) { using (CellphoneComponentEntities db = new CellphoneComponentEntities()) { LoaiHangHoa loaiHangHoa = new LoaiHangHoa(); loaiHangHoa.MaLoaiHangHoa = obj.MaLoaiHangHoa; loaiHangHoa.TenLoaiHangHoa = obj.TenLoaiHangHoa; loaiHangHoa.PhanTramLoiNhuan = obj.PhanTramLoiNhuan; db.LoaiHangHoas.Attach(loaiHangHoa); db.Entry(loaiHangHoa).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { return(true); } return(false); } }