public void Update_TestCase4() { ThanhToanDTO thanhToanDTO = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10, MaHoSo = TestCommon.LEN_10, ChiPhiKham = 1, ChiPhiXetNghiem = 1, TongChiPhi = 2, NhanVienThu = TestCommon.LEN_10, NgayThu = TestCommon.LEN_8 }; ThanhToanBUS thanhToanBUS = new ThanhToanBUS(); thanhToanBUS.InsertThanhToan(db, thanhToanDTO); ThanhToanDTO thanhtoanUpdate = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10 + "1", MaHoSo = TestCommon.LEN_10 + "1", ChiPhiKham = 1111111111111, ChiPhiXetNghiem = 1111111111111, TongChiPhi = 22222222222222, NhanVienThu = TestCommon.LEN_10 + "1", NgayThu = TestCommon.LEN_8 + "1" }; string actual = thanhToanBUS.UpdateThanhToan(db, thanhtoanUpdate); string expected = "1111"; Assert.Equals(expected, actual); }
public void Update_TestCase3() { ThanhToanDTO thanhToanDTO = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10, MaHoSo = TestCommon.LEN_10, ChiPhiKham = 1, ChiPhiXetNghiem = 1, TongChiPhi = 2, }; ThanhToanBUS thanhToanBUS = new ThanhToanBUS(); thanhToanBUS.InsertThanhToan(db, thanhToanDTO); ThanhToanDTO thanhtoanUpdate = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10, MaHoSo = TestCommon.LEN_10, ChiPhiKham = -1, ChiPhiXetNghiem = -1, TongChiPhi = -2, }; string actual = thanhToanBUS.UpdateThanhToan(db, thanhtoanUpdate); string expected = "1111"; Assert.Equals(expected, actual); }
public void Update_TestCase2() { ThanhToanDTO thanhToanDTO = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10, MaHoSo = TestCommon.LEN_10, }; ThanhToanBUS thanhToanBUS = new ThanhToanBUS(); thanhToanBUS.InsertThanhToan(db, thanhToanDTO); ThanhToanDTO thanhtoanUpdate = new ThanhToanDTO { MaThanhToan = TestCommon.LEN_10, }; string actual = thanhToanBUS.UpdateThanhToan(db, thanhtoanUpdate); string expected = "1111"; Assert.Equals(expected, actual); }
// 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); }