// Abstract Overrides // -------------------------------------------------------------------------- #region Abstract Overrides protected override bool UpdateWorkbook() { Excel.Application excelApplication = ExcelGenerator.GetExcelApplication(); InvoiceConfiguration invoiceConfiguration = Configuration.Configuration.Instance.InvoiceConfiguration; PersonalConfiguration personalConfiguration = Configuration.Configuration.Instance.PersonalConfiguration; // Name... ExcelCell nameCell = Helpers.Excel.ToCell(invoiceConfiguration.NameCell); excelApplication.Cells[nameCell.Row, nameCell.Column].Value = personalConfiguration.Name; // Address... ExcelCell addressCell = Helpers.Excel.ToCell(invoiceConfiguration.AddressCell); excelApplication.Cells[addressCell.Row, addressCell.Column].Value = personalConfiguration.Address; // Invoice Number... ExcelCell invoiceNumberCell = Helpers.Excel.ToCell(invoiceConfiguration.CurrentInvoiceNumberCell); excelApplication.Cells[invoiceNumberCell.Row, invoiceNumberCell.Column].Value = this.MonthlyTimesheets.InvoiceNumber; int rowIndex = -1; //for (int i = 0; i < this.MonthlyTimesheets.Count; i++) { foreach (Timesheet timesheet in this.MonthlyTimesheets) { //Timesheet timesheet = this.MonthlyTimesheets[i]; if (timesheet.IsSplitRate()) { // If we have a Timesheet that has split rates (e.g. all TimesheetDates do not have the same // RatePerHour), we need to handle this separately so it is properly reflected on the Invoice. AddSplitRateEntries(ref rowIndex, timesheet, invoiceConfiguration); } else { // Note: If timesheet.IsSplitRate() == false, all the TimesheetDates within the Timesheet // have the same rate/hour, so all we need to do is get the RatePerHour from any TimesheetDate // within the Timesheet and we're good to go... decimal ratePerHour = timesheet[0].RatePerHour; AddEntry(++rowIndex, timesheet.GetBillableHours(), ratePerHour, timesheet.WeekNumber, timesheet.StartDate.Date, timesheet.EndDate.Date, invoiceConfiguration); } } return(true); }
// Abstract Overrides // -------------------------------------------------------------------------- #region Abstract Overrides protected override bool UpdateWorkbook() { Excel.Application excelApplication = ExcelGenerator.GetExcelApplication(); TimesheetConfiguration timesheetConfiguration = Configuration.Configuration.Instance.TimesheetConfiguration; PersonalConfiguration personalConfiguration = Configuration.Configuration.Instance.PersonalConfiguration; ExcelCell cell = null; // Notes and remarks cell ExcelCell notesAndRemarksCell = Helpers.Excel.ToCell(timesheetConfiguration.NotesAndRemarksCell); // Timesheet name... cell = Helpers.Excel.ToCell(timesheetConfiguration.NameCell); excelApplication.Cells[cell.Row, cell.Column].Value = personalConfiguration.Name; // From date... cell = Helpers.Excel.ToCell(timesheetConfiguration.StartDateCell); excelApplication.Cells[cell.Row, cell.Column].Value = this.Timesheet.StartDate.Date; // Timesheet project description... cell = Helpers.Excel.ToCell(timesheetConfiguration.ProjectDescriptionCell); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetConfiguration.ProjectDescription; // Billable hours... // ------------------------------------------------------------------- string hourCellString = string.Empty; DayOfWeek dayOfWeek; TimesheetDate timesheetDate = null; // Monday... hourCellString = timesheetConfiguration.MondayHourCell; dayOfWeek = DayOfWeek.Monday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Tuesday... hourCellString = timesheetConfiguration.TuesdayHourCell; dayOfWeek = DayOfWeek.Tuesday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Wednesday... hourCellString = timesheetConfiguration.WednesdayHourCell; dayOfWeek = DayOfWeek.Wednesday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Thursday... hourCellString = timesheetConfiguration.ThursdayHourCell; dayOfWeek = DayOfWeek.Thursday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Friday... hourCellString = timesheetConfiguration.FridayHourCell; dayOfWeek = DayOfWeek.Friday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Saturday... hourCellString = timesheetConfiguration.SaturdayHourCell; dayOfWeek = DayOfWeek.Saturday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } // Sunday... hourCellString = timesheetConfiguration.SundayHourCell; dayOfWeek = DayOfWeek.Sunday; cell = Helpers.Excel.ToCell(hourCellString); timesheetDate = this.Timesheet.Dates.First(p => p.Date.DayOfWeek == dayOfWeek); excelApplication.Cells[cell.Row, cell.Column].Value = timesheetDate.BillableHours; if (timesheetDate.HasNotes) { AddNote(excelApplication, timesheetDate.Date, timesheetDate.Notes, notesAndRemarksCell); } return(true); }