public List <Timesheet> Report(int empId) { //returns a list of timesheets based on current EmpId table List <Timesheet> lst = new List <Timesheet>(); SqlConnection conn = new SqlConnection(); conn.ConnectionString = DataHelper.GetConnectionString(); conn.Open(); using (conn) { SqlCommand comm = new SqlCommand("sp_Select_EmpID_Show_Hours", conn); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add(new SqlParameter("@empId", empId)); SqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { Timesheet tim = new Timesheet(); tim.EmpId = empId; tim.WorkDate = Convert.ToDateTime(reader.GetDateTime(2)); tim.Hours = Convert.ToDouble(reader.GetDecimal(3)); lst.Add(tim); } return(lst); } }
/// <summary> /// This member creates ListViewItems for Timsheets. /// </summary> /// <param name="timesheet">The Timesheet from which the ListViewItems will be created.</param> /// <returns>A ListViewItem object.</returns> private ListViewItem CreateTimesheetListViewItem(Timesheet timesheet) { ListViewItem listViewItem = new ListViewItem(timesheet.GetFileName()); listViewItem.ImageIndex = timesheet.TimesheetSent ? (int)Timesheet.ImageListIndexes.Locked : -1; listViewItem.SubItems.Add(timesheet.StartDate.Date.ToShortDateString()); listViewItem.SubItems.Add(timesheet.EndDate.Date.ToShortDateString()); listViewItem.SubItems.Add(timesheet.GetBillableHours().ToString()); listViewItem.SubItems.Add(timesheet.GetFormattedRatesPerHour()); listViewItem.SubItems.Add(timesheet.GetFormattedInvoiceAmount()); string action = string.Empty; if (timesheet.TimesheetSent) { action = "No Action"; } else if (File.Exists(Path.Combine(new string[] { this.OutputFolder, timesheet.GetFileName() }))) { action = "Overwrite"; listViewItem.ForeColor = Color.Red; } else { action = "Create"; } listViewItem.SubItems.Add(action); listViewItem.Tag = timesheet; return listViewItem; }
protected void OnTimesheetSentClick(object sender, EventArgs e) { if (m_timesheetsListView.SelectedItems.Count > 0) { ListViewItem listViewItem = m_timesheetsListView.SelectedItems[0]; if (listViewItem.Tag is Timesheet) { // If there is a selected timesheet, determine if the "Timesheet Sent" check is checked // or not. If the check is different from the original value (e.g. if it changed), we // need to update the timesheet and the UI. ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)m_timesheetContextMenu.Items[0]; bool timesheetSent = toolStripMenuItem.Checked; Timesheet timesheet = (Timesheet)listViewItem.Tag; if (timesheet.TimesheetSent != timesheetSent) { m_apply.Enabled = true; timesheet.TimesheetSent = timesheetSent; UpdateTimesheetListViewItem(timesheet); m_detailContainer.Controls.OfType <TimesheetDetailContainer>().First().UpdateTimesheet(timesheet); } } } }
public async Task <SingleTimesheetDto> InsertTimesheet(TimesheetCreateInputDto timesheetCreateInputDto) { var result = new SingleTimesheetDto(); try { var timesheet = new Timesheet() { Date = timesheetCreateInputDto.Date, HoursWorked = timesheetCreateInputDto.HoursWorked, DateReported = timesheetCreateInputDto.DateReported, ResourceId = timesheetCreateInputDto.ResourceId, }; _context.Timesheet.Add(timesheet); await _context.SaveChangesAsync(); result = new SingleTimesheetDto() { Id = timesheet.Id, Date = timesheetCreateInputDto.Date, HoursWorked = timesheetCreateInputDto.HoursWorked, DateReported = timesheetCreateInputDto.DateReported, ResourceId = timesheetCreateInputDto.ResourceId, }; return(result); } catch (Exception ex) { throw ex; } }
public TimesheetViewModel(Timesheet ts) { this.TimesheetId = ts.TimesheetId; this.VersionNumber = ts.VersionNumber; this.EmployeeId = ts.EmployeeId; this.WeekNumber = ts.WeekNumber; this.Status = ts.Status.ToString(); this.WeekNumber = WeekNumber; this.WeekEndingIn = WeekEndingIn; List <TimesheetRowViewModel> tsRowModelList = new List <TimesheetRowViewModel>(); try { foreach (TimesheetRow tsRow in ts.TimesheetRows) { tsRowModelList.Add(new TimesheetRowViewModel(tsRow)); } } catch (Exception e) { Debug.WriteLine("catching and resuming..."); } //doesnt work now... //foreach (TimesheetRow tsRow in ts.TimesheetRows) //{ // tsRowModelList.Add(new TimesheetRowViewModel(tsRow)); //} this.TimesheetRows = tsRowModelList; //rename timesheetRows to timesheetRowViewModels this.Comment = ts.Comment; }
private void InitializeTimesheetContextMenuStrip() { m_timesheetsListView.ContextMenuStrip = m_timesheetContextMenu; m_timesheetContextMenu.ShowCheckMargin = true; m_timesheetContextMenu.ShowImageMargin = false; // Add our context menu item... ToolStripMenuItem toolStripMenuItem0 = new ToolStripMenuItem("Timesheet Sent"); toolStripMenuItem0.Click += new EventHandler(this.OnTimesheetSentClick); toolStripMenuItem0.CheckOnClick = true; m_timesheetContextMenu.Items.AddRange(new ToolStripItem[] { toolStripMenuItem0 }); // Context menu Opening event processing... m_timesheetContextMenu.Opening += new CancelEventHandler( delegate(object sender, CancelEventArgs e) { ListViewItem listViewItem = m_timesheetsListView.SelectedItems[0]; if (!(listViewItem.Tag is Timesheet)) { e.Cancel = true; } else { Timesheet timesheet = (Timesheet)listViewItem.Tag; ToolStripMenuItem toolStripMenuItem = (ToolStripMenuItem)m_timesheetContextMenu.Items[0]; toolStripMenuItem.Checked = timesheet.TimesheetSent; e.Cancel = false; } } ); }
// Construction/Initialization // -------------------------------------------------------------------------- #region Construction/Initialization public TimesheetDetailListView(Timesheet timesheet) { InitializeComponent(); this.Timesheet = timesheet; InitializeListView(); // Scroll options... this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; // Header... if (timesheet.IsSplitTimesheet) { m_header.Text = string.Format("Week {0} ({1} through {2}, {3} of 2)", timesheet.WeekNumber, Dates.GetMMDDYYYY(timesheet.StartDate.Date), Dates.GetMMDDYYYY(timesheet.EndDate.Date), timesheet.SplitIndex ); } else { m_header.Text = string.Format("Week {0} ({1} through {2})", timesheet.WeekNumber, Dates.GetMMDDYYYY(timesheet.StartDate.Date), Dates.GetMMDDYYYY(timesheet.EndDate.Date) ); } // Background color... if (this.Timesheet.IsSplitTimesheet) { this.BackColor = TimesheetDetailListView.SplitColor; } else { this.BackColor = TimesheetDetailListView.GetDefaultTimesheetBackColor(this.Timesheet); } }
private bool GetTimesheetListViewItem(Timesheet timesheet, out ListViewItem timesheetListViewItem, bool createIfNotExists) { int itemCount = m_timesheetsListView.Items.Count; if (itemCount == 0) { timesheetListViewItem = createIfNotExists ? CreateTimesheetListViewItem(timesheet) : null; return(false); } else { foreach (ListViewItem listViewItem in m_timesheetsListView.Items) { if (listViewItem.Tag is Timesheet) { Timesheet timeheetToCheck = (Timesheet)listViewItem.Tag; if (timeheetToCheck.Equals(timesheet)) { timesheetListViewItem = listViewItem; return(true); } } } // If we get here there is no ListViewItem associated with the timesheet in the ListView... timesheetListViewItem = createIfNotExists ? CreateTimesheetListViewItem(timesheet) : null; return(false); } }
public async Task <ActionResult <Timesheet> > PostTimesheet(Timesheet timesheet) { _context.Timesheets.Add(timesheet); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTimesheet", new { id = timesheet.TimesheetId }, timesheet)); }
public async Task <ActionResult <TimesheetViewModel> > GetTimesheet(int id, int versionId) { Debug.WriteLine("inside multi param get.. version id is: " + versionId); Timesheet ts = await _timesheetRepository.Get(id, versionId); return(Ok(new TimesheetViewModel(ts))); }
public int Create(Timesheet timesheet) { _context.Timesheets.Add(timesheet); _context.SaveChanges(); return(timesheet.IdTimesheet); }
public async Task <Timesheet> GetFullTimesheetDetails(Timesheet ts) { Employee emp = await _employeeRepository.Get(ts.EmployeeId); emp.Timesheets = null; ts.Employee = emp; var timesheetRows = (await _timesheetRowRepository.GetAll()) .Where(t => t.TimesheetId == ts.TimesheetId && t.TimesheetVersionNumber == ts.VersionNumber); if (ts.TimesheetRows != null) { foreach (var tsTimesheetRow in ts.TimesheetRows) { tsTimesheetRow.Timesheet = null; WorkPackage wp = await _workPackageRepository.Get(tsTimesheetRow.WorkPackageId); Project proj = await _projectRepository.Get(wp.ProjectId); TimesheetRowViewModel tsRowViewModel = new TimesheetRowViewModel(tsTimesheetRow, proj, wp.WorkPackageCode); } } TimesheetViewModel tsViewModel = new TimesheetViewModel(ts); ts.TimesheetRows = timesheetRows.ToList(); return(ts); }
public Result UpdateTimesheetRecordIdByEmployeeAndWeekStartDate(TimesheetByEmployeeAndStartDateAndStatusViewModel objTimesheetRecord, string siteUrl) { Result res = new Result(); try { List <TimesheetWithWorkItems> objTimesheetList = GetTimesheetsByEmployeeAndWeekStartDate(objTimesheetRecord, siteUrl); foreach (var _recordIDObj in objTimesheetList) { Timesheet objTimesheet = new Timesheet(); objTimesheet.ID = _recordIDObj.ID; objTimesheet.RecordID = objTimesheetRecord.RecordID; UpdateTimesheet(objTimesheet, siteUrl); } res.StatusCode = StatusCode.Success; res.Message = Messages.MsgSuccessUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
public IActionResult UpdateTimesheet(Guid id, [FromBody] Timesheet timesheet) { try { if (timesheet == null) { return(BadRequest("User object is null")); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } var dbTimesheet = _repository.Timesheet.GetTimesheetById(id); if (dbTimesheet.IsEmptyObject()) { return(NotFound()); } timesheet.Id = id; _repository.Timesheet.UpdateTimesheet(dbTimesheet, timesheet); _repository.Save(); return(NoContent()); } catch (Exception ex) { Console.WriteLine($"Something went wrong inside UpdateTimesheet action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }
public ActionResult Create([Bind(Include = "Id,UserId,Time,Type")] Activity activity) { if (ModelState.IsValid) { if (activity.Type == "out") { Activity lastActivity = db.Activities.Where(s => s.UserId == activity.UserId).OrderByDescending(s => s.Time).First(); if (lastActivity.Type == "in") { double hours = (activity.Time - lastActivity.Time).TotalHours; var timesheet = new Timesheet { UserId = activity.UserId, Date = DateTime.Now, Hours = Math.Round(hours, 2), Type = "workingday" }; db.Timesheets.Add(timesheet); } } db.Activities.Add(activity); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Email", activity.UserId); if (Session["Role"] != null && Session["Role"].ToString() != "admin") { ViewBag.UserId = Session["UserId"].ToString(); } return(View(activity)); }
public async Task <IActionResult> Edit(int id, [Bind("Mon,Tue,Wed,Thur,Fri,Sat,Sun,ID,Status,HoursWorked")] Timesheet timesheet) { if (id != timesheet.ID) { return(NotFound()); } var currentUser = await _userManager.GetUserAsync(User); if (ModelState.IsValid) { try { timesheet.OwnerId = currentUser.Id; timesheet.HoursWorked = timesheet.Mon + timesheet.Tue + timesheet.Wed + timesheet.Thur + timesheet.Fri + timesheet.Sat + timesheet.Sun; _context.Update(timesheet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(timesheet.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(timesheet)); }
// /* Locks all timesheets that ended more than two days ago. If there was a holiday during * the previous pay period, lockDate will have an extra day added to it. * (note: called from /ScheduledJobs/TarsScheduledJobs every Tuesday and Wednesday at 12am) */ public void lockTimesheets() { DateTime refDate = DateTime.Now.Date; DateTime lockDate = DateTime.Now.Date; Timesheet tmpTimesheet = new Timesheet(); List <Timesheet> tsList = new List <Timesheet>(); // If there was a holiday, allow three days after periodEnd before locking if (isHolidayWeek(refDate.AddDays(-7))) { lockDate = refDate.AddDays(-1); } else { lockDate = refDate.AddDays(-2); } var searchTimesheets = from t in TimesheetDB.TimesheetList where t.locked != true where t.periodEnd < lockDate select t; foreach (var item in searchTimesheets) { tmpTimesheet = item; tmpTimesheet.locked = true; tsList.Add(tmpTimesheet); } foreach (var item in tsList) { //save changes in database TimesheetDB.Entry(item).State = System.Data.EntityState.Modified; TimesheetDB.SaveChanges(); } }
/// <summary> /// Asynchronously Create Timesheets. /// </summary> /// <remarks> /// Add a single timesheet to your company. /// </remarks> /// <param name="timesheet"> /// The <see cref="Timesheet"/> object to be created. /// </param> /// <returns> /// The <see cref="Timesheet"/> object that was created, along with /// an output instance of the <see cref="ResultsMeta"/> class containing additional data. /// </returns> public async Task <(Timesheet, ResultsMeta)> CreateTimesheetAsync( Timesheet timesheet) { (IList <Timesheet> timesheets, ResultsMeta resultsMeta) = await CreateTimesheetsAsync(new[] { timesheet }, default).ConfigureAwait(false); return(timesheets.FirstOrDefault(), resultsMeta); }
public HttpResponseMessage EditTimeSheetRecord(Timesheet sheetdetails) { HttpResponseMessage response = null; try { if (sheetdetails != null) { if (TimeSheetRepo.GetSheetById(sheetdetails.id) != null) { TimeSheetRepo.UpdateTimeSheetRecord(sheetdetails); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", "TimeSheet updated Succesfully")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_901", "Invalid", "TimeSheet doesnot exists!")); } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Input", "Please check input Json")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
// /* Retrieves the Timesheet object for the specified employee and reference date, * changes "locked", "approved", and "submitted" fields to FALSE, and saves the * changes in the database. */ public void adminUnlockTimesheet(string username, DateTime refDate) { Authentication auth = new Authentication(); if (auth.isAdmin(this) || Authentication.DEBUG_bypassAuth) { Timesheet tmpTs = new Timesheet(); var searchTs = from t in TimesheetDB.TimesheetList where (t.worker.CompareTo(username) == 0) where t.periodStart <= refDate where t.periodEnd >= refDate select t; foreach (var item in searchTs) { tmpTs = item; tmpTs.locked = false; tmpTs.approved = false; tmpTs.submitted = false; } //save changes in database TimesheetDB.Entry(tmpTs).State = System.Data.EntityState.Modified; TimesheetDB.SaveChanges(); } return; }
/// <summary> /// Clock a user into a jobcode, on a timesheet. /// </summary> /// <returns>A tuple of the user and timesheet.</returns> private (User, Timesheet) ClockAUserIntoATimesheet() { // Get the user id var userFilter = new UserFilter { UserNames = new[] { "bobsmith" } }; IList <User> users = this.apiClient.GetUsers(userFilter).Item1; User user = users.First(); // Now get the jobcode id. var jobcodeFilter = new JobcodeFilter { Name = "TestJobcode3" }; IList <Jobcode> jobcodes = this.apiClient.GetJobcodes(jobcodeFilter).Item1; Jobcode jobcode = jobcodes.First(); // Now clock the user into the jobcode. Note that active (i.e. "on-the-clock") timesheets // are created with an End time of DateTimeOffset.MinValue. The dedicated constructor // we're using here does that for you automatically. var timesheetToCreate = new Timesheet(user.Id, jobcode.Id, DateTimeOffset.Now); var createdTimesheet = this.apiClient.CreateTimesheet(timesheetToCreate).Item1; return(user, createdTimesheet); }
public async Task <IActionResult> Edit(int id, [Bind("Id,MinutesWorked,StaffId,ClientId,LocationId")] Timesheet timesheet) { if (id != timesheet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(timesheet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(timesheet.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "BillingAddress", timesheet.ClientId); ViewData["LocationId"] = new SelectList(_context.Locations, "Id", "Address", timesheet.LocationId); ViewData["StaffId"] = new SelectList(_context.Staff, "Id", "Email", timesheet.StaffId); return(View(timesheet)); }
public async Task <IActionResult> PutTimesheet(int id, Timesheet timesheet) { if (id != timesheet.TimesheetId) { return(BadRequest()); } _context.Entry(timesheet).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTimesheet([FromRoute] long id, [FromBody] Timesheet timesheet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != timesheet.Id) { return(BadRequest()); } _context.Entry(timesheet).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Timesheet> CreateTimesheet(Timesheet timesheet) { const string SQL = @"INSERT INTO Timesheet (employeeId, workDate, createdDate, createdBy, modifiedDate, modifiedBy) VALUES (@employeeId, @workDate, @createdDate, @createdBy, @modifiedDate, @modifiedBy); SELECT CAST (SCOPE_IDENTITY() as int)"; timesheet.CreatedBy = userContext.UserId; timesheet.ModifiedBy = userContext.UserId; timesheet.CreatedDate = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc); timesheet.ModifiedDate = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc); var timesheetId = await Insert <int>(SQL, new { employeeId = timesheet.EmployeeId, workDate = timesheet.WorkDate, createdBy = timesheet.CreatedBy, createdDate = timesheet.CreatedDate, modifiedBy = timesheet.ModifiedBy, modifiedDate = timesheet.ModifiedDate }); timesheet.TimesheetId = timesheetId; foreach (var tsEntry in timesheet.Entries) { tsEntry.TimesheetId = timesheetId; var tsEntrySaved = await CreateTimesheetEntry(tsEntry); tsEntry.TimesheetEntryId = tsEntrySaved.TimesheetEntryId; } return(timesheet); }
public async Task <IActionResult> PostTimesheet([FromBody] Timesheet timesheet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Timesheet.Add(timesheet); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TimesheetExists(timesheet.Id)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetTimesheet", new { id = timesheet.Id }, timesheet)); }
private string RegisterActivity(string id, string type) { var activity = new Activity { UserId = Convert.ToInt32(id), Time = DateTime.Now, Type = type }; if (activity.Type == "out") { Activity lastActivity = db.Activities.Where(s => s.UserId == activity.UserId).OrderByDescending(s => s.Time).First(); if (lastActivity.Type == "in") { double hours = (activity.Time - lastActivity.Time).TotalHours; if (Math.Round(hours, 2) == 0) { hours = 0.01; } var timesheet = new Timesheet { UserId = activity.UserId, Date = DateTime.Now, Hours = Math.Round(hours, 2), Type = "workingday" }; db.Timesheets.Add(timesheet); } } db.Activities.Add(activity); db.SaveChanges(); return(db.Users.Find(Convert.ToInt32(id))?.FirstName); }
public async Task <IActionResult> Edit(int id, [Bind("FirstName,LastName,MobileNumber,Email,Occupation,DescriptionOfYoursef,Username")] Timesheet timesheet) { if (id != timesheet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(timesheet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimesheetExists(timesheet.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(timesheet)); }
public int CreateTimesheet(Timesheet timesheet) { int returnValue = 0; try { var connectionString = ConfigurationManager.AppSettings["PayMe-Connectionstring"]; SqlConnection connection = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand("CreateTimesheet", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserID", timesheet.fkEmpId); cmd.Parameters.AddWithValue("@UserName", timesheet.CreatedBy); cmd.Parameters.AddWithValue("@ClientId", timesheet.fkClientId); cmd.Parameters.AddWithValue("@ProjectId", timesheet.fkProjectID); cmd.Parameters.AddWithValue("@TaskId", timesheet.fkTaskID); cmd.Parameters.AddWithValue("@CheckInDate", timesheet.CheckInDate); cmd.Parameters.AddWithValue("@CheckInDateTime", timesheet.CheckInDateTime); cmd.Parameters.AddWithValue("@CheckOutDateTime", timesheet.CheckOutDatetime); cmd.Parameters.AddWithValue("@Description", ""); cmd.Parameters.Add("@output", SqlDbType.Int).Direction = ParameterDirection.Output; connection.Open(); cmd.ExecuteNonQuery(); returnValue = Convert.ToInt32(cmd.Parameters["@output"].Value); connection.Close(); } catch (Exception ex) { throw new ApplicationException(ex.Message.ToString()); } return(returnValue); }
public Result UpdateTimesheetRecordId(List <SyncRecordID> objRecordIDs, string siteUrl) { Result res = new Result(); try { Timesheet objTimesheet = new Timesheet(); int recordsUpdatedCounter = 0; foreach (var _recordIDObj in objRecordIDs) { Result updateResult = new Result(); objTimesheet.ID = _recordIDObj.ID; objTimesheet.RecordID = _recordIDObj.RecordID; updateResult = UpdateTimesheet(objTimesheet, siteUrl); if (updateResult.StatusCode.Equals(1)) { recordsUpdatedCounter++; } } res.StatusCode = StatusCode.Success; res.Message = recordsUpdatedCounter + " " + Messages.MsgSuccessRecordsUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
public Result UpdateTimesheetSyncStatusByRecordID(List <SyncStatusByRecordID> objSyncStatus, string siteUrl) { Result res = new Result(); try { int recordsUpdatedCounter = 0; foreach (var _recordIDObj in objSyncStatus) { List <TimesheetWithWorkItems> objWorkItemList = GetTimesheetByRecordID(_recordIDObj.RecordID, siteUrl); foreach (var timesheetRecord in objWorkItemList) { Timesheet objTimesheetItem = new Timesheet(); Result updateResult = new Result(); objTimesheetItem.ID = timesheetRecord.ID; objTimesheetItem.IsSynced = _recordIDObj.IsSynced; updateResult = UpdateTimesheet(objTimesheetItem, siteUrl); if (updateResult.StatusCode.Equals(1)) { recordsUpdatedCounter++; } } } res.StatusCode = StatusCode.Success; res.Message = recordsUpdatedCounter + " " + Messages.MsgSuccessRecordsUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
public void IsChanged__ChangedProjectItemTimeEntryLoggedTimeObservableTimesheet_True() { var ts = new Timesheet(); var projectCode = new PickListItem(1, "pc1"); var taskCode = new PickListItem(1, "tc1"); var projectItem = new ProjectTaskTimesheetItem(projectCode, taskCode); for (int i = 0; i < 7; i++) { projectItem.TimeEntries[i].LoggedTime = TimeSpan.FromMinutes(1); } ts.ProjectTimeItems.Add(projectItem); for (int i = 0; i < 7; i++) { ts.RequiredHours[i] = TimeSpan.FromHours(7.5); } var timesheet = new ObservableTimesheet(ts); Assert.IsFalse(timesheet.IsChanged); timesheet.ProjectTimeItems[0].TimeEntries[6].LoggedTime = new TimeSpan(1, 0, 0); Assert.IsTrue(timesheet.IsChanged); }
/// <summary> /// Scrolls the Timesheet in to view. /// </summary> /// <param name="timesheet">The Timesheet to scroll in to view.</param> public void ScrollInToView(Timesheet timesheet, bool selectTimesheet) { this.AutoScroll = false; TimesheetDetailListView timesheetDetailListView = GetTimesheetDetailListView(timesheet); Point point = this.ScrollToControl(timesheetDetailListView); this.AutoScrollPosition = point; this.TopLevelControl.AutoScrollOffset = point; this.SetDisplayRectLocation(point.X, point.Y); this.AutoScroll = true; if (selectTimesheet) { this.SelectTimesheet(timesheet); } }
/// <summary> /// This function returns the DISTINCT Rates used by the given timesheet. /// </summary> /// <param name="timesheet">The Timesheet whose Rates are to be returned.</param> /// <returns>An Enumerable collection distinct Rates used by this Timesheet.</returns> public static IEnumerable<Rate> GetRates(Timesheet timesheet) { lock (m_syncRoot) { Configuration.Configuration config = Configuration.Configuration.Instance; IEnumerable<Rate> rates = config.RatesConfiguration.Rates; List<Rate> filteredRates = new List<Rate>(); for (int i = 0; i < timesheet.Dates.Count(); i++) { TimesheetDate timesheetDate = timesheet[i]; if (timesheetDate.IsValidDate) { filteredRates.Add(timesheetDate.Rate); } } return filteredRates.Distinct().OrderBy(p => p.EffectiveDate); } }
private bool GetTimesheetListViewItem(Timesheet timesheet, out ListViewItem timesheetListViewItem, bool createIfNotExists) { int itemCount = m_timesheetsListView.Items.Count; if (itemCount == 0) { timesheetListViewItem = createIfNotExists ? CreateTimesheetListViewItem(timesheet) : null; return false; } else { foreach (ListViewItem listViewItem in m_timesheetsListView.Items) { if (listViewItem.Tag is Timesheet) { Timesheet timeheetToCheck = (Timesheet)listViewItem.Tag; if (timeheetToCheck.Equals(timesheet)) { timesheetListViewItem = listViewItem; return true; } } } // If we get here there is no ListViewItem associated with the timesheet in the ListView... timesheetListViewItem = createIfNotExists ? CreateTimesheetListViewItem(timesheet) : null; return false; } }
/// <summary> /// This member creates ListViewItems for Timsheets. /// </summary> /// <param name="timesheet">The Timesheet from which the ListViewItems will be created.</param> /// <returns>A ListViewItem object.</returns> private ListViewItem CreateTimesheetListViewItem(Timesheet timesheet) { ListViewItem listViewItem = new ListViewItem(timesheet.GetFileName()); listViewItem.StateImageIndex = timesheet.TimesheetSent ? DefaultImageList.Instance.GetLockedIconIndex() : -1; listViewItem.ImageIndex = DefaultImageList.Instance.GetCalendarIconIndex(); if (timesheet.IsSplitTimesheet) { listViewItem.ForeColor = Color.Red; } listViewItem.SubItems.Add(Dates.GetMMDDYYYY(timesheet.StartDate.Date)); listViewItem.SubItems.Add(Dates.GetMMDDYYYY(timesheet.EndDate.Date)); listViewItem.SubItems.Add(timesheet.GetBillableHours().ToString()); listViewItem.SubItems.Add(timesheet.GetFormattedRatesPerHour()); listViewItem.SubItems.Add(timesheet.GetFormattedInvoiceAmount()); listViewItem.Tag = timesheet; return listViewItem; }
private void UpdateTimesheetListViewItem(Timesheet timesheet) { const string noExistsError = "UpdateTimesheetListViewItem() failed in an attempt " + "to update the Timesheet's ListItem in the ListView because it does not exist; " + "use InsertTimesheetListViewItem() instead."; ListViewItem listViewItem; if (!GetTimesheetListViewItem(timesheet, out listViewItem)) { throw new InvalidOperationException(noExistsError); } else { listViewItem.StateImageIndex = timesheet.TimesheetSent ? DefaultImageList.Instance.GetLockedIconIndex() : -1; listViewItem.ImageIndex = DefaultImageList.Instance.GetCalendarIconIndex(); listViewItem.SubItems[1].Text = Dates.GetMMDDYYYY(timesheet.StartDate.Date); listViewItem.SubItems[2].Text = Dates.GetMMDDYYYY(timesheet.EndDate.Date); listViewItem.SubItems[3].Text = timesheet.GetBillableHours().ToString(); listViewItem.SubItems[4].Text = timesheet.GetFormattedRatesPerHour(); listViewItem.SubItems[5].Text = timesheet.GetFormattedInvoiceAmount(); } }
private void InsertTimesheetListViewItem(Timesheet timesheet) { ListViewItem timesheetListViewItem = CreateTimesheetListViewItem(timesheet); m_timesheetsListView.Items.Add(timesheetListViewItem); }
public Task<Timesheet> UpdateAsync(Timesheet item) { return Timesheets.UpdateAsync(item); }
public Task<Timesheet> CreateAsync(Timesheet item) { return Timesheets.CreateAsync(item); }
public Timesheet Update(Timesheet item) { return Timesheets.Update(item); }
public Timesheet Create(Timesheet item) { return Timesheets.Create(item); }
private TimesheetDetailListView GetTimesheetDetailListView(Timesheet timesheet) { return this.Controls.OfType<TimesheetDetailListView>().Where(p => p.Timesheet.Equals(timesheet)).First(); }
/// <summary> /// Updates the Timesheet. /// </summary> /// <param name="timesheet">The Timesheet to be updated.</param> /// <remarks>Call this member when a Timesheet has been or needs to be updated so that the changes /// are reflected in the UI.</remarks> public void UpdateTimesheet(Timesheet timesheet) { TimesheetDetailListView timesheetDetailListView = GetTimesheetDetailListView(timesheet); timesheetDetailListView.UpdateTimesheet(); }
private IEnumerable<TimesheetDetailListView> GetTimesheetDetailListViewNotEqual(Timesheet timesheet) { return this.Controls.OfType<TimesheetDetailListView>().Where(p => !p.Timesheet.Equals(timesheet)); }
/// <summary> /// Selects the Timesheet, that is, the TimesheetDetailListView object is highlighted in some way /// to indicate it has been selected by the user. /// </summary> /// <param name="timesheet">The Timesheet to be selected.</param> public void SelectTimesheet(Timesheet timesheet) { // Select the indicated TimesheetDetailListView object... GetTimesheetDetailListView(timesheet).SelectTimesheet(true); // UNselect all other TimesheetDetailListView's... IEnumerable<TimesheetDetailListView> notEqualTimesheets = GetTimesheetDetailListViewNotEqual(timesheet); if (notEqualTimesheets.Count() > 0) { foreach (TimesheetDetailListView timesheetDetailListView in notEqualTimesheets) { timesheetDetailListView.SelectTimesheet(false); } } }
private void AddSplitRateEntries(ref int entryIndex, Timesheet timesheet, InvoiceConfiguration invoiceConfiguration) { if (!timesheet.IsSplitRate()) { MessageBox.Show("InvoiceGenerator.AddSplitRateEntries(...) encountered a problem; parameter 'timesheet' must be a 'split rate' Timesheet (e.g Timesheet.IsSplitRate() == true)."); return; } decimal ratePerHour = 0; decimal billableHours = 0; IEnumerable<TimesheetDate> timesheetDates = timesheet.Dates.Where(p => p.IsValidDate); foreach (TimesheetDate timesheetDate in timesheetDates) { if (ratePerHour == 0) { ratePerHour = timesheetDate.RatePerHour; billableHours += timesheetDate.BillableHours; } else if (timesheetDate.RatePerHour != ratePerHour) { // Add Entries... AddEntry(++entryIndex, billableHours, ratePerHour, timesheet.WeekNumber, timesheet.StartDate.Date, timesheet.EndDate.Date, invoiceConfiguration, true); // Reset our counters... ratePerHour = timesheetDate.RatePerHour; billableHours = timesheetDate.BillableHours; } else { // Roll up totals... billableHours += timesheetDate.BillableHours; } } // Get the last entry... if (timesheetDates != null) { AddEntry(++entryIndex, billableHours, ratePerHour, timesheet.WeekNumber, timesheet.StartDate.Date, timesheet.EndDate.Date, invoiceConfiguration, true); } }
public TimesheetDetailEventArgs(Timesheet timesheet) { this.Timesheet = timesheet; }
private bool GetTimesheetListViewItem(Timesheet timesheet, out ListViewItem timesheetListViewItem) { return GetTimesheetListViewItem(timesheet, out timesheetListViewItem, false); }
public void SaveTimesheet(Timesheet timesheet) { }
static private Color GetDefaultTimesheetBackColor(Timesheet timesheet) { if (timesheet.IsSplitTimesheet) { return TimesheetDetailListView.SplitColor; } else { int result; Math.DivRem(timesheet.WeekNumber, 2, out result); return (result == 0) ? TimesheetDetailListView.EvenColor : TimesheetDetailListView.OddColor; } }
public TimesheetChangedEventArgs(Timesheet timesheet) { this.Timesheet = timesheet; }
public TimesheetGenerator(Timesheet timesheet, string outputPath) : base(Configuration.Configuration.Instance.TimesheetConfiguration.TimesheetTemplate, Path.Combine(new string[] { outputPath, timesheet.GetFileName() })) { this.Timesheet = timesheet; }
private Timesheet GetActualTimesheet() { var actualTime = GetActualTime(); var actualTimesheet = Timesheets.FirstOrDefault(timesheet => timesheet.Month == actualTime.Month && timesheet.Year == actualTime.Year); if (actualTimesheet == null) { actualTimesheet = new Timesheet { Month = actualTime.Month, Year = actualTime.Year }; Timesheets.Insert(0, actualTimesheet); } return actualTimesheet; }
public void Update(int Id, string Username, int Periodaccountid, int Perdiemcount, bool IsDeleted, DateTime? CreatedOn, string CreatedBy, DateTime? ModifiedOn, string ModifiedBy, double Mileageclaimed, int Rategroupid) { Timesheet item = new Timesheet(); item.Id = Id; item.Username = Username; item.Periodaccountid = Periodaccountid; item.Perdiemcount = Perdiemcount; item.IsDeleted = IsDeleted; item.CreatedOn = CreatedOn; item.CreatedBy = CreatedBy; item.ModifiedOn = ModifiedOn; item.ModifiedBy = ModifiedBy; item.Mileageclaimed = Mileageclaimed; item.Rategroupid = Rategroupid; item.MarkOld(); item.Save(UserName); }