コード例 #1
0
        private void PostPageChanges()
        {
            ServiceRequestsManagerToolBasicInformationGateway serviceRequestsManagerToolBasicInformationGateway = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolTDS);

            // basic variables
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int serviceId = Int32.Parse(hdfSelectedSRId.Value);

            int? libraryCategoriesId = null; if (serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId).HasValue) libraryCategoriesId = (int)serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId);

            // Service state
            string serviceState = "Assigned";
            string checklistState = "In Progress";
            if (ckbxAcceptSR.Checked) serviceState = "Accepted";
            if (ckbxStartSR.Checked) serviceState = "In Progress";
            if (ckbxCompleteSR.Checked)
            {
                serviceState = "Completed";
                checklistState = "Healthy";
            }

            // Get Assignment information
            DateTime? assignDeadlineDate = null;
            bool assignTeamMember = false;
            int? assignTeamMemberId = null;
            string assignThirdPartyVendor = "";
            DateTime? assignDateTime = null;

            if (hdfPnlAssignmentInformation.Value == "True")
            {
                // If data is modified
                if (hdfDeadlineDate.Value != "") assignDeadlineDate = DateTime.Parse(hdfDeadlineDate.Value);

                if ((hdfAssignToMyself.Value == "True") || (hdfAssignToTeamMember.Value == "True"))
                {
                    assignTeamMember = true;
                    assignTeamMemberId = Int32.Parse(hdfTeamMemberId.Value);
                }

                if (hdfThirdPartyVendor.Value != "")
                {
                    assignThirdPartyVendor = hdfThirdPartyVendor.Value;
                }

                assignDateTime = DateTime.Now;
            }
            else
            {
                // If data is not modified
                assignTeamMember = serviceRequestsManagerToolBasicInformationGateway.GetAssignTeamMember(serviceId);
                assignTeamMemberId = serviceRequestsManagerToolBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                assignThirdPartyVendor = serviceRequestsManagerToolBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                assignDeadlineDate = serviceRequestsManagerToolBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                assignDateTime = serviceRequestsManagerToolBasicInformationGateway.GetAssignmentDateTime(serviceId);
            }

            // Get acceptance information
            DateTime? acceptDateTime = null;
            DateTime? rejectDateTime = null;
            string rejectReason = "";

            if (hdfPnlAcceptInformation.Value == "True")
            {
                // If data is modified
                if (hdfAcceptSR.Value == "True")
                {
                    acceptDateTime = DateTime.Now;
                }
            }
            else
            {
                // If data is not modified
                acceptDateTime = serviceRequestsManagerToolBasicInformationGateway.GetAcceptedDateTime(serviceId);
                rejectDateTime = serviceRequestsManagerToolBasicInformationGateway.GetRejectDateTime(serviceId);
                rejectReason = serviceRequestsManagerToolBasicInformationGateway.GetRejectReason(serviceId);
            }

            // Get start work information
            DateTime? startWorkDateTime = null;
            DateTime? unitOutOfServiceDate = null;
            string unitOutOfServiceTime = "";
            string startWorkMileage = "";

            if (hdfPnlStartWorkInformation.Value == "True")
            {
                // If data is modified
                if (hdfStartSR.Value == "True")
                {
                    startWorkDateTime = DateTime.Now;
                    if (hdfUnitOutOfServiceDate.Value != "") unitOutOfServiceDate = DateTime.Parse(hdfUnitOutOfServiceDate.Value);
                    unitOutOfServiceTime = hdfUnitOutOfServiceTime.Value;
                    if (hdfStartMileage.Value != "") startWorkMileage = hdfStartMileage.Value;
                }
            }
            else
            {
                // If data is not modified
                startWorkDateTime = serviceRequestsManagerToolBasicInformationGateway.GetStartWorkDateTime(serviceId);
                unitOutOfServiceDate = serviceRequestsManagerToolBasicInformationGateway.GetUnitOutOfServiceDate(serviceId);
                unitOutOfServiceTime = serviceRequestsManagerToolBasicInformationGateway.GetUnitOutOfServiceTime(serviceId);
                startWorkMileage = serviceRequestsManagerToolBasicInformationGateway.GetStartWorkMileage(serviceId);
            }

            // Get complete work information
            DateTime? completeWorkDateTime = null;
            DateTime? unitBackInServiceDate = null;
            string unitBackInServiceTime = "";
            string completeWorkDetailDescription = "";
            bool completeWorkDetailPreventable = false;
            Decimal? completeWorkDetailTMLabourHours = null;
            Decimal? completeWorkDetailTMCost = null;
            string completeWorkInvoiceNumber = "";
            Decimal? completeWorkInvoiceAmount = null;
            string completeWorkMileage = "";

            if (hdfPnlCompleteWorkInformation.Value == "True")
            {
                // If data is modified
                if (ckbxCompleteSR.Checked)
                {
                    completeWorkDateTime = DateTime.Now;
                    if (hdfUnitBackInServiceDate.Value != "") unitBackInServiceDate = DateTime.Parse(hdfUnitBackInServiceDate.Value);
                    unitBackInServiceTime = hdfUnitBackInServiceTime.Value;
                    completeWorkDetailDescription = hdfCompleteWorkDescription.Value;
                    completeWorkDetailPreventable = Boolean.Parse(hdfCompleteWorkPreventable.Value);
                    if (hdfCompleteWorkLabourHours.Value != "") completeWorkDetailTMLabourHours = decimal.Parse(hdfCompleteWorkLabourHours.Value);
                    if (hdfCompleteWorkCosts.Value != "") completeWorkDetailTMCost = decimal.Parse(hdfCompleteWorkCosts.Value);
                    if (hdfInvoiceNumber.Value != "") completeWorkInvoiceNumber = hdfInvoiceNumber.Value;
                    if (hdfInvoiceAmount.Value != "") completeWorkInvoiceAmount = decimal.Parse(hdfInvoiceAmount.Value);
                    if (hdfCompleteWorkMileage.Value != "") completeWorkMileage = hdfCompleteWorkMileage.Value;
                }
            }
            else
            {
                // If data is not modified
                completeWorkDateTime = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDateTime(serviceId);
                unitBackInServiceDate = serviceRequestsManagerToolBasicInformationGateway.GetUnitBackInServiceDate(serviceId);
                unitBackInServiceTime = serviceRequestsManagerToolBasicInformationGateway.GetUnitBackInServiceTime(serviceId);
                completeWorkDetailDescription = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailDescription(serviceId);
                completeWorkDetailPreventable = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailPreventable(serviceId);
                completeWorkDetailTMLabourHours = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailTMLabourHours(serviceId);
                completeWorkDetailTMCost = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailTMCost(serviceId);
                completeWorkInvoiceNumber = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumber(serviceId);
                completeWorkInvoiceAmount = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmout(serviceId);
                completeWorkMileage = serviceRequestsManagerToolBasicInformationGateway.GetCompleteWorkMileage(serviceId);
            }

            // Insert to dataset
            ServiceRequestsManagerToolBasicInformation serviceRequestsManagerToolBasicInformation = new ServiceRequestsManagerToolBasicInformation(serviceRequestsManagerToolTDS);
            serviceRequestsManagerToolBasicInformation.Update(serviceId, serviceState, assignDateTime, assignDeadlineDate, assignTeamMember, assignTeamMemberId, assignThirdPartyVendor, acceptDateTime, startWorkDateTime, unitOutOfServiceDate, unitOutOfServiceTime, completeWorkDateTime, unitBackInServiceDate, unitBackInServiceTime, completeWorkDetailDescription, completeWorkDetailPreventable, completeWorkDetailTMLabourHours, completeWorkDetailTMCost, completeWorkInvoiceNumber, completeWorkInvoiceAmount, startWorkMileage, completeWorkMileage, checklistState, false, companyId, libraryCategoriesId);

            // Store session
            Session["serviceRequestsManagerToolTDS"] = serviceRequestsManagerToolTDS;
        }
コード例 #2
0
        // ////////////////////////////////////////////////////////////////////////
        // STEP2 - STEPS INFORMATION - METHODS
        //
        private void StepStepsInformationIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "";

            // Load data for selected service request
            int serviceId = Int32.Parse(hdfSelectedSRId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            ServiceRequestsManagerToolBasicInformation serviceRequestsManagerToolBasicInformation = new ServiceRequestsManagerToolBasicInformation(serviceRequestsManagerToolTDS);
            ServiceRequestsManagerToolCostInformation serviceRequestsManagerToolCostInformation = new ServiceRequestsManagerToolCostInformation(serviceRequestsManagerToolTDS);
            ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);

            if (Session["dialogOpenedServicesManagerTool"] == null)
            {
                // ... Load basic data
                serviceRequestsManagerToolBasicInformation.LoadByServiceId(serviceId, companyId);

                // ... Load costs
                serviceRequestsManagerToolCostInformation.LoadByServiceId(serviceId, companyId);

                //... Load notes
                serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);
            }
            else
            {
                ServiceRequestsManagerToolBasicInformationGateway serviceRequestsManagerToolBasicInformationGateway2 = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolBasicInformation.Data);

                Session.Remove("dialogOpenedServicesManagerTool");

                if (serviceRequestsManagerToolBasicInformationGateway2.GetAcceptedDateTime(serviceId).HasValue) ckbxAcceptSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetStartWorkDateTime(serviceId).HasValue) ckbxStartSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetUnitOutOfServiceDate(serviceId).HasValue) tkrdpStartWorkUnitOutOfServiceDate.SelectedDate = serviceRequestsManagerToolBasicInformationGateway2.GetUnitOutOfServiceDate(serviceId);
                tbxStartWorkStartMileage.Text = serviceRequestsManagerToolBasicInformationGateway2.GetStartWorkMileage(serviceId);
                if (serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDateTime(serviceId).HasValue) ckbxCompleteSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetUnitBackInServiceDate(serviceId).HasValue) tkrdpCompleteWorkUnitBackInServiceDate.SelectedDate = serviceRequestsManagerToolBasicInformationGateway2.GetUnitBackInServiceDate(serviceId);
                tbxCompleteWorkCompleteMileage.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkMileage(serviceId);
                tbxCompleteWorkDataDescription.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailDescription(serviceId);
                ckbxPreventableTPV.Checked = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailPreventable(serviceId);
                tbxCompleteWorkDataLabourHours.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailTMLabourHours(serviceId).ToString();
            }

            ServiceRequestsManagerToolBasicInformationGateway serviceRequestsManagerToolBasicInformationGateway = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolBasicInformation.Data);

            // Validate panels and information
            string state = serviceRequestsManagerToolBasicInformationGateway.GetServiceStateOriginal(serviceId);
            hdfState.Value = state;
            hdfServiceNumber.Value = serviceRequestsManagerToolBasicInformationGateway.GetServiceNumberOriginal(serviceId);
            hdfServiceDescription.Value = serviceRequestsManagerToolBasicInformationGateway.GetServiceDescriptionOriginal(serviceId);

            string originalThirdsPartyVendor = serviceRequestsManagerToolBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
            int? unitId = null;
            if (serviceRequestsManagerToolBasicInformationGateway.GetUnitId(serviceId).HasValue)
            {
                unitId = (int)serviceRequestsManagerToolBasicInformationGateway.GetUnitId(serviceId);
                hdfUnitId.Value = unitId.ToString();
            }

            // ... Validate vehicle information
            if (unitId.HasValue)
            {
                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId((int)unitId, companyId);
                string unitType = unitsGateway.GetType((int)unitId);
                hdfUnitType.Value = unitType;
                int companyLevel = unitsGateway.GetCompanyLevelId((int)unitId);
                hdfCompanyLevel.Value = unitsGateway.GetCompanyLevelId((int)unitId).ToString();

                CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
                companyLevelGateway.LoadByCompanyLevelId(companyLevel, companyId);
                hdfMileageUnitOfMeasurement.Value = companyLevelGateway.GetUnitsUnitOfMeasurement(companyLevel);
                lblStartWorkStartMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;
                lblCompleteWorkCompleteMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;

                if (unitType == "Vehicle")
                {
                    lblStartWorkStartMileage.Visible = true;
                    tbxStartWorkStartMileage.Visible = true;
                    lblCompleteWorkCompleteMileage.Visible = true;
                    tbxCompleteWorkCompleteMileage.Visible = true;
                    lblStartWorkStartMileageUnitOfMeasurement.Visible = true;
                    lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = true;
                }
                else
                {
                    lblStartWorkStartMileage.Visible = false;
                    tbxStartWorkStartMileage.Visible = false;
                    lblStartWorkStartMileageUnitOfMeasurement.Visible = false;
                    lblCompleteWorkCompleteMileage.Visible = false;
                    tbxCompleteWorkCompleteMileage.Visible = false;
                    lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = false;
                }
            }

            // ... Validate visible internal panels (complete work info)
            if (state == "Unassigned")
            {
                if (!rbtnAssignToThirdPartyVendor.Checked)
                {
                    pnlAssignTeamMember.Visible = true;
                    pnlAssignThirdPartyVendor.Visible = false;
                }
                else
                {
                    pnlAssignThirdPartyVendor.Visible = true;
                    pnlAssignTeamMember.Visible = false;
                }
            }
            else
            {
                bool teamMemberAssigned = serviceRequestsManagerToolBasicInformationGateway.GetAssignTeamMember(serviceId);
                if (teamMemberAssigned)
                {
                    pnlAssignTeamMember.Visible = true;
                    pnlAssignThirdPartyVendor.Visible = false;
                }
                else
                {
                    pnlAssignThirdPartyVendor.Visible = true;
                    pnlAssignTeamMember.Visible = false;
                }
            }

            // ... Validate panels
            switch (state)
            {
                case "Unassigned":
                    pnlAssignmentInformation.Visible = true;
                    acceptInformationSeparator.Visible = true;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Assigned":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Rejected":
                    pnlAssignmentInformation.Visible = true;
                    acceptInformationSeparator.Visible = true;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Accepted":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = false;
                    startWorkSeparator.Visible = false;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "In Progress":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = false;
                    startWorkSeparator.Visible = false;
                    pnlStartWorkInformation.Visible = false;
                    completeWorkSeparator.Visible = false;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                default:
                    throw new Exception("The option for " + wzServices.ActiveStep.Name + " step in services_manager_tool.Wizard_ActiveStepChanged function does not exist");
            }

            hdfPnlAcceptInformation.Value = pnlAcceptInformation.Visible.ToString();
            hdfPnlAssignmentInformation.Value = pnlAssignmentInformation.Visible.ToString();
            hdfPnlStartWorkInformation.Value = pnlStartWorkInformation.Visible.ToString();
            hdfPnlCompleteWorkInformation.Value = pnlCompleteWorkInformation.Visible.ToString();

            // ... Load resource library
            int? libraryCategoriesId = null; if (serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId).HasValue) libraryCategoriesId = (int)serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId);

            if (libraryCategoriesId.HasValue)
            {
                ViewState["libraryCategoriesId"] = (int)libraryCategoriesId;
                tbxCategoryAssocited.Text = GetFullCategoryName((int)libraryCategoriesId, companyId);
                btnAssociate.Visible = false;
                btnUnassociate.Visible = true;
            }
            else
            {
                tbxCategoryAssocited.Text = "";
                btnAssociate.Visible = true;
                btnUnassociate.Visible = false;
            }

            // Store session
            Session["serviceRequestsManagerToolTDS"] = serviceRequestsManagerToolTDS;
        }
        /// <summary>
        /// Save services
        /// </summary>        
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ServiceRequestsManagerToolTDS serviceRequestsManagerToolChanges = (ServiceRequestsManagerToolTDS)Data.GetChanges();

            if (serviceRequestsManagerToolChanges.BasicInformation.Rows.Count > 0)
            {
                ServiceRequestsManagerToolBasicInformationGateway srManagerToolBasicInformationGateway = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolChanges);

                foreach (ServiceRequestsManagerToolTDS.BasicInformationRow row in (ServiceRequestsManagerToolTDS.BasicInformationDataTable)serviceRequestsManagerToolChanges.BasicInformation)
                {
                    // Unchanged values
                    int serviceId = row.ServiceID;
                    string type = srManagerToolBasicInformationGateway.GetTypeOriginal(serviceId);
                    string serviceNumber = srManagerToolBasicInformationGateway.GetServiceNumberOriginal(serviceId);
                    DateTime dateTime_ = srManagerToolBasicInformationGateway.GetDateTime_Original(serviceId);
                    int? unitID = srManagerToolBasicInformationGateway.GetUnitIdOriginal(serviceId);
                    int ownerId = srManagerToolBasicInformationGateway.GetOwnerIdOriginal(serviceId);
                    string serviceDescription = srManagerToolBasicInformationGateway.GetServiceDescriptionOriginal(serviceId);
                    DateTime? rejectDateTime = srManagerToolBasicInformationGateway.GetRejectDateTimeOriginal(serviceId);
                    string rejectReason = srManagerToolBasicInformationGateway.GetRejectReasonOriginal(serviceId);
                    string notes = srManagerToolBasicInformationGateway.GetNotesOriginal(serviceId);
                    int? ruleId = srManagerToolBasicInformationGateway.GetRuleIdOriginal(serviceId);
                    bool deleted = srManagerToolBasicInformationGateway.GetDeletedOriginal(serviceId);
                    bool mto = srManagerToolBasicInformationGateway.GetMtoOriginal(serviceId);

                    // Original values
                    string originalState = srManagerToolBasicInformationGateway.GetServiceStateOriginal(serviceId);
                    DateTime? originalDateTime_ = srManagerToolBasicInformationGateway.GetAssignmentDateTimeOriginal(serviceId);
                    DateTime? originalAssignmentDeadlineDate = srManagerToolBasicInformationGateway.GetAssignedDeadlineDateOriginal(serviceId);
                    bool originalAssignTeamMember = srManagerToolBasicInformationGateway.GetAssignTeamMemberOriginal(serviceId);
                    int? originalAssignTeamMemberId = srManagerToolBasicInformationGateway.GetAssignTeamMemberIdOriginal(serviceId);
                    string originalAssignThirdPartyVendor = srManagerToolBasicInformationGateway.GetAssignedThirdPartyVendorOriginal(serviceId);
                    DateTime? originalAcceptDatetime = srManagerToolBasicInformationGateway.GetAcceptedDateTimeOriginal(serviceId);
                    DateTime? originalStartWorkDateTime = srManagerToolBasicInformationGateway.GetStartWorkDateTimeOriginal(serviceId);
                    DateTime? originalUnitOutOfServiceDate = srManagerToolBasicInformationGateway.GetUnitOutOfServiceDateOriginal(serviceId);
                    string originalUnitOutOfServiceTime = srManagerToolBasicInformationGateway.GetUnitOutOfServiceTimeOriginal(serviceId);
                    DateTime? originalCompleteWorkDateTime = srManagerToolBasicInformationGateway.GetCompleteWorkDateTimeOriginal(serviceId);
                    DateTime? originalUnitBackInServiceDate = srManagerToolBasicInformationGateway.GetUnitBackInServiceDateOriginal(serviceId);
                    string originalUnitBackInServiceTime = srManagerToolBasicInformationGateway.GetUnitBackInServiceTimeOriginal(serviceId);
                    string originalCompleteWorkDetailDescription = srManagerToolBasicInformationGateway.GetCompleteWorkDetailDescriptionOriginal(serviceId);
                    bool originalCompleteWorkDetailPreventable = srManagerToolBasicInformationGateway.GetCompleteWorkDetailPreventableOriginal(serviceId);
                    Decimal? originalCompleteWorkDetailTMLabourHours = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTMLabourHoursOriginal(serviceId);
                    Decimal? originalCompleteWorkDetailTMCost = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTMCostOriginal(serviceId);
                    string originalCompleteWorkDetailTPVInvoiceNumber = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumberOriginal(serviceId);
                    Decimal? originalCompleteWorkDetailTPVInvoiceAmount = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmoutOriginal(serviceId);
                    string originalMileage = srManagerToolBasicInformationGateway.GetMileageOriginal(serviceId);
                    string originalStartWorkMileage = srManagerToolBasicInformationGateway.GetStartWorkMileageOriginal(serviceId);
                    string originalCompleteWorkMileage = srManagerToolBasicInformationGateway.GetCompleteWorkMileageOriginal(serviceId);
                    int? originalLibraryCategoriesId = null; if (srManagerToolBasicInformationGateway.GetLibraryCategoriesIdOriginal(serviceId).HasValue) originalLibraryCategoriesId = srManagerToolBasicInformationGateway.GetLibraryCategoriesIdOriginal(serviceId).Value;

                    // New values
                    string newState = srManagerToolBasicInformationGateway.GetServiceState(serviceId);
                    DateTime? newDateTime_ = srManagerToolBasicInformationGateway.GetAssignmentDateTime(serviceId);
                    DateTime? newAssignmentDeadlineDate = srManagerToolBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                    bool newAssignTeamMember = srManagerToolBasicInformationGateway.GetAssignTeamMember(serviceId);
                    int? newAssignTeamMemberId = srManagerToolBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                    string newAssignThirdPartyVendor = srManagerToolBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                    DateTime? newAcceptDatetime = srManagerToolBasicInformationGateway.GetAcceptedDateTime(serviceId);
                    DateTime? newStartWorkDateTime = srManagerToolBasicInformationGateway.GetStartWorkDateTime(serviceId);
                    DateTime? newUnitOutOfServiceDate = srManagerToolBasicInformationGateway.GetUnitOutOfServiceDate(serviceId);
                    string newUnitOutOfServiceTime = srManagerToolBasicInformationGateway.GetUnitOutOfServiceTime(serviceId);
                    DateTime? newCompleteWorkDateTime = srManagerToolBasicInformationGateway.GetCompleteWorkDateTime(serviceId);
                    DateTime? newUnitBackInServiceDate = srManagerToolBasicInformationGateway.GetUnitBackInServiceDate(serviceId);
                    string newUnitBackInServiceTime = srManagerToolBasicInformationGateway.GetUnitBackInServiceTime(serviceId);
                    string newCompleteWorkDetailDescription = srManagerToolBasicInformationGateway.GetCompleteWorkDetailDescription(serviceId);
                    bool newCompleteWorkDetailPreventable = srManagerToolBasicInformationGateway.GetCompleteWorkDetailPreventable(serviceId);
                    Decimal? newCompleteWorkDetailTMLabourHours = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTMLabourHours(serviceId);
                    Decimal? newCompleteWorkDetailTMCost = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTMCost(serviceId);
                    string newCompleteWorkDetailTPVInvoiceNumber = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumber(serviceId);
                    Decimal? newCompleteWorkDetailTPVInvoiceAmount = srManagerToolBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmout(serviceId);
                    string newMileage = srManagerToolBasicInformationGateway.GetMileage(serviceId);
                    string newStartWorkMileage = srManagerToolBasicInformationGateway.GetStartWorkMileage(serviceId);
                    string newCompleteWorkMileage = srManagerToolBasicInformationGateway.GetCompleteWorkMileage(serviceId);
                    int? newLibraryCategoriesId = null; if (srManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId).HasValue) newLibraryCategoriesId = srManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId).Value;

                    Services services = new Services(null);
                    services.UpdateDirect(serviceId, serviceNumber, dateTime_, mto, serviceDescription, unitID, type, originalState, ownerId, originalDateTime_, originalAssignmentDeadlineDate, originalAssignTeamMember, originalAssignTeamMemberId, originalAssignThirdPartyVendor, originalAcceptDatetime, rejectDateTime, rejectReason, originalStartWorkDateTime, originalUnitOutOfServiceDate, originalUnitOutOfServiceTime, originalCompleteWorkDateTime, originalUnitBackInServiceDate, originalUnitBackInServiceTime, originalCompleteWorkDetailDescription, originalCompleteWorkDetailPreventable, originalCompleteWorkDetailTMLabourHours, originalCompleteWorkDetailTMCost, originalCompleteWorkDetailTPVInvoiceNumber, originalCompleteWorkDetailTPVInvoiceAmount, deleted, companyId, notes, ruleId, originalMileage, originalStartWorkMileage, originalCompleteWorkMileage, originalLibraryCategoriesId, serviceNumber, dateTime_, mto, serviceDescription, unitID, type, newState, ownerId, newDateTime_, newAssignmentDeadlineDate, newAssignTeamMember, newAssignTeamMemberId, newAssignThirdPartyVendor, newAcceptDatetime, rejectDateTime, rejectReason, newStartWorkDateTime, newUnitOutOfServiceDate, newUnitOutOfServiceTime, newCompleteWorkDateTime, newUnitBackInServiceDate, newUnitBackInServiceTime, newCompleteWorkDetailDescription, newCompleteWorkDetailPreventable, newCompleteWorkDetailTMLabourHours, newCompleteWorkDetailTMCost, newCompleteWorkDetailTPVInvoiceNumber, newCompleteWorkDetailTPVInvoiceAmount, deleted, companyId, notes, ruleId, newMileage, newStartWorkMileage, newCompleteWorkMileage, newLibraryCategoriesId);

                    if (unitID.HasValue)
                    {
                        if (newState == "In Progress")
                        {
                            LiquiForce.LFSLive.BL.FleetManagement.Units.Units units = new LiquiForce.LFSLive.BL.FleetManagement.Units.Units(null);
                            units.UpdateStateDirect((int)unitID, companyId, "Out Of Service");
                        }

                        if (newState == "Completed")
                        {
                            LiquiForce.LFSLive.BL.FleetManagement.Units.Units units = new LiquiForce.LFSLive.BL.FleetManagement.Units.Units(null);
                            units.UpdateStateDirect((int)unitID, companyId, "Active");
                        }
                    }

                    // Update checklist
                    if (type == "Checklist")
                    {
                        // ... Original values
                        DateTime? originalAssociatedChecklistLastService = srManagerToolBasicInformationGateway.GetAssociatedChecklistLastServiceOriginal(serviceId);
                        DateTime? originalAssociatedChecklistNextDue = srManagerToolBasicInformationGateway.GetAssociatedChecklistNextDueOriginal(serviceId);
                        bool originalAssociatedChecklistDone = srManagerToolBasicInformationGateway.GetAssociatedChecklistDoneOriginal(serviceId);
                        bool originalAssociatedChecklistDeleted = srManagerToolBasicInformationGateway.GetAssociatedChecklistDeletedOriginal(serviceId);
                        int originalAssociatedChecklistCompanyId = srManagerToolBasicInformationGateway.GetAssociatedChecklistCompanyIdOriginal(serviceId);
                        string originalAssociatedChecklistRuleState = srManagerToolBasicInformationGateway.GetAssociatedChecklistRuleStateOriginal(serviceId);

                        // ... New values
                        DateTime? newAssociatedChecklistLastService = srManagerToolBasicInformationGateway.GetAssociatedChecklistLastService(serviceId);
                        DateTime? newAssociatedChecklistNextDue = srManagerToolBasicInformationGateway.GetAssociatedChecklistNextDue(serviceId);
                        bool newAssociatedChecklistDone = srManagerToolBasicInformationGateway.GetAssociatedChecklistDone(serviceId);
                        bool newAssociatedChecklistDeleted = srManagerToolBasicInformationGateway.GetAssociatedChecklistDeleted(serviceId);
                        int newAssociatedChecklistCompanyId = srManagerToolBasicInformationGateway.GetAssociatedChecklistCompanyId(serviceId);
                        string newAssociatedChecklistRuleState = srManagerToolBasicInformationGateway.GetAssociatedChecklistRuleState(serviceId);

                        // ... Update
                        Checklist checklist = new Checklist();
                        checklist.UpdateDirect((int)unitID, (int)ruleId, originalAssociatedChecklistLastService, originalAssociatedChecklistNextDue, originalAssociatedChecklistDone, originalAssociatedChecklistRuleState, originalAssociatedChecklistDeleted, originalAssociatedChecklistCompanyId, (int)unitID, (int)ruleId, newAssociatedChecklistLastService, newAssociatedChecklistNextDue, newAssociatedChecklistDone, newAssociatedChecklistRuleState, originalAssociatedChecklistDeleted, originalAssociatedChecklistCompanyId);
                    }
                }
            }
        }