public ActionResult Nhapvien(NoitruPhanbuonggiuong objBuongGiuong, KcbLuotkham objLuotkham, NoitruGoinhapvien objThongtinGoiDvu) { try { using (var Scope = new TransactionScope()) { using (var dbScope = new SharedDbConnectionScope()) { if (objBuongGiuong != null) { NoitruPhanbuonggiuongCollection _NoitruPhanbuonggiuong = new Select().From(NoitruPhanbuonggiuong.Schema) .Where(NoitruPhanbuonggiuong.Columns.NoiTru).IsEqualTo(1) .And(NoitruPhanbuonggiuong.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(NoitruPhanbuonggiuong.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).ExecuteAsCollection<NoitruPhanbuonggiuongCollection>(); if (_NoitruPhanbuonggiuong!=null && _NoitruPhanbuonggiuong.Count == 1) { if (Utility.Int32Dbnull(_NoitruPhanbuonggiuong[0].IdBuong, -1) == -1) { //Chỉ việc cập nhật lại thông tin khoa new Update(NoitruPhanbuonggiuong.Schema) .Set(NoitruPhanbuonggiuong.Columns.IdKhoanoitru).EqualTo(objBuongGiuong.IdKhoanoitru) .Set(NoitruPhanbuonggiuong.Columns.NguoiSua).EqualTo(objBuongGiuong.NguoiSua) .Set(NoitruPhanbuonggiuong.Columns.NgaySua).EqualTo(objBuongGiuong.NgaySua) .Set(NoitruPhanbuonggiuong.Columns.NgayVaokhoa).EqualTo(objBuongGiuong.NgayVaokhoa) .Set(NoitruPhanbuonggiuong.Columns.IdBacsiChidinh).EqualTo(objBuongGiuong.IdBacsiChidinh) .Where(NoitruPhanbuonggiuong.Columns.Id).IsEqualTo(_NoitruPhanbuonggiuong[0].Id) .Execute(); objBuongGiuong.Id = _NoitruPhanbuonggiuong[0].Id; } } else { if (objBuongGiuong.NgayVaokhoa <= Convert.ToDateTime("01/01/1900")) objBuongGiuong.NgayVaokhoa = DateTime.Now; if (objBuongGiuong.NgayTao <= Convert.ToDateTime("01/01/1900")) objBuongGiuong.NgayTao = DateTime.Now; if (objLuotkham.NgayNhapvien <= Convert.ToDateTime("01/01/1900")) objLuotkham.NgayNhapvien = DateTime.Now; new Delete().From(NoitruPhanbuonggiuong.Schema) .Where(NoitruPhanbuonggiuong.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(NoitruPhanbuonggiuong.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(NoitruPhanbuonggiuong.Columns.NoiTru).IsEqualTo(1) .AndExpression(NoitruPhanbuonggiuong.Columns.IdBuong) .IsEqualTo(-1) .Or(NoitruPhanbuonggiuong.Columns.IdBuong) .IsNull().CloseExpression().Execute(); objBuongGiuong.IdBacsiChidinh = globalVariables.gv_intIDNhanvien; objBuongGiuong.IdBuong = -1; objBuongGiuong.IdGiuong = -1; objBuongGiuong.IdChuyen = -1; objBuongGiuong.SoLuong = 1; objBuongGiuong.TuTuc = 0; objBuongGiuong.IdGoi = -1; objBuongGiuong.TrongGoi = -1; objBuongGiuong.IdNhanvienPhangiuong = -1; objBuongGiuong.TrangthaiXacnhan = 0; objBuongGiuong.TenHienthi = "Nhập viện nội trú"; objBuongGiuong.NguoiTao = globalVariables.UserName; objBuongGiuong.NgayTao = globalVariables.SysDate; objBuongGiuong.NoiTru = 1; objBuongGiuong.IsNew = true; objBuongGiuong.Save(); } KcbLuotkham _tempt=new Select().From(KcbLuotkham.Schema) .Where(KcbLuotkham.Columns.MaLuotkham).IsNotEqualTo(objLuotkham.MaLuotkham) .And(KcbLuotkham.Columns.IdBenhnhan).IsNotEqualTo(objLuotkham.IdBenhnhan) .And(KcbLuotkham.Columns.SoBenhAn).IsEqualTo(objLuotkham.SoBenhAn) .ExecuteSingle<KcbLuotkham>(); //Tạm bỏ -->Phải giữ nguyên số bệnh án nội trú chứ? //if (_tempt != null) // objLuotkham.SoBenhAn = THU_VIEN_CHUNG.LaySoBenhAn(); new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(objLuotkham.SoBenhAn) .Set(KcbLuotkham.Columns.IdKhoanoitru).EqualTo(objBuongGiuong.IdKhoanoitru) .Set(KcbLuotkham.Columns.IdNhapvien).EqualTo(objBuongGiuong.Id) .Set(KcbLuotkham.Columns.IdRavien).EqualTo(objBuongGiuong.Id) .Set(KcbLuotkham.Columns.TrangthaiNoitru).EqualTo(1) .Set(KcbLuotkham.Columns.NgayNhapvien).EqualTo(objBuongGiuong.NgayVaokhoa) .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).Execute(); //Phần gói này sẽ thiết kế lại sau if (objThongtinGoiDvu != null) { if (Utility.Int32Dbnull(objThongtinGoiDvu.TrangthaiHuy, -1) <= 0) objThongtinGoiDvu.TrangthaiHuy = 0; if (Utility.Int32Dbnull(objThongtinGoiDvu.TrangthaiDattruoc, -1) <= 0) objThongtinGoiDvu.TrangthaiDattruoc = 0; if (objThongtinGoiDvu.NgayTao <= Convert.ToDateTime("01/01/1900")) objThongtinGoiDvu.NgayTao = globalVariables.SysDate; SqlQuery sqlQuery = new Select().From(NoitruGoinhapvien.Schema) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo(objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru) .And(NoitruGoinhapvien.Columns.TrangthaiThanhtoan).IsEqualTo(1); if (sqlQuery.GetRecordCount() > 0) { return ActionResult.ExistedRecord; } sqlQuery = new Select().From(NoitruGoinhapvien.Schema) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo(objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru); if (sqlQuery.GetRecordCount() <= 0) { //objThongtinGoiDvu.DatTruoc = 0; objThongtinGoiDvu.IdNhanvien = globalVariables.gv_intIDNhanvien; objThongtinGoiDvu.IsNew = true; objThongtinGoiDvu.Save(); } else { new Update(NoitruGoinhapvien.Schema) .Set(NoitruGoinhapvien.Columns.IdNhanvien) .EqualTo(globalVariables.gv_intIDNhanvien) .Set(NoitruGoinhapvien.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(NoitruGoinhapvien.Columns.NgaySua).EqualTo(DateTime.Now) .Set(NoitruGoinhapvien.Columns.IdGoi).EqualTo(objThongtinGoiDvu.IdGoi) .Set(NoitruGoinhapvien.Columns.SoTien).EqualTo(objThongtinGoiDvu.SoTien) .Set(NoitruGoinhapvien.Columns.SoNgay).EqualTo(objThongtinGoiDvu.SoNgay) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo( objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru). Execute(); } } } else { return ActionResult.Error; } } Scope.Complete(); return ActionResult.Success; } } catch (Exception ex) { Utility.CatchException( ex); return ActionResult.Error; } }
public void Insert(string MaLuotkham,int IdBenhnhan,string MaDoitruongKcb,int? IdGoi,int? SoNgay,decimal? SoTien,DateTime? NgayHethan,DateTime? NgayTao,string NguoiTao,int? TrangThai,byte? TrangthaiXacnhan,int? IdNhanvien,byte? TrangthaiThanhtoan,DateTime? NgayKichhoat,string NguoiKichhoat,int? IdThanhtoan,string MotaThem,int? NoiTru,int? IdKhoa,int? IdBuong,int? FromIdGoiDvu,DateTime? NgaySua,string NguoiSua,string KydoChuyen,DateTime? NgayKetthuc,string NguoiKetthuc,int? TrangthaiHuy,decimal? SotienTralai,int? TrangthaiDattruoc,string KetLuan,int? IdKham,DateTime? NgayThien,string NguoiThien) { NoitruGoinhapvien item = new NoitruGoinhapvien(); item.MaLuotkham = MaLuotkham; item.IdBenhnhan = IdBenhnhan; item.MaDoitruongKcb = MaDoitruongKcb; item.IdGoi = IdGoi; item.SoNgay = SoNgay; item.SoTien = SoTien; item.NgayHethan = NgayHethan; item.NgayTao = NgayTao; item.NguoiTao = NguoiTao; item.TrangThai = TrangThai; item.TrangthaiXacnhan = TrangthaiXacnhan; item.IdNhanvien = IdNhanvien; item.TrangthaiThanhtoan = TrangthaiThanhtoan; item.NgayKichhoat = NgayKichhoat; item.NguoiKichhoat = NguoiKichhoat; item.IdThanhtoan = IdThanhtoan; item.MotaThem = MotaThem; item.NoiTru = NoiTru; item.IdKhoa = IdKhoa; item.IdBuong = IdBuong; item.FromIdGoiDvu = FromIdGoiDvu; item.NgaySua = NgaySua; item.NguoiSua = NguoiSua; item.KydoChuyen = KydoChuyen; item.NgayKetthuc = NgayKetthuc; item.NguoiKetthuc = NguoiKetthuc; item.TrangthaiHuy = TrangthaiHuy; item.SotienTralai = SotienTralai; item.TrangthaiDattruoc = TrangthaiDattruoc; item.KetLuan = KetLuan; item.IdKham = IdKham; item.NgayThien = NgayThien; item.NguoiThien = NguoiThien; item.Save(UserName); }
public ActionResult Nhapvien(NoitruPhanbuonggiuong objBuongGiuong, KcbLuotkham objLuotkham, NoitruGoinhapvien objThongtinGoiDvu) { try { using (var Scope = new TransactionScope()) { using (var dbScope = new SharedDbConnectionScope()) { if (objBuongGiuong != null) { NoitruPhanbuonggiuongCollection _NoitruPhanbuonggiuong = new Select().From(NoitruPhanbuonggiuong.Schema) .Where(NoitruPhanbuonggiuong.Columns.NoiTru).IsEqualTo(1) .And(NoitruPhanbuonggiuong.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(NoitruPhanbuonggiuong.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).ExecuteAsCollection <NoitruPhanbuonggiuongCollection>(); if (_NoitruPhanbuonggiuong != null && _NoitruPhanbuonggiuong.Count == 1) { if (Utility.Int32Dbnull(_NoitruPhanbuonggiuong[0].IdBuong, -1) == -1) { //Chỉ việc cập nhật lại thông tin khoa new Update(NoitruPhanbuonggiuong.Schema) .Set(NoitruPhanbuonggiuong.Columns.IdKhoanoitru).EqualTo(objBuongGiuong.IdKhoanoitru) .Set(NoitruPhanbuonggiuong.Columns.NguoiSua).EqualTo(objBuongGiuong.NguoiSua) .Set(NoitruPhanbuonggiuong.Columns.NgaySua).EqualTo(objBuongGiuong.NgaySua) .Set(NoitruPhanbuonggiuong.Columns.NgayVaokhoa).EqualTo(objBuongGiuong.NgayVaokhoa) .Set(NoitruPhanbuonggiuong.Columns.IdBacsiChidinh).EqualTo(objBuongGiuong.IdBacsiChidinh) .Where(NoitruPhanbuonggiuong.Columns.Id).IsEqualTo(_NoitruPhanbuonggiuong[0].Id) .Execute(); } } else { if (objBuongGiuong.NgayVaokhoa <= Convert.ToDateTime("01/01/1900")) { objBuongGiuong.NgayVaokhoa = DateTime.Now; } if (objBuongGiuong.NgayTao <= Convert.ToDateTime("01/01/1900")) { objBuongGiuong.NgayTao = DateTime.Now; } if (objLuotkham.NgayNhapvien <= Convert.ToDateTime("01/01/1900")) { objLuotkham.NgayNhapvien = DateTime.Now; } new Delete().From(NoitruPhanbuonggiuong.Schema) .Where(NoitruPhanbuonggiuong.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(NoitruPhanbuonggiuong.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan) .And(NoitruPhanbuonggiuong.Columns.NoiTru).IsEqualTo(1) .AndExpression(NoitruPhanbuonggiuong.Columns.IdBuong) .IsEqualTo(-1) .Or(NoitruPhanbuonggiuong.Columns.IdBuong) .IsNull().CloseExpression().Execute(); objBuongGiuong.IdBacsiChidinh = globalVariables.gv_intIDNhanvien; objBuongGiuong.IdBuong = -1; objBuongGiuong.IdGiuong = -1; objBuongGiuong.IdChuyen = -1; objBuongGiuong.SoLuong = 1; objBuongGiuong.TuTuc = 0; objBuongGiuong.IdGoi = -1; objBuongGiuong.TrongGoi = -1; objBuongGiuong.IdNhanvienPhangiuong = -1; objBuongGiuong.TrangthaiXacnhan = 0; objBuongGiuong.TenHienthi = "Nhập viện nội trú"; objBuongGiuong.NguoiTao = globalVariables.UserName; objBuongGiuong.NgayTao = globalVariables.SysDate; objBuongGiuong.NoiTru = 1; objBuongGiuong.IsNew = true; objBuongGiuong.Save(); } new Update(KcbLuotkham.Schema) .Set(KcbLuotkham.Columns.SoBenhAn).EqualTo(objLuotkham.SoBenhAn) .Set(KcbLuotkham.Columns.IdKhoanoitru).EqualTo(objBuongGiuong.IdKhoanoitru) .Set(KcbLuotkham.Columns.IdNhapvien).EqualTo(objBuongGiuong.Id) .Set(KcbLuotkham.Columns.IdRavien).EqualTo(objBuongGiuong.Id) .Set(KcbLuotkham.Columns.TrangthaiNoitru).EqualTo(1) .Set(KcbLuotkham.Columns.NgayNhapvien).EqualTo(objBuongGiuong.NgayVaokhoa) .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objLuotkham.MaLuotkham) .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objLuotkham.IdBenhnhan).Execute(); if (objThongtinGoiDvu != null) { if (Utility.Int32Dbnull(objThongtinGoiDvu.TrangthaiHuy, -1) <= 0) { objThongtinGoiDvu.TrangthaiHuy = 0; } if (Utility.Int32Dbnull(objThongtinGoiDvu.TrangthaiDattruoc, -1) <= 0) { objThongtinGoiDvu.TrangthaiDattruoc = 0; } if (objThongtinGoiDvu.NgayTao <= Convert.ToDateTime("01/01/1900")) { objThongtinGoiDvu.NgayTao = globalVariables.SysDate; } SqlQuery sqlQuery = new Select().From(NoitruGoinhapvien.Schema) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo(objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru) .And(NoitruGoinhapvien.Columns.TrangthaiThanhtoan).IsEqualTo(1); if (sqlQuery.GetRecordCount() > 0) { return(ActionResult.ExistedRecord); } sqlQuery = new Select().From(NoitruGoinhapvien.Schema) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo(objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru); if (sqlQuery.GetRecordCount() <= 0) { //objThongtinGoiDvu.DatTruoc = 0; objThongtinGoiDvu.IdNhanvien = globalVariables.gv_intIDNhanvien; objThongtinGoiDvu.IsNew = true; objThongtinGoiDvu.Save(); } else { new Update(NoitruGoinhapvien.Schema) .Set(NoitruGoinhapvien.Columns.IdNhanvien) .EqualTo(globalVariables.gv_intIDNhanvien) .Set(NoitruGoinhapvien.Columns.NguoiSua).EqualTo(globalVariables.UserName) .Set(NoitruGoinhapvien.Columns.NgaySua).EqualTo(DateTime.Now) .Set(NoitruGoinhapvien.Columns.IdGoi).EqualTo(objThongtinGoiDvu.IdGoi) .Set(NoitruGoinhapvien.Columns.SoTien).EqualTo(objThongtinGoiDvu.SoTien) .Set(NoitruGoinhapvien.Columns.SoNgay).EqualTo(objThongtinGoiDvu.SoNgay) .Where(NoitruGoinhapvien.Columns.MaLuotkham).IsEqualTo( objThongtinGoiDvu.MaLuotkham) .And(NoitruGoinhapvien.Columns.IdBenhnhan).IsEqualTo( objThongtinGoiDvu.IdBenhnhan) .And(NoitruGoinhapvien.Columns.NoiTru).IsEqualTo(objThongtinGoiDvu.NoiTru). Execute(); } } } else { return(ActionResult.Error); } } Scope.Complete(); return(ActionResult.Success); } } catch (Exception ex) { Utility.CatchException(ex); return(ActionResult.Error); } }
public void Insert(string MaLuotkham, int IdBenhnhan, string MaDoitruongKcb, int?IdGoi, int?SoNgay, decimal?SoTien, DateTime?NgayHethan, DateTime?NgayTao, string NguoiTao, int?TrangThai, byte?TrangthaiXacnhan, int?IdNhanvien, byte?TrangthaiThanhtoan, DateTime?NgayKichhoat, string NguoiKichhoat, int?IdThanhtoan, string MotaThem, int?NoiTru, int?IdKhoa, int?IdBuong, int?FromIdGoiDvu, DateTime?NgaySua, string NguoiSua, string KydoChuyen, DateTime?NgayKetthuc, string NguoiKetthuc, int?TrangthaiHuy, decimal?SotienTralai, int?TrangthaiDattruoc, string KetLuan, int?IdKham, DateTime?NgayThien, string NguoiThien) { NoitruGoinhapvien item = new NoitruGoinhapvien(); item.MaLuotkham = MaLuotkham; item.IdBenhnhan = IdBenhnhan; item.MaDoitruongKcb = MaDoitruongKcb; item.IdGoi = IdGoi; item.SoNgay = SoNgay; item.SoTien = SoTien; item.NgayHethan = NgayHethan; item.NgayTao = NgayTao; item.NguoiTao = NguoiTao; item.TrangThai = TrangThai; item.TrangthaiXacnhan = TrangthaiXacnhan; item.IdNhanvien = IdNhanvien; item.TrangthaiThanhtoan = TrangthaiThanhtoan; item.NgayKichhoat = NgayKichhoat; item.NguoiKichhoat = NguoiKichhoat; item.IdThanhtoan = IdThanhtoan; item.MotaThem = MotaThem; item.NoiTru = NoiTru; item.IdKhoa = IdKhoa; item.IdBuong = IdBuong; item.FromIdGoiDvu = FromIdGoiDvu; item.NgaySua = NgaySua; item.NguoiSua = NguoiSua; item.KydoChuyen = KydoChuyen; item.NgayKetthuc = NgayKetthuc; item.NguoiKetthuc = NguoiKetthuc; item.TrangthaiHuy = TrangthaiHuy; item.SotienTralai = SotienTralai; item.TrangthaiDattruoc = TrangthaiDattruoc; item.KetLuan = KetLuan; item.IdKham = IdKham; item.NgayThien = NgayThien; item.NguoiThien = NguoiThien; item.Save(UserName); }