public static CThanhToan THANHTOAN(long Ma_Nguon_Vay, DateTime From, DateTime To) { CThanhToan result = new CThanhToan(); long goc = 0; long lai = 0; try { goc = (from _tt in DataInstance.Instance().DBContext().TRA_NO_VAY where _tt.MA_NGUON_VAY == Ma_Nguon_Vay && _tt.NGAY_TRA >= From && _tt.NGAY_TRA <= To select _tt.TIEN_GOC).Sum(); } catch (Exception ex) { } try { lai = (from _tt in DataInstance.Instance().DBContext().TRA_NO_VAY where _tt.MA_NGUON_VAY == Ma_Nguon_Vay && _tt.NGAY_TRA >= From && _tt.NGAY_TRA <= To select _tt.TIEN_LAI).Sum(); } catch (Exception ex) { } result.GOC = goc; result.LAI = lai; return(result); }
public static CThanhToan THANHTOAN(VAY vay) { CThanhToan result = new CThanhToan(); try { CThanhToan _e = (from tnv in DataInstance.Instance().DBContext().TRA_NO_VAY where tnv.VAY_ID == vay.ID group tnv by tnv.VAY_ID into g select new CThanhToan { GOC = g.Sum(u => u.TIEN_GOC), LAI = g.Sum(u => u.TIEN_LAI) }).First(); result.GOC = _e.GOC; result.LAI = _e.LAI; } catch (Exception ex) { } return(result); }