/// <summary> /// Saving a new NV to DB /// </summary> /// <param name="nv"></param> public void SaveNewNV(NHANVIEN nv) { using (var dc = new QLPM_ModelDataContext()) { dc.NHANVIENs.InsertOnSubmit(nv); dc.SubmitChanges(); } }
/// <summary> /// Delete a CT_PHIEUKHAM from DB /// </summary> /// <param name="ct"></param> public static void RemovePill(CT_PHIEUKHAMBENH ct) { using (var dc = new QLPM_ModelDataContext()) { dc.CT_PHIEUKHAMBENHs.DeleteOnSubmit(ct); dc.SubmitChanges(); } }
/// <summary> /// Save new data to DB /// </summary> /// <param name="hoso"></param> public void SaveNewHoSo(HOSOBENHNHAN hoso) { using (var dc = new QLPM_ModelDataContext()) { dc.HOSOBENHNHANs.InsertOnSubmit(hoso); dc.SubmitChanges(); } }
/// <summary> /// Delete a HOADON /// </summary> /// <param name="pk"></param> public static void RemoveHoaDon(PHIEUKHAM pk) { using (var dc = new QLPM_ModelDataContext()) { dc.HOADONs.DeleteOnSubmit(dc.HOADONs.Single(hd => hd.Ma_PhieuKham == pk.Ma_PhieuKham)); dc.SubmitChanges(); } }
/// <summary> /// Add a CT_PHIEUKHAM to DB /// </summary> /// <param name="ct"></param> public static void AddPill(CT_PHIEUKHAMBENH ct) { using (var dc = new QLPM_ModelDataContext()) { dc.CT_PHIEUKHAMBENHs.InsertOnSubmit(ct); dc.SubmitChanges(); } }
/// <summary> /// Remove a benhnhan obj from database /// </summary> /// <param name="bn"></param> public static void RemoveBenhNhan(BENHNHAN bn) { using (var dc = new QLPM_ModelDataContext()) { dc.HOSOBENHNHANs.DeleteOnSubmit((HOSOBENHNHAN)bn); dc.SubmitChanges(); } }
/// <summary> /// Add a new benhnhan obj to database /// </summary> /// <param name="bn">BenhNhan</param> public static void AddBenhNhan(BENHNHAN bn) { using (var dc = new QLPM_ModelDataContext()) { dc.HOSOBENHNHANs.InsertOnSubmit((HOSOBENHNHAN)bn); dc.SubmitChanges(); } }
/// <summary> /// Remove a PHIEUKHAMBENH from DB /// </summary> /// <param name="bn"></param> public static void RemovePhieuKham(BENHNHAN bn) { using (var dc = new QLPM_ModelDataContext()) { var phieukham = dc.PHIEUKHAMBENHs.Single(pk => pk.Ma_BenhNhan == bn.Ma_BenhNhan && pk.NgayKham == DateTime.Today); dc.CT_PHIEUKHAMBENHs.DeleteAllOnSubmit(dc.CT_PHIEUKHAMBENHs.Where(ctpk => ctpk.Ma_PhieuKham == phieukham.Ma_PhieuKham)); dc.PHIEUKHAMBENHs.DeleteOnSubmit(phieukham); dc.SubmitChanges(); } }
/// <summary> /// Create a new PHIEUKHAMBENH after add a BENHNHAN to DSKHAMBENH /// </summary> /// <param name="bn"></param> public static void AddPhieuKham(BENHNHAN bn) { using (var dc = new QLPM_ModelDataContext()) { var pk = new PHIEUKHAMBENH(); pk.Ma_PhieuKham = GetNewID(pk); pk.Ma_BenhNhan = bn.Ma_BenhNhan; pk.NgayKham = DateTime.Today; dc.PHIEUKHAMBENHs.InsertOnSubmit(pk); dc.SubmitChanges(); } }
/// <summary> /// Add a HOADON to DB /// </summary> /// <param name="pk"></param> public static void AddHoaDon(PHIEUKHAM pk) { using (var dc = new QLPM_ModelDataContext()) { if (dc.HOADONs.Any(x => x.Ma_PhieuKham == pk.Ma_PhieuKham)) { var hd = dc.HOADONs.Single(x => x.Ma_PhieuKham == pk.Ma_PhieuKham); if (pk.DONTHUOC.Count > 0) { foreach (var item in pk.DONTHUOC) { hd.TienThuoc += item.SoLuong * item.DonGia; } } dc.SubmitChanges(); } else { var hd = new HOADON(); hd.Ma_HoaDon = GetNewID(hd); hd.Ma_PhieuKham = pk.Ma_PhieuKham; hd.TienKham = (from ts in dc.THAMSOs select ts.TienKham).FirstOrDefault(); if (pk.DONTHUOC.Count > 0) { foreach (var item in pk.DONTHUOC) { hd.TienThuoc += item.SoLuong * item.DonGia; } } dc.HOADONs.InsertOnSubmit(hd); dc.SubmitChanges(); } } }