public static List <thietbiPUB> dsthietbitt(int Matinhtrang, DateTime thoidiem) { List <thietbiPUB> dstb = new List <thietbiPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.THIETBIs where s.matinhtrang == Matinhtrang && s.ngaycapnhat <= thoidiem select s; foreach (var row in query) { thietbiPUB tb = new thietbiPUB(); tb.Mathietbi = row.mathietbi; tb.Tenthietbi = row.tenthietbi; tb.Dongia = row.dongia; tb.Thongsokythuat = row.thongsokythuat; tb.Ngaysanxuat = row.ngaysanxuat; tb.Ngayduavaosudung = row.ngayduavaosudung; tb.Ngaycapnhat = row.ngaycapnhat; tb.Soluong = row.soluong; tb.Madonvitinh = row.madonvitinh; tb.Maloai = row.maloai; tb.Maphongquantri = row.maphongquantri; tb.Matinhtrang = row.matinhtrang; dstb.Add(tb); } } return(dstb); }
public static List <thietbiPUB> dsthietbitim(string Ten) { List <thietbiPUB> dstbtim = new List <thietbiPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.THIETBIs where s.tenthietbi.Contains(@Ten) select s; foreach (var row in query) { thietbiPUB tb = new thietbiPUB(); tb.Mathietbi = row.mathietbi; tb.Tenthietbi = row.tenthietbi; tb.Dongia = row.dongia; tb.Thongsokythuat = row.thongsokythuat; tb.Ngaysanxuat = row.ngaysanxuat; tb.Ngayduavaosudung = row.ngayduavaosudung; tb.Ngaycapnhat = row.ngaycapnhat; tb.Soluong = row.soluong; tb.Madonvitinh = row.madonvitinh; tb.Maloai = row.maloai; tb.Maphongquantri = row.maphongquantri; tb.Matinhtrang = row.matinhtrang; dstbtim.Add(tb); } return(dstbtim); } }
public static void themthietbi(THIETBI tb) { using (TSCDEntities ts = new TSCDEntities()) { ts.THIETBIs.Add(tb); ts.SaveChanges(); } }
public static void xoathietbi(THIETBI tb) { using (TSCDEntities ts = new TSCDEntities()) { THIETBI tbb = ts.THIETBIs.Find(tb.mathietbi); ts.THIETBIs.Remove(tbb); ts.SaveChanges(); } }
public static List <thietbiPUB> dsthietbikho(DateTime thoidiem) { List <thietbiPUB> dstb = new List <thietbiPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.THIETBIs select s; foreach (var row in query) { thietbiPUB tb = new thietbiPUB(); tb.Mathietbi = row.mathietbi; tb.Tenthietbi = row.tenthietbi; tb.Dongia = row.dongia; tb.Thongsokythuat = row.thongsokythuat; tb.Ngaysanxuat = row.ngaysanxuat; tb.Ngayduavaosudung = row.ngayduavaosudung; tb.Ngaycapnhat = row.ngaycapnhat; //tính số lượng tồn int soluongnhap = 0; try { soluongnhap = (int)t.PHIEUNHAPs.Where(x => x.mathietbi == tb.Mathietbi && x.ngaynhap <= thoidiem).Sum(x => x.soluong); } catch { } int soluongxuat = 0; try { soluongxuat = (int)t.CHITIETPHIEUGIAOs.Where(x => x.mathietbi == tb.Mathietbi && x.PHIEUGIAO.ngaygiao <= thoidiem).Sum(x => x.soluong); } catch { } //tính số lượng xong if (soluongnhap == 0) { tb.Soluong = 0; } if (soluongnhap != 0 && soluongxuat == 0) { tb.Soluong = soluongnhap; } else { tb.Soluong = soluongnhap - soluongxuat; } tb.Madonvitinh = row.madonvitinh; tb.Maloai = row.maloai; tb.Maphongquantri = row.maphongquantri; tb.Matinhtrang = row.matinhtrang; dstb.Add(tb); } return(dstb); } }
public static List <phongquantriPUB> dsphongquantri() { List <phongquantriPUB> dspqt = new List <phongquantriPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.PHONGQUANTRIs select s; foreach (var row in query) { phongquantriPUB tb = new phongquantriPUB(); tb.Maphongquantri = row.maphongquantri; tb.Tenphongquantri = row.tenphongquantri; dspqt.Add(tb); } return(dspqt); } }
public static List <donvitinhPUB> dsdonvitinh() { List <donvitinhPUB> dsdvt = new List <donvitinhPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.DONVITINHs select s; foreach (var row in query) { donvitinhPUB tb = new donvitinhPUB(); tb.Madonvitinh = row.madonvitinh; tb.Tendonvitinh = row.tendonvitinh; dsdvt.Add(tb); } return(dsdvt); } }
public static List <tinhtrangPUB> dstinhtrang() { List <tinhtrangPUB> dstt = new List <tinhtrangPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.TINHTRANGs select s; foreach (var row in query) { tinhtrangPUB tt = new tinhtrangPUB(); tt.Matinhtrang = row.matinhtrang; tt.Tentinhtrang = row.tentinhtrang; dstt.Add(tt); } return(dstt); } }
public static List <loaithietbiPUB> dsloaithietbi() { List <loaithietbiPUB> dsltb = new List <loaithietbiPUB>(); using (TSCDEntities t = new TSCDEntities()) { var query = from s in t.LOAITHIETBIs select s; foreach (var row in query) { loaithietbiPUB tb = new loaithietbiPUB(); tb.Maloai = row.maloai; tb.Tenloai = row.tenloai; dsltb.Add(tb); } return(dsltb); } }
public static void suathietbi(THIETBI tb) { using (TSCDEntities ts = new TSCDEntities()) { THIETBI tbb = ts.THIETBIs.Find(tb.mathietbi); tbb.tenthietbi = tb.tenthietbi; tbb.dongia = tb.dongia; tbb.thongsokythuat = tb.thongsokythuat; tbb.ngaysanxuat = tb.ngaysanxuat; tbb.ngayduavaosudung = tb.ngayduavaosudung; tbb.ngaycapnhat = tb.ngaycapnhat; tbb.soluong = tb.soluong; tbb.madonvitinh = tb.madonvitinh; tbb.maloai = tb.maloai; tbb.maphongquantri = tb.maphongquantri; tbb.matinhtrang = tb.matinhtrang; ts.SaveChanges(); } }