protected async Task <bool> UpdateErpTechnicianStatus(JT_Technician technician) { bool result = false; switch (_dataConnectionType) { case ConnectionType.Rest: result = await UpdateTechnicianStatusToRestService(technician); break; case ConnectionType.SData: result = UpdateTechnicianStatusToSData(technician); break; default: break; } return(result); }
public TicketDetailsPageViewModel(App_ScheduledAppointment scheduledAppointment) { _scheduledAppointment = scheduledAppointment; _workTicket = App.Database.GetWorkTicket(_scheduledAppointment); _customer = App.Database.GetAppCustomer(_workTicket); _salesOrder = App.Database.GetSalesOrder(_workTicket, _customer); if (_workTicket.DtlRepairItemCode != null) { _repairItem = App.Database.GetItemFromDB(_workTicket.DtlRepairItemCode); } else { _repairItem = new CI_Item(); } JT_Technician jt_technician = App.Database.GetCurrentTechnicianFromDb(); _appTechnician = new App_Technician(jt_technician); AR_CustomerContact customerContact = App.Database.GetCustomerContact(_customer.ContactCode); _customerContact = new App_CustomerContact(customerContact); }
// dch rkl 11/1/2016 use textbox instead of datetime picker for times END // dch rkl 11/22/2016 if activity code changed, set department to default for this activity code // If the department for the activity code is null/blank, use the employee department private void pickerActivityCode_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Set the Department string sActivityCode = ""; if (pickerActivityCode.SelectedIndex > -1 && pickerActivityCode.SelectedValue != null) { sActivityCode = pickerActivityCode.SelectedValue.ToString(); } JT_ActivityCode activityCode = App.Database.GetActivityCodeFromDB(sActivityCode); if (activityCode != null && activityCode.DeptWorkedIn != null) { pickerDepartment.SelectedValue = activityCode.DeptWorkedIn; } else { JT_Technician tech = App.Database.GetCurrentTechnicianFromDb(); if (tech != null && tech.TechnicianDeptNo != null) { pickerDepartment.SelectedValue = tech.TechnicianDeptNo; } } // Determine if the Billable Dropdown is enabled // An activity code is considered billable when a misc item code is assigned to the activity code if (activityCode != null && activityCode.BillingMiscCode != null && activityCode.BillingMiscCode.Trim().Length > 0) { // When a billable activity code is assigned to the activity code, the billing status dropdown is enabled. pickerBillable.IsEnabled = true; SetBillable(); } else { // When a non-billable activity code is assigned to the activity code, the billing // status is disabled and set to no charge. pickerBillable.IsEnabled = false; pickerBillable.SelectedValue = "N"; } }
private void ButtonSave_Clicked(object sender, System.EventArgs e) { // dch rkl 10/17/2016 Device ID Required if (_vm.DeviceName == null) { DisplayAlert("Invalid Device Name", "A device name must be provided.", "OK"); return; } _vm.SaveAppSettings(); string techno = (_vm.LoggedInTechnicianNo != null) ? _vm.LoggedInTechnicianNo : ""; string techdeptno = (_vm.LoggedInTechnicianDeptNo != null) ? _vm.LoggedInTechnicianDeptNo : ""; JT_Technician technician = App.Database.GetTechnician(_vm.LoggedInTechnicianDeptNo, _vm.LoggedInTechnicianNo); // dch rkl 11/02/2016 If this is the initial setup, the technician table will not be loaded yet if (technician == null) { List <JT_Technician> technicians = App.Database.GetErpData <JT_Technician>("where", String.Format("TechnicianNo eq '{0}' and TechnicianDeptNo eq '{1}'", techno, techdeptno)); if (technicians.Count > 0) { technician = technicians[0]; } } if ((techdeptno.Length > 0 && techno.Length > 0) && technician == null) { DisplayAlert("Invalid Technician", "The technician you entered is not valid. Please check your entries and try again.", "OK"); return; } bool hasValidSetup = App.Database.HasValidSetup().Result; if (!hasValidSetup) { DisplayAlert("SETTINGS VERIFICATION FAILED", "These settings do not appear to work. Please check your Internet connection or verify your settings.", "OK"); return; } OnSettingsSaved(sender, e); }
public ClockOutPageViewModel(App_WorkTicket workTicket) { try { _currentTechnician = App.Database.GetCurrentTechnicianFromDb(); _workTicket = workTicket; _scheduleDetail = App.Database.RetrieveCurrentScheduleDetail(); _technicianStatusList = App.Database.GetTechnicianStatusesFromDB(); _serviceTicketStatusList = App.Database.GetAllWorkTicketStatusesFromDB().Where(x => x.CodeType == "ST").ToList(); //App.Database.GetAllWorkTicketStatusesFromDB().Where(wt => wt.MiscellaneousCode == "ST").ToList(); _earningsCodeList = App.Database.GetEarningsCodesFromDB(); _activityCodeList = App.Database.GetActivityCodesFromDB(); _erpOptions = App.Database.GetErpOptions(); // billable flags _billableList = new List <App_Billable>(); _billableList.Add(new App_Billable("B", "Billable")); _billableList.Add(new App_Billable("N", "Do Not Bill")); _billableList.Add(new App_Billable("X", "No Charge")); _departmentCodesList = App.Database.GetMiscellaneousCodesFromDB("M", "DP"); for (int i = 0; i < _departmentCodesList.Count; i++) { _departmentCodesList[i].Description = string.Format("{0} - {1}", _departmentCodesList[i].MiscellaneousCode, _departmentCodesList[i].Description); } // dch rkl 11/30/2016 allow blank department BEGIN JT_MiscellaneousCodes blankCode = new JT_MiscellaneousCodes(); blankCode.AddtlDescNum = ""; blankCode.CodeType = ""; blankCode.Description = ""; blankCode.MiscellaneousCode = ""; blankCode.RecordType = ""; _departmentCodesList.Add(blankCode); _departmentCodesList = _departmentCodesList.OrderBy(item => item.Description).ToList(); // dch rkl 11/30/2016 allow blank department END //}; } catch (Exception exception) { App.sendException(exception, "TechDashboard.ClockOutPageViewModel(App_Workticket)"); } }
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); }
void ButtonUpdateData_Clicked(object sender, EventArgs e) { JT_Technician currentTechnician = App.Database.GetCurrentTechnicianFromDb(); if (!App.Database.HasDataConnection()) { MessageBoxResult result = System.Windows.MessageBox.Show("No data connection presently, please check and try again.", "Connectivity Issue", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { return; } } else { App.Database.CreateGlobalTables(); // dch rkl 01/20/2017 After database is refreshed, reset current technician based on the latest values pulled from JobOps currentTechnician = App.Database.GetTechnician(currentTechnician.TechnicianDeptNo, currentTechnician.TechnicianNo); App.Database.SaveTechnicianAsCurrent(currentTechnician); App.Database.CreateDependentTables(currentTechnician); } //App.Database.CreateDependentTables(currentTechnician); }
/// <summary> /// Marks the given JT_Technician record as being the currently-selected /// technician by setting the IsCurrent flag on the local database record. /// </summary> /// <param name="technician">The JT_Technician object/record to mark as current.</param> public void SaveTechnicianAsCurrent(JT_Technician technician) { // dch rkl 12/08/2016 add try/catch to capture exception try { int rows = 0; lock (_locker) { // Unset any techs that are marked as "current" List <JT_Technician> currentTechnicians = _database.Table <JT_Technician>().Where(t => t.IsCurrent == true).ToList(); if (currentTechnicians.Count > 0) { foreach (JT_Technician technicianInList in currentTechnicians) { technicianInList.IsCurrent = false; } _database.UpdateAll(currentTechnicians); } // Set this tech as current. technician.IsCurrent = true; rows = _database.Update(technician); } if (rows > 0) { OnCurrentTechnicianChanged(EventArgs.Empty); } } catch (Exception ex) { //ErrorReporting oErrRpt = new Data.ErrorReporting(); App.sendException(ex, "TechDashboard.Data.TechDashboardDB_Technician.cs/SaveTechnicianAsCurrent"); } }
protected bool UpdateTechnicianStatusToSData(JT_Technician technician) { bool result = _sDataClient.UpdateTechnicianRecord(technician); return(result); }
protected async Task <bool> UpdateTechnicianStatusToRestService(JT_Technician technician) { bool result = await _restClient.UpdateTechnicianRecord(technician); return(result); }
public bool UpdateJT_Technician(JT_Technician technician) { return(UpdateTechnicianRecord(technician)); }
public MainWindow() { InitializeComponent(); btnSettings.Click += BtnSettings_Click; btnExpenses.Click += BtnExpenses_Click; btnSchedule.Click += BtnSchedule_Click; btnHistory.Click += BtnHistory_Click; btnMiscTime.Click += BtnMiscTime_Click; btnSync.Click += BtnSync_Click; btnTechnician.Click += BtnTechnician_Click; //btnSMS.Click += BtnSMS_Click; btnExit.Click += BtnExit_Click; App_Settings appSettings = App.Database.GetApplicationSettings(); // dch rkl 12/08/2016 Get Application Version and Compare to Current DB Version // If the versions do not match, they need to do a sync and refresh of their data System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string Buildversion = fvi.FileVersion; string dbVersion = appSettings.DbVersion.Substring(0, 5); // dch rkl 02/03/2017 Need more positions for version if (Buildversion != dbVersion) { bool bHasDataConnection = App.Database.HasDataConnection(); if (bHasDataConnection == false) { string sMsg = string.Format("WARNING: Your local database version is {0}, and your \napplication version is {1}. An internet connection is required \nto refresh your database schema, and is not currently present. Please log into the application when an internet connection \nis available so the sync and upgrade can be completed.", dbVersion, Buildversion); var result = MessageBox.Show(sMsg, "Database Update Required", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); Application.Current.Shutdown(); return; } else { string sMsg = string.Format("WARNING: Your local database version is {0}, and your \napplication version is {1}. A database Sync is required at this time. \nClick OK to continue with the upgrade, or Cancel to exit.\n \nIf OK is selected, any pending transactions will be sent to JobOps prior to sync.", dbVersion, Buildversion); var result = MessageBox.Show(sMsg, "Database Update Required", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); if (result == MessageBoxResult.Cancel) { Application.Current.Shutdown(); return; } else { // Send any JT_TransactionImportDetail records back to JobOps TransactionSync(); // Update local Data App.Database.CreateGlobalTables(); appSettings.DbVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); App.Database.SaveAppSettings(appSettings); } } } if (appSettings.LoggedInTechnicianNo != null) { if (appSettings.LoggedInTechnicianNo.Length > 0 && appSettings.LoggedInTechnicianDeptNo.Length > 0) { JT_Technician technician = App.Database.GetTechnician(appSettings.LoggedInTechnicianDeptNo, appSettings.LoggedInTechnicianNo); App.Database.SaveTechnicianAsCurrent(technician); if (App.Database.HasDataConnection()) { App.Database.CreateDependentTables(technician); } contentArea.Content = new SchedulePage(); } else { contentArea.Content = new TechnicianListPage(); } } else { contentArea.Content = new TechnicianListPage(); } contentArea.IsTabStop = false; // dch rkl 01/16/2017 Make sure the main window isn't a tab stop, and doesn't get selected. AddHandler(TechnicianListPage.SignedInEvent, new RoutedEventHandler(SignedInEventHandlerMethod)); AddHandler(SchedulePage.SelectedTicketEvent, new RoutedEventHandler(SelectedTicketEventHandlerMethod)); this.Closed += MainWindow_Closed; if (App.Database.GetCurrentTechnicianFromDb() == null) { btnTechnician.Visibility = Visibility.Collapsed; btnSchedule.Visibility = Visibility.Collapsed; btnHistory.Visibility = Visibility.Collapsed; btnMiscTime.Visibility = Visibility.Collapsed; btnExpenses.Visibility = Visibility.Collapsed; //btnSMS.Visibility = Visibility.Collapsed; btnSync.Visibility = Visibility.Collapsed; } }
public void FillDailyTimeEntryTable() { JT_Technician currentTechnician = GetCurrentTechnicianFromDb(); FillLocalTable <JT_DailyTimeEntry>("where", "(DepartmentNo eq '" + currentTechnician.TechnicianDeptNo + "') and (EmployeeNo eq '" + currentTechnician.TechnicianNo + "')"); // TODO filter }
/// <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); } }
protected async override void OnStart() { // Handle when your app starts bool hasValidSetup = false; App_Settings appSettings = App.Database.GetApplicationSettings(); string loggiedintechnicianno; JT_Technician technician = null; bool tableExists = false; try { hasValidSetup = await Database.HasValidSetup(appSettings); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); await MainPage.DisplayAlert("Error!", ex.Message, "OK"); throw; } tableExists = App.Database.TableExists <JT_Technician>(); // Are the settings valid? if (hasValidSetup) { // Yes, so move on to the technician login //App_Settings appSettings = App.Database.GetApplicatioinSettings(); loggiedintechnicianno = (appSettings.LoggedInTechnicianNo != null) ? appSettings.LoggedInTechnicianNo : ""; if (tableExists && loggiedintechnicianno.Length > 0) // we've already established we do && Database.HasDataConnection()) { technician = App.Database.GetTechnician(appSettings.LoggedInTechnicianDeptNo, appSettings.LoggedInTechnicianNo); if (technician != null) { App.Database.SaveTechnicianAsCurrent(technician); App.Database.CreateDependentTables(technician); MainPage = new MainDashboard(); } else { if (Database.HasDataConnection()) { Database.CreateGlobalTables(); } Thread.Sleep(5000); TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel(); viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged; MainPage = new TechnicianListPage(viewModel); } } else { if (Database.HasDataConnection()) { Database.CreateGlobalTables(); } Thread.Sleep(5000); TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel(); viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged; MainPage = new TechnicianListPage(viewModel); } } else { // Invalid settings, so show the settings page. // Otherwise, data calls will never work. AppSettingsPage settingsPage = new AppSettingsPage(); settingsPage.SettingsSaved += AppSettingsPage_SettingsSaved; MainPage = settingsPage; return; } }
/// <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); } }
public ClockOutPage(App_WorkTicket workTicket) { // Set the page title. //Title = "Clock Out"; _vm = new ClockOutPageViewModel(workTicket); Color asbestos = Color.FromHex("#7f8c8d"); BackgroundColor = Color.White; _labelTitle = new Xamarin.Forms.Label(); _labelTitle.Text = "CLOCK OUT"; _labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); _labelTitle.FontSize = 22; _labelTitle.TextColor = Color.White; _labelTitle.HorizontalTextAlignment = TextAlignment.Center; _labelTitle.VerticalTextAlignment = TextAlignment.Center; Grid titleLayout = new Grid() { BackgroundColor = Color.FromHex("#2980b9"), HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(_labelTitle, 0, 0); Label lblServiceTicket = new Label(); lblServiceTicket.TextColor = asbestos; lblServiceTicket.Text = _vm.ScheduleDetail.ServiceTicketNumber; JT_Technician technician = App.Database.GetCurrentTechnicianFromDb(); Label lblEmployeeNo = new Label(); lblEmployeeNo.TextColor = asbestos; lblEmployeeNo.Text = technician.FormattedTechnicianNo; //_vm.CurrentTechnician.FormattedTechnicianNo; Label lblEmployeeName = new Label(); lblEmployeeName.TextColor = asbestos; lblEmployeeName.Text = string.Format("{0} {1}", technician.FirstName, technician.LastName); //_vm.CurrentTechnician.FirstName + " " + _vm.CurrentTechnician.LastName; Grid clockoutLayout = new Grid(); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); clockoutLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); clockoutLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); clockoutLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); clockoutLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); // service ticket line clockoutLayout.Children.Add(new Label() { Text = "Service Ticket", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 0); Grid.SetColumnSpan(lblServiceTicket, 3); clockoutLayout.Children.Add(lblServiceTicket, 1, 0); // employee number clockoutLayout.Children.Add(new Label() { Text = "Employee Number", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 1); clockoutLayout.Children.Add(lblEmployeeNo, 1, 1); clockoutLayout.Children.Add(lblEmployeeName, 2, 1); // checks switches Switch switchWarrantyRepair = new Switch() { IsEnabled = false }; if (_vm.WorkTicket.DtlWarrantyRepair == "Y") { switchWarrantyRepair.IsToggled = true; } clockoutLayout.Children.Add(new Label() { Text = "Warranty Repair", TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), FontSize = 12 }, 0, 2); clockoutLayout.Children.Add(switchWarrantyRepair, 1, 2); bool isChkd = false; switchLaborCoveredWarranty = new Switch() { IsEnabled = false }; if (_vm.WorkTicket.StatusDate != null && _vm.WorkTicket.RepairItem.MfgLaborWarrantyPeriod != null) { TimeSpan tsDateDiff = _vm.WorkTicket.RepairItem.MfgLaborWarrantyPeriod.Subtract(_vm.WorkTicket.StatusDate); if (tsDateDiff.TotalDays > 0 && _vm.WorkTicket.DtlWarrantyRepair == "Y") { switchLaborCoveredWarranty.IsToggled = true; isChkd = true; } } if (_vm.WorkTicket.StatusDate != null && _vm.WorkTicket.RepairItem.IntLaborWarrantyPeriod != null) { TimeSpan tsDateDiff = _vm.WorkTicket.RepairItem.IntLaborWarrantyPeriod.Subtract(_vm.WorkTicket.StatusDate); if (tsDateDiff.TotalDays > 0 && _vm.WorkTicket.DtlWarrantyRepair == "Y") { switchLaborCoveredWarranty.IsToggled = true; isChkd = true; } } clockoutLayout.Children.Add(new Label() { Text = "Labor Covered on Warranty", TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), FontSize = 12 }, 2, 2); clockoutLayout.Children.Add(switchLaborCoveredWarranty, 3, 2); Switch switchServiceAgreementRepair = new Switch() { IsEnabled = false }; if (_vm.WorkTicket.DtlCoveredOnContract == "Y") { switchServiceAgreementRepair.IsToggled = true; } clockoutLayout.Children.Add(new Label() { Text = "Svc Agmt Repair", TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), FontSize = 12 }, 0, 3); clockoutLayout.Children.Add(switchServiceAgreementRepair, 1, 3); switchLaborCoveredSvcAgreement = new Switch() { IsEnabled = false }; if (_vm.WorkTicket.IsPreventativeMaintenance && _vm.WorkTicket.ServiceAgreement.IsPMLaborCovered) { switchLaborCoveredSvcAgreement.IsToggled = true; } else if (_vm.WorkTicket.IsPreventativeMaintenance == false && _vm.WorkTicket.IsServiceAgreementRepair && _vm.WorkTicket.ServiceAgreement.IsLaborCovered) { switchLaborCoveredSvcAgreement.IsToggled = true; } clockoutLayout.Children.Add(new Label() { Text = "Labor Covered on Svc Agmt", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), FontSize = 12, TextColor = asbestos }, 2, 3); clockoutLayout.Children.Add(switchLaborCoveredSvcAgreement, 3, 3); // date part of the grid _pickerBillable = new BindablePicker(); _pickerBillable.ItemsSource = _vm.BillableList; _pickerBillable.SelectedIndexChanged += _pickerBillable_SelectedIndexChanged; DateTime dtStartDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _vm.StartTime; _pickerStartDate = new DatePicker(); _pickerStartDate.Date = technician.CurrentStartDate; //_vm.CurrentTechnician.CurrentStartDate; _pickerStartTime = new TimePicker(); _pickerStartTime.Time = _vm.StartTime; _pickerStartTime.IsEnabled = false; clockoutLayout.Children.Add(new Label() { Text = "Start Time", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 4); clockoutLayout.Children.Add(_pickerStartDate, 1, 4); clockoutLayout.Children.Add(_pickerStartTime, 2, 4); _pickerDepartDate = new DatePicker(); _pickerDepartDate.Date = DateTime.Now; _pickerDepartTime = new TimePicker { Time = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second) }; _pickerDepartTime.Unfocused += PickerDepartTime_Unfocused; if (App.Database.GetApplicationSettings().TwentyFourHourTime) { _pickerStartTime.Format = "HH:mm"; _pickerDepartTime.Format = "HH:mm"; } //if (_pickerStartTime.Time != null && _pickerDepartTime.Time != null) { // SetHoursBilled(); //} clockoutLayout.Children.Add(new Label() { Text = "Depart Time", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 5); clockoutLayout.Children.Add(_pickerDepartDate, 1, 5); clockoutLayout.Children.Add(_pickerDepartTime, 2, 5); //hours worked clockoutLayout.Children.Add(new Label() { Text = "Hours Worked", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 6); _editorHoursWorked = new Editor(); _editorHoursWorked.Text = Math.Round((_pickerDepartTime.Time - _pickerStartTime.Time).TotalHours, 2).ToString(); _editorHoursWorked.Keyboard = Keyboard.Numeric; _editorHoursWorked.IsEnabled = false; clockoutLayout.Children.Add(_editorHoursWorked, 1, 6); Grid.SetColumnSpan(_pickerBillable, 2); _pickerBillable.SetBinding(BindablePicker.DisplayPropertyProperty, "BillableDesc"); clockoutLayout.Children.Add(_pickerBillable, 2, 6); //hours billed clockoutLayout.Children.Add(new Label() { Text = "Billable Hours", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 7); _editorHoursBilled = new Editor(); _editorHoursBilled.Text = Math.Round((_pickerDepartTime.Time - _pickerStartTime.Time).TotalHours, 2).ToString(); _editorHoursBilled.Keyboard = Keyboard.Numeric; clockoutLayout.Children.Add(_editorHoursBilled, 1, 7); clockoutLayout.Children.Add(new Label() { Text = "Ref Rate", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 2, 7); _editorRefRate = new Editor() { IsEnabled = false }; clockoutLayout.Children.Add(_editorRefRate, 3, 7); // rates clockoutLayout.Children.Add(new Label() { Text = "Billable Rate", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 8); _editorBillableRate = new Editor() { IsEnabled = false }; clockoutLayout.Children.Add(_editorBillableRate, 1, 8); clockoutLayout.Children.Add(new Label() { Text = "Billable Amount", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 2, 8); _editorBillableAmount = new Editor() { IsEnabled = false }; clockoutLayout.Children.Add(_editorBillableAmount, 3, 8); _pickerTechnicianStatus = new BindablePicker { Title = "Technician Status", ItemsSource = _vm.TechnicianStatusList }; _pickerTechnicianStatus.SetBinding(BindablePicker.DisplayPropertyProperty, "StatusDescription"); for (int i = 0; i < _pickerTechnicianStatus.Items.Count; i++) { if (_pickerTechnicianStatus.Items[i] == _vm.DefaultDepartStatusCodeDescription) { _pickerTechnicianStatus.SelectedIndex = i; break; } } clockoutLayout.Children.Add(new Label() { Text = "Technician Status", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 9); Grid.SetColumnSpan(_pickerTechnicianStatus, 3); clockoutLayout.Children.Add(_pickerTechnicianStatus, 1, 9); _pickerTicketStatus = new BindablePicker { Title = "Service Ticket Status", ItemsSource = _vm.ServiceTicketStatusList }; _pickerTicketStatus.SetBinding(BindablePicker.DisplayPropertyProperty, "Description"); /*for (int i = 0; i < _pickerTicketStatus.Items.Count; i++) { * if (_pickerTicketStatus.Items[i].Substring(0, 3) == _vm.DefaultServiceTicketStatusCode) { * _pickerTicketStatus.SelectedIndex = i; * break; * } * }*/ clockoutLayout.Children.Add(new Label() { Text = "Ticket Status", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 10); Grid.SetColumnSpan(_pickerTicketStatus, 3); clockoutLayout.Children.Add(_pickerTicketStatus, 1, 10); _pickerActivityCode = new BindablePicker { Title = "Activity Code", ItemsSource = _vm.ActivityCodeList }; _pickerActivityCode.SetBinding(BindablePicker.DisplayPropertyProperty, "ActivityDescription"); for (int i = 0; i < _pickerActivityCode.Items.Count; i++) { if (_pickerActivityCode.Items[i] == _vm.DefaultActivityCode) { _pickerActivityCode.SelectedIndex = i; break; } } clockoutLayout.Children.Add(new Label() { Text = "Activity Code", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 11); Grid.SetColumnSpan(_pickerActivityCode, 3); clockoutLayout.Children.Add(_pickerActivityCode, 1, 11); _pickerDepartment = new BindablePicker { Title = "Department", ItemsSource = _vm.DepartmentCodesList }; _pickerDepartment.SetBinding(BindablePicker.DisplayPropertyProperty, "MiscellaneousCode"); JT_ActivityCode dfltActCode = new JT_ActivityCode(); if (_vm.DefaultActivityCode != null) { dfltActCode = App.Database.GetActivityCodeFromDB(_vm.DefaultActivityCode); } if (dfltActCode != null) { for (int i = 0; i < _pickerDepartment.Items.Count; i++) { if (_pickerDepartment.Items[i] == dfltActCode.DeptWorkedIn) { _pickerDepartment.SelectedIndex = i; break; } } } clockoutLayout.Children.Add(new Label() { Text = "Department", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 12); Grid.SetColumnSpan(_pickerDepartment, 3); clockoutLayout.Children.Add(_pickerDepartment, 1, 12); _pickerEarningsCode = new BindablePicker { Title = "Earnings Code", ItemsSource = _vm.EarningsCodeList }; _pickerEarningsCode.SetBinding(BindablePicker.DisplayPropertyProperty, "EarningsDeductionDesc"); /*for (int i = 0; i < _pickerEarningsCode.Items.Count; i++) { * if (_pickerEarningsCode.Items[i] == _vm.DefaultEarningCode) { * _pickerEarningsCode.SelectedIndex = i; * break; * } * }*/ clockoutLayout.Children.Add(new Label() { Text = "Earnings Code", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 13); Grid.SetColumnSpan(_pickerEarningsCode, 3); clockoutLayout.Children.Add(_pickerEarningsCode, 1, 13); _editorMeterReading = new Editor(); _editorMeterReading.Keyboard = Keyboard.Numeric; _editorMeterReading.HeightRequest = 100; _editorMeterReading.IsEnabled = _vm.IsRepairItemAnEquipmentAsset; clockoutLayout.Children.Add(new Label() { Text = "Meter Reading", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 14); Grid.SetColumnSpan(_editorMeterReading, 3); clockoutLayout.Children.Add(_editorMeterReading, 1, 14); _editorWorkPerformed = new Editor(); _editorWorkPerformed.HeightRequest = 100; _editorWorkPerformed.TextChanged += EditorWorkPerformed_TextChanged; clockoutLayout.Children.Add(new Label() { Text = "Work Performed", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = asbestos }, 0, 15); Grid.SetColumnSpan(_editorWorkPerformed, 3); clockoutLayout.Children.Add(_editorWorkPerformed, 1, 15); // create a "clock out" button to go back Xamarin.Forms.Button buttonClockOut = new Button() { Text = "Clock Out", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = Color.White, BackgroundColor = asbestos, HorizontalOptions = LayoutOptions.FillAndExpand }; buttonClockOut.Clicked += ButtonClockOut_Clicked; // create a "cancel" button to go back Xamarin.Forms.Button buttonCancel = new Button() { Text = "Cancel", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = Color.White, BackgroundColor = Color.FromHex("#E74C3C"), HorizontalOptions = LayoutOptions.FillAndExpand }; buttonCancel.Clicked += buttonCancel_Clicked; Content = new StackLayout { Children = { titleLayout, new StackLayout { Orientation = StackOrientation.Vertical, Padding = 30, Children = { clockoutLayout, buttonClockOut, buttonCancel } } } }; }
public bool UpdateJT_Technician([FromBody] JT_Technician technician) { return(tdws.UpdateJT_Technician(technician)); }
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(); }
public void CreateDependentTables(JT_Technician technician) { // The below file checking code is throwing an exception in the Android version because // assembly.Location does not contain the full path of the file, and a FileNotFound exception // occurs. Since we aren't doing anything with the file version info anyway, I commented it all out. // (GJH 2016-09-23) //add a modicum of version checking //System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); //FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); //string version = fvi.FileVersion; //decimal versionNo = Convert.ToDecimal(version.Substring(0, 3)); //ci options are now crucial, so if (!TableExists <CI_Options>()) { _database.CreateTable <CI_Options>(); FillCIOptions(); } try { _database.DropTable <JT_TechnicianScheduleDetail>(); } catch { } try { _database.DropTable <SO_SalesOrderHeader>(); } catch { } try { _database.DropTable <SO_ShipToAddress>(); } catch { } try { _database.DropTable <SO_SalesOrderDetail>(); } catch { } try { _database.DropTable <JT_WorkTicket>(); } catch { } try { _database.DropTable <JT_WorkTicketText>(); } catch { } try { _database.DropTable <JT_WorkTicketClass>(); } catch { } try { _database.DropTable <JT_WorkTicketHistory>(); } catch { } try { _database.DropTable <AR_Customer>(); } catch { } try { _database.DropTable <AR_CustomerContact>(); } catch { } try { _database.DropTable <JT_ServiceEquipmentParts>(); } catch { } //try { _database.DropTable<JT_DailyTimeEntry>(); } catch { } try { _database.DropTable <JT_EquipmentAsset>(); } catch { } try { _database.DropTable <JT_ServiceAgreementHeader>(); } catch { } try { _database.DropTable <JT_ServiceAgreementDetail>(); } catch { } try { _database.DropTable <JT_ServiceAgreementPMDetail>(); } catch { } try { _database.DropTable <JT_WorkTicketClass>(); } catch { } try { _database.DropTable <JT_Transaction>(); } catch { } try { _database.DropTable <JT_TransactionHistory>(); } catch { } try { _database.DropTable <JT_LaborText>(); } catch { } // dch rkl 01/13/2017 add CI_ExtendedDescription try { _database.DropTable <CI_ExtendedDescription>(); } catch { } if (!TableExists <JT_TransactionImportDetail>()) { try { _database.DropTable <JT_TransactionImportDetail>(); } catch { } _database.CreateTable <JT_TransactionImportDetail>(); } else { // dch rkl 11/30/2016 // When data is pulled back from JobOps, remove any parts records in JT_TransactionImportDetail where // quantity used is zero. These are the default parts, and they will get reloaded when the parts // screen is accessed for a ticket. This will allow any changes in the Sales Order Detail table // for the default parts to get refreshed. List <JT_TransactionImportDetail> lsTrans = _database.Table <JT_TransactionImportDetail>().Where( wt => (wt.RecordType == "P" && wt.QuantityUsed == 0)).ToList <JT_TransactionImportDetail>(); foreach (JT_TransactionImportDetail tranDtl in lsTrans) { DeleteExportRow(tranDtl); } } if (!TableExists <JT_DailyTimeEntry>()) { try { _database.DropTable <JT_DailyTimeEntry>(); } catch { } _database.CreateTable <JT_DailyTimeEntry>(); } //for later versions, check to see if these tables exist if (!TableExists <IM_ItemCost>()) { try { _database.DropTable <IM_ItemCost>(); } catch { } _database.CreateTable <IM_ItemCost>(); } // Next, create the tables _database.CreateTable <JT_TechnicianScheduleDetail>(); _database.CreateTable <SO_SalesOrderHeader>(); _database.CreateTable <SO_SalesOrderDetail>(); _database.CreateTable <SO_ShipToAddress>(); _database.CreateTable <JT_WorkTicket>(); _database.CreateTable <JT_WorkTicketText>(); _database.CreateTable <JT_WorkTicketHistory>(); _database.CreateTable <JT_WorkTicketClass>(); _database.CreateTable <AR_Customer>(); _database.CreateTable <AR_CustomerContact>(); _database.CreateTable <JT_ServiceEquipmentParts>(); //_database.CreateTable<JT_DailyTimeEntry>(); _database.CreateTable <JT_EquipmentAsset>(); _database.CreateTable <JT_ServiceAgreementHeader>(); _database.CreateTable <JT_ServiceAgreementDetail>(); _database.CreateTable <JT_ServiceAgreementPMDetail>(); _database.CreateTable <JT_WorkTicketClass>(); _database.CreateTable <JT_TransactionHistory>(); _database.CreateTable <JT_Transaction>(); _database.CreateTable <JT_LaborText>(); // dch rkl 01/13/2017 add CI_ExtendedDescription _database.CreateTable <CI_ExtendedDescription>(); try { // Fill the tables with data. FillTechnicianScheduleDetailTable(technician.TechnicianNo); FillWorkTicketTable(); // dch rkl 01/20/2017 This is done as part of work ticket load //FillWorkTicketTextTable(); FillSalesOrderHeaderTable(); FillShipToAddressTable(); FillSalesOrderDetails(); FillItemCostTable(); FillCustomerTable(); FillCustomerContactTable(); FillServiceEquipmentPartsTable(); FillDailyTimeEntryTable(); //FillExpensesTableFromSdata(); TODO... not implemented yet. FillEquipmentAssetTable(); FillServiceAgreementHeaderTable(); FillWorkTicketClassTable(); FillTransactionTable(); FillTransactionHistoryTable(); FillLaborTextTable(); // dch rkl 01/13/2017 add CI_ExtendedDescription FillExtendedDescriptionTable(); } catch (Exception exception) { Console.Write(exception); } }
private async void BtnSaveAppSettings_Click(object sender, RoutedEventArgs e) { _saved = true; // dch rkl 10/26/2016 OnSettingsSaved(sender, e); btnSaveAppSettings.IsEnabled = false; btnSaveAppSettings.Content = "SAVING..."; _vm.SaveAppSettings(); //check for valid technician string techno = (_vm.LoggedInTechnicianNo != null) ? _vm.LoggedInTechnicianNo : ""; string techdeptno = _vm.LoggedInTechnicianDeptNo != null ? _vm.LoggedInTechnicianDeptNo : ""; JT_Technician technician = App.Database.GetTechnician(_vm.LoggedInTechnicianDeptNo, _vm.LoggedInTechnicianNo); // dch rkl 10/12/2016 if the technician is null, try querying directly // TODO pass technician filter in so loop is not necessary if (technician == null && techdeptno.Length > 0) { List <JT_Technician> technicians = App.Database.GetErpData <JT_Technician>(string.Empty, string.Empty); if (technicians != null && technicians.Count > 0) { foreach (JT_Technician tech in technicians) { if (tech.TechnicianNo == techno && tech.TechnicianDeptNo == techdeptno) { technician = tech; break; } } } } if ((techdeptno.Length > 0 && techno.Length > 0) && technician == null) { var result = MessageBox.Show("The technician you entered is not valid. Please check your entries and try again.", "Invalid Technician", MessageBoxButton.OK); btnSaveAppSettings.IsEnabled = true; btnSaveAppSettings.Content = "SAVE SETTINGS"; return; } //bool hasValidSetup = await App.Database.HasValidSetup(); bool hasValidSetup = App.Database.HasValidSetup(); if (!hasValidSetup) { var result = MessageBox.Show("These settings do not appear to work. Please check your Internet connection or verify your settings.", "SETTINGS VERIFICATION FAILED", MessageBoxButton.OK); btnSaveAppSettings.IsEnabled = true; btnSaveAppSettings.Content = "SAVE SETTINGS"; return; } else { App.Database.CreateGlobalTables(); // dch rkl 10/26/2016 _parent = new WPF.MainWindow(); //MainWindow mainWindow = new MainWindow(); //mainWindow.Show(); this.Close(); } }
protected void InitializePage() { // Create a label for the technician list Label _labelTitle = new Label(); _labelTitle.Content = "CLOCK IN"; _labelTitle.FontWeight = FontWeights.Bold; _labelTitle.Foreground = new SolidColorBrush(Colors.White); _labelTitle.HorizontalAlignment = HorizontalAlignment.Center; _labelTitle.VerticalAlignment = VerticalAlignment.Center; _labelTitle.FontSize = 18; // dch rkl 10/26/2016 Grid titleLayout = new Grid() { Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3498db")), HorizontalAlignment = HorizontalAlignment.Stretch, Height = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(_labelTitle); Grid.SetColumn(_labelTitle, 0); Grid.SetRow(_labelTitle, 0); //Xamarin.Forms.Label mainLabel = new Xamarin.Forms.Label { Text = "CLOCK IN", FontFamily = Device.OnPlatform("OpenSans-Bold",null,null), TextColor = asbestos }; Label labelTime = new Label() { HorizontalAlignment = HorizontalAlignment.Left, // dch rkl 10/26/2016 Content = "Arrival Time", FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7F8C8D")) }; // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN _textArriveTime = new TextBox(); if (App.Database.GetApplicationSettings().TwentyFourHourTime) { _textArriveTime.Text = DateTime.Now.ToString("HH:mm"); } else { _textArriveTime.Text = DateTime.Now.ToString("hh:mm tt"); } _textArriveTime.Width = 60; _textArriveTime.HorizontalAlignment = HorizontalAlignment.Left; _textArriveTime.LostFocus += textArriveTime_LostFocus; _textArriveTime.GotFocus += textArriveTime_GotFocus; // dch rkl 11/22/2016 on focus on time, select all text Label labelTechStatus = new Label() { Content = "Technician Status", FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7F8C8D")) }; _pickerTechnicianStatus = new ComboBox { ItemsSource = _vm.TechnicianStatusList, DisplayMemberPath = "StatusDescription", Width = 250 // dch rkl 10/26/2016 }; // dch rkl 01/16/2017 If there is no value for the Default Arrive Status Code, use the technician's current status BEGIN string arriveCode = _vm.DefaultArriveStatusCode; if (arriveCode.Trim().Length == 0) { JT_Technician tech = App.Database.GetCurrentTechnicianFromDb(); arriveCode = tech.CurrentStatus; } // dch rkl 01/16/2017 If there is no value for the Default Arrive Status Code, use the technician's current status END for (int i = 0; i < _pickerTechnicianStatus.Items.Count; i++) { // dch rkl 01/16/2017 If there is no value for the Default Arrive Status Code, use the technician's current status BEGIN //if (((JT_TechnicianStatus)_pickerTechnicianStatus.Items[i]).StatusDescription == _vm.DefaultArriveStatusCodeDescription) if (((JT_TechnicianStatus)_pickerTechnicianStatus.Items[i]).StatusCode == arriveCode) // dch rkl 01/16/2017 If there is no value for the Default Arrive Status Code, use the technician's current status END { _pickerTechnicianStatus.SelectedIndex = i; break; } } Label labelTicketStatus = new Label() { Content = "Ticket Status", FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7F8C8D")) }; _pickerTicketStatus = new ComboBox { ItemsSource = _vm.ServiceTicketStatusList, DisplayMemberPath = "Description", Width = 250 // dch rkl 10/26/2016 }; // dch rkl 10/31/2016 If _vm.DefaultServiceTicketArriveStatusCodeDescription is null, set clock in // status to service ticket status. Per Jeanne Jackson if (_vm.DefaultServiceTicketArriveStatusCodeDescription == null) { App_WorkTicket workTicket = App.Database.GetWorkTicket(_scheduleDetail); if (workTicket != null) { for (int i = 0; i < _pickerTicketStatus.Items.Count; i++) { if (((JT_MiscellaneousCodes)_pickerTicketStatus.Items[i]).MiscellaneousCode == workTicket.StatusCode) { _pickerTicketStatus.SelectedIndex = i; break; } } } } else { for (int i = 0; i < _pickerTicketStatus.Items.Count; i++) { if (((JT_MiscellaneousCodes)_pickerTicketStatus.Items[i]).Description == _vm.DefaultServiceTicketArriveStatusCodeDescription) { _pickerTicketStatus.SelectedIndex = i; break; } } } // dch rkl 10/26/2016 make the button look like the rest of the buttons in the app BEGIN Button buttonClockIn = new Button() { Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2ECC71")), BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2ECC71")), HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(30, 5, 30, 0), Height = 40 }; TextBlock clockInText = new TextBlock() { Text = "CLOCK IN", Foreground = new SolidColorBrush(Colors.White), FontWeight = FontWeights.Bold }; // dch rkl 10/26/2016 make the button look like the rest of the buttons in the app END buttonClockIn.Content = clockInText; buttonClockIn.Click += ButtonClockIn_Clicked; // dch rkl 10/26/2016 create a "cancel" button to go back BEGIN Button buttonCancel = new Button() { Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E74C3C")), BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E74C3C")), HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(30, 5, 30, 5), Height = 40 }; TextBlock cancelText = new TextBlock() { Text = "CANCEL", FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; buttonCancel.Content = cancelText; buttonCancel.Click += buttonCancel_Clicked; // dch rkl 10/26/2016 create a "cancel" button to go back END // dch rkl 10/26/2016 format the grid for arrival time, technician status and ticket status BEGIN Grid topGrid = new Grid(); topGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); topGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); topGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); topGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(150, GridUnitType.Pixel) }); topGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); topGrid.Children.Add(labelTime); Grid.SetColumn(labelTime, 0); Grid.SetRow(labelTime, 0); // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN //topGrid.Children.Add(_pickerArriveTime); //Grid.SetColumn(_pickerArriveTime, 1); //Grid.SetRow(_pickerArriveTime, 0); topGrid.Children.Add(_textArriveTime); Grid.SetColumn(_textArriveTime, 1); Grid.SetRow(_textArriveTime, 0); // dch rkl 11/1/2016 use textbox instead of datetime picker for times END topGrid.Children.Add(labelTechStatus); Grid.SetColumn(labelTechStatus, 0); Grid.SetRow(labelTechStatus, 1); topGrid.Children.Add(_pickerTechnicianStatus); Grid.SetColumn(_pickerTechnicianStatus, 1); Grid.SetRow(_pickerTechnicianStatus, 1); topGrid.Children.Add(labelTicketStatus); Grid.SetColumn(labelTicketStatus, 0); Grid.SetRow(labelTicketStatus, 2); topGrid.Children.Add(_pickerTicketStatus); Grid.SetColumn(_pickerTicketStatus, 1); Grid.SetRow(_pickerTicketStatus, 2); // dch rkl 10/26/2016 format the grid for arrival time, technician status and ticket status END gridMain.Children.Add(new StackPanel { Children = { titleLayout, new StackPanel { Margin = new Thickness(30), Children = { //labelTime, //_pickerArriveTime, //labelTechStatus, //_pickerTechnicianStatus, //labelTicketStatus, //_pickerTicketStatus, topGrid, // dch rkl 10/26/2016 buttonClockIn , buttonCancel // dch rkl 10/26/2016 add cancel button } } } }); }
protected void InitializePage() { StackPanel stackLayout = new StackPanel(); //stackLayout.BackgroundColor = Color.FromHex ("#bcd5d1"); SolidColorBrush asbestos = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7f8c8d")); Label labelModalTitle = new Label() { //FontAttributes = FontAttributes.Bold, FontSize = 18, Content = "SCHEDULE DETAILS", FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Grid titleLayout = new Grid() { Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3498DB")), HorizontalAlignment = HorizontalAlignment.Stretch, Height = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(labelModalTitle); Grid.SetColumn(labelModalTitle, 0); Grid.SetRow(labelModalTitle, 0); stackLayout.Children.Add(titleLayout); Grid grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); Label labelScheduledTitle = new Label() { //FontAttributes = FontAttributes.Bold, Foreground = asbestos, FontWeight = FontWeights.Bold, Content = "Scheduled" }; grid.Children.Add(labelScheduledTitle); Grid.SetColumn(labelScheduledTitle, 1); Grid.SetRow(labelScheduledTitle, 0); Label labelActualTitle = new Label() { //FontAttributes = FontAttributes.Bold, Foreground = asbestos, FontWeight = FontWeights.Bold, Content = "Actual" }; grid.Children.Add(labelActualTitle); Grid.SetColumn(labelActualTitle, 2); Grid.SetRow(labelActualTitle, 0); Label labelDateTitle = new Label(); labelDateTitle.Content = "Date"; //labelDateTitle.FontAttributes = FontAttributes.Bold; labelDateTitle.FontWeight = FontWeights.Bold; labelDateTitle.Foreground = asbestos; grid.Children.Add(labelDateTitle); Grid.SetColumn(labelDateTitle, 0); Grid.SetRow(labelDateTitle, 1); Label labelStartTimeTitle = new Label(); labelStartTimeTitle.Content = "Start Time"; //labelStartTimeTitle.FontAttributes = FontAttributes.Bold; labelStartTimeTitle.Foreground = asbestos; labelStartTimeTitle.FontWeight = FontWeights.Bold; grid.Children.Add(labelStartTimeTitle); Grid.SetColumn(labelStartTimeTitle, 0); Grid.SetRow(labelStartTimeTitle, 2); Label labelEndTimetitle = new Label(); labelEndTimetitle.Content = "End Time"; //labelEndTimetitle.FontAttributes = FontAttributes.Bold; labelEndTimetitle.Foreground = asbestos; labelEndTimetitle.FontWeight = FontWeights.Bold; grid.Children.Add(labelEndTimetitle); Grid.SetColumn(labelEndTimetitle, 0); Grid.SetRow(labelEndTimetitle, 3); Label labelDurationTitle = new Label(); labelDurationTitle.Content = "Duration"; labelDurationTitle.Foreground = asbestos; labelDurationTitle.FontWeight = FontWeights.Bold; grid.Children.Add(labelDurationTitle); Grid.SetColumn(labelDurationTitle, 0); Grid.SetRow(labelDurationTitle, 4); Label labelScheduledDate = new Label() { Content = _vm.ScheduleDetail.ScheduleDate.ToShortDateString(), Foreground = asbestos }; grid.Children.Add(labelScheduledDate); Grid.SetColumn(labelScheduledDate, 1); Grid.SetRow(labelScheduledDate, 1); Label labelScheduledStartTime = new Label() { // dch rkl 10/12/2016 show formatted time //Content = _vm.ScheduleDetail.StartTime, Content = _vm.ScheduleDetail.StartTimeFormatted, Foreground = asbestos }; grid.Children.Add(labelScheduledStartTime); Grid.SetColumn(labelScheduledStartTime, 1); Grid.SetRow(labelScheduledStartTime, 2); schedStartTime = _vm.ScheduleDetail.StartTime; // dch rkl 10/31/2016 Label labelScheduledEndTime = new Label() { // dch rkl 10/12/2016 show formatted time //Content = _vm.ScheduleDetail.EndTime, Content = _vm.ScheduleDetail.EndTimeFormatted, Foreground = asbestos }; grid.Children.Add(labelScheduledEndTime); Grid.SetColumn(labelScheduledEndTime, 1); Grid.SetRow(labelScheduledEndTime, 3); schedEndTime = _vm.ScheduleDetail.EndTime; // dch rkl 10/31/2016 Label labelActualDate = new Label() { Foreground = asbestos }; // dch rkl 02/03/2017 define this here Label labelActualEndTime = new Label() { Foreground = asbestos, Content = "" }; Label labelActualStartTime = new Label() { Content = "", Foreground = asbestos }; if (_vm.TimeEntryDetail != null) { labelActualDate.Content = _vm.TimeEntryDetail.TransactionDate.ToShortDateString(); } grid.Children.Add(labelActualDate); Grid.SetColumn(labelActualDate, 2); Grid.SetRow(labelActualDate, 1); bool bStartTimeSet = false; // dch rkl 10/14/2016 Get Start Time from the Technician Record if (_vm.ImportDetail != null) { if (_vm.ImportDetail.StartTime != null) { labelActualStartTime.Content = FormattedTime(_vm.TimeEntryDetail.StartTime); //Label labelActualStartTime = new Label() //{ // Content = FormattedTime(_vm.TimeEntryDetail.StartTime), // Foreground = asbestos //}; actStartTime = _vm.TimeEntryDetail.StartTime; // dch rkl 10/31/2016 grid.Children.Add(labelActualStartTime); Grid.SetColumn(labelActualStartTime, 2); Grid.SetRow(labelActualStartTime, 2); bStartTimeSet = true; // dch rkl 10/14/2016 Get Start Time from the Technician Record } if (_vm.ImportDetail.EndTime != null) { labelActualEndTime.Content = FormattedTime(_vm.TimeEntryDetail.EndTime); //Label labelActualEndTime = new Label() //{ // Content = FormattedTime(_vm.TimeEntryDetail.EndTime), // Foreground = asbestos //}; grid.Children.Add(labelActualEndTime); Grid.SetColumn(labelActualEndTime, 2); Grid.SetRow(labelActualEndTime, 3); actEndTime = _vm.TimeEntryDetail.EndTime; // dch rkl 10/31/2016 } } // dch rkl 01/12/2017 If Actual End Time is blank, use current date BEGIN else { labelActualEndTime.Content = FormattedTime(DateTime.Now.ToString("hh:mm tt")); //Label labelActualEndTime = new Label() //{ // Content = FormattedTime(DateTime.Now.ToString("hh:mm tt")), // Foreground = asbestos //}; grid.Children.Add(labelActualEndTime); Grid.SetColumn(labelActualEndTime, 2); Grid.SetRow(labelActualEndTime, 3); actEndTime = DateTime.Now.ToString("hhmm"); } // dch rkl 01/12/2017 If Actual End Time is blank, use current date END // dch rkl 10/14/2016 Get Start Time from the Technician Record BEGIN if (bStartTimeSet == false) { JT_Technician tech = App.Database.GetCurrentTechnicianFromDb(); if (tech.CurrentStartTime != null) { labelActualStartTime.Content = FormattedTime(tech.CurrentStartTime); //Label labelActualStartTime = new Label() //{ // Content = FormattedTime(tech.CurrentStartTime), // Foreground = asbestos //}; grid.Children.Add(labelActualStartTime); Grid.SetColumn(labelActualStartTime, 2); Grid.SetRow(labelActualStartTime, 2); actStartTime = tech.CurrentStartTime; // dch rkl 10/31/2016 } } // dch rkl 10/14/2016 Get Start Time from the Technician Record END //compute duration, if available // dch rkl 10/31/2016 Calculate Duration for Scheduled and Actual // Scheduled DateTime dtSST; DateTime dtSET; if (schedStartTime.Length > 0) { schedStartTime = schedStartTime.Substring(0, 2) + ":" + schedStartTime.Substring(2, 2); } if (schedEndTime.Length > 0) { schedEndTime = schedEndTime.Substring(0, 2) + ":" + schedEndTime.Substring(2, 2); } if (DateTime.TryParse(schedStartTime, out dtSST) && DateTime.TryParse(schedEndTime, out dtSET)) { TimeSpan tsSchDur = dtSET.Subtract(dtSST); Label labelSchedDur = new Label() { Content = Math.Round(tsSchDur.TotalHours, 2, MidpointRounding.AwayFromZero).ToString(), Foreground = asbestos }; grid.Children.Add(labelSchedDur); Grid.SetColumn(labelSchedDur, 1); Grid.SetRow(labelSchedDur, 4); } // Actual DateTime dtAST; DateTime dtAET; if (actStartTime != null && actStartTime.Length > 0) { actStartTime = actStartTime.Substring(0, 2) + ":" + actStartTime.Substring(2, 2); } // dch rkl 11/22/2016 make sure actEndTime is not null if (actEndTime != null && actEndTime.Length > 0) { actEndTime = actEndTime.Substring(0, 2) + ":" + actEndTime.Substring(2, 2); } else { if (App.Database.GetApplicationSettings().TwentyFourHourTime) { actEndTime = DateTime.Now.ToString("HH:mm"); } else { actEndTime = DateTime.Now.ToString("hh:mm tt"); } } // dch rkl 02/03/2017 Actual duration is not being calculated correctly //if (DateTime.TryParse(actStartTime, out dtAST) && DateTime.TryParse(actEndTime, out dtAET)) if (DateTime.TryParse(labelActualStartTime.Content.ToString(), out dtAST) && DateTime.TryParse(labelActualEndTime.Content.ToString(), out dtAET)) { TimeSpan tsActDur = dtAET.Subtract(dtAST); Label labelActDur = new Label() { Content = Math.Round(tsActDur.TotalHours, 2, MidpointRounding.AwayFromZero).ToString(), Foreground = asbestos }; grid.Children.Add(labelActDur); Grid.SetColumn(labelActDur, 2); Grid.SetRow(labelActDur, 4); } stackLayout.Children.Add(grid); Button buttonCloseSchedule = new Button() { Content = "OK", Foreground = new SolidColorBrush(Colors.White), FontWeight = FontWeights.Bold, Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2ecc71")), VerticalAlignment = VerticalAlignment.Center, Height = 40 // dch rkl 11/22/2016 change height }; buttonCloseSchedule.Click += ButtonCloseSchedule_Clicked; stackLayout.Children.Add(buttonCloseSchedule); Content = stackLayout; }
// dch rkl 12/09/2016 return number failed and number successful //public void syncWithServer() public void syncWithServer(ref int syncSuccess, ref int syncFailed) { // dch rkl 12/07/2016 catch exception try { // dch rkl 12/09/2016 return number failed and number successful syncSuccess = 0; syncFailed = 0; TechDashboard.Data.RestClient restClient = new Data.RestClient(App.Database.GetApplicationSettings().IsUsingHttps, App.Database.GetApplicationSettings().RestServiceUrl); foreach (JT_TransactionImportDetail transaction in _transactionImportDetails) { // dch rkl 12/05/2016 If Lot/Serial Nbr Data, sync back to JobOps with multiple rows //bool updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction); bool updateWorked = true; if (transaction.LotSerialNo == null || transaction.LotSerialNo.Trim().Length == 0) { // dch rkl 12/09/2016 This now returns a results object //updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction); updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction).Success; } else { // Split into LotSerNo/Qty strings string[] lotSerQty = transaction.LotSerialNo.Split('|'); double qty = 0; foreach (string lsq in lotSerQty) { // Split each LotSerNo/Qty string into LotSerNo and Qty string[] sqty = lsq.Split('~'); if (sqty.GetUpperBound(0) > 0) { double.TryParse(sqty[1], out qty); if (qty > 0) { transaction.QuantityUsed = qty; transaction.LotSerialNo = sqty[0]; // dch rkl 12/09/2016 This now returns a results object //bool updateWorkedLS = restClient.InsertTransactionImportDetailRecordSync(transaction); bool updateWorkedLS = restClient.InsertTransactionImportDetailRecordSync(transaction).Success; if (updateWorkedLS == false) { updateWorked = false; break; } } } } } if (updateWorked) { App.Database.DeleteExportRow(transaction); // dch rkl 12/09/2016 return number failed and number successful syncSuccess++; } // dch rkl 12/09/2016 return number failed and number successful else { syncFailed++; } } _transactionImportDetails = App.Database.GetCurrentExport(); PropertyChanged(this, new PropertyChangedEventArgs("UpdateCount")); PropertyChanged(this, new PropertyChangedEventArgs("transactionImportDetails")); JT_Technician technician = App.Database.GetCurrentTechnicianFromDb(); var techUpdateWorked = restClient.UpdateTechnicianRecordSync(technician); PropertyChanged(this, new PropertyChangedEventArgs("UpdateCount")); PropertyChanged(this, new PropertyChangedEventArgs("transactionImportDetails")); App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LastSyncDate = DateTime.Now.ToString(); LastSyncDate = appSettings.LastSyncDate; App.Database.SaveAppSettings(appSettings); } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.SyncPageViewModel.syncWithServer"); } }
// dch rkl 10/26/2016 include schedule detail //public ClockOutPage(App_WorkTicket workTicket) public ClockOutPage(App_WorkTicket workTicket, App_ScheduledAppointment scheduleDetail) { InitializeComponent(); _vm = new ClockOutPageViewModel(workTicket); _ciOptions = App.Database.GetCIOptions(); // dch rkl 10/26/2016 return to ticket details instead of scheduled ticket list on cancel _scheduleDetail = scheduleDetail; // dch rkl 11/30/2016 display coverage checkboxes _workTicket = workTicket; // dch rkl 12/02/2016 Ticket Details // Get Current Technician JT_Technician technician = App.Database.GetCurrentTechnicianFromDb(); // Service Ticket textServiceTicket.Content = _scheduleDetail.ServiceTicketNumber; // Employee Number and Name textEmployeeNumber.Content = technician.FormattedTechnicianNo; textEmployeeName.Content = string.Format("{0} {1}", technician.FirstName, technician.LastName); // Set Coverage Checkboxes // Warranty Repair if (_workTicket.DtlWarrantyRepair == "Y") { switchWarrRepair.IsChecked = true; } // Labor Coverred on Warranty bool bIsChkd = false; if (_workTicket.StatusDate != null && _workTicket.RepairItem.MfgLaborWarrantyPeriod != null) { TimeSpan tsDateDiff = _workTicket.RepairItem.MfgLaborWarrantyPeriod.Subtract(_workTicket.StatusDate); if (tsDateDiff.TotalDays > 0 && _workTicket.DtlWarrantyRepair == "Y") { switchLaborCovWarr.IsChecked = true; bIsChkd = true; } } if (_workTicket.StatusDate != null && _workTicket.RepairItem.IntLaborWarrantyPeriod != null) { TimeSpan tsDateDiff = _workTicket.RepairItem.IntLaborWarrantyPeriod.Subtract(_workTicket.StatusDate); if (tsDateDiff.TotalDays > 0 && _workTicket.DtlWarrantyRepair == "Y") { switchLaborCovWarr.IsChecked = true; bIsChkd = true; } } // Service Agreement Repair if (_workTicket.DtlCoveredOnContract == "Y") { switchSvcAgrRepair.IsChecked = true; } // LLabor Covered on Service Agreement if (_workTicket.IsPreventativeMaintenance && _workTicket.ServiceAgreement.IsPMLaborCovered) { switchLaborCovSvcAgr.IsChecked = true; } else if (_workTicket.IsPreventativeMaintenance == false && _workTicket.IsServiceAgreementRepair && _workTicket.ServiceAgreement.IsLaborCovered) { switchLaborCovSvcAgr.IsChecked = true; } // Billable Picker pickerBillable.ItemsSource = _vm.BillableList; // Start Time DateTime dtStartDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _vm.StartTime; if (App.Database.GetApplicationSettings().TwentyFourHourTime) { textStartTime.Text = dtStartDateTime.ToString("HH:mm"); } else { textStartTime.Text = dtStartDateTime.ToString("hh:mm tt"); } // Start Date textStartDate.Text = technician.CurrentStartDate.ToShortDateString(); // Depart Time textEndDate.Text = DateTime.Now.ToShortDateString(); if (App.Database.GetApplicationSettings().TwentyFourHourTime) { textDepartTime.Text = DateTime.Now.ToString("HH:mm"); } else { textDepartTime.Text = DateTime.Now.ToString("hh:mm tt"); } // dch rkl 01/23/2017 If Time Tracker Options is "Y", they enter start / end time.If "N", they enter hours. BEGIN // bk rkl 02/01/2017 moving north of sethoursbilled call _captureTimeInTimeTracker = "N"; _MinHourlyCostIncrement = 0; JT_TimeTrackerOptions tto = App.Database.GetTimeTrackerOptions(); if (tto != null && tto.CaptureTimeInTimeTracker != null) { _captureTimeInTimeTracker = tto.CaptureTimeInTimeTracker; _MinHourlyCostIncrement = tto.MinHourlyCostIncrement; if (_captureTimeInTimeTracker == "O") { _captureTimeInTimeTracker = "Y"; } } // Set Hours Billed if (textStartTime.Text != null && textDepartTime.Text != null) { SetHoursBilled(); } // Technician Status // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status BEGIN string statusCode = _vm.DefaultDepartStatusCode; if (statusCode == null || statusCode.Trim().Length == 0) { statusCode = technician.CurrentStatus; } // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status END pickerTechnicianStatus.ItemsSource = _vm.TechnicianStatusList; for (int i = 0; i < pickerTechnicianStatus.Items.Count; i++) { // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status BEGIN //if (((JT_TechnicianStatus)pickerTechnicianStatus.Items[i]).StatusDescription == _vm.DefaultDepartStatusCodeDescription) if (((JT_TechnicianStatus)pickerTechnicianStatus.Items[i]).StatusCode == statusCode) // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status END { pickerTechnicianStatus.SelectedIndex = i; break; } } // Ticket Status pickerTicketStatus.ItemsSource = _vm.ServiceTicketStatusList; pickerTicketStatus.SelectedValue = _vm.DefaultServiceTicketStatusCode; // Activity Code pickerActivityCode.ItemsSource = _vm.ActivityCodeList; pickerActivityCode.SelectedValue = _vm.DefaultActivityCode; // Department pickerDepartment.ItemsSource = _vm.DepartmentCodesList; JT_ActivityCode dfltActCode = new JT_ActivityCode(); if (_vm.DefaultActivityCode != null) { dfltActCode = App.Database.GetActivityCodeFromDB(_vm.DefaultActivityCode); } if (dfltActCode != null) { pickerDepartment.SelectedValue = dfltActCode.DeptWorkedIn; } // Earnings Code List <JT_EarningsCode> lsEarnCd = new List <Models.JT_EarningsCode>(); foreach (JT_EarningsCode earncd in _vm.EarningsCodeList) { // Only include types of Regular or Overtime if (earncd.TypeOfEarnings == "O" || earncd.TypeOfEarnings == "R") { earncd.EarningsDeductionDesc = string.Format("{0} - {1}", earncd.EarningsCode, earncd.EarningsDeductionDesc); lsEarnCd.Add(earncd); } } pickerEarningsCode.ItemsSource = lsEarnCd; // dch rkl 11/01/2016 make sure default earning code is not null if (_vm.DefaultEarningCode != null) { pickerEarningsCode.SelectedValue = _vm.DefaultEarningCode; } else { pickerEarningsCode.SelectedIndex = 0; } // Meter Reading // dch rkl 11/1/2016 per Jeanne, hide the meter reading if JT_ServiceAgreementPMDetail.Basis = "M" BEGIN if (_vm.WorkTicket.ServiceAgreement != null && _vm.WorkTicket.ServiceAgreement.PmDetail != null && _vm.WorkTicket.ServiceAgreement.PmDetail.Basis != null && _vm.WorkTicket.ServiceAgreement.PmDetail.Basis == "M") { labelMeterReading.Visibility = Visibility.Visible; editorMeterReading.Visibility = Visibility.Visible; } else { labelMeterReading.Visibility = Visibility.Hidden; editorMeterReading.Visibility = Visibility.Hidden; } // dch rkl 11/1/2016 per Jeanne, hide the meter reading if JT_ServiceAgreementPMDetail.Basis = "M" END // Set Ref Rate SetRefRate(); // Work Performed editorWorkPerformed.MaxHeight = editorWorkPerformed.MinHeight; if (_captureTimeInTimeTracker == "Y") { // Enter start/end time textStartDate.IsEnabled = true; textStartTime.IsEnabled = true; textEndDate.IsEnabled = true; textDepartTime.IsEnabled = true; editorHoursWorked.IsEnabled = false; } else { // Enter hours textStartDate.IsEnabled = false; textStartDate.Text = ""; textStartTime.IsEnabled = false; textStartTime.Text = ""; textEndDate.IsEnabled = false; textEndDate.Text = ""; textDepartTime.IsEnabled = false; textDepartTime.Text = ""; editorHoursWorked.IsEnabled = true; } // dch rkl 01/23/2017 If Time Tracker Options is "Y", they enter start / end time.If "N", they enter hours. END // dch rkl 01/12/2017 Set Tab Indexes textStartDate.TabIndex = 0; textStartTime.TabIndex = 1; textEndDate.TabIndex = 2; textDepartTime.TabIndex = 3; editorHoursWorked.TabIndex = 4; pickerBillable.TabIndex = 5; editorHoursBilled.TabIndex = 6; editorBillableRate.TabIndex = 7; pickerTechnicianStatus.TabIndex = 8; pickerTicketStatus.TabIndex = 9; pickerActivityCode.TabIndex = 10; pickerDepartment.TabIndex = 11; pickerEarningsCode.TabIndex = 12; editorMeterReading.TabIndex = 13; editorWorkPerformed.TabIndex = 14; buttonClockout.TabIndex = 15; buttonCancel.TabIndex = 16; }
// dch rkl 12/02/2016 Set Ref Rate private void SetRefRate() { decimal billingRate = 0; string sActivityCode = ""; decimal billingRateMultiplier = 1; if (pickerActivityCode.SelectedIndex > -1 && pickerActivityCode.SelectedValue != null) { sActivityCode = pickerActivityCode.SelectedValue.ToString(); } if (sActivityCode.Length > 0) { JT_ActivityCode activityCode = App.Database.GetActivityCodeFromDB(sActivityCode); billingRateMultiplier = activityCode.BillingRateMultiplier; if (billingRateMultiplier == 0) { billingRateMultiplier = 1; } } if (_workTicket.DtlCoverageExceptionCode != null && _workTicket.DtlCoverageExceptionCode.Trim().Length > 0) { billingRate = _workTicket.DtlCoverageExceptionFixedRate; } if (_workTicket.IsPreventativeMaintenance) { billingRate = Math.Round(_workTicket.ServiceAgreement.PmDetail.Rate * billingRateMultiplier, 2, MidpointRounding.AwayFromZero); } else { if (_workTicket.ServiceAgreement.DetailRate != 0) { billingRate = Math.Round(_workTicket.ServiceAgreement.DetailRate * billingRateMultiplier, 2, MidpointRounding.AwayFromZero); } else { billingRate = Math.Round(_workTicket.ServiceAgreement.StandardLaborRate * billingRateMultiplier, 2, MidpointRounding.AwayFromZero); } } // Look for customer billing rates if (sActivityCode.Trim().Length > 0) { App_Customer customer = App.Database.GetAppCustomer(_workTicket); JT_CustomerBillingRates custBillRate = App.Database.GetJT_CustomerBillingRate(customer.ARDivisionNo, customer.CustomerNo, sActivityCode); if (custBillRate != null) { billingRate = Math.Round(custBillRate.BillRatePerHour * billingRateMultiplier, 2, MidpointRounding.AwayFromZero); } } // Set Rate based on Technician if (billingRate == 0) { JT_Technician technician = App.Database.GetCurrentTechnicianFromDb(); billingRate = Math.Round(technician.StandardBillingRate * billingRateMultiplier, 2, MidpointRounding.AwayFromZero); } // Set the value in the rate box editorRefRate.Text = billingRate.ToString("C2"); // Billable Rate SetBillableRate(); }
protected void InitializePage() { BackgroundColor = Color.White; this.Title = "Schedule Details"; StackLayout stackLayout = new StackLayout(); //stackLayout.BackgroundColor = Color.FromHex ("#bcd5d1"); stackLayout.Padding = 30; Color asbestos = Color.FromHex("#7f8c8d"); Xamarin.Forms.Label labelModalTitle = new Xamarin.Forms.Label() { //FontAttributes = FontAttributes.Bold, FontSize = 22, Text = "SCHEDULE DETAILS", FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = Color.White, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; Grid titleLayout = new Grid() { BackgroundColor = Color.FromHex("#2980b9"), HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(labelModalTitle, 0, 0); stackLayout.Children.Add(titleLayout); Grid grid = new Grid(); grid.RowSpacing = 5; grid.ColumnSpacing = 5; grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); Xamarin.Forms.Label labelScheduledTitle = new Xamarin.Forms.Label() { //FontAttributes = FontAttributes.Bold, TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), Text = "SCHEDULED" }; grid.Children.Add(labelScheduledTitle, 1, 0); Xamarin.Forms.Label labelActualTitle = new Xamarin.Forms.Label() { //FontAttributes = FontAttributes.Bold, TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), Text = "ACTUAL" }; grid.Children.Add(labelActualTitle, 2, 0); Xamarin.Forms.Label labelDateTitle = new Xamarin.Forms.Label(); labelDateTitle.Text = "Date"; //labelDateTitle.FontAttributes = FontAttributes.Bold; labelDateTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); labelDateTitle.TextColor = asbestos; grid.Children.Add(labelDateTitle, 0, 1); Xamarin.Forms.Label labelStartTimeTitle = new Xamarin.Forms.Label(); labelStartTimeTitle.Text = "Start Time"; //labelStartTimeTitle.FontAttributes = FontAttributes.Bold; labelStartTimeTitle.TextColor = asbestos; labelStartTimeTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); grid.Children.Add(labelStartTimeTitle, 0, 2); Xamarin.Forms.Label labelEndTimetitle = new Xamarin.Forms.Label(); labelEndTimetitle.Text = "End Time"; //labelEndTimetitle.FontAttributes = FontAttributes.Bold; labelEndTimetitle.TextColor = asbestos; labelEndTimetitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); grid.Children.Add(labelEndTimetitle, 0, 3); Xamarin.Forms.Label labelDurationTitle = new Xamarin.Forms.Label(); labelDurationTitle.Text = "Duration"; labelDurationTitle.TextColor = asbestos; labelDurationTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); grid.Children.Add(labelDurationTitle, 0, 4); Xamarin.Forms.Label labelScheduledDate = new Xamarin.Forms.Label() { Text = _vm.ScheduleDetail.ScheduleDate.ToShortDateString(), TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelScheduledDate, 1, 1); Xamarin.Forms.Label labelScheduledStartTime = new Xamarin.Forms.Label() { // dch rkl 10/12/2016 show formatted time //Text = _vm.ScheduleDetail.StartTime, Text = _vm.ScheduleDetail.StartTimeFormatted, TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelScheduledStartTime, 1, 2); Xamarin.Forms.Label labelScheduledEndTime = new Xamarin.Forms.Label() { // dch rkl 10/12/2016 show formatted time //Text = "", Text = _vm.ScheduleDetail.EndTimeFormatted, TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelScheduledEndTime, 1, 3); Xamarin.Forms.Label labelActualDate = new Xamarin.Forms.Label() { Text = _vm.TechnicianScheduleDetail.ScheduleDate.ToShortDateString(), TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelActualDate, 2, 1); bool bStartTimeSet = false; // dch rkl 10/14/2016 Get Start Time from the Technician Record if (_vm.TimeEntryDetail != null) { if (_vm.TimeEntryDetail.StartTime != null) { Xamarin.Forms.Label labelActualStartTime = new Xamarin.Forms.Label() { Text = FormattedTime(_vm.TimeEntryDetail.StartTime), TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelActualStartTime, 2, 2); bStartTimeSet = true; // dch rkl 10/14/2016 Get Start Time from the Technician Record } if (_vm.TimeEntryDetail.EndTime != null) { Xamarin.Forms.Label labelActualEndTime = new Xamarin.Forms.Label() { Text = FormattedTime(_vm.TimeEntryDetail.EndTime), TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelActualEndTime, 2, 3); } } // dch rkl 10/14/2016 Get Start Time from the Technician Record BEGIN if (bStartTimeSet == false) { JT_Technician tech = App.Database.GetCurrentTechnicianFromDb(); if (tech.CurrentStartTime != null) { Xamarin.Forms.Label labelActualStartTime = new Xamarin.Forms.Label() { Text = FormattedTime(tech.CurrentStartTime), TextColor = asbestos, FontFamily = Device.OnPlatform("OpenSans-Regular", "sans-serif", null) }; grid.Children.Add(labelActualStartTime, 2, 2); } } // dch rkl 10/14/2016 Get Start Time from the Technician Record END //compute duration, if available stackLayout.Children.Add(grid); Button buttonCloseSchedule = new Button() { Text = "OK", TextColor = Color.White, FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), BackgroundColor = Color.FromHex("#2ecc71"), VerticalOptions = LayoutOptions.Fill }; buttonCloseSchedule.Clicked += ButtonCloseSchedule_Clicked; stackLayout.Children.Add(buttonCloseSchedule); Content = stackLayout; }