// xử lý thanh toán public string ThanhToanProcessing(List <KetQuaXetNghiemDTO> ketQuaXetNghiems) { if (ketQuaXetNghiems == null || ketQuaXetNghiems.Count == 0) { return(Constant.RES_FAI); } KetQuaXetNghiemBUS ketQuaXetNghiemBUS = new KetQuaXetNghiemBUS(); ThanhToanBUS thanhToanBUS = new ThanhToanBUS(); LuonCongViecBUS luonCongViecBUS = new LuonCongViecBUS(); using (QLPHONGKHAMEntities db = new QLPHONGKHAMEntities()) { ThanhToanDTO thanhToan = new ThanhToanDTO(); if (thanhToanBUS.GetThanhToan(db, ketQuaXetNghiems.ElementAt(0).MaHoSo, out thanhToan) == Constant.RES_FAI) { return(Constant.RES_FAI); } if (thanhToan == null) { return(Constant.RES_FAI); } decimal tongtien = 0; foreach (var kq in ketQuaXetNghiems) { tongtien += kq.TongChiPhi; } thanhToan.TongChiPhi += tongtien; thanhToan.ChiPhiXetNghiem = tongtien; LuonCongViecDTO luonCongViec = new LuonCongViecDTO(); if (luonCongViecBUS.GetInformationLuonCongViec(db, thanhToan.MaHoSo, out luonCongViec) == Constant.RES_FAI) { return(Constant.RES_FAI); } luonCongViec.NodeHienTai = BusConstant.NODE_XET_NGHIEM; using (var trans = db.Database.BeginTransaction()) { foreach (var kq in ketQuaXetNghiems) { // yeu cau PRESENT phai update doi tuong if (ketQuaXetNghiemBUS.UpdateKetQuaXetNghiem(db, kq).Equals(Constant.RES_FAI)) { trans.Rollback(); return(Constant.RES_FAI); } } if (thanhToanBUS.UpdateThanhToan(db, thanhToan).Equals(Constant.RES_FAI)) { trans.Rollback(); return(Constant.RES_FAI); } if (luonCongViecBUS.UpdateLuonCongViec(db, luonCongViec).Equals(Constant.RES_FAI)) { trans.Rollback(); return(Constant.RES_FAI); } trans.Commit(); } db.SaveChanges(); } return(Constant.RES_SUC); }