public virtual void UpdateMonthlyTimesheets(MonthlyTimesheets monthlyTimesheets) { this.Clear(); // Note: Must populate property MonthlyTimesheets AFTER Clear() is called because // Clear() nulls out MonthlyTimesheets. this.MonthlyTimesheets = monthlyTimesheets; int y = 0; foreach (Timesheet timesheet in this.MonthlyTimesheets) { TimesheetDetailListView timesheetDetailListView = new TimesheetDetailListView(timesheet); timesheetDetailListView.TimesheetDetailUpdatingEvent += new EventHandler <TimesheetDetailListView.TimesheetDetailEventArgs>(this.OnTimesheetUpdating); timesheetDetailListView.TimesheetDetailUpdatedEvent += new EventHandler <TimesheetDetailListView.TimesheetDetailEventArgs>(this.OnTimesheetUpdated); Controls.Add(timesheetDetailListView); timesheetDetailListView.Dock = DockStyle.Top; timesheetDetailListView.Location = new Point(0, y + 1); timesheetDetailListView.BringToFront(); y += timesheetDetailListView.Height; } this.AutoScroll = true; this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; }
/// <summary> /// If the MonthlyTimesheet switched or changed, the timesheets ListView must change to /// reflect the MonthlyTimesheet. /// </summary> /// <param name="selectedIndex">The index of the ListViewItem associated with the Timesheet that should be selected.</param> private void MonthlyTimesheetChangedProcessing(int selectedIndex) { // Create a new MonthlyTimesheets object to use... m_monthlyTimesheets = new MonthlyTimesheets(new TimesheetMonth(m_calendar.SelectionStart)); m_timesheetsListView.Items.Clear(); // Invoice number... m_invoiceNumbers.Items.Clear(); m_invoiceNumbers.SelectedIndexChanged -= new EventHandler(this.OnInvoiceNumbersSelectedIndexChanged); if (m_monthlyTimesheets == null || m_monthlyTimesheets.Count == 0) { m_invoiceNumbers.Enabled = false; } else { // Set up our Invoice number DropDown... m_invoiceNumbers.Enabled = true; int invoiceNumber = m_monthlyTimesheets.InvoiceNumber.GetValueOrDefault(1); for (int i = 1; i <= 1000; i++) { int index = m_invoiceNumbers.Items.Add(i); if (i == invoiceNumber) { m_invoiceNumbers.SelectedIndex = index; } } m_invoiceNumbers.SelectedIndexChanged += new EventHandler(this.OnInvoiceNumbersSelectedIndexChanged); // Add the Timesheet information to the ListView for Timesheets... foreach (Timesheet timesheet in m_monthlyTimesheets) { InsertTimesheetListViewItem(timesheet); } // Add the total row... InsertTimesheetTotalsListViewItem(); } ResizeTimesheetsListViewColumns(); // WARNING: The call to LoadTimesheetsDetail() must take place BEFORE the m_timesheetsListView // selected index is changed in the below code. Changing the m_timesheetsListView selected prior to // calling LoadTimesheetsDetail() causes the SelectedIndexChanged event for m_timesheetsListView // which calls TimesheetDetailContainer.ScrollInToView(...), which then crashes because the // TimesheetDetailContainer has not been update with the correct Timesheet Detail objects. LoadTimesheetsDetail(); int itemCount = m_timesheetsListView.Items.Count; if (itemCount > 0) { // This will force the timesheet detail list view to populate with the timesheet detail just selected... m_timesheetsListView.Items[(selectedIndex < itemCount) ? selectedIndex : 0].Selected = true; } // Calculations... AddMonthlyTimesheetCalculations(); }
public TimesheetCalculations(MonthlyTimesheets monthlyTimesheets) { InitializeComponent(); this.MonthlyTimesheets = monthlyTimesheets; m_collapseButton.Click += new EventHandler( delegate(object sender, EventArgs e) { bool expanded = Convert.ToBoolean(this.Tag); this.Height = expanded ? this.CollapseHeight : this.ExpandHeight; m_collapseButton.Image = expanded ? BillingUtils.Properties.Resources.Expand : BillingUtils.Properties.Resources.Collapse; this.Tag = !expanded; } ); m_collapseButton.Image = BillingUtils.Properties.Resources.Collapse; this.Tag = true; // Expanded SetColors(); Recalculate(); }
protected void OnGenerateFilesClick(object sender, EventArgs e) { m_folderBrowserDialog.SelectedPath = Configuration.Instance.MiscellaneousConfiguration.DefaultSaveFolder; m_folderBrowserDialog.Description = "Save Generated Files To..."; if (m_folderBrowserDialog.ShowDialog() == DialogResult.OK) { MonthlyTimesheets monthlyTimesheets = m_monthlyTimesheets; string outputFolder = m_folderBrowserDialog.SelectedPath; FileGenerateConfirmationDialog fileGenerateConfirmationDialog = new FileGenerateConfirmationDialog(monthlyTimesheets, outputFolder); if (fileGenerateConfirmationDialog.ShowDialog(this) == DialogResult.Cancel) { return; } else { InvoiceNumberComfirmationDialog invoiceNumberComfirmationDialog = new InvoiceNumberComfirmationDialog(monthlyTimesheets, false /* Handle the save below*/); if (invoiceNumberComfirmationDialog.ShowDialog(this) == DialogResult.Cancel) { return; } this.Enabled = false; // Save whatever changes were made first. MonthlyTimesheetSaveProcessing(); // Generate any unsent Timesheets... foreach (Timesheet timesheet in monthlyTimesheets.UnSentTimesheets) { TimesheetGenerator timesheetGenerator = new TimesheetGenerator(timesheet, outputFolder); if (timesheetGenerator.Generate(false)) { } timesheetGenerator.Save(); } // Generate our invoice... InvoiceGenerator invoiceGenerator = new InvoiceGenerator(monthlyTimesheets, outputFolder); if (invoiceGenerator.Generate(false)) { } invoiceGenerator.Save(); TimesheetGenerator.QuitExcel(); this.Enabled = true; } } }
public InvoiceNumberComfirmationDialog(MonthlyTimesheets monthlyTimesheets, bool saveOnOK) { InitializeComponent(); this.SaveOnOK = saveOnOK; this.MonthlyTimesheets = monthlyTimesheets; int invoiceNumber = this.MonthlyTimesheets.InvoiceNumber.GetValueOrDefault(0); this.OriginalInvoiceNumber = invoiceNumber; this.SelectedInvoiceNumber = invoiceNumber; InitializeForm(); InitializeInvoiceNumber(); }
public FileGenerateConfirmationDialog(MonthlyTimesheets monthlyTimesheets, string outputFolder) { InitializeComponent(); InitializeForm(); InitializeTimesheetsListView(); this.MonthlyTimesheets = monthlyTimesheets; this.OutputFolder = outputFolder; foreach (Timesheet timesheet in this.MonthlyTimesheets) { InsertTimesheetListViewItem(timesheet); } ResizeTimesheetsListViewColumns(); }
// Construction/Initialization // -------------------------------------------------------------------------- #region Construction/Initialization public FileGenerateConfirmationDialog(MonthlyTimesheets monthlyTimesheets, string outputFolder) { InitializeComponent(); InitializeForm(); InitializeTimesheetsListView(); this.MonthlyTimesheets = monthlyTimesheets; this.OutputFolder = outputFolder; foreach (Timesheet timesheet in this.MonthlyTimesheets) { InsertTimesheetListViewItem(timesheet); } ResizeTimesheetsListViewColumns(); }
public MonthlyTimesheetChangedEventArgs(MonthlyTimesheets monthlyTimesheets) { this.MonthlyTimesheets = monthlyTimesheets; }
public InvoiceGenerator(MonthlyTimesheets monthlyTimeSheets, string outputPath) : base(Configuration.Configuration.Instance.InvoiceConfiguration.InvoiceTemplate, Path.Combine(new string[] { outputPath, monthlyTimeSheets.GetFileName() })) { this.MonthlyTimesheets = monthlyTimeSheets; }
public virtual void UpdateMonthlyTimesheets(MonthlyTimesheets monthlyTimesheets) { this.Clear(); // Note: Must populate property MonthlyTimesheets AFTER Clear() is called because // Clear() nulls out MonthlyTimesheets. this.MonthlyTimesheets = monthlyTimesheets; int y = 0; foreach (Timesheet timesheet in this.MonthlyTimesheets) { TimesheetDetailListView timesheetDetailListView = new TimesheetDetailListView(timesheet); timesheetDetailListView.TimesheetDetailUpdatingEvent += new EventHandler<TimesheetDetailListView.TimesheetDetailEventArgs>(this.OnTimesheetUpdating); timesheetDetailListView.TimesheetDetailUpdatedEvent += new EventHandler<TimesheetDetailListView.TimesheetDetailEventArgs>(this.OnTimesheetUpdated); Controls.Add(timesheetDetailListView); timesheetDetailListView.Dock = DockStyle.Top; timesheetDetailListView.Location = new Point(0, y + 1); timesheetDetailListView.BringToFront(); y += timesheetDetailListView.Height; } this.AutoScroll = true; this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; }
public void Recalculate() { MonthlyTimesheets monthlyTimesheets = this.MonthlyTimesheets; int executiveOrderCount = monthlyTimesheets.GetDayTypeCount(DayType.ExecutiveOrder); int flexDayCount = monthlyTimesheets.GetDayTypeCount(DayType.FlexDay); int halfDayCount = monthlyTimesheets.GetDayTypeCount(DayType.HalfDay); int NACount = monthlyTimesheets.GetDayTypeCount(DayType.NA); int otherCount = monthlyTimesheets.GetDayTypeCount(DayType.Other); int personalDayCount = monthlyTimesheets.GetDayTypeCount(DayType.PersonalDay); int sickDayCount = monthlyTimesheets.GetDayTypeCount(DayType.SickDay); int vacationDayCount = monthlyTimesheets.GetDayTypeCount(DayType.VacationDay); int workDayCount = monthlyTimesheets.GetDayTypeCount(DayType.WorkDay); int weekendCount = monthlyTimesheets.GetDayTypeCount(DayType.Weekend); // Real work days... int realWorkDayCount = monthlyTimesheets.GetWeekdayCount() - executiveOrderCount; m_realWorkDays.Text = realWorkDayCount.ToString(); // Work days... m_workDays.Text = workDayCount.ToString(); // Max billable hours decimal maxBillableHours = (realWorkDayCount * Configuration.Instance.MiscellaneousConfiguration.DefaultMaxBillableHoursPerWorkDay); m_maxBillableHours.Text = maxBillableHours.ToString(Constants.HoursFormatString); // Weekends... m_weekends.Text = weekendCount.ToString(); // Executive orders... m_executiveOrders.Text = executiveOrderCount.ToString(); // Flex days... m_flexDays.Text = flexDayCount.ToString(); // Vacation days... m_vacationDays.Text = vacationDayCount.ToString(); // Half days... m_halfDays.Text = halfDayCount.ToString(); // Sick days... m_sickDays.Text = sickDayCount.ToString(); // "Other" days... m_otherDays.Text = otherCount.ToString(); // N/A? // Billable hours... decimal billableHours = monthlyTimesheets.GetBillableHours(); m_billableHours.Text = billableHours.ToString(Constants.HoursFormatString); // Check... decimal hoursWorkedCheckDifference = (billableHours - maxBillableHours); m_hoursWorkedCheckDifference.Tag = hoursWorkedCheckDifference; m_hoursWorkedCheckDifference.Text = (hoursWorkedCheckDifference > 0.00m) ? "+" : ""; m_hoursWorkedCheckDifference.Text += hoursWorkedCheckDifference.ToString(); bool isOver = hoursWorkedCheckDifference > 0.00m; m_hoursWorkedCheckDifference.ForeColor = isOver ? Color.DarkRed : Color.DarkGreen; m_billableHoursCheckLabel.ForeColor = isOver ? Color.DarkRed : Color.DarkGreen; m_billableHoursCheckInformation.ForeColor = isOver ? Color.DarkRed : Color.DarkGreen; m_hoursWorkedCheckDifferenceLabel.ForeColor = isOver ? Color.DarkRed : Color.DarkGreen; m_billableHoursCheckPictureBox.BackColor = isOver ? Color.DarkRed : Color.DarkGreen; DoBillableHoursCheck(); }
/// <summary> /// Clears all Timesheet Detail from the control. /// </summary> public virtual void Clear() { this.MonthlyTimesheets = null; this.Controls.Clear(); }
protected virtual void Add(TimesheetMonth timesheetMonth) { MonthlyTimesheets monthlyTimesheets = new MonthlyTimesheets(timesheetMonth); this.MonthlyTimesheets.Add(monthlyTimesheets); }