public bool LoadNPThuoc(DTO_CTDonThuoc ctDonThuoc) { try { using (var context = new SQLServerDBContext()) { context.CT_DonThuoc.Attach(ctDonThuoc); var entry = context.Entry(ctDonThuoc); entry.Reference(p => p.Thuoc).Load(); return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL CTDonThuoc] {e.Message}"); return(false); } }
public ObservableCollection <DTO_BCSudungThuoc> GetListBCSuDungThuoc() { ObservableCollection <DTO_BCSudungThuoc> res = null; using (var context = new SQLServerDBContext()) { try { context.BaoCaoSuDungThuoc.Load(); res = new ObservableCollection <DTO_BCSudungThuoc>(context.BaoCaoSuDungThuoc.Local); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
//public void DelCachDung(DTO_CachDung cd) //{ // SQLServerDBContext.Instant.CachDung.Local.Remove(cd); //} public async Task <ObservableCollection <DTO_CachDung> > GetListCDAsync() { ObservableCollection <DTO_CachDung> res = null; using (var context = new SQLServerDBContext()) { try { var list = await context.CachDung.SqlQuery("select * from CACHDUNG").ToListAsync(); res = new ObservableCollection <DTO_CachDung>(list); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public ObservableCollection <DTO_Thuoc> GetListThuoc() { ObservableCollection <DTO_Thuoc> res = null; using (var context = new SQLServerDBContext()) { try { context.Database.Log = s => Debug.WriteLine(s); context.Thuoc.Load(); res = new ObservableCollection <DTO_Thuoc>(context.Thuoc.Local); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public async Task <ObservableCollection <DTO_CTPhieuNhapThuoc> > GetListCTPNTAsync() { ObservableCollection <DTO_CTPhieuNhapThuoc> res = null; using (var context = new SQLServerDBContext()) { try { var list = await context.CTPhieuNhapThuoc.SqlQuery("select * from CT_PHIEUNHAPTHUOC").ToListAsync(); res = new ObservableCollection <DTO_CTPhieuNhapThuoc>(list); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public bool LoadNPGroup(DTO_NhanVien nhanVien) { try { using (var context = new SQLServerDBContext()) { context.NhanVien.Attach(nhanVien); var entry = context.Entry(nhanVien); //if (!entry.Reference(p => p.Nhom).IsLoaded) entry.Reference(p => p.Nhom).Load(); return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL NHANVIEN] {e.Message}"); return(false); } }
public async Task <ObservableCollection <DTO_PKChuyenKhoa> > GetListPKCKAsync() { ObservableCollection <DTO_PKChuyenKhoa> res = null; using (var context = new SQLServerDBContext()) { try { var list = await context.PKChuyenKhoa.SqlQuery("select * from PKCHUYENKHOA").ToListAsync(); res = new ObservableCollection <DTO_PKChuyenKhoa>(list); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public async Task <ObservableCollection <DTO_PKDaKhoa> > GetListPKDKAsync() { ObservableCollection <DTO_PKDaKhoa> res = null; using (var context = new SQLServerDBContext()) { try { await context.PKDaKhoa.LoadAsync(); res = new ObservableCollection <DTO_PKDaKhoa>(context.PKDaKhoa.Local); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public async Task <ObservableCollection <DTO_Group> > GetListNhomAsync() { ObservableCollection <DTO_Group> res = null; using (var context = new SQLServerDBContext()) { try { //context.Database.Log = s => Debug.WriteLine(s); await context.Group.LoadAsync(); res = new ObservableCollection <DTO_Group>(context.Group.Local); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public async Task <ObservableCollection <DTO_Phong> > GetListPhongAsync() { ObservableCollection <DTO_Phong> res = null; using (var context = new SQLServerDBContext()) { try { context.Database.Log = s => Debug.WriteLine(s); var list = await context.Phong.SqlQuery("select * from PHONG").ToListAsync(); res = new ObservableCollection <DTO_Phong>(list); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } } return(res); }
public async Task <string> AddPhieuNhapThuocAsync(DTO_PhieuNhapThuoc phieuNhapThuoc) { using (var context = new SQLServerDBContext()) { string res = null; try { res = await context.Database.SqlQuery <string>("exec proc_PNhapThuoc_insert @1, @2", new SqlParameter[] { new SqlParameter("@1", phieuNhapThuoc.NgayNhap), new SqlParameter("@2", phieuNhapThuoc.MaDuocSi) }).FirstOrDefaultAsync(); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } return(res); } }
public bool LoadNPNhanVien(DTO_Account acc) { try { using (var context = new SQLServerDBContext()) { context.Account.Attach(acc); var entry = context.Entry(acc); if (!entry.Reference(p => p.NhanVien).IsLoaded) { entry.Reference(p => p.NhanVien).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL ACCOUNT] {e.Message}"); return(false); } }
public bool LoadNP_DSCTDonThuoc(DTO_DonThuoc donThuoc) { try { using (var context = new SQLServerDBContext()) { context.DonThuoc.Attach(donThuoc); var entry = context.Entry(donThuoc); if (!entry.Collection(p => p.DS_CTDonThuoc).IsLoaded) { entry.Collection(p => p.DS_CTDonThuoc).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL DonThuoc] {e.Message}"); return(false); } }
public bool LoadNP_PhieuNhapThuoc(DTO_CTPhieuNhapThuoc cTPhieuNhapThuoc) { try { using (var context = new SQLServerDBContext()) { context.CTPhieuNhapThuoc.Attach(cTPhieuNhapThuoc); var entry = context.Entry(cTPhieuNhapThuoc); if (!entry.Reference(p => p.PhieuNhapThuoc).IsLoaded) { entry.Reference(p => p.PhieuNhapThuoc).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL CTPHIEUNHAPTHUOC] {e.Message}"); return(false); } }
public bool LoadNPThuoc(DTO_CTHDThuoc cTHDThuoc) { try { using (var context = new SQLServerDBContext()) { context.CTHoaDdonThuoc.Attach(cTHDThuoc); var entry = context.Entry(cTHDThuoc); if (!entry.Reference(p => p.Thuoc).IsLoaded) { entry.Reference(p => p.Thuoc).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL BENH] {e.Message}"); return(false); } }
public async Task <ObservableCollection <DTO_BenhNhan> > GetListBNAsync() { ObservableCollection <DTO_BenhNhan> res = null; using (var context = new SQLServerDBContext()) { context.Database.Log = s => Debug.WriteLine(s); try { context.Database.Log = s => Debug.WriteLine(s); await context.BenhNhan.LoadAsync(); res = new ObservableCollection <DTO_BenhNhan>(context.BenhNhan.Local); } catch (Exception e) { Debug.WriteLine("[ERROR GET LIST PATIENT] " + e.Message); } } return(res); }
public bool LoadNP_DSPKDK(DTO_BenhNhan bn) { try { using (var context = new SQLServerDBContext()) { context.BenhNhan.Attach(bn); var entry = context.Entry(bn); if (!entry.Collection(p => p.DS_PKDaKhoa).IsLoaded) { entry.Collection(p => p.DS_PKDaKhoa).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR LOADNP_DSPKDK] {e.Message}"); return(false); } }
public bool LoadNPBenhNhan(DTO_PKDaKhoa pKDaKhoa) { try { using (var context = new SQLServerDBContext()) { context.PKDaKhoa.Attach(pKDaKhoa); var entry = context.Entry(pKDaKhoa); if (!entry.Reference(p => p.BenhNhan).IsLoaded) { entry.Reference(p => p.BenhNhan).Load(); } return(true); } } catch (Exception e) { Debug.WriteLine($"[ERRROR DAL_PKDAKHOA] {e.Message}"); return(false); } }
public bool isSigned(DTO_BenhNhan bn) { using (var context = new SQLServerDBContext()) { try { var res = context.PKDaKhoa.Count(p => p.MaBenhNhan == bn.MaBenhNhan && p.NgayKham.Day == DateTime.Now.Day && p.NgayKham.Month == DateTime.Now.Month && p.NgayKham.Year == DateTime.Now.Year && (p.MaBacSi == null || p.ChanDoan == null)); if (res == 0) { return(false); } return(true); } catch (Exception e) { return(false); } } }
public async Task <string> AddAccAsync(DTO_Account acc) { using (var context = new SQLServerDBContext()) { string res = null; try { res = await context.Database.SqlQuery <string>("insert into ACCOUNT values(@1,@2, @3)", new SqlParameter[] { new SqlParameter("@1", acc.MaNhanVien), new SqlParameter("@2", acc.Username), new SqlParameter("@3", acc.Password) }).FirstOrDefaultAsync(); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } return(res); } }
public async Task <string> AddPhongAsync(DTO_Phong phong) { using (var context = new SQLServerDBContext()) { string res = null; try { var tenPhong = new SqlParameter("@1", System.Data.SqlDbType.NVarChar); tenPhong.Value = phong.TenPhong; res = await context.Database.SqlQuery <string>("exec proc_Phong_insert @1", new SqlParameter[] { tenPhong }).FirstOrDefaultAsync(); } catch (Exception e) { Debug.WriteLine("[ERROR] " + e.Message); } return(res); } }
public bool UpdateInfoNV(DTO_NhanVien nv, string ten, DateTime ngaySinh, bool gioiTinh, string email, string diaChi, string sdt, string soCMND, string maNhom, string maPhong) { using (var context = new SQLServerDBContext()) { var res = context.NhanVien.FirstOrDefault(n => n.MaNhanVien == nv.MaNhanVien); if (res != null) { res.HoTen = ten; res.NgaySinh = ngaySinh; res.GioiTinh = gioiTinh; res.Email = email; res.DiaChi = diaChi; res.SoDienThoai = sdt; res.SoCMND = soCMND; res.MaNhom = maNhom; res.MaPhong = maPhong; context.SaveChanges(); return(true); } } return(false); }