public static Result GetValue(string key) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); Setting settings = (from s in db.Settings where s.SettingKey == key select s).FirstOrDefault(); result.QueryResult = settings; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetInvoice(string invoiceGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); InvoiceView invoice = db.InvoiceViews.SingleOrDefault <InvoiceView>(i => i.InvoiceGUID.ToString() == invoiceGUID && i.Status == (byte)Status.Actived); result.QueryResult = invoice; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetLoThuoc(string loThuocGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); LoThuoc loThuoc = db.LoThuocs.SingleOrDefault(l => l.LoThuocGUID.ToString() == loThuocGUID); result.QueryResult = loThuoc; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetSoHoaDonChuaXuat(int count) { Result result = new Result(); MMOverride db = null; try { string query = string.Format("SELECT TOP {0} CAST(0 AS Bit) AS Checked, * FROM QuanLySoHoaDonXetNghiemYKhoa WITH(NOLOCK) WHERE XuatTruoc = 'False' AND DaXuat = 'False' AND NgayBatDau >= '{1}' ORDER BY SoHoaDon", count, Global.NgayThayDoiSoHoaDonXetNghiemSauCung.ToString("yyyy-MM-dd HH:mm:ss")); return(ExcuteQuery(query)); } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetThongTinKhachHang(string thongTinKhachHangGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); ThongTinKhachHang ttkh = db.ThongTinKhachHangs.FirstOrDefault(t => t.ThongTinKhachHangGUID.ToString().ToLower() == thongTinKhachHangGUID.ToLower()); result.QueryResult = ttkh; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetMauHoaDonList() { Result result = new Result(); MMOverride db = null; try { string query = string.Format("SELECT *, MauSo + '-' + KiHieu AS MauHoaDon FROM dbo.NgayBatDauLamMoiSoHoaDon ORDER BY NgayBatDau DESC"); return(ExcuteQuery(query)); } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetThongTinCongTy(string maCongTy) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); Company com = db.Companies.Where(c => c.MaCty.ToUpper() == maCongTy.Trim().ToUpper()).FirstOrDefault(); result.QueryResult = com; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetChiTietXetNghiemList2(string xetNghiem_ManualGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); List <ChiTietXetNghiem_Manual> ctxns = (from x in db.ChiTietXetNghiem_Manuals where x.XetNghiem_ManualGUID.ToString() == xetNghiem_ManualGUID && x.Status == (byte)Status.Actived select x).ToList(); result.QueryResult = ctxns; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } return(result); }
public static Result UpdateKetLuan(string yKienKhachHangGUID, string ketLuan) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); string desc = string.Empty; using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { YKienKhachHang ykkh = db.YKienKhachHangs.SingleOrDefault <YKienKhachHang>(s => s.YKienKhachHangGUID.ToString() == yKienKhachHangGUID); if (ykkh != null) { ykkh.NguoiKetLuan = Guid.Parse(Global.UserGUID); ykkh.KetLuan = ketLuan; //Tracking desc += string.Format("- GUID: '{0}', Tên khách hàng: '{1}', Số điện thoại: '{2}', Địa chỉ: '{3}', Yêu cầu: '{4}', Nguồn: '{5}', Ghi chú: '{6}', Người kết luận: '{7}', Kết luận: '{8}'", ykkh.YKienKhachHangGUID.ToString(), ykkh.TenKhachHang, ykkh.SoDienThoai, ykkh.DiaChi, ykkh.YeuCau, ykkh.Nguon, ykkh.Note, ykkh.NguoiKetLuan, ykkh.KetLuan); Tracking tk = new Tracking(); tk.TrackingGUID = Guid.NewGuid(); tk.TrackingDate = DateTime.Now; tk.DocStaffGUID = Guid.Parse(Global.UserGUID); tk.ActionType = (byte)ActionType.Edit; tk.Action = "Cập nhật kết luận ý kiến khách hàng"; tk.Description = desc; tk.TrackingType = (byte)TrackingType.None; tk.ComputerName = Utility.GetDNSHostName(); db.Trackings.InsertOnSubmit(tk); db.SubmitChanges(); } t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
protected static Result ExcuteQuery(string spName, List <SqlParameter> sqlParams) { Result result = new Result(); MMOverride db = null; SqlDataAdapter adapter = null; SqlCommand cmd = null; try { db = new MMOverride(); cmd = new SqlCommand(); cmd.Connection = (SqlConnection)db.Connection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.CommandText = spName; foreach (SqlParameter param in sqlParams) { cmd.Parameters.Add(param); } adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt); result.QueryResult = dt; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (cmd != null) { cmd.Dispose(); cmd = null; } if (adapter != null) { adapter.Dispose(); adapter = null; } if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result UpdateGiaDichVuXetNghiem(string key, double soTien) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 30, 0))) { string desc = string.Empty; ThucHienXetNghiem thxn = db.ThucHienXetNghiems.SingleOrDefault <ThucHienXetNghiem>(x => x.ThucHienXetNghiemGUID.ToString() == key); if (thxn != null) { thxn.SoTien = soTien; thxn.UpdatedDate = DateTime.Now; thxn.UpdatedBy = Guid.Parse(Global.UserGUID); desc = string.Format("- GUID: '{0}', Ngày thực hiện: '{1}', Tên công ty: '{2}', Tên khách hàng: '{3}', Tên dịch vụ: '{4}', Số tiền: '{5}', Source: '{6}'", thxn.ThucHienXetNghiemGUID.ToString(), thxn.NgayThucHien.ToString("dd/MM/yyyy"), thxn.TenCongTy, thxn.TenKhachHang, thxn.TenDichVu, soTien, thxn.SourcePath); //Tracking Tracking tk = new Tracking(); tk.TrackingGUID = Guid.NewGuid(); tk.TrackingDate = DateTime.Now; tk.DocStaffGUID = Guid.Parse(Global.UserGUID); tk.ActionType = (byte)ActionType.Delete; tk.Action = "Sửa giá dịch vụ xét nghiệm"; tk.Description = desc; tk.TrackingType = (byte)TrackingType.Price; tk.ComputerName = Utility.GetDNSHostName(); db.Trackings.InsertOnSubmit(tk); } db.SubmitChanges(); t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetGiaNhapTrungBinh(string thuocGUID) { Result result = new Result(); MMOverride db = null; try { DateTime dt = DateTime.Now; db = new MMOverride(); var loThuocList = from l in db.LoThuocs where l.Status == (byte)Status.Actived && l.ThuocGUID.ToString() == thuocGUID && new DateTime(l.NgayHetHan.Year, l.NgayHetHan.Month, l.NgayHetHan.Day) > dt && l.SoLuongNhap * l.SoLuongQuiDoi - l.SoLuongXuat > 0 select l; double giaNhapTB = 0; if (loThuocList != null) { double tongGiaNhap = 0; int soLuong = 0; foreach (var lt in loThuocList) { int soLuongTon = lt.SoLuongNhap * lt.SoLuongQuiDoi - lt.SoLuongXuat; soLuong += soLuongTon; tongGiaNhap += (soLuongTon * lt.GiaNhapQuiDoi); } if (soLuong > 0) { giaNhapTB = Math.Round(tongGiaNhap / soLuong, 0); } } result.QueryResult = giaNhapTB; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result InsertBenhNhanNgoaiGoiKham(List <BenhNhanNgoaiGoiKham> benhNhanNgoaiGoiKhamList) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); string desc = string.Empty; using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { foreach (BenhNhanNgoaiGoiKham bnngk in benhNhanNgoaiGoiKhamList) { bnngk.BenhNhanNgoaiGoiKhamGUID = Guid.NewGuid(); db.BenhNhanNgoaiGoiKhams.InsertOnSubmit(bnngk); db.SubmitChanges(); //Tracking desc += string.Format("- GUID: '{0}', Ngày khám: '{1}', Bệnh nhân: '{2}', Dịch vụ: '{3}', Lần đầu: '{4}'\n", bnngk.BenhNhanNgoaiGoiKhamGUID.ToString(), bnngk.NgayKham.ToString("dd/MM/yyyy HH:mm:ss"), bnngk.Patient.Contact.FullName, bnngk.Service.Name, bnngk.LanDau == 0 ? "Lần đầu" : "Tái khám"); Tracking tk = new Tracking(); tk.TrackingGUID = Guid.NewGuid(); tk.TrackingDate = DateTime.Now; tk.DocStaffGUID = Guid.Parse(Global.UserGUID); tk.ActionType = (byte)ActionType.Add; tk.Action = "Thêm bệnh nhân ngoài gói khám"; tk.Description = desc; tk.TrackingType = (byte)TrackingType.None; tk.ComputerName = Utility.GetDNSHostName(); db.Trackings.InsertOnSubmit(tk); } t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result InsertThongTinKhachHang(ThongTinKhachHang ttkh) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { ThongTinKhachHang thongTinKhachHang = (from tt in db.ThongTinKhachHangs where tt.TenKhachHang.Trim().ToLower() == ttkh.TenKhachHang.Trim().ToLower() && tt.MaDonVi.Trim().ToLower() == ttkh.MaDonVi.Trim().ToLower() //tt.TenDonVi.Trim().ToLower() == ttkh.TenDonVi.Trim().ToLower() && //tt.DiaChi.Trim().ToLower() == ttkh.DiaChi.Trim().ToLower() select tt).FirstOrDefault(); if (thongTinKhachHang == null) { ttkh.ThongTinKhachHangGUID = Guid.NewGuid(); db.ThongTinKhachHangs.InsertOnSubmit(ttkh); } else { //thongTinKhachHang.MaDonVi = ttkh.MaDonVi; //thongTinKhachHang.TenDonVi = ttkh.TenDonVi; //thongTinKhachHang.MaSoThue = ttkh.MaSoThue; //thongTinKhachHang.DiaChi = ttkh.DiaChi; thongTinKhachHang.SoTaiKhoan = ttkh.SoTaiKhoan; thongTinKhachHang.HinhThucThanhToan = ttkh.HinhThucThanhToan; } db.SubmitChanges(); t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetThongTinDonVi(string tenDonVi) { Result result = new Result(); MMOverride db = null; try { if (tenDonVi == null) { tenDonVi = string.Empty; } db = new MMOverride(); ThongTinKhachHang thongTinKhachHang = null; Company company = db.Companies.FirstOrDefault(t => t.TenCty.Trim().ToLower() == tenDonVi.Trim().ToLower() && t.Status == (byte)Status.Actived); if (company != null) { thongTinKhachHang = new ThongTinKhachHang(); thongTinKhachHang.MaDonVi = company.MaCty; thongTinKhachHang.TenDonVi = company.TenCty; thongTinKhachHang.DiaChi = company.DiaChi; thongTinKhachHang.MaSoThue = company.MaSoThue; thongTinKhachHang.HinhThucThanhToan = 0; ThongTinKhachHang ttkh = db.ThongTinKhachHangs.FirstOrDefault(t => t.TenDonVi.Trim().ToLower() == tenDonVi.Trim().ToLower()); if (ttkh != null) { thongTinKhachHang.HinhThucThanhToan = ttkh.HinhThucThanhToan; thongTinKhachHang.SoTaiKhoan = ttkh.SoTaiKhoan; } } result.QueryResult = thongTinKhachHang; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetThayDoiSoHoaDon(string mauSo, string kiHieu, ref DateTime nextNgayThayDoi) { Result result = new Result(); MMOverride db = null; nextNgayThayDoi = Global.MaxDateTime; try { db = new MMOverride(); var ngayThayDoi = (from n in db.NgayBatDauLamMoiSoHoaDons where n.KiHieu.ToLower() == kiHieu.ToLower() && n.MauSo.ToLower() == mauSo.ToLower() select n).FirstOrDefault(); if (ngayThayDoi != null) { result.QueryResult = ngayThayDoi; } else { result.QueryResult = null; } var nextThayDoi = (from n in db.NgayBatDauLamMoiSoHoaDons where n.NgayBatDau > ngayThayDoi.NgayBatDau orderby n.NgayBatDau ascending select n).FirstOrDefault(); if (nextThayDoi != null) { nextNgayThayDoi = nextThayDoi.NgayBatDau; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result UpdateCauHinhDichVuXetNghiem(string serviceGUID, bool normal_abnormal, bool negative_positive) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { CauHinhDichVuXetNghiem xn = (from x in db.CauHinhDichVuXetNghiems where x.ServiceGUID.ToString() == serviceGUID select x).FirstOrDefault(); if (xn == null) { xn = new CauHinhDichVuXetNghiem(); xn.CauHinhDichVuXetNghiemGUID = Guid.NewGuid(); xn.ServiceGUID = Guid.Parse(serviceGUID); xn.Normal_Abnormal = normal_abnormal; xn.Negative_Positive = negative_positive; db.CauHinhDichVuXetNghiems.InsertOnSubmit(xn); } else { xn.Normal_Abnormal = normal_abnormal; xn.Negative_Positive = negative_positive; } db.SubmitChanges(); t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
static void ConvertKetQuaSoiCTC2ShareFolder() { MMOverride db = null; try { db = new MMOverride(); bool isSubmit = false; foreach (var kq in db.KetQuaSoiCTCs) { string key = kq.KetQuaSoiCTCGUID.ToString(); if (kq.Hinh1 != null) { string fileName = Path.Combine(Global.ShareFolder, string.Format("{0}_1.png", key)); Utility.SaveImage(kq.Hinh1.ToArray(), fileName); kq.ImageName1 = string.Format("{0}_1.png", key); //kq.Hinh1 = null; isSubmit = true; } if (kq.Hinh2 != null) { string fileName = Path.Combine(Global.ShareFolder, string.Format("{0}_2.png", key)); Utility.SaveImage(kq.Hinh2.ToArray(), fileName); kq.ImageName2 = string.Format("{0}_2.png", key); //kq.Hinh2 = null; isSubmit = true; } } if (isSubmit) { db.SubmitChanges(); } } catch (System.Data.SqlClient.SqlException se) { Console.WriteLine(se.ToString()); } catch (Exception e) { Console.WriteLine(e.Message); } finally { if (db != null) { db.Dispose(); db = null; } } }
public static Result CheckKhachHangExist(string tenKhachHang, string yKienKhachHangGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); YKienKhachHang ykkh = null; if (yKienKhachHangGUID == null || yKienKhachHangGUID == string.Empty) { ykkh = db.YKienKhachHangs.FirstOrDefault <YKienKhachHang>(n => n.TenKhachHang.ToLower() == tenKhachHang.ToLower() && n.ContactBy.Value.ToString() == Global.UserGUID && n.Status == (byte)Status.Actived); } else { ykkh = db.YKienKhachHangs.FirstOrDefault <YKienKhachHang>(n => n.TenKhachHang.ToLower() == tenKhachHang.ToLower() && n.ContactBy.Value.ToString() == Global.UserGUID && n.YKienKhachHangGUID.ToString() != yKienKhachHangGUID && n.Status == (byte)Status.Actived); } if (ykkh == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckNhanXetExist(string nhanXetKhamLamSangGUID, int loai, string nhanXet) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); NhanXetKhamLamSang nxkls = null; if (nhanXetKhamLamSangGUID == null || nhanXetKhamLamSangGUID == string.Empty) { nxkls = db.NhanXetKhamLamSangs.SingleOrDefault <NhanXetKhamLamSang>(s => s.NhanXet.Trim().ToLower() == nhanXet.Trim().ToLower() && s.Loai == loai); } else { nxkls = db.NhanXetKhamLamSangs.SingleOrDefault <NhanXetKhamLamSang>(s => s.NhanXet.Trim().ToLower() == nhanXet.Trim().ToLower() && s.Loai == loai && s.NhanXetKhamLamSangGUID.ToString() != nhanXetKhamLamSangGUID); } if (nxkls == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetLoaiSieuAmList(bool isNam) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); List <LoaiSieuAm> loaiSieuAmList = null; if (isNam) { loaiSieuAmList = (from s in db.LoaiSieuAms join m in db.MauBaoCaos on s.LoaiSieuAmGUID equals m.LoaiSieuAmGUID where (m.DoiTuong == (byte)DoiTuong.Chung || m.DoiTuong == (byte)DoiTuong.Nam) && m.Status == (byte)Status.Actived && s.Status == (byte)Status.Actived orderby s.ThuTu ascending select s).ToList(); } else { loaiSieuAmList = (from s in db.LoaiSieuAms join m in db.MauBaoCaos on s.LoaiSieuAmGUID equals m.LoaiSieuAmGUID where (m.DoiTuong == (byte)DoiTuong.Chung || m.DoiTuong == (byte)DoiTuong.Nu) && m.Status == (byte)Status.Actived && s.Status == (byte)Status.Actived orderby s.ThuTu ascending select s).ToList(); } result.QueryResult = loaiSieuAmList; } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckTenXetNghiemExist(string xetNghiem_ManualGUID, string tenXetNghiem, string groupName) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); XetNghiem_Manual xn = null; if (xetNghiem_ManualGUID == null || xetNghiem_ManualGUID == string.Empty) { xn = db.XetNghiem_Manuals.SingleOrDefault <XetNghiem_Manual>(x => x.Fullname.ToLower() == tenXetNghiem.ToLower() && x.GroupName.ToLower() == groupName.ToLower()); } else { xn = db.XetNghiem_Manuals.SingleOrDefault <XetNghiem_Manual>(x => x.Fullname.ToLower() == tenXetNghiem.ToLower() && x.XetNghiem_ManualGUID.ToString() != xetNghiem_ManualGUID && x.GroupName.ToLower() == groupName.ToLower()); } if (xn == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result GetThuocTonKho(string thuocGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); DateTime dt = DateTime.Now; List <LoThuoc> loThuocList = (from l in db.LoThuocs where l.Status == (byte)Status.Actived && l.ThuocGUID.ToString() == thuocGUID && new DateTime(l.NgayHetHan.Year, l.NgayHetHan.Month, l.NgayHetHan.Day) > dt && l.SoLuongNhap * l.SoLuongQuiDoi - l.SoLuongXuat > 0 select l).ToList <LoThuoc>(); if (loThuocList != null && loThuocList.Count > 0) { int tongSLNhap = 0; int tongSLXuat = 0; foreach (LoThuoc lt in loThuocList) { tongSLNhap += lt.SoLuongNhap * lt.SoLuongQuiDoi; tongSLXuat += lt.SoLuongXuat; } result.QueryResult = tongSLNhap - tongSLXuat; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result AddPhongCho(List <string> patientKeys) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); using (TransactionScope t = new TransactionScope(TransactionScopeOption.RequiresNew)) { DateTime fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); DateTime toDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); foreach (string key in patientKeys) { PhongCho pc = db.PhongChos.SingleOrDefault(p => p.PatientGUID.ToString() == key && p.Ngay >= fromDate && p.Ngay <= toDate); if (pc == null) { pc = new PhongCho(); pc.PhongChoGUID = Guid.NewGuid(); pc.PatientGUID = Guid.Parse(key); pc.Ngay = DateTime.Now; db.PhongChos.InsertOnSubmit(pc); } } db.SubmitChanges(); t.Complete(); } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckChiDinhExistCode(string chiDinhGUID, string code) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); ChiDinh chiDinh = null; if (chiDinhGUID == null || chiDinhGUID == string.Empty) { chiDinh = db.ChiDinhs.SingleOrDefault <ChiDinh>(c => c.MaChiDinh.ToLower() == code.ToLower()); } else { chiDinh = db.ChiDinhs.SingleOrDefault <ChiDinh>(c => c.MaChiDinh.ToLower() == code.ToLower() && c.ChiDinhGUID.ToString() != chiDinhGUID); } if (chiDinh == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckLoThuocExistCode(string loThuocGUID, string code) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); LoThuoc lt = null; if (loThuocGUID == null || loThuocGUID == string.Empty) { lt = db.LoThuocs.SingleOrDefault <LoThuoc>(l => l.MaLoThuoc.ToLower() == code.ToLower()); } else { lt = db.LoThuocs.SingleOrDefault <LoThuoc>(l => l.MaLoThuoc.ToLower() == code.ToLower() && l.LoThuocGUID.ToString() != loThuocGUID); } if (lt == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckUserLogonExist(string logonGUID, string docStaffGUID) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); Logon logon = null; if (logonGUID == null || logonGUID == string.Empty) { logon = db.Logons.SingleOrDefault <Logon>(l => l.DocStaffGUID.ToString() == docStaffGUID && l.Status == 0); } else { logon = db.Logons.SingleOrDefault <Logon>(l => l.DocStaffGUID.ToString() == docStaffGUID && l.LogonGUID.ToString() != logonGUID && l.Status == 0); } if (logon == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckSoPhieuExistCode(string ketQuaNoiSoiGUID, string code) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); KetQuaNoiSoi kqns = null; if (ketQuaNoiSoiGUID == null || ketQuaNoiSoiGUID == string.Empty) { kqns = db.KetQuaNoiSois.SingleOrDefault <KetQuaNoiSoi>(k => k.SoPhieu.ToLower() == code.ToLower()); } else { kqns = db.KetQuaNoiSois.SingleOrDefault <KetQuaNoiSoi>(k => k.SoPhieu.ToLower() == code.ToLower() && k.KetQuaNoiSoiGUID.ToString() != ketQuaNoiSoiGUID); } if (kqns == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckUserGroupExist(string userGroupGUID, string groupName) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); UserGroup userGroup = null; if (userGroupGUID == null || userGroupGUID == string.Empty) { userGroup = db.UserGroups.SingleOrDefault <UserGroup>(l => l.GroupName.ToLower() == groupName.ToLower() && l.Status == 0); } else { userGroup = db.UserGroups.SingleOrDefault <UserGroup>(l => l.GroupName.ToLower() == groupName.ToLower() && l.UserGroupGUID.ToString() != userGroupGUID && l.Status == 0); } if (userGroup == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }
public static Result CheckSpecialityExistCode(string specGUID, string code) { Result result = new Result(); MMOverride db = null; try { db = new MMOverride(); Speciality spec = null; if (specGUID == null || specGUID == string.Empty) { spec = db.Specialities.SingleOrDefault <Speciality>(s => s.Code.ToLower() == code.ToLower()); } else { spec = db.Specialities.SingleOrDefault <Speciality>(s => s.Code.ToLower() == code.ToLower() && s.SpecialityGUID.ToString() != specGUID); } if (spec == null) { result.Error.Code = ErrorCode.NOT_EXIST; } else { result.Error.Code = ErrorCode.EXIST; } } catch (System.Data.SqlClient.SqlException se) { result.Error.Code = (se.Message.IndexOf("Timeout expired") >= 0) ? ErrorCode.SQL_QUERY_TIMEOUT : ErrorCode.INVALID_SQL_STATEMENT; result.Error.Description = se.ToString(); } catch (Exception e) { result.Error.Code = ErrorCode.UNKNOWN_ERROR; result.Error.Description = e.ToString(); } finally { if (db != null) { db.Dispose(); db = null; } } return(result); }