public bool CreateReportPeriod(ReportPeriodListR item) { // Insert must not work if any article exists in this Budget. // return budrep.CreateReportPeriod(item); if (GetFinArticleCategory(item.BudgetID).Count() == 0) //If No BUDGET { return(budrep.CreateReportPeriod(item)); } else //IF BUDGET EXISTS { if (budrep.CreateReportPeriod(item)) //if success. { // IEnumerable <FinArticleCategoryR> fincats = GetFinArticleCategory(item.BudgetID); List <ReportPeriodR> ReportPeriods = new List <ReportPeriodR>(); foreach (FinArticleCategoryR fincat in fincats) { //insert article itself. ReportPeriodR repper = new ReportPeriodR(); repper.ReportPeriodID = item.ReportPeriodID; repper.FinArticleCatID = fincat.FinArticleCatID; repper.Amount = 0; ReportPeriods.Add(repper); } return(budrep.InsertArticleToReportPeriodR(ReportPeriods)); } return(false); } }
/// <summary> /// Returns the amount to be transfered for the given repper. /// </summary> /// <param name="repper"></param> /// <returns></returns> public decimal Project_PeriodTrancheAmount(ReportPeriodR repper) { decimal PeriodTrancheAmount = 0; try { foreach (BudgetPaymentReport bpr in bpayrep) { if (repper.ReportPeriodID == bpr.repper.ReportPeriodID) { PeriodTrancheAmount = bpr.CalcMoneyToTransfer; } } } catch { PeriodTrancheAmount = 0; } return(PeriodTrancheAmount); }
public int AddFinArticleCategory(int id, int FinCatSel) { BOTADataContext db = new BOTADataContext(connectString); //Check if Any Report Periods Exist! if (!db.ReportPeriodListRs.Any(l => l.BudgetID == id)) // !if exists. { return(-2); //this means no ReportPeriods created yet. } FinArticleCategoryR fcat = new FinArticleCategoryR(); // fcat.FinArticleCatListID = FinCatSel; FinArtCatListR fcatr = (from ls in db.FinArtCatListRs where ls.FinArticleCatListID == FinCatSel select ls).FirstOrDefault(); fcat.FinArticleCatText = fcatr.FinArticleCatName; fcat.BudgetID = id; fcat.Price = 0; fcat.FinCatID = FinCatSel; try { db.FinArticleCategoryRs.InsertOnSubmit(fcat); db.SubmitChanges(); } catch (Exception ex) { //Log4Net uses its dll, bin/Log4Net.config -> has C:/Logs/errors2.txt Log.EnsureInitialized(); Log.Error(typeof(ProjectRepository), "Exception catched while Insert Project.", ex); return(-1); //could not insert new Category somehow. } try { IEnumerable <ReportPeriodListR> ReportPeriodsList = from ls in db.ReportPeriodListRs where ls.BudgetID == id select ls; List <ReportPeriodR> ReportPeriods = new List <ReportPeriodR>(); foreach (ReportPeriodListR rep in ReportPeriodsList) { ReportPeriodR repper = new ReportPeriodR(); repper.ReportPeriodID = rep.ReportPeriodID; repper.FinArticleCatID = fcat.FinArticleCatID; repper.Amount = 0; ReportPeriods.Add(repper); } db.ReportPeriodRs.InsertAllOnSubmit(ReportPeriods.AsEnumerable()); db.SubmitChanges(); } catch (Exception ex) { //Log4Net uses its dll, bin/Log4Net.config -> has C:/Logs/errors2.txt Log.EnsureInitialized(); Log.Error(typeof(ProjectRepository), "Exception catched while Insert Project.", ex); return(-3); //could not insert into Report Periods. } return(fcat.FinArticleCatID); }