public void MoveToTimesheet(Int32 ExpenseEntryID, Int32 NewBillingPeriodAccountID, Int32 OldTimesheetID) { TimesheetController timesheetcontroller = new TimesheetController(); Timesheet oldtimesheet = timesheetcontroller.FetchByID(OldTimesheetID)[0]; String username = oldtimesheet.Username; if (!timesheetcontroller.TimesheetExists(username, NewBillingPeriodAccountID)) { timesheetcontroller.Insert(username, NewBillingPeriodAccountID, oldtimesheet.Rategroupid); } TimesheetCollection col = new BillingPeriodAccountController().FetchByID(NewBillingPeriodAccountID)[0].Timesheets(); foreach (Timesheet timesheet in col) { if (timesheet.Username.Equals(username)) { ExpenseEntry item = this.FetchByID(ExpenseEntryID)[0]; this.Update(item.Id, timesheet.Id, item.Expensedate, item.Cost, item.Expensedesc); return; } } return; }
public Double GetTotalByBillingPeriodAccountID(Int32 BillingPeriodAccountID) { Double total = 0; ExpenseEntryCollection col = this.FetchAll().Where(ExpenseEntry.Columns.IsDeleted, false); var allTimesheets = new TimesheetController().FetchAll(); foreach (ExpenseEntry expenseentry in col) { var timesheet = allTimesheets.FirstOrDefault(x => x.Id == expenseentry.Timesheetid); if (timesheet != null && timesheet.Periodaccountid == BillingPeriodAccountID && expenseentry.IsDeleted == false) total += expenseentry.Cost; } return total; }
protected void Page_Load(object sender, EventArgs e) { TimesheetId = Int32.Parse(Request.Params["id"]); var controller = new TimesheetController(); month.Value = Request.Params["month"]; year.Value = Request.Params["year"]; if (!IsPostBack) { TFS.Intranet.Data.Billing.Timesheet timesheet = new TFS.Intranet.Data.Billing.TimesheetController().FetchByID(TimesheetId)[0]; //check and see if there are any BillingCityRates for this account //var billingCityRateController = new BillingDefaultCityRateController(); //var billingCityRateCol = billingCityRateController.FetchAllActiveByAccountId(timesheet.BillingPeriodAccount.Accountid); //if (billingCityRateCol.Count > 0) //{ //} var timeBillingCityRateJoinController = new TimesheetBillingCityRateJoinController(); var cityCountPerDiem = timeBillingCityRateJoinController.CityPerDiemCountGrandTotalByTimesheetId(TimesheetId); if (cityCountPerDiem > 0) { //hide default per diem count UI element pnlDefaultPerdiemCount.Visible = false; //show city per diem UI elements pnlTimesheetBillingCityRates.Visible = true; DaysPerDiem.Text = cityCountPerDiem.ToString(); } else { DaysPerDiem.Text = timesheet.Perdiemcount.ToString(); } Mileage.Text = timesheet.Mileageclaimed.ToString(); PayRateGroup.Text = timesheet.RateGroup.Name; } }
protected void lnkBtnStartUserTimesheet_OnClick(object sender, EventArgs e) { if (PeriodId <= 0) return; var accountId = int.Parse(drpDwnAccounts.SelectedValue); var billingPeriodController = new TFS.Intranet.Data.Billing.BillingPeriodAccountController(); var periodaccountid = billingPeriodController.GetIdByPeriodIdAndAccountId(PeriodId, accountId); var username = drpDwnActiveUsers.SelectedValue; var user = new UserController().ByUsername(username); var timesheetId = new TFS.Intranet.Data.Billing.TimesheetController().Insert(username, periodaccountid, user.Rategroup); var period = TFS.Intranet.Data.Billing.BillingPeriod.FetchByID(PeriodId); var url = "/Billing/timecard.aspx?username={0}&id={1}&month={2}&year={3}"; url = string.Format(url, username, timesheetId, period.Month, period.Year); Response.Redirect(url); }
protected void lnkBtnStartUserTimesheet_OnClick(object sender, EventArgs e) { if (PeriodId <= 0) { return; } var accountId = int.Parse(drpDwnAccounts.SelectedValue); var billingPeriodController = new TFS.Intranet.Data.Billing.BillingPeriodAccountController(); var periodaccountid = billingPeriodController.GetIdByPeriodIdAndAccountId(PeriodId, accountId); var username = drpDwnActiveUsers.SelectedValue; var user = new UserController().ByUsername(username); var timesheetId = new TFS.Intranet.Data.Billing.TimesheetController().Insert(username, periodaccountid, user.Rategroup); var period = TFS.Intranet.Data.Billing.BillingPeriod.FetchByID(PeriodId); var url = "/Billing/timecard.aspx?username={0}&id={1}&month={2}&year={3}"; url = string.Format(url, username, timesheetId, period.Month, period.Year); Response.Redirect(url); }
public DataTable GetAccountSummaryTotals(Int32 Billingaccountid, Int32 PeriodID) { BillingPeriodAccountsJoin billingperiodaccount = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Periodid, PeriodID).Where(BillingPeriodAccountsJoin.Columns.Accountid, Billingaccountid).Load()[0]; Int32 billingperiodaccountid = billingperiodaccount.Id; var timeSheetController = new TimesheetController(); DataTable summaryTotals = new DataTable(); summaryTotals.Columns.Add("RateGroupID"); summaryTotals.Columns.Add("RateGroupName"); summaryTotals.Columns.Add("Rate"); summaryTotals.Columns.Add("TotalHours"); summaryTotals.Columns.Add("PerDiemRate"); summaryTotals.Columns.Add("PerDiemTotal"); summaryTotals.Columns.Add("MileageRate"); summaryTotals.Columns.Add("MileageTotal"); summaryTotals.Columns.Add("ExpenseTotal"); Double perdiemrate = billingperiodaccount.Perdiemrate; Double cityPerdiemRateAverage = timeSheetController.GetPerCityDiemRateAverageByBillingPeriodAccountID(billingperiodaccountid); Double perdiemtotal = timeSheetController.GetPerDiemCountByBillingPeriodAccountID(billingperiodaccountid); Double expensetotal = new ExpenseEntryController().GetTotalByBillingPeriodAccountID(billingperiodaccountid); Double mileagerate = billingperiodaccount.Mileagerate; Double mileagetotal = timeSheetController.GetMileageCountByBillingPeriodAccountID(billingperiodaccountid); if (cityPerdiemRateAverage > 0) { perdiemrate = cityPerdiemRateAverage; } RateGroupCollection rategroups = new RateGroupController().FetchAll(); foreach (RateGroup rategroup in rategroups) { DataRow newrow = summaryTotals.NewRow(); newrow["RateGroupID"] = rategroup.Id; newrow["RateGroupName"] = rategroup.Name; BillingRateCollection billingratecollection = new BillingRateCollection().Where(BillingRate.Columns.Periodaccountid, billingperiodaccountid).Where(BillingRate.Columns.Groupid, rategroup.Id).Load(); newrow["Rate"] = billingratecollection[0].Rate; Double totalHours = 0; EmployeeTimesheetInfoCollection col = GetTimesheets(Billingaccountid, PeriodID, rategroup.Id); foreach (EmployeeTimesheetInfo timesheet in col) { totalHours += new TimeEntriesTotalController().GetTotalHoursByTimesheetID(timesheet.Timesheetid); } newrow["TotalHours"] = totalHours; newrow["PerDiemRate"] = perdiemrate; newrow["PerDiemTotal"] = perdiemtotal; newrow["MileageRate"] = mileagerate; newrow["MileageTotal"] = mileagetotal; newrow["ExpenseTotal"] = expensetotal; summaryTotals.Rows.Add(newrow); } return(summaryTotals); }
public DataTable GetAccountSummaryTotals(Int32 Billingaccountid, Int32 PeriodID) { BillingPeriodAccountsJoin billingperiodaccount = new BillingPeriodAccountsJoinCollection().Where(BillingPeriodAccountsJoin.Columns.Periodid, PeriodID).Where(BillingPeriodAccountsJoin.Columns.Accountid, Billingaccountid).Load()[0]; Int32 billingperiodaccountid = billingperiodaccount.Id; var timeSheetController = new TimesheetController(); DataTable summaryTotals = new DataTable(); summaryTotals.Columns.Add("RateGroupID"); summaryTotals.Columns.Add("RateGroupName"); summaryTotals.Columns.Add("Rate"); summaryTotals.Columns.Add("TotalHours"); summaryTotals.Columns.Add("PerDiemRate"); summaryTotals.Columns.Add("PerDiemTotal"); summaryTotals.Columns.Add("MileageRate"); summaryTotals.Columns.Add("MileageTotal"); summaryTotals.Columns.Add("ExpenseTotal"); Double perdiemrate = billingperiodaccount.Perdiemrate; Double cityPerdiemRateAverage = timeSheetController.GetPerCityDiemRateAverageByBillingPeriodAccountID(billingperiodaccountid); Double perdiemtotal = timeSheetController.GetPerDiemCountByBillingPeriodAccountID(billingperiodaccountid); Double expensetotal = new ExpenseEntryController().GetTotalByBillingPeriodAccountID(billingperiodaccountid); Double mileagerate = billingperiodaccount.Mileagerate; Double mileagetotal = timeSheetController.GetMileageCountByBillingPeriodAccountID(billingperiodaccountid); if (cityPerdiemRateAverage > 0) { perdiemrate = cityPerdiemRateAverage; } RateGroupCollection rategroups = new RateGroupController().FetchAll(); foreach (RateGroup rategroup in rategroups) { DataRow newrow = summaryTotals.NewRow(); newrow["RateGroupID"] = rategroup.Id; newrow["RateGroupName"] = rategroup.Name; BillingRateCollection billingratecollection = new BillingRateCollection().Where(BillingRate.Columns.Periodaccountid, billingperiodaccountid).Where(BillingRate.Columns.Groupid, rategroup.Id).Load(); newrow["Rate"] = billingratecollection[0].Rate; Double totalHours = 0; EmployeeTimesheetInfoCollection col = GetTimesheets(Billingaccountid, PeriodID, rategroup.Id); foreach (EmployeeTimesheetInfo timesheet in col) { totalHours += new TimeEntriesTotalController().GetTotalHoursByTimesheetID(timesheet.Timesheetid); } newrow["TotalHours"] = totalHours; newrow["PerDiemRate"] = perdiemrate; newrow["PerDiemTotal"] = perdiemtotal; newrow["MileageRate"] = mileagerate; newrow["MileageTotal"] = mileagetotal; newrow["ExpenseTotal"] = expensetotal; summaryTotals.Rows.Add(newrow); } return summaryTotals; }