/// <summary> /// Populate the line item based on the reference to the time entry data /// </summary> public void PopulateLineItem(TimeSheetDS.TimeEntryRow row) { // store a local reference to the data _timeentryrow = row; // bind to the project time entry data _project.DataSource = _projectdata.Project; _project.DisplayMember = "ProjectName"; _project.ValueMember = "ProjectID"; Binding bind = new Binding("SelectedValue", _timeentryrow, "ProjectID"); _project.DataBindings.Add(bind); // bind to the worktype entry data _worktype.DataSource = _worktypedata.WorkType; _worktype.DisplayMember = "WorkTypeName"; _worktype.ValueMember = "WorkTypeID"; bind = new Binding("SelectedValue", _timeentryrow, "WorkTypeID"); _worktype.DataBindings.Add(bind); // bind the time entry data to the days of the week sun.DataBindings.Add("Text", _timeentryrow, "Sunday"); sat.DataBindings.Add("Text", _timeentryrow, "Saturday"); fri.DataBindings.Add("Text", _timeentryrow, "Friday"); thu.DataBindings.Add("Text", _timeentryrow, "Thursday"); wed.DataBindings.Add("Text", _timeentryrow, "Wednesday"); tue.DataBindings.Add("Text", _timeentryrow, "Tuesday"); mon.DataBindings.Add("Text", _timeentryrow, "Monday"); // update the display with the appropriate project item if (_timeentryrow.ProjectID != -1) { _project.SelectedIndex = _project.FindStringExact(_projectdata.Project.FindByProjectID(_timeentryrow.ProjectID).RefJobNum); } // update the work type with the appropriate item if (_timeentryrow.WorkTypeID != -1) { _worktype.SelectedIndex = _worktype.FindStringExact(_worktypedata.WorkType.FindByWorkTypeID(_timeentryrow.WorkTypeID).WorkTypeName); } // upate the client name //if (_timeentryrow.ClientID != -1) client.Text = _clientdata.Client.FindByClientID(_timeentryrow.ClientID).ClientName; // update the total lbl_total.Text = WeekTotal().ToString(); }
/// <summary> /// Add a line item entry to the Time Entry Panel /// Note: only 25 rows are possible - a UI error will be thrown if more than 25 are added /// </summary> public void AddLineItem() { if (m_itemcursor == LINE_ITEM_MAX) { MessageBox.Show(getStringResource("17")); } else { // get a reference to the timesheet table that we are working with TimeSheetDS.TimeSheetDataTable tstable = (TimeSheetDS.TimeSheetDataTable)_timesheetrow.Table; // create a new time entry row TimeSheetDS.TimeEntryRow newrow = ((TimeSheetDS.TimeEntryDataTable)tstable.ChildRelations[0].ChildTable).NewTimeEntryRow(); // associate the timesheet id to the entry row newrow.TID = _timesheetrow.TID; // then add the row to the table TimeSheetDS.TimeEntryDataTable timeentrytb = (TimeSheetDS.TimeEntryDataTable)((TimeSheetDS.TimeSheetDataTable)_timesheetrow.Table).ChildRelations[0].ChildTable; timeentrytb.AddTimeEntryRow(newrow); addRowToPanel(newrow); } }
/// <summary> /// Add a row to the line items panel based on a timesheet.timeentry row /// </summary> /// <param name="row"></param> private void AddRowToPanel(TimeSheetDS.TimeEntryRow row) { // check to see we haven't exceeded the limit for rows if (m_itemcursor == LINE_ITEM_MAX) { MessageBox.Show(getStringResource("17")); } else { // build the ui object AP_LineItemPanel li = new AP_LineItemPanel(); // and update hte current user interface m_lineitems[m_itemcursor++] = li; li.Location = new Point(x_gutter, y_cursor); // add it to the panel this.Controls.Add(li); y_cursor += y_separation; // declare the event handler for when input is added in the line item entry li.PopulateLineItem(row); } }
/// <summary> /// Add a row to the line items panel based on a timesheet.timeentry row /// </summary> /// <param name="row"></param> private void addRowToPanel(TimeSheetDS.TimeEntryRow row) { // check to see we haven't exceeded the limit for rows if (m_itemcursor == LINE_ITEM_MAX) { MessageBox.Show(getStringResource("17")); } else { // build the ui object LineItem li = new LineItem(); // and update hte current user interface m_lineitems[m_itemcursor++] = li; li.Location = new Point(x_gutter, this.AutoScrollPosition.Y + y_cursor); // add it to the panel this.Controls.Add(li); y_cursor += y_separation; // declare the event handler for when input is added in the line item entry li.onLineItemRowTotalChange += new LineItem.LineItemRowTotalChangedDelegate(LineItemTotalUpdated); li.onLineItemRemove += new LineItem.LineItemRemoveDelegate(LineItemRemoved); li.PopulateLineItem(row); } }