private void AddEntryActivity(int userId, int projectId, int categoryId, DateTime date, string description, decimal hours) { BusinessLogicLayer.TimeEntry te = new BusinessLogicLayer.TimeEntry(0, userId, projectId, categoryId, date, ITSecurity.CleanStringRegex(description), hours ); te.Save(); }
//******************************************************* // // TimeEntryGrid_OnUpdate server event handler on this page is used to // update the changes made from in-line-editing. // //******************************************************* protected void TimeEntryGrid_OnUpdate(Object sender, DataGridCommandEventArgs e) { DataGridItem item = TimeEntryGrid.Items[TimeEntryGrid.EditItemIndex]; RequiredFieldValidator required = (RequiredFieldValidator)item.FindControl("RequiredFieldValidatorGridHours"); CompareValidator comparer = (CompareValidator)item.FindControl("CompareValidatorGridHours"); required.Validate(); comparer.Validate(); // Check for validation, if all valid, update the object to data entered and save it. if (required.IsValid && comparer.IsValid) { int entryLogID; int userID; int projectID; int categoryID; DateTime taskDate; string description; decimal duration; BusinessLogicLayer.TimeEntry te = null; // Fill in properties for TimeEntry object. entryLogID = Convert.ToInt32(TimeEntryGrid.DataKeys[(int)e.Item.ItemIndex]); userID = Convert.ToInt32(UserList.SelectedItem.Value); projectID = Convert.ToInt32(((DropDownList)e.Item.FindControl("EntryProjects")).SelectedItem.Value); categoryID = Convert.ToInt32(((DropDownList)e.Item.FindControl("EntryCategories")).SelectedItem.Value); taskDate = Convert.ToDateTime(((DropDownList)e.Item.FindControl("EntryDays")).SelectedItem.Value); description = ITSecurity.CleanStringRegex(((TextBox)e.Item.FindControl("EntryDescription")).Text); duration = Convert.ToDecimal(((TextBox)e.Item.FindControl("EntryHours")).Text); // Save the TimeEntry object. te = new BusinessLogicLayer.TimeEntry(entryLogID, userID, projectID, categoryID, taskDate, description, duration); te.Save(); // Quit in-line-editing mode. TimeEntryGrid.EditItemIndex = -1; BindTimeSheet(_user.UserID, Convert.ToInt32(UserList.SelectedItem.Value), _weekStartingDate, _weekEndingDate); } }
//******************************************************* // // AddEntry_Click server event handler on this page is used to // saves a time entry and adds it to the system. // //******************************************************* protected void AddEntry_Click(object sender, System.EventArgs e) { // check validation. Requiredfieldvalidator1.Validate(); RequiredFieldValidator2.Validate(); RangeValidator1.Validate(); CompareValidator1.Validate(); // proceeds if data is valid then create an obejct and save it. if (Requiredfieldvalidator1.IsValid && RequiredFieldValidator2.IsValid && CompareValidator1.IsValid && RangeValidator1.IsValid) { BusinessLogicLayer.TimeEntry te = new BusinessLogicLayer.TimeEntry(0, Convert.ToInt32(UserList.SelectedItem.Value), Convert.ToInt32(ProjectList.SelectedItem.Value), Convert.ToInt32(CategoryList.SelectedItem.Value), Convert.ToDateTime(Days.SelectedItem.Value), ITSecurity.CleanStringRegex(Description.Text), Convert.ToDecimal(Hours.Text)); te.Save(); ClearEntryFields(); } }