private void InitializeData() { _toDoList = new List <TimeSheetEntry>(); var todoItem1 = new TimeSheetEntry { ID = "6bb8a868-dba1-4f1a-93b7-24ebce87e243", JobLocation = "Learn app development", JobNumber = "Attend Xamarin University" }; var todoItem2 = new TimeSheetEntry { ID = "b94afb54-a1cb-4313-8af3-b7511551b33b", JobLocation = "Develop apps", JobNumber = "Use Xamarin Studio/Visual Studio", }; var todoItem3 = new TimeSheetEntry { ID = "ecfa6f80-3671-4911-aabe-63cc442c1ecf", JobLocation = "Publish apps", JobNumber = "All app stores", }; _toDoList.Add(todoItem1); _toDoList.Add(todoItem2); _toDoList.Add(todoItem3); }
//CRUD UPDATE //POST an update to the db //error checking public string UpdateTSEntry(TSEntryModel tsEntry) { if (tsEntry != null) { //create a new oTSEntry object TimeSheetEntry oTSEntry = new TimeSheetEntry(); //populate the object with the object data from tsEntry oTSEntry.TSEntryID = tsEntry.TSEntryID; oTSEntry.EntryDate = tsEntry.Date; oTSEntry.EmployeeID = tsEntry.EmployeeID; oTSEntry.ProdZoneID = tsEntry.ProdZoneID; oTSEntry.StartTime = tsEntry.StartTime; oTSEntry.EndTime = tsEntry.EndTime; oTSEntry.EquipmentMeterReading = tsEntry.EquipmentMeterReading; oTSEntry.EquipmentNumber = tsEntry.EquipmentNumber; oTSEntry.ImplementNumber = tsEntry.ImplementNumber; oTSEntry.TaskWOID = tsEntry.Task_WO_ID; oTSEntry.FieldNumber = tsEntry.FieldNumber; //connect via interface to DAL App, and update the ts entry as an object itsApp.UpdateTSEntry(oTSEntry); return("Entry Updated Successfully"); } else { return("Entry Not Updated! Try Again"); } }
//CRUD DELETE //POST a deletion to the db //error checking public string DeleteTSEntry(TSEntryModel tsEntry) { if (tsEntry != null) { //create a new oTSEntry object TimeSheetEntry oTSEntry = new TimeSheetEntry(); //populate the object with the object data from tsEntry oTSEntry.TSEntryID = tsEntry.TSEntryID; oTSEntry.EntryDate = tsEntry.Date; oTSEntry.EmployeeID = tsEntry.EmployeeID; oTSEntry.ProdZoneID = tsEntry.ProdZoneID; oTSEntry.StartTime = tsEntry.StartTime; oTSEntry.EndTime = tsEntry.EndTime; oTSEntry.EquipmentMeterReading = tsEntry.EquipmentMeterReading; oTSEntry.EquipmentNumber = tsEntry.EquipmentNumber; oTSEntry.ImplementNumber = tsEntry.ImplementNumber; oTSEntry.TaskWOID = tsEntry.Task_WO_ID; oTSEntry.FieldNumber = tsEntry.FieldNumber; //connect via interface to DAL App, and delete the ts entry as an object. The DAL parses out just the tsEntry.TSEntryID, and removed the entry by it's particular id/insertion order itsApp.DeleteTSEntry(oTSEntry); return("Entry Deleted Successfully"); } else { return("Entry Not Deleted! Try Again"); } }
/// <summary> /// CreatedBy : sangee /// CreatedOn : 15 Jan, 2017 /// Description : Add Time Sheet Entry /// </summary> /// <param name="TimeSheetInfo"></param> /// <returns></returns> public bool AddLogTime(TimeSheetInfo TimeSheetInfo) { TimeSheetEntry timeSheetEntry = new TimeSheetEntry(); try { if (TimeSheetInfo == null) { return(false); } _unitOfWork.TimeSheetInfoRepository.Add(TimeSheetInfo); _unitOfWork.Commit(); timeSheetEntry.ResourceInfoId = TimeSheetInfo.ResourceId; timeSheetEntry.TimeSheetInfoId = TimeSheetInfo.Id; _unitOfWork.TimeSheetEntryRepository.Add(timeSheetEntry); _unitOfWork.Commit(); if (TimeSheetInfo.Id > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
private void UnlinkHoursPayButton_Click(object sender, EventArgs e) { if (IsPaymentSelected() == false) { return; } PaymentEntry selectedPayment = (PaymentEntry)PayListViewBox.SelectedItems[0].Tag; var selectedItems = HoursListViewBox.SelectedItems; foreach (ListViewItem item in selectedItems) { TimeSheetEntry hoursEntry = (TimeSheetEntry)item.Tag; if (item.Checked == true) { GlobalConfig.Connection.DeletePayHoursLink(selectedPayment, hoursEntry); item.Checked = false; } } HighlightLinkedHours(); UpdateExpectedValues(); }
private void PopulateHoursListView() { HoursListViewBox.Items.Clear(); HoursListViewItems = Employment.TimeSheetEntries; for (int i = 0; i < HoursListViewItems.Count; i++) { TimeSheetEntry entry = HoursListViewItems[i]; string[] cols = { entry.Date.ToLongDateString(), entry.Type.ToUpperInvariant(), entry.HoursWorked.ToString(), $"{entry.HourlyRate:C2}" }; var listViewItem = new ListViewItem(cols); listViewItem.Tag = entry; HoursListViewBox.Items.Add(listViewItem); } HoursListViewBox.Sort(); }
private void HighlightLinkedHours() { List <TimeSheetEntry> linked; if (IsPaymentSelected() == false) { linked = new List <TimeSheetEntry>(); } else { PaymentEntry selectedPayment = (PaymentEntry)PayListViewBox.SelectedItems[0].Tag; linked = GlobalConfig.Connection.GetLinkedHours(selectedPayment); } foreach (ListViewItem item in HoursListViewBox.Items) { TimeSheetEntry hoursEntry = (TimeSheetEntry)item.Tag; if (linked.Contains(hoursEntry, new TimeSheetComparer()) == true) { item.BackColor = Color.Gray; item.Checked = true; } else { item.BackColor = Color.White; } } }
// GET: TimeSheetEntries/Details/5 public ActionResult Details(int?id) { ViewBag.error = id == null; TimeSheetEntry timeSheetEntry = db.TimeSheetEntries.Find(id); ViewBag.clientError = timeSheetEntry == null; return(View(timeSheetEntry)); }
public void Update(TimeSheetEntry item) { var todoItem = this.Find(item.ID); var index = _toDoList.IndexOf(todoItem); _toDoList.RemoveAt(index); _toDoList.Insert(index, item); }
public ActionResult DelayedPunchout(int id, TimeSheetEntry entry) { var punchIn = db.TimeSheetEntries.Find(id); punchIn.EndTime = entry.EndTime; db.Entry(punchIn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <int> UpdateEntry(TimeSheetEntry entry) { // TODO: [TESTS] (TimeSheetEntryRepo.UpdateEntry) Add tests return(await ExecuteAsync( nameof(UpdateEntry), _queries.UpdateEntry(), entry )); }
public void DeleteTimeSheetEntry(TimeSheetEntry entry) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetCnnString("WorkTimeSheet"))) { var parameters = new DynamicParameters(); parameters.Add("@ID", entry.ID); connection.Execute("dbo.spHours_Delete", parameters, commandType: CommandType.StoredProcedure); } }
public void DeletePayHoursLink(PaymentEntry payment, TimeSheetEntry hours) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetCnnString("WorkTimeSheet"))) { var parameters = new DynamicParameters(); parameters.Add("@PayID", payment.ID); parameters.Add("@HoursID", hours.ID); connection.Execute("dbo.spPayHoursLink_DeleteLink", parameters, commandType: CommandType.StoredProcedure); } }
//[Authorize] public IActionResult Post([FromForm] addvalue value) { TimeSheet timeSheet = new TimeSheet(); TimeSheetItem timeSheetItem = new TimeSheetItem(); TimeSheetEntry timeSheetEntry = new TimeSheetEntry(); try { //TimeSheet obj = JsonConvert.DeserializeObject<TimeSheet>(value); timeSheet.EmpId = value.EmpId; timeSheetItem.Hours = value.Hours; timeSheetItem.EmpId = value.EmpId; timeSheetEntry.Customer = value.Customer; timeSheetEntry.Company = value.Company; timeSheetEntry.Task = value.Task; timeSheetEntry.Project = value.Project; timeSheetEntry.EmpId = value.EmpId; timeSheetEntry.Status = "pending"; timeSheetItem.Date = "null"; timeSheetItem.From = "null"; timeSheetItem.To = "null"; timeSheet.EmployeeName = "null"; timeSheetEntry.EmployeeName = timeSheet.EmployeeName; timeSheet.Id = 1; timeSheetEntry.Id = timeSheet.Id; timeSheetItem.Id = 1; db.TimeSheet.Add(timeSheet); db.TimeSheetItem.Add(timeSheetItem); db.TimeSheetEntry.Add(timeSheetEntry); db.SaveChanges(); return(Ok(new { StatusCode = 200, Message = "done", // data = q })); } catch (Exception e) { Console.WriteLine(e); return(Ok(new { StatusCode = 500, Message = "unauthorized" })); } }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } TimeSheetEntry = await GetEntry(id); if (TimeSheetEntry == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } TimeSheetEntry = await _context.GetEntryById(id.Value, GetUserGuid()); if (TimeSheetEntry == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } TimeSheetEntry = await GetEntry(id); if (TimeSheetEntry != null) { await _context.RemoveTimeSheetEntry(TimeSheetEntry); } return(RedirectToPage("./Index")); }
private void PopulateListViewBox() { var viewOption = (HoursViewOption)HoursViewOptionComboBox.SelectedItem; if (viewOption.GetType() != typeof(HoursViewOption)) { MessageBox.Show("Invalid selection"); HoursViewOptionComboBox.SelectedIndex = 0; return; } HoursListViewBox.Items.Clear(); switch (viewOption) { case HoursViewOption.All: HoursListViewItems = Employment.TimeSheetEntries; break; case HoursViewOption.ThisWeek: HoursListViewItems = GlobalConfig.Connection.GetHours_ThisWeek(Employment); break; default: throw new Exception("Something went wrong..."); } for (int i = 0; i < HoursListViewItems.Count; i++) { TimeSheetEntry entry = HoursListViewItems[i]; string[] cols = { entry.Date.ToLongDateString(), entry.Type.ToUpperInvariant(), entry.HoursWorked.ToString(), $"{entry.HourlyRate:C2}" }; var listViewItem = new ListViewItem(cols); listViewItem.Tag = entry; HoursListViewBox.Items.Add(listViewItem); } HoursListViewBox.Sort(); }
public IActionResult save([FromBody] AddTimeSheet items) { try { TimeSheet timeSheet = new TimeSheet(); var existingEmployeee = db.TimeSheet.FirstOrDefault(item => items.Empid == item.Empid); if (existingEmployeee == null) { timeSheet.Empid = items.Empid; timeSheet.Empname = items.Empname; db.Add(timeSheet); db.SaveChanges(); } foreach (TimeSheetData value in items.data) { TimeSheetItem timeSheetItem = new TimeSheetItem(); TimeSheetEntry timeSheetEntry = new TimeSheetEntry(); timeSheetItem.Hours = value.Hours; timeSheetItem.Empid = items.Empid; timeSheetItem.Status = "Drafted"; timeSheetItem.Submittedto = value.Submittedto; timeSheetItem.To = items.To; timeSheetItem.From = items.From; timeSheetItem.Date = value.Date; db.Add(timeSheetItem); db.SaveChanges(); int index = timeSheetItem.Timestampid; timeSheetEntry.Customer = value.Customer; timeSheetEntry.Company = value.Company; timeSheetEntry.Task = value.Task; timeSheetEntry.Project = value.Project; timeSheetEntry.Timestampid = index; db.Add(timeSheetEntry); db.SaveChanges(); } } catch (Exception e) { Console.Write(e); } return(Ok()); }
/// <summary> /// Delete a timesheet entry by a resource /// </summary> /// <param name="id"></param> /// <param name="resourceId"></param> /// <returns></returns> public bool DeleteTimeSheetEntry(int id, int resourceId) { try { TimeSheetEntry _timeSheetEntryDb = _unitOfWork.TimeSheetEntryRepository.GetSingle(id); if (_timeSheetEntryDb == null) { return(false); } _unitOfWork.TimeSheetInfoRepository.DeleteWhere(x => x.Id == _timeSheetEntryDb.TimeSheetInfoId); _unitOfWork.TimeSheetEntryRepository.Delete(_timeSheetEntryDb); _unitOfWork.Commit(); return(true); } catch (Exception ex) { return(false); } }
private async Task OnChargableOptionSelected(IDialogContext context, IAwaitable <string> result) { try { string optionSelected = await result; timeSheetEntry = new TimeSheetEntry(); timeSheetEntry.IsChargable = optionSelected; this.ShowEntryTypeOptions(context); } catch (TooManyAttemptsException ex) { await context.PostAsync($"Ooops! Too many attemps :(. But don't worry, I'm handling that exception and you can try again!"); context.Done <object>(null); } }
public IActionResult Edit([FromBody] TimeSheetEntry item) { try { if (item == null || !ModelState.IsValid) { return(BadRequest(ErrorCode.TimeSheetEntryPropsRequired.ToString())); } var existingItem = _timeSheetRepository.Find(item.ID); if (existingItem == null) { return(NotFound(ErrorCode.RecordNotFound.ToString())); } _timeSheetRepository.Update(item); } catch (Exception) { return(BadRequest(ErrorCode.CouldNotUpdateItem.ToString())); } return(NoContent()); }
public IActionResult Create([FromBody] TimeSheetEntry item) { try { if (item == null || !ModelState.IsValid) { return(BadRequest(ErrorCode.TimeSheetEntryPropsRequired.ToString())); } bool itemExists = _timeSheetRepository.DoesItemExist(item.ID); if (itemExists) { return(StatusCode(StatusCodes.Status409Conflict, ErrorCode.TimeSheetEntryIDInUse.ToString())); } _timeSheetRepository.Insert(item); } catch (Exception) { return(BadRequest(ErrorCode.CouldNotCreateItem.ToString())); } return(Ok(item)); }
public TimeSheetEntry AddNewTimeSheetEntry(TimeSheetEntry entry, Employment employment) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetCnnString("WorkTimeSheet"))) { var parameters = new DynamicParameters(); parameters.Add("@Date", entry.Date); parameters.Add("@Type", entry.Type); parameters.Add("@HoursWorked", entry.HoursWorked); parameters.Add("@HourlyRate", entry.HourlyRate); parameters.Add("@EmploymentID", employment.ID); parameters.Add("@ID", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.spHours_AddNewTimeSheetEntry", parameters, commandType: CommandType.StoredProcedure); entry.ID = parameters.Get <int>("@ID"); } employment.TimeSheetEntries.Add(entry); return(entry); }
public void UpdateTimeSheetEntry(TimeSheetEntry timeSheetEntry) { if (timeSheetEntry == null) { throw new ArgumentNullException("timeSheetEntry can not be null"); } if (timeSheetEntry.TimeSheetEntryId > 0) { if (timeSheetEntry.EntityState == EntityState.Detached) { context.TimeSheetEntry.Attach(timeSheetEntry); } context.TimeSheetEntry.Context.ObjectStateManager.ChangeObjectState(timeSheetEntry, EntityState.Modified); } else { context.TimeSheetEntry.AddObject(timeSheetEntry); context.TimeSheetEntry.Context.ObjectStateManager.ChangeObjectState(timeSheetEntry, EntityState.Added); } context.SaveChanges(); }
public void Should_Return_Total_HoursWorked_Cost_ForWeek_When_Employee_EntryPresent() { //Arrange TimeSheetEntry firstEntry = new TimeSheetEntry() { EmployeeID = 1, InTime = new DateTime(2019, 1, 15, 09, 00, 00), OutTime = new DateTime(2019, 1, 15, 16, 30, 00) }; TimeSheetEntry secondEntry = new TimeSheetEntry() { EmployeeID = 1, InTime = new DateTime(2019, 1, 16, 09, 00, 00), OutTime = new DateTime(2019, 1, 16, 16, 30, 00) }; WorkWeekDetails expected = new WorkWeekDetails() { WeekNumber = 3, HoursWorked = 15, Cost = 375 }; timeSheet.AddEntry(firstEntry); timeSheet.AddEntry(secondEntry); int employeeId = 1; int weekNumber = 3; //Act weekDetails = timeSheet.CalculateWeeklyWages(employeeId, weekNumber); //Assert Assert.AreEqual(Newtonsoft.Json.JsonConvert.SerializeObject(expected), Newtonsoft.Json.JsonConvert.SerializeObject(weekDetails)); }
private void SubmitHoursButton_Click(object sender, EventArgs e) { bool formValid = ValidateForm(); if (formValid == true) { var newEntry = new TimeSheetEntry() { Date = DateTime.Parse(SelectedDateLabel.Text), Type = HoursTypeComboBox.SelectedItem.ToString().ToLower(), HoursWorked = double.Parse(HoursWorkedEntryBox.Text), HourlyRate = decimal.Parse(HourlyRateTextBox.Text) }; GlobalConfig.Connection.AddNewTimeSheetEntry(newEntry, Employment); ClearInputs(); PopulateListViewBox(); } else { MessageBox.Show("Invalid data entered into form"); } }
public async Task UpdateTimeSheetEntry(TimeSheetEntry entry) { Attach(entry).State = EntityState.Modified; await SaveChangesAsync(); }
public static TimeSheetEntryDto FromEntity(TimeSheetEntry entity) { // TODO: [TESTS] (TimeSheetEntryDto.FromEntity) Add tests return(entity == null ? null : Projection.Compile()(entity)); }
public void Insert(TimeSheetEntry item) { _toDoList.Add(item); }