Created
September 22, 2010 14:30
-
-
Save ArnisL/591769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Map=BudgetPerPartnersMap; | |
//you all going to die down here! | |
public static class BudgetPerPartnersReader{ | |
public static void Read(IExcelReader r,ApplicationForm f){ | |
r.ChangeSheet(SheetMap.BudgetPerPartners); | |
var b=f.BudgetPerPartners; | |
var fillCostsType=new Action<CostsType,string[,]>( | |
(costsType,map)=>{ | |
costsType.AllPartnersTotal=r.Get(Map.AllPartnersTotal[0]); | |
for(var i=0;i<map.GetUpperBound(0);i++) | |
for(var ei=0;ei<costsType.Entries.Length;ei++){ | |
var row=map[i,0].GetRow()+ei; | |
//debug this, suckaa! | |
var getPartnerCell=new Func<int,string>( | |
index=>Map.PartnerCols[index]+row.ToString()); | |
var getPartnerCellValue=new Func<int,int,string>( | |
(colIndex,colOffset)=> | |
r.Get(getPartnerCell(colIndex).ColOffset(colOffset*Map.PartnerColOffset))); | |
var getPartnerCosts=new Func<Func<int,string> /*get cell func*/,PartnerCosts>( | |
x=>new PartnerCosts {NumberOfUnits=x(0),UnitRate=x(1),Costs=x(2),InKind=x(3),Total=x(4)}); | |
var getEntryCellValue=new Func<int,string>( | |
colIndex=>r.Get(map[ei,colIndex])); | |
var e=costsType.Entries[ei]=new CostsTypeEntry | |
{ | |
Name=getEntryCellValue(0), | |
AllPartnersTotal=getEntryCellValue(1), | |
Unit=getEntryCellValue(2) | |
}; | |
e.ApplicantCosts=getPartnerCosts(x=>getPartnerCellValue(x,0 /*offset 0==applicant*/)); | |
for(var partnerIndex=0;partnerIndex<e.PartnerCosts.Length;partnerIndex++) | |
e.PartnerCosts[partnerIndex]=getPartnerCosts(x=>getPartnerCellValue(x,partnerIndex)); | |
} | |
}); | |
fillCostsType(b.HumanResources,Map.HumanResources); | |
fillCostsType(b.Administrative,Map.AdministrativeCosts); | |
fillCostsType(b.DirectLocalOffice,Map.DirectLocalOfficeCosts); | |
fillCostsType(b.EquipmentAndSupplies,Map.EquipmentAndSupplies); | |
fillCostsType(b.Infrastructure,Map.Infrastructure); | |
fillCostsType(b.OtherCostsAndExternalServices,Map.OtherCostsExternalServices); | |
fillCostsType(b.ProvisionForContingencyReserve,Map.ProvisionForContingencyReserve); | |
fillCostsType(b.SubtotalDirectEligible,Map.SubtotalDirectEligibleCosts); | |
fillCostsType(b.TotalDirectEligible,Map.TotalDirectEligibleCosts); | |
fillCostsType(b.TotalEligible,Map.TotalEligibleCosts); | |
fillCostsType(b.Travel,Map.Travel); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment