public SchedulePageViewModel() { _clockedInTimeEntry = App.Database.GetClockedInTimeEntry(); _scheduleDetails = new ObservableCollection <App_ScheduledAppointment>(App.Database.GetScheduledAppointments()); // dch rkl 10/14/2016 if any tickets in the schedule list are marked COM (completed) // in the JT_TransactionImportDetail table, remove them from the schedule list List <JT_TransactionImportDetail> lsTrans = App.Database.GetCurrentExport(); if (lsTrans.Count > 0) { var copy = new ObservableCollection <App_ScheduledAppointment>(_scheduleDetails); foreach (App_ScheduledAppointment sched in copy) { foreach (JT_TransactionImportDetail tran in lsTrans) { if (tran.RecordType == "S" && tran.SalesOrderNo == sched.SalesOrderNumber && tran.WTNumber == sched.WorkTicketNumber && tran.WTStep == sched.WorkTicketStep && tran.StatusCode == "COM") { _scheduleDetails.Remove(sched); break; } } } } // dch rkl 10/14/2016 END }
public void SaveMiscellaneousTimeEntry(JT_DailyTimeEntry dailyTimeEntry, double hoursWorked) { JT_TransactionImportDetail transactionDetail = new JT_TransactionImportDetail() { // dch rkl 11/01/2016 per Jeanne, this should be an "M" //RecordType = "L", RecordType = "M", SalesOrderNo = dailyTimeEntry.SalesOrderNo, WTNumber = dailyTimeEntry.WTNumber, WTStep = dailyTimeEntry.WTStep, EmployeeDeptNo = dailyTimeEntry.DepartmentNo, EmployeeNo = dailyTimeEntry.EmployeeNo, EarningsCode = dailyTimeEntry.EarningsCode, StartTime = dailyTimeEntry.StartTime, EndTime = dailyTimeEntry.EndTime, // dch rkl 11/01/2016 Transaction Date should come from the entry screen BEGIN //TransactionDate = DateTime.Now.ToSage100DateString(), //TransactionDateAsDateTime = DateTime.Now, TransactionDate = dailyTimeEntry.TransactionDate.ToSage100DateString(), TransactionDateAsDateTime = dailyTimeEntry.TransactionDate, // dch rkl 11/01/2016 Transaction Date should come from the entry screen END HoursWorked = hoursWorked }; _database.Insert(transactionDetail); _database.Insert(dailyTimeEntry); }
/// <summary> /// Sets the given technician as being clocked-in to a ticket represented by the /// specified scheduled appointment object. The time and status codes provided /// will also be used to update the technician data. /// </summary> /// <param name="technician">Technician to clock in</param> /// <param name="scheduledAppointment">Scheduled Appointment object to clock into</param> /// <param name="startDateTime">Start date/time</param> /// <param name="technicianStatus">Technician status object for the new, clocked-in status</param> /// <param name="serviceTicketStatusCode">Work ticket status for the new, clocked-in status</param> public void ClockIn(App_Technician technician, App_ScheduledAppointment scheduledAppointment, DateTime startDateTime, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatusCode) { // Is this tech already clocked into a ticket? if (IsClockedIn(technician)) { throw new Exception("Technician is already clocked into a ticket!"); } int rows = 0; // Update the erp record with the ticket info JT_Technician erpTech = GetTechnician(technician.TechnicianDeptNo, technician.TechnicianNo); erpTech.CurrentStartDate = startDateTime.Date; erpTech.CurrentStartTime = startDateTime.ToSage100TimeString(); erpTech.CurrentSalesOrderNo = scheduledAppointment.SalesOrderNumber; erpTech.CurrentWTNumber = scheduledAppointment.WorkTicketNumber; erpTech.CurrentWTStep = scheduledAppointment.WorkTicketStep; erpTech.CurrentStatus = technicianStatus.StatusCode; // dch rkl 11/03/2016 Save Current Status code to JT_Technician table rows = _database.Update(erpTech); // create the JT_TransactionImportDetail record JT_TransactionImportDetail importDetail = new JT_TransactionImportDetail(); importDetail.RecordType = "S"; importDetail.SalesOrderNo = scheduledAppointment.SalesOrderNumber; importDetail.WTNumber = scheduledAppointment.WorkTicketNumber; importDetail.WTStep = scheduledAppointment.WorkTicketStep; importDetail.StatusCode = serviceTicketStatusCode.MiscellaneousCode; //importDetail.statusDate TODO>>> not in table spec! importDetail.TransactionDate = startDateTime.ToShortDateString(); importDetail.TransactionDateAsDateTime = startDateTime; // dch rkl 12/09/2016 per Chris, store start time in start time //importDetail.StatusTime = startDateTime.ToSage100TimeString(); importDetail.StartTime = startDateTime.ToSage100TimeString(); //importDetail.StatusComment = ""; // not used at this time but might be in the future rows = _database.Insert(importDetail); // TODO... do we need this anymore now that we are tracking in/out // on technician record? JT_DailyTimeEntry newTimeEntry = new JT_DailyTimeEntry(); newTimeEntry.DepartmentNo = technician.TechnicianDeptNo; newTimeEntry.EmployeeNo = technician.TechnicianNo; newTimeEntry.SalesOrderNo = scheduledAppointment.SalesOrderNumber; newTimeEntry.WTNumber = scheduledAppointment.WorkTicketNumber; newTimeEntry.WTStep = scheduledAppointment.WorkTicketStep; newTimeEntry.StartTime = startDateTime.ToSage100TimeString(); newTimeEntry.TransactionDate = startDateTime; newTimeEntry.IsModified = true; rows = _database.Insert(newTimeEntry); }
public ScheduleDetailPageViewModel(App_ScheduledAppointment scheduleDetail) { _scheduleDetail = scheduleDetail; _technicianScheduleDetail = App.Database.GetTechnicianScheduleDetailFromDB().Where(x => x.WTNumber == _scheduleDetail.WorkTicketNumber && x.WTStep == _scheduleDetail.WorkTicketStep).FirstOrDefault(); _timeEntryDetail = App.Database.GetTimeEntryData(scheduleDetail); _timportDetail = App.Database.GetCurrentExport().Where(x => x.RecordType == "L" && x.WTNumber == _scheduleDetail.WorkTicketNumber && x.WTStep == _scheduleDetail.WorkTicketStep && x.SalesOrderNo == _scheduleDetail.SalesOrderNumber).FirstOrDefault(); }
public JT_DailyTimeEntry GetClockedInTimeEntry() { JT_DailyTimeEntry returnData = null; lock (_locker) { JT_Technician technician = GetCurrentTechnicianFromDb(); if (technician != null) { returnData = GetClockedInTimeEntry(new App_Technician(technician)); } } return(returnData); }
public JT_DailyTimeEntry GetClockedInTimeEntry(App_Technician technician) { JT_DailyTimeEntry returnData = null; lock (_locker) { returnData = _database.Table <JT_DailyTimeEntry>().Where( dte => (dte.DepartmentNo == technician.TechnicianDeptNo) && (dte.EmployeeNo == technician.TechnicianNo) && (dte.StartTime != null) && (dte.EndTime == null) ).FirstOrDefault(); } return(returnData); }
public ScheduleDetailPageViewModel(App_ScheduledAppointment scheduleDetail) { // dch rkl 12/07/2016 catch exception try { _scheduleDetail = scheduleDetail; _technicianScheduleDetail = App.Database.GetTechnicianScheduleDetailFromDB().Where(x => x.WTNumber == _scheduleDetail.WorkTicketNumber && x.WTStep == _scheduleDetail.WorkTicketStep).FirstOrDefault(); _timeEntryDetail = App.Database.GetTimeEntryData(scheduleDetail); _timportDetail = App.Database.GetCurrentExport().Where(x => x.RecordType == "L" && x.WTNumber == _scheduleDetail.WorkTicketNumber && x.WTStep == _scheduleDetail.WorkTicketStep && x.SalesOrderNo == _scheduleDetail.SalesOrderNumber).FirstOrDefault(); } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.ScheduleDetailPageViewModel"); } }
protected async void ButtonAccept_Clicked(object sender, EventArgs e) { JT_DailyTimeEntry newTimeEntry = new JT_DailyTimeEntry(); JT_Technician currentTechnician = App.Database.GetCurrentTechnicianFromDb(); newTimeEntry.DepartmentNo = currentTechnician.TechnicianDeptNo; newTimeEntry.EmployeeNo = currentTechnician.TechnicianNo; newTimeEntry.EndTime = endTimePicker.Time.ToSage100TimeString(); newTimeEntry.IsModified = true; newTimeEntry.StartTime = startTimePicker.Time.ToSage100TimeString(); newTimeEntry.TransactionDate = transactionDatePicker.Date; newTimeEntry.WTNumber = currentTechnician.CurrentWTNumber; newTimeEntry.WTStep = currentTechnician.CurrentWTStep; newTimeEntry.EarningsCode = earningCodeToDesc[earningCodePicker.Items[earningCodePicker.SelectedIndex]]; _vm.DailyTimeEntry = newTimeEntry; _vm.SaveDailyTimeEntry(Convert.ToDouble(CalcHours())); await Navigation.PopAsync(); }
public SchedulePageViewModel() { // dch rkl 12/07/2016 catch exception try { App_Settings appSettings = App.Database.GetApplicationSettings(); _clockedInTimeEntry = App.Database.GetClockedInTimeEntry(); _scheduleDetails = new ObservableCollection <App_ScheduledAppointment>(App.Database.GetScheduledAppointments()); // dch rkl 10/14/2016 if any tickets in the schedule list are marked COM (completed) // in the JT_TransactionImportDetail table, remove them from the schedule list List <JT_TransactionImportDetail> lsTrans = App.Database.GetCurrentExport(); if (lsTrans.Count > 0) { var copy = new ObservableCollection <App_ScheduledAppointment>(_scheduleDetails); foreach (App_ScheduledAppointment sched in copy) { foreach (JT_TransactionImportDetail tran in lsTrans) { if (tran.RecordType == "S" && tran.SalesOrderNo == sched.SalesOrderNumber && tran.WTNumber == sched.WorkTicketNumber && tran.WTStep == sched.WorkTicketStep && tran.StatusCode == "COM") { _scheduleDetails.Remove(sched); break; } } } } // dch rkl 10/14/2016 END _defaultStartDate = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; _defaultEndDate = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.SchedulePageViewModel"); } }
public JT_DailyTimeEntry GetTimeEntryData(App_ScheduledAppointment scheduledAppointment) { JT_DailyTimeEntry returnData = null; JT_Technician technician = null; lock (_locker) { technician = GetCurrentTechnicianFromDb(); if (technician != null) { returnData = _database.Table <JT_DailyTimeEntry>().Where( x => x.EmployeeNo == technician.TechnicianNo && x.DepartmentNo == technician.TechnicianDeptNo && x.WTNumber == scheduledAppointment.WorkTicketNumber && x.WTStep == scheduledAppointment.WorkTicketStep ).OrderByDescending(x => x.TransactionDate).FirstOrDefault(); } } return(returnData); }
private void ButtonAccept_Clicked(object sender, RoutedEventArgs e) { JT_DailyTimeEntry newTimeEntry = new JT_DailyTimeEntry(); JT_Technician currentTechnician = App.Database.GetCurrentTechnicianFromDb(); if (earningCodePicker.SelectedIndex < 0) { var result = System.Windows.MessageBox.Show("Please select an earnings code before saving.", "Missing Earnings Code", MessageBoxButton.OK); return; } // dch rkl 02/03/2017 Validate Date DateTime dtTranDate; if (textTransactionDate.Text.Trim().Length == 0 || DateTime.TryParse(textTransactionDate.Text, out dtTranDate) == false) { var result = System.Windows.MessageBox.Show("Please enter a valid transaction date.", "Invalid Transaction Date", MessageBoxButton.OK); return; } // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN string startTime = ""; string endTime = ""; double hours = 0; if (_captureTimeInTimeTracker == "N") { // Enter Hours double iHours = 0; if (double.TryParse(durationTextCell.Text, out iHours) == false) { var result = System.Windows.MessageBox.Show("Please enter valid hours before saving.", "Invalid Hours", MessageBoxButton.OK); return; } else if (iHours <= 0 || iHours > 24) { var result = System.Windows.MessageBox.Show("Please enter valid hours before saving.", "Invalid Hours", MessageBoxButton.OK); return; } hours = iHours; } else { // Enter From and To Time DateTime dtStartTime; if (DateTime.TryParse(startTimeText.Text, out dtStartTime) == false) { var result = System.Windows.MessageBox.Show("Please enter a valid start time before saving.", "Invalid Start Time", MessageBoxButton.OK); return; } DateTime dtEndTime; if (DateTime.TryParse(endTimeText.Text, out dtEndTime) == false) { var result = System.Windows.MessageBox.Show("Please enter a valid end time before saving.", "Invalid End Time", MessageBoxButton.OK); return; } startTime = dtStartTime.TimeOfDay.ToSage100TimeString(); endTime = dtEndTime.TimeOfDay.ToSage100TimeString(); hours = Convert.ToDouble(CalcHours()); } // dch rkl 11/1/2016 use textbox instead of datetime picker for times END newTimeEntry.DepartmentNo = currentTechnician.TechnicianDeptNo; newTimeEntry.EmployeeNo = currentTechnician.TechnicianNo; // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN //newTimeEntry.EndTime = ((DateTime)endTimePicker.Value).TimeOfDay.ToSage100TimeString(); newTimeEntry.EndTime = endTime; // dch rkl 11/1/2016 use textbox instead of datetime picker for times END newTimeEntry.IsModified = true; // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN //newTimeEntry.StartTime = ((DateTime)startTimePicker.Value).TimeOfDay.ToSage100TimeString(); newTimeEntry.StartTime = startTime; // dch rkl 11/1/2016 use textbox instead of datetime picker for times END newTimeEntry.TransactionDate = dtTranDate; // dch rkl 01/23/2017 Do not include WT Number and WT Step for miscellaneous time. //newTimeEntry.WTNumber = currentTechnician.CurrentWTNumber; //newTimeEntry.WTStep = currentTechnician.CurrentWTStep; newTimeEntry.EarningsCode = earningCodePicker.SelectedValue.ToString(); _vm.DailyTimeEntry = newTimeEntry; // dch rkl 11/04/2016 Hours calculated above, since they can be entered manually //_vm.SaveDailyTimeEntry(Convert.ToDouble(CalcHours())); _vm.SaveDailyTimeEntry(Convert.ToDouble(hours)); // dch rkl 11/01/2016 confirmation that transaction was saved var result2 = System.Windows.MessageBox.Show("Miscellaneous Time Entry Saved.", "Entry Saved", MessageBoxButton.OK); ContentControl contentArea = (ContentControl)this.Parent; contentArea.Content = new MiscellaneousTimePage(); }
/// <summary> /// Sets the given technician as being clocked-out of a ticket represented by the /// specified work ticket object. The time and status codes provided /// will also be used to update the technician data. /// dch rkl 01/23/2017 This version of ClockOut includes parameters for when the hours are entered, not the start/stop date and time. /// </summary> /// <param name="technician">Technician to clock out</param> /// <param name="workTicket">Work ticket clocking out of</param> /// <param name="stopDateTime">Stop date/time</param> /// <param name="technicianStatus">Technician status object for the new, clocked-out status</param> /// <param name="serviceTicketStatusCode">Work ticket status for the new, clocked-out status</param> /// <param name="activityCode">Activity code to report</param> /// <param name="deptWorked">Department in which work was performed</param> /// <param name="earningsCode">Earnings code to report</param> /// <param name="meterReading">Meter reading (if any) to report</param> /// <param name="workPerformedText">Text/notes</param> public void ClockOut(App_Technician technician, App_WorkTicket workTicket, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatusCode, string activityCode, string deptWorked, JT_EarningsCode earningsCode, double hoursBilled, double meterReading, string workPerformedText, double hoursWorked, string svcAgmtContractCode, string billingType) { int rows = 0; lock (_locker) { // Clear out fields for JT_Technician record JT_Technician erpTech = GetTechnician(technician.TechnicianDeptNo, technician.TechnicianNo); // update time entry first DateTime dtStartTime = DateTime.Now; JT_DailyTimeEntry currentTimeEntry = GetClockedInTimeEntry(technician); if (currentTimeEntry != null) { if (DateTime.TryParse(currentTimeEntry.StartTime, out dtStartTime)) { DateTime dtStopTime = dtStartTime.AddHours(hoursWorked); currentTimeEntry.EndTime = dtStopTime.ToSage100TimeString(); _database.Update(currentTimeEntry); } } erpTech.CurrentStartDate = new DateTime(); erpTech.CurrentStartTime = null; erpTech.CurrentSalesOrderNo = null; erpTech.CurrentWTNumber = null; erpTech.CurrentWTStep = null; erpTech.CurrentStatus = technicianStatus.StatusCode; // dch rkl 11/03/2016 Save Current Status code to JT_Technician table rows = _database.Update(erpTech); // insert the JT_TransactionImportDetail record JT_TransactionImportDetail importDetail = new JT_TransactionImportDetail(); importDetail.RecordType = "S"; importDetail.SalesOrderNo = workTicket.SalesOrderNo; importDetail.WTNumber = workTicket.WTNumber; importDetail.WTStep = workTicket.WTStep; importDetail.StatusCode = serviceTicketStatusCode.MiscellaneousCode; importDetail.TransactionDate = dtStartTime.ToSage100DateString(); importDetail.TransactionDateAsDateTime = dtStartTime; importDetail.HoursWorked = hoursWorked; rows = _database.Insert(importDetail); // insert another JT_TransactionImportDetail record to record the labor importDetail = new JT_TransactionImportDetail(); importDetail.RecordType = "L"; importDetail.SalesOrderNo = workTicket.SalesOrderNo; importDetail.WTNumber = workTicket.WTNumber; importDetail.WTStep = workTicket.WTStep; importDetail.EmployeeDeptNo = technician.TechnicianDeptNo; importDetail.EmployeeNo = technician.TechnicianNo; importDetail.ActivityCode = activityCode; importDetail.DeptWorkedIn = deptWorked; importDetail.EarningsCode = earningsCode.EarningsCode; importDetail.TransactionDate = dtStartTime.ToSage100DateString(); importDetail.TransactionDateAsDateTime = dtStartTime; importDetail.HoursWorked = hoursWorked; //bk add hours billed importDetail.BillableHours = hoursBilled; importDetail.BillingType = billingType; importDetail.MeterReading = meterReading; importDetail.WorkPerformed = workPerformedText; importDetail.SvcAgmtContractCode = svcAgmtContractCode; // dch rkl 01/23/2017 Include Service Agreement Code rows = _database.Insert(importDetail); } }
/// <summary> /// Sets the given technician as being clocked-out of a ticket represented by the /// specified work ticket object. The time and status codes provided /// will also be used to update the technician data. /// </summary> /// <param name="technician">Technician to clock out</param> /// <param name="workTicket">Work ticket clocking out of</param> /// <param name="stopDateTime">Stop date/time</param> /// <param name="technicianStatus">Technician status object for the new, clocked-out status</param> /// <param name="serviceTicketStatusCode">Work ticket status for the new, clocked-out status</param> /// <param name="activityCode">Activity code to report</param> /// <param name="deptWorked">Department in which work was performed</param> /// <param name="earningsCode">Earnings code to report</param> /// <param name="meterReading">Meter reading (if any) to report</param> /// <param name="workPerformedText">Text/notes</param> public void ClockOut(App_Technician technician, App_WorkTicket workTicket, DateTime stopDateTime, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatusCode, string activityCode, string deptWorked, JT_EarningsCode earningsCode, double hoursBilled, double hoursWorked, double meterReading, string workPerformedText, string svcAgmtContractCode, string clockoutDate, string billingType) { int rows = 0; DateTime startDateTime; lock (_locker) { // Clear out fields for JT_Technician record JT_Technician erpTech = GetTechnician(technician.TechnicianDeptNo, technician.TechnicianNo); // Record starting date/time in local variable startDateTime = erpTech.CurrentStartDate; // Add time startDateTime = startDateTime.Add(erpTech.CurrentStartTime.ToSage100TimeSpan()); if (hoursBilled <= 0) { hoursBilled = (stopDateTime - startDateTime).TotalHours; } // update time entry first JT_DailyTimeEntry currentTimeEntry = GetClockedInTimeEntry(technician); if (currentTimeEntry != null) { currentTimeEntry.EndTime = stopDateTime.ToSage100TimeString(); _database.Update(currentTimeEntry); } erpTech.CurrentStartDate = new DateTime(); erpTech.CurrentStartTime = null; erpTech.CurrentSalesOrderNo = null; erpTech.CurrentWTNumber = null; erpTech.CurrentWTStep = null; erpTech.CurrentStatus = technicianStatus.StatusCode; // dch rkl 11/03/2016 Save Current Status code to JT_Technician table rows = _database.Update(erpTech); rows = _database.Update(erpTech); // insert the JT_TransactionImportDetail record JT_TransactionImportDetail importDetail = new JT_TransactionImportDetail(); importDetail.RecordType = "S"; importDetail.SalesOrderNo = workTicket.SalesOrderNo; importDetail.WTNumber = workTicket.WTNumber; importDetail.WTStep = workTicket.WTStep; importDetail.StatusCode = serviceTicketStatusCode.MiscellaneousCode; //importDetail.statusDate TODO>>> not in table spec! // dch rkl 12/09/2016 per Chris, store start time in start time //importDetail.StatusTime = stopDateTime.ToSage100TimeString(); importDetail.StartTime = stopDateTime.ToSage100TimeString(); importDetail.TransactionDate = stopDateTime.ToSage100DateString(); importDetail.TransactionDateAsDateTime = stopDateTime; //importDetail.StatusComment = "TODO"; // not used at this time but might be in the future rows = _database.Insert(importDetail); // insert another JT_TransactionImportDetail record to record the labor importDetail = new JT_TransactionImportDetail(); importDetail.RecordType = "L"; importDetail.SalesOrderNo = workTicket.SalesOrderNo; importDetail.WTNumber = workTicket.WTNumber; importDetail.WTStep = workTicket.WTStep; importDetail.EmployeeDeptNo = technician.TechnicianDeptNo; importDetail.EmployeeNo = technician.TechnicianNo; importDetail.ActivityCode = activityCode; importDetail.DeptWorkedIn = deptWorked; importDetail.EarningsCode = earningsCode.EarningsCode; importDetail.SvcAgmtContractCode = svcAgmtContractCode; //importDetail.TransactionDate = stopDateTime.ToSage100DateString(); // dch rkl 02/03/2017 Use Start Date as Tran Date DateTime dtTranDt; if (DateTime.TryParse(clockoutDate, out dtTranDt)) { importDetail.TransactionDate = dtTranDt.ToSage100DateString(); importDetail.TransactionDateAsDateTime = dtTranDt; } else { importDetail.TransactionDate = startDateTime.ToSage100DateString(); importDetail.TransactionDateAsDateTime = startDateTime; } //importDetail.TransactionDate = startDateTime.ToSage100DateString(); //importDetail.TransactionDateAsDateTime = startDateTime; importDetail.StartTime = startDateTime.ToSage100TimeString(); importDetail.EndTime = stopDateTime.ToSage100TimeString(); importDetail.HoursWorked = hoursWorked; // (stopDateTime - startDateTime).TotalHours; //bk adding hours billed and billing type importDetail.BillableHours = hoursBilled; importDetail.BillingType = billingType; importDetail.MeterReading = meterReading; importDetail.WorkPerformed = workPerformedText; importDetail.SvcAgmtContractCode = svcAgmtContractCode; // dch rkl 01/23/2017 Include Service Agreement Code rows = _database.Insert(importDetail); } }