public App_ErpOptions GetErpOptions()
        {
            App_ErpOptions erpOptions = null;

            lock (_locker)
            {
                JT_FieldServiceOptions fieldServiceOption  = GetFieldServiceOption();
                JT_TechnicianStatus    defaultArriveStatus = null;
                JT_TechnicianStatus    defaultDepartStatus = null;
                JT_MiscellaneousCodes  defaultServiceTicketArriveStatus = null;

                if (fieldServiceOption != null)
                {
                    if (fieldServiceOption.ArriveStatusCode != null)
                    {
                        defaultArriveStatus = GetTechnicianStatusFromDB(fieldServiceOption.ArriveStatusCode);
                    }
                    if (fieldServiceOption.DepartStatusCode != null)
                    {
                        defaultDepartStatus = GetTechnicianStatusFromDB(fieldServiceOption.DepartStatusCode);
                    }
                    if (fieldServiceOption.ServiceStartedStatusCode1 != null)
                    {
                        defaultServiceTicketArriveStatus = GetMiscellaneousCodeFromDB("ST", fieldServiceOption.ServiceStartedStatusCode1);
                    }

                    erpOptions = new App_ErpOptions(fieldServiceOption, defaultArriveStatus, defaultDepartStatus, defaultServiceTicketArriveStatus);
                }
            }

            return(erpOptions);
        }
Exemplo n.º 2
0
        protected void UpdateExpenseCategory(string category)
        {
            JT_MiscellaneousCodes categoryRecord = App.Database.GetExpenseCategory(category);

            string[] brokenDescription = App_Expense.BreakDescription(categoryRecord.AddtlDescNum);

            try
            {
                _expenseItem.ChargeCode = brokenDescription[0];
            }
            catch
            {
                _expenseItem.ChargeCode = null;
            }
            try
            {
                _expenseItem.UnitOfMeasure = brokenDescription[1];
            }
            catch
            {
                _expenseItem.UnitOfMeasure = null;
            }
            try
            {
                _expenseItem.UnitPrice = double.Parse(brokenDescription[2]);
            }
            catch
            {
                _expenseItem.UnitPrice = 0;
            }
        }
        public JT_MiscellaneousCodes GetChargeCode(string code)
        {
            JT_MiscellaneousCodes chargeCode = null;

            chargeCode = GetMiscellaneousCodesFromDB("*E").Where(cc => cc.MiscellaneousCode == code).FirstOrDefault();

            return(chargeCode);
        }
Exemplo n.º 4
0
        /// <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);
        }
        protected void UpdateExpenseCategory(string category)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                // dch rkl 11/21/2016 make sure category is not blank/null BEGIN
                if (category != null && category.Trim().Length > 0)
                {
                    // dch rkl 11/21/2016 make sure category is not blank/null END
                    JT_MiscellaneousCodes categoryRecord = App.Database.GetExpenseCategory(category);
                    string[] brokenDescription           = App_Expense.BreakDescription(categoryRecord.AddtlDescNum);

                    try
                    {
                        _expenseItem.ChargeCode = brokenDescription[0];
                    }
                    catch
                    {
                        _expenseItem.ChargeCode = null;
                    }
                    try
                    {
                        _expenseItem.UnitOfMeasure = brokenDescription[1];
                    }
                    catch
                    {
                        _expenseItem.UnitOfMeasure = null;
                    }
                    try
                    {
                        _expenseItem.UnitPrice = double.Parse(brokenDescription[2]);
                    }
                    catch
                    {
                        _expenseItem.UnitPrice = 0;
                    }
                    // dch rkl 11/21/2016 make sure category is not blank/null BEGIN
                }
                else
                {
                    _expenseItem.ChargeCode    = "";
                    _expenseItem.UnitOfMeasure = null;
                    _expenseItem.UnitPrice     = 0;
                }
                // dch rkl 11/21/2016 make sure category is not blank/null END
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.ExpensesEditPageViewModel.UpdateExpenseCategory");
            }
        }
        protected async void ButtonClockIn_Clicked(object sender, EventArgs e)
        {
            if (_pickerTechnicianStatus.SelectedIndex < 0)
            {
                //await new MessageBox ("Status", "Select a technician status.", "OK");
                //return;
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a technician status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (_pickerTicketStatus.SelectedIndex < 0)
            {
                // await DisplayAlert("Status", "Select a ticket status.", "OK");
                // return;
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a ticket status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }

            // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN
            // Validate Arrive Time
            DateTime dtArriveTime;

            if (DateTime.TryParse(_textArriveTime.Text, out dtArriveTime) == false)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Arrive Time.", "Arrive Time", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            // dch rkl 11/1/2016 use textbox instead of datetime picker for times BEGIN

            JT_TechnicianStatus   selectedTechnicianStatus = _pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = _pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;

            // dch rkl 11/1/2016 use textbox instead of datetime picker for times
            //TimeSpan timeofday = ((DateTime)_pickerArriveTime.Value).TimeOfDay;
            TimeSpan timeofday = dtArriveTime.TimeOfDay;

            // dch rkl 11/1/2016 use textbox instead of datetime picker for times END

            _vm.ClockIn(timeofday, selectedTechnicianStatus, selectedTicketStatus);
            ContentControl contentArea = (ContentControl)this.Parent;

            _vm.ScheduleDetail.IsCurrent = true;            // dch rkl 01/12/2017 This is what makes the Clock Out Button Appear
            contentArea.Content          = new TicketDetailsPage(_vm.ScheduleDetail);
            //await Navigation.PopToRootAsync();
        }
Exemplo n.º 7
0
        public ClockOutPageViewModel(App_WorkTicket workTicket)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                _currentTechnician = App.Database.GetCurrentTechnicianFromDb();
                //_timeEntry = App.Database.GetClockedInTimeEntry();
                _workTicket              = workTicket;
                _scheduleDetail          = App.Database.RetrieveCurrentScheduleDetail();
                _technicianStatusList    = App.Database.GetTechnicianStatusesFromDB();
                _serviceTicketStatusList = App.Database.GetWorkTicketStatusesFromDB();
                _earningsCodeList        = App.Database.GetEarningsCodesFromDB();
                _activityCodeList        = App.Database.GetActivityCodesFromDB();
                _erpOptions              = App.Database.GetErpOptions();

                // dch rkl 12/02/2016 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"));

                // dch rkl 11/01/2016 Department Codes BEGIN
                _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/01/2016 Department Codes END

                // 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 ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.ClockOut(App_WorkTicket workTicket)");
            }
        }
Exemplo n.º 8
0
        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)");
            }
        }
        protected async void ButtonClockIn_Clicked(object sender, EventArgs e)
        {
            if (_pickerTechnicianStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a technician status.", "OK");

                return;
            }
            if (_pickerTicketStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a ticket status.", "OK");

                return;
            }

            JT_TechnicianStatus   selectedTechnicianStatus = _pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = _pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;



            _vm.ClockIn(_pickerArriveTime.Time, selectedTechnicianStatus, selectedTicketStatus);
            await Navigation.PopToRootAsync();
        }
Exemplo n.º 10
0
        // dch rkl 11/15/2016 Add clock out date
        // dch rkl 01/23/2017 Check value of CaptureTimeInTimeTracker to see if hours or timespan is entered
        // dch rkl 01/23/2017 Include Service Agreement Code
        // bk  rkl 01/26/2017 adjust to only include transaction date
        public void ClockOut(TimeSpan departTime, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatus,
                             JT_ActivityCode activityCode, string departmentWorked, JT_EarningsCode earningsCode, double hoursBilled,
                             double meterReading, string workPerformedText, string clockOutDate, string captureTimeInTimeTracker,
                             double hoursWorked, string svcAgmtContractCode)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                if (captureTimeInTimeTracker == "Y")
                {
                    // dch rkl 11/15/2016 Add clock out date
                    //DateTime clockOutTime = DateTime.Today;
                    DateTime clockOutTime = DateTime.Parse(clockOutDate);

                    clockOutTime = clockOutTime.Add(departTime);

                    // dch rkl 02/03/2017 Include clockOutDate
                    //App.Database.ClockOut(App.CurrentTechnician, _workTicket, clockOutTime, technicianStatus, serviceTicketStatus,
                    //    activityCode.ActivityCode, departmentWorked, earningsCode, hoursBilled, meterReading, workPerformedText, svcAgmtContractCode);
                    App.Database.ClockOut(App.CurrentTechnician, _workTicket, clockOutTime, technicianStatus, serviceTicketStatus,
                                          activityCode.ActivityCode, departmentWorked, earningsCode, hoursBilled, meterReading, workPerformedText,
                                          svcAgmtContractCode, clockOutDate);
                }
                else
                {
                    App.Database.ClockOut(App.CurrentTechnician, _workTicket, technicianStatus, serviceTicketStatus, activityCode.ActivityCode,
                                          departmentWorked, earningsCode, hoursBilled, meterReading, workPerformedText, hoursWorked, svcAgmtContractCode);
                }
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.BlockOutPageViewModel.ClockOut()");
            }
        }
 public void ClockIn(TimeSpan arriveTime, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatus)
 {
     // dch rkl 12/07/2016 catch exception
     try
     {
         DateTime clockInTime = DateTime.Today;
         clockInTime = clockInTime.Add(arriveTime);
         App.Database.ClockIn(App.CurrentTechnician, _scheduleDetail, clockInTime, technicianStatus, serviceTicketStatus);
         _scheduleDetail.IsCurrent = true;
     }
     catch (Exception ex)
     {
         // dch rkl 12/07/2016 Log Error
         ErrorReporting errorReporting = new ErrorReporting();
         errorReporting.sendException(ex, "TechDashboard.ClockIn");
     }
 }
        protected async void ButtonClockOut_Clicked(object sender, EventArgs e)
        {
            if (_pickerTechnicianStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a technician status.", "OK");

                return;
            }
            if (_pickerTicketStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a ticket status.", "OK");

                return;
            }
            if (_pickerEarningsCode.SelectedIndex < 0)
            {
                await DisplayAlert("Earnings Code", "Select an earnings code.", "OK");

                return;
            }
            if (_pickerActivityCode.SelectedIndex < 0)
            {
                await DisplayAlert("Activity Code", "Select an activity code.", "OK");

                return;
            }

            DateTime dtDepart    = DateTime.Now;
            double   hoursWorked = 0;

            if (_captureTimeInTimeTracker == "Y")
            {
                DateTime dtArrive;
                if (_pickerStartDate.Date == null)
                {
                    await DisplayAlert("Arrive Date", "Enter a valid arrival date.", "OK");

                    return;
                }

                if (_pickerDepartDate.Date == null)
                {
                    await DisplayAlert("Depart Date", "Enter a valid departure date.", "OK");

                    return;
                }

                // dch rkl 02/03/2017 Capture hours worked, for validation
                if (_editorHoursWorked.Text != null)
                {
                    double.TryParse(_editorHoursWorked.Text, out hoursWorked);
                }
            }
            else
            {
                // dch rkl 01/23/2017 captureTimeInTimeTracker == "N", hours must be entered
                if (_editorHoursWorked.Text != null)
                {
                    double.TryParse(_editorHoursWorked.Text, out hoursWorked);
                }
                if (hoursWorked == 0)
                {
                    await DisplayAlert("Hours Worked", "Enter valid hours worked.", "OK");

                    return;
                }
            }
            if (hoursWorked > 24)
            {
                await DisplayAlert("Hours Worked", "Time entry cannot exceed 24 hours.  Please adjust your Depart Date/Time and create a separate Clock In/Clock Out for additional hours.", "OK");

                return;
            }

            double meterReading = 0;
            double hoursBilled  = 0;

            JT_TechnicianStatus   selectedTechnicianStatus = _pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = _pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;
            JT_EarningsCode       selectedEarningsCode     = _pickerEarningsCode.SelectedItem as JT_EarningsCode;
            JT_ActivityCode       selectedActivityCode     = _pickerActivityCode.SelectedItem as JT_ActivityCode;

            try
            {
                if (_vm.IsRepairItemAnEquipmentAsset)
                {
                    meterReading = double.Parse(_editorMeterReading.Text);
                }
                else
                {
                    meterReading = 0;
                }
            }
            catch
            {
                // empty
            }
            try
            {
                hoursBilled = double.Parse(_editorHoursBilled.Text);
            }
            catch
            {
                // empty
            }
            JT_MiscellaneousCodes deptCode = (JT_MiscellaneousCodes)_pickerDepartment.SelectedItem;

            ClockOutPageViewModel.App_Billable appBillable = (ClockOutPageViewModel.App_Billable)_pickerBillable.SelectedItem;

            if (_captureTimeInTimeTracker == "Y")
            {
                //_vm.ClockOut(_pickerDepartTime.Time, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, string.Empty,
                //             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, _pickerDepartDate.Date.ToShortDateString());
                _vm.ClockOut(_pickerDepartTime.Time, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, deptCode.MiscellaneousCode,
                             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, _pickerDepartDate.Date.ToShortDateString(), _captureTimeInTimeTracker,
                             hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber, appBillable.BillableFlag);
            }
            else
            {
                _vm.ClockOut(new TimeSpan(), selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, deptCode.MiscellaneousCode,
                             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, "", _captureTimeInTimeTracker, hoursWorked,
                             _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber, appBillable.BillableFlag);
            }
            await Navigation.PopToRootAsync();
        }
Exemplo n.º 13
0
        /// <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);
            }
        }
Exemplo n.º 14
0
        /// <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);
            }
        }
        private void ButtonClockOut_Clicked(object sender, RoutedEventArgs e)
        {
            if (pickerTechnicianStatus.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a technician status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerTicketStatus.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a ticket status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerEarningsCode.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select an earnings code.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerActivityCode.SelectedIndex < 0)
            {
                //await DisplayAlert("Activity Code", "Select an activity code.", "OK");
                //return;
                MessageBoxResult result = System.Windows.MessageBox.Show("Select an activity code.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }

            // Validate Dates
            DateTime dtDepart    = DateTime.Now;
            double   hoursWorked = 0;

            // dch rkl 01/23/2017 captureTimeInTimeTracker == "Y", date and time must be entered
            if (_captureTimeInTimeTracker == "Y")
            {
                DateTime dtArrive;
                if (textStartTime.Text != null)
                {
                    if (DateTime.TryParse(textStartTime.Text, out dtArrive) == false)
                    {
                        MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Arrive Date.", "Arrive Date", MessageBoxButton.OK);
                        if (result == MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Arrive Date.", "Arrive Date", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }

                if (textDepartTime.Text != null)
                {
                    if (DateTime.TryParse(textDepartTime.Text, out dtDepart) == false)
                    {
                        MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Depart Date.", "Depart Date", MessageBoxButton.OK);
                        if (result == MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Depart Date.", "Depart Date", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }

                // dch rkl 02/03/2017 Capture hours worked, for validation
                if (editorHoursWorked != null)
                {
                    double.TryParse(editorHoursWorked.Text, out hoursWorked);
                }
            }
            else
            {
                // dch rkl 01/23/2017 captureTimeInTimeTracker == "N", hours must be entered
                if (editorHoursWorked != null)
                {
                    double.TryParse(editorHoursWorked.Text, out hoursWorked);
                }
                if (hoursWorked == 0)
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter valid Hours Worked.", "Hours Worked", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }
            }
            if (hoursWorked > 24)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Time entry cannot exceed 24 hours.  Please adjust your Depart Date/Time and create separate Clock In/Clock Out for additional hours.", "Hours Worked", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }

            double meterReading = 0;
            double hoursBilled  = 0;

            JT_TechnicianStatus   selectedTechnicianStatus = pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;
            JT_EarningsCode       selectedEarningsCode     = pickerEarningsCode.SelectedItem as JT_EarningsCode;
            JT_ActivityCode       selectedActivityCode     = pickerActivityCode.SelectedItem as JT_ActivityCode;

            try
            {
                if (_vm.IsRepairItemAnEquipmentAsset)
                {
                    meterReading = double.Parse(editorMeterReading.Text);
                }
                else
                {
                    meterReading = 0;
                }
            }
            catch
            {
                // empty
            }
            try
            {
                hoursBilled = double.Parse(editorHoursBilled.Text);
            }
            catch
            {
                // empty
            }

            // dch rkl 01/23/2017 captureTimeInTimeTracker == "Y", date and time must be entered
            if (_captureTimeInTimeTracker == "Y")
            {
                // dch rkl 02/03/2017 use arrive date
                //_vm.ClockOut(dtDepart.TimeOfDay, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                //    pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                //    textEndDate.Text, _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
                _vm.ClockOut(dtDepart.TimeOfDay, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                             pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                             textStartDate.Text, _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
            }
            else
            {
                TimeSpan ts = new TimeSpan();
                _vm.ClockOut(ts, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                             pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                             "", _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
            }

            ContentControl contentArea = (ContentControl)this.Parent;

            contentArea.Content = new SchedulePage();
        }
        public JT_MiscellaneousCodes GetExpenseCategory(string category)
        {
            JT_MiscellaneousCodes expenseCategory = GetMiscellaneousCodeFromDB("*E", category);

            return(expenseCategory);
        }
 public void ClockIn(TimeSpan arriveTime, JT_TechnicianStatus technicianStatus, JT_MiscellaneousCodes serviceTicketStatus)
 {
     // dch rkl 12/07/2016 catch exception
     try
     {
         DateTime clockInTime = DateTime.Today;
         clockInTime = clockInTime.Add(arriveTime);
         App.Database.ClockIn(App.CurrentTechnician, _scheduleDetail, clockInTime, technicianStatus, serviceTicketStatus);
         _scheduleDetail.IsCurrent = true;
     }
     catch (Exception ex)
     {
     }
 }