public void xoa(int ma) { NguyenLieu nl = ql.NguyenLieus.Where(t => t.MaNL == ma).FirstOrDefault(); if (nl != null) { ql.NguyenLieus.DeleteOnSubmit(nl); ql.SubmitChanges(); } }
public void sua(string tennl, int ma) { NguyenLieu nglieu = ql.NguyenLieus.Where(t => t.MaNL == ma).FirstOrDefault(); if (nglieu != null) { nglieu.TenNL = tennl; ql.SubmitChanges(); } }
public bool ktraSLNL(int manl, int soluong) { NguyenLieu nl = ql.NguyenLieus.FirstOrDefault(t => t.MaNL == manl); if (nl.SoLuong < soluong) { return(false); } return(true); }
public void luu(string ten, int soluong, string tinhtrang) { NguyenLieu nglieu = new NguyenLieu(); nglieu.TenNL = ten; nglieu.SoLuong = soluong; nglieu.TinhTrang = tinhtrang; ql.NguyenLieus.InsertOnSubmit(nglieu); ql.SubmitChanges(); }
public void capNhatTinhTrangNL(int manl) { NguyenLieu px = ql.NguyenLieus.FirstOrDefault(t => t.MaNL == manl); if (px != null) { if (px.SoLuong.Value == 0) { px.TinhTrang = "Hết Hàng"; ql.SubmitChanges(); } } }
public bool them(NguyenLieu nguyenLieu) { try { ketNoi.NguyenLieus.InsertOnSubmit(nguyenLieu); ketNoi.SubmitChanges(); return(true); } catch (Exception) { return(false); } }
public bool CapNhat(NguyenLieu nguyenLieu) { try { var ketQua = (from item in ketNoi.NguyenLieus where item.MaNguyenLieu == nguyenLieu.MaNguyenLieu select item).FirstOrDefault(); ketQua.TenNguyenLieu = nguyenLieu.TenNguyenLieu; ketNoi.SubmitChanges(); return(true); } catch (Exception) { return(false); } }