/// <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);
                    }
                }
            }
        }