コード例 #1
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        public void Save(int unitId, int companyId)
        {
            foreach (UnitsAddTDS.UnitsChecklistRulesTempRow row in (UnitsAddTDS.UnitsChecklistRulesTempDataTable)Data.Tables["UnitsChecklistRulesTemp"])
            {
                string state = "Healthy";
                if (row.Selected)
                {
                    DateTime? lastService = null; if (!row.IsLastServiceNull()) lastService = row.LastService;
                    DateTime? nextDue = null; if (!row.IsNextDueNull()) nextDue = row.NextDue;

                    // Get state
                    state = GetChecklistState(row.RuleID, row.Frequency, lastService, nextDue, companyId);

                    if (row.Frequency != "Only once")
                    {
                        if (lastService.HasValue)
                        {
                            // Get next due
                            DateTime timeToAdded = new DateTime(((DateTime)lastService).Year, ((DateTime)lastService).Month, ((DateTime)lastService).Day);

                            if (row.Frequency == "Monthly") nextDue = timeToAdded.AddMonths(1);
                            if (row.Frequency == "Every 2 months") nextDue = timeToAdded.AddMonths(2);
                            if (row.Frequency == "Every 3 months") nextDue = timeToAdded.AddMonths(3);
                            if (row.Frequency == "Every 4 months") nextDue = timeToAdded.AddMonths(4);
                            if (row.Frequency == "Every 6 months") nextDue = timeToAdded.AddMonths(6);
                            if (row.Frequency == "Yearly") nextDue = timeToAdded.AddYears(1);
                        }
                    }

                    Checklist checklist = new Checklist(null);
                    checklist.InsertDirect(unitId, row.RuleID, lastService, nextDue, row.Done, state, false, companyId);
                }
                else
                {
                    state = "Inactive";

                    DateTime? lastService = null; if (!row.IsLastServiceNull()) lastService = row.LastService;
                    DateTime? nextDue = null; if (!row.IsNextDueNull()) nextDue = row.NextDue;

                    Checklist checklist = new Checklist(null);
                    checklist.InsertDirect(unitId, row.RuleID, lastService, nextDue, row.Done, state, false, companyId);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Save services
        /// </summary>
        /// <param name="dateTime_">dateTime_</param>
        /// <param name="employeeId">employeeId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="checklistState">checklistState</param>
        public int? Save(DateTime dateTime_, int employeeId, int companyId)
        {
            int? newServiceId = null;

            ServicesAddRequestTDS servicesAddRequestSelfAsignedChanges = (ServicesAddRequestTDS)Data.GetChanges();
            if (servicesAddRequestSelfAsignedChanges.BasicInformation.Rows.Count > 0)
            {
                ServicesGateway servicesGateway = new ServicesGateway(servicesAddRequestSelfAsignedChanges);

                foreach (ServicesAddRequestTDS.BasicInformationRow row in (ServicesAddRequestTDS.BasicInformationDataTable)servicesAddRequestSelfAsignedChanges.BasicInformation)
                {
                    DateTime? assignmentDeadlineDate = null; if (!row.IsAssignedDeadlineDateNull()) assignmentDeadlineDate = row.AssignedDeadlineDate;
                    DateTime? assignDateTime = null; if(row.IsAssignDateTimeNull()) row.AssignDateTime = DateTime.Now;
                    DateTime? acceptDatetime = null; if (!row.IsAcceptDatetimeNull()) acceptDatetime = row.AcceptDatetime;
                    DateTime? unitOutOfServiceDate = null; if (!row.IsUnitOutOfServiceDateNull()) unitOutOfServiceDate = row.UnitOutOfServiceDate;
                    string unitOutOfServiceTime = ""; if (!row.IsUnitOutOfServiceTimeNull()) unitOutOfServiceTime = row.UnitOutOfServiceTime;
                    DateTime? completeWorkDateTime = null; if (!row.IsCompleteWorkDateTimeNull()) completeWorkDateTime = row.CompleteWorkDateTime;
                    DateTime? unitBackInServiceDate = null; if (!row.IsUnitBackInServiceDateNull()) unitBackInServiceDate = row.UnitBackInServiceDate;
                    string unitBackInServiceTime = ""; if (!row.IsUnitBackInServiceTimeNull()) unitBackInServiceTime = row.UnitBackInServiceTime;
                    string completeWorkDetailDescription = ""; if (!row.IsCompleteWorkDetailDescriptionNull()) completeWorkDetailDescription = row.CompleteWorkDetailDescription;
                    bool completeWorkDetailPreventable = row.CompleteWorkDetailPreventable;
                    Decimal? completeWorkDetailTMLabourHours = null; if (!row.IsCompleteWorkDetailTMLabourHoursNull()) completeWorkDetailTMLabourHours = row.CompleteWorkDetailTMLabourHours;
                    Decimal? completeWorkDetailTMCost = null; if (!row.IsCompleteWorkDetailTMCostNull()) completeWorkDetailTMCost = row.CompleteWorkDetailTMCost;
                    string completeWorkDetaildTPVInvoiceNumber = ""; if (!row.IsCompleteWorkInvoiceNumberNull()) completeWorkDetaildTPVInvoiceNumber = row.CompleteWorkInvoiceNumber;
                    Decimal? completeWorkDetaildTPVInvoiceAmount = null; if (!row.IsCompleteWorkInvoiceAmountNull()) completeWorkDetaildTPVInvoiceAmount = row.CompleteWorkInvoiceAmount;
                    string mileage = ""; if (!row.IsMileageNull()) mileage = row.Mileage;
                    string startWorkMileage = ""; if (!row.IsStartWorkMileageNull()) startWorkMileage = row.StartWorkMileage;
                    string completeWorkMileage = ""; if (!row.IsCompleteWorkMileageNull()) completeWorkMileage = row.CompleteWorkMileage;
                    bool assignTeamMember = row.AssignTeamMember;
                    int? assignTeamMemberId = null; if (!row.IsAssignTeamMemberIdNull()) assignTeamMemberId = row.AssignTeamMemberId;
                    string assignThirdPartyVendor = ""; if (!row.IsAssignThirdPartyVendorNull()) assignThirdPartyVendor = row.AssignThirdPartyVendor;
                    DateTime? startWorkDateTime = null; if (!row.IsUnitOutOfServiceDateNull()) startWorkDateTime =  DateTime.Now;
                    int? ruleId = null; if (!row.IsRuleIDNull()) ruleId = row.RuleID;
                    string type = ""; if (ruleId.HasValue) type = "Checklist"; else type = "Normal";
                    int? libraryCategoriesId = 3736;//Fleet Maintence Invoices folder

                    Services services = new Services(null);
                    newServiceId = services.InsertDirect(dateTime_, row.MtoDot, row.ServiceDescription, row.UnitID, type, row.ServiceState, employeeId, assignDateTime, assignmentDeadlineDate, assignTeamMember, assignTeamMemberId, assignThirdPartyVendor, acceptDatetime, null, "", startWorkDateTime, unitOutOfServiceDate, unitOutOfServiceTime, completeWorkDateTime, unitBackInServiceDate, unitBackInServiceTime, completeWorkDetailDescription, completeWorkDetailPreventable, completeWorkDetailTMLabourHours, completeWorkDetailTMCost, completeWorkDetaildTPVInvoiceNumber, completeWorkDetaildTPVInvoiceAmount, "", ruleId, mileage, startWorkMileage, completeWorkMileage, row.Deleted, row.COMPANY_ID, libraryCategoriesId);

                    // modify checklist state
                    if (ruleId.HasValue)
                    {
                        string newChecklistState = "In Progress";

                        if (row.ServiceState == "Completed")
                        {
                            RuleGateway ruleGateway = new RuleGateway();
                            ruleGateway.LoadAllByRuleId(row.RuleID, row.COMPANY_ID);

                            DateTime? newLastService = null; newLastService = DateTime.Now;
                            DateTime? newNextDue = null;
                            bool newDone = true;
                            newChecklistState = "Healthy";

                            if (newLastService.HasValue)
                            {
                                ChecklistGateway checklistGateway = new ChecklistGateway();
                                checklistGateway.LoadByUnitIdRuleId(row.UnitID, row.RuleID, companyId);

                                // ... Original values
                                DateTime? originalLastService = checklistGateway.GetLastService(row.UnitID, row.RuleID);
                                DateTime? originalNextDue = checklistGateway.GetNextDue(row.UnitID, row.RuleID);
                                bool originalDone = checklistGateway.GetDone(row.UnitID, row.RuleID);
                                string originalState = checklistGateway.GetState(row.UnitID, row.RuleID);

                                string frecuency = ruleGateway.GetFrequency(row.RuleID);

                                if (frecuency != "Only once")
                                {
                                    // Get next due
                                    DateTime timeToAdded = new DateTime(((DateTime)newLastService).Year, ((DateTime)newLastService).Month, ((DateTime)newLastService).Day);

                                    if (frecuency == "Monthly") newNextDue = timeToAdded.AddMonths(1);
                                    if (frecuency == "Every 2 months") newNextDue = timeToAdded.AddMonths(2);
                                    if (frecuency == "Every 3 months") newNextDue = timeToAdded.AddMonths(3);
                                    if (frecuency == "Every 4 months") newNextDue = timeToAdded.AddMonths(4);
                                    if (frecuency == "Every 6 months") newNextDue = timeToAdded.AddMonths(6);
                                    if (frecuency == "Yearly") newNextDue = timeToAdded.AddYears(1);

                                    newDone = false;
                                }

                                Checklist checklist = new Checklist();
                                checklist.UpdateDirect(row.UnitID, row.RuleID, originalLastService, originalNextDue, originalDone, originalState, false, companyId, row.UnitID, row.RuleID, newLastService, newNextDue, newDone, newChecklistState, false, companyId);
                            }
                        }
                        else
                        {
                            Checklist checklist = new Checklist(null);
                            checklist.UpdateStateDirect(ruleId.Value, row.UnitID, companyId, newChecklistState);
                        }
                    }
                }
            }

            return newServiceId;
        }
コード例 #3
0
        /// <summary>
        /// DeleteChecklists
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        private void DeleteChecklists(int unitId, int companyId)
        {
            ChecklistGateway checklistGateway = new ChecklistGateway(null);

            if (checklistGateway.IsUnitUsedInChecklist(unitId))
            {
                // Delete all checklists for unitId
                Checklist checklist = new Checklist(null);
                checklist.DeleteDirectByUnitId(unitId, companyId);
            }
        }
コード例 #4
0
        /// <summary>
        /// UpdateRuleCategory
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="companyLevelsSelected">companyLevelsSelected</param>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="unitsSelected">unitsSelected</param>
        private void UpdateRuleCategory(int ruleId, int companyId, ArrayList companyLevelsSelected, ArrayList categoriesSelected, ArrayList unitsSelected)
        {
            // Insert into checklist only selected units
            foreach (int categoryId in categoriesSelected)
            {
                RuleCategory ruleCategory = new RuleCategory(null);
                ruleCategory.InsertDirect(ruleId, categoryId, false, companyId);

                foreach (int unitId in unitsSelected)
                {
                    //int unitId = row.UnitID;

                    // Save categories and selected units
                    UnitsCategoryGateway unitsCategoryGatewayExist = new UnitsCategoryGateway(null);
                    if (unitsCategoryGatewayExist.IsUsedInUnitCategory(unitId, categoryId, false))
                    {
                        RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                        ruleCategoryUnits.InsertDirect(ruleId, categoryId, unitId, false, companyId);
                    }

                    // Save Chechklists for selected units
                    foreach (int companyLevelId in companyLevelsSelected)
                    {
                        UnitsGateway unitsGateway = new UnitsGateway(null);

                        if (unitsGateway.IsUsedInUnitsAndNotIsDisposed(unitId, companyLevelId))
                        {
                            ChecklistGateway checklistGateway = new ChecklistGateway(null);
                            if (!checklistGateway.IsUsedInChecklist(unitId, ruleId))
                            {
                                Checklist checklist = new Checklist(null);
                                checklist.InsertDirect(unitId, ruleId, null, null, false, "Unknown", false, companyId);
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ServiceInformationTDS servicesInformationChanges = (ServiceInformationTDS)Data.GetChanges();

            if (servicesInformationChanges.BasicInformation.Rows.Count > 0)
            {
                ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(servicesInformationChanges);

                // Update services
                foreach (ServiceInformationTDS.BasicInformationRow basicInformationRow in (ServiceInformationTDS.BasicInformationDataTable)servicesInformationChanges.BasicInformation)
                {
                    // Unchanged values
                    int serviceId = basicInformationRow.ServiceID;
                    string number = serviceInformationBasicInformationGateway.GetServiceNumber(serviceId);
                    DateTime dateTime_ = serviceInformationBasicInformationGateway.GetDateTime_(serviceId);
                    int? unitId = null; if (serviceInformationBasicInformationGateway.GetUnitID(serviceId).HasValue) unitId = serviceInformationBasicInformationGateway.GetUnitID(serviceId);
                    string type = serviceInformationBasicInformationGateway.GetType(serviceId);
                    int ownerId = serviceInformationBasicInformationGateway.GetOwnerID(serviceId);

                    // Original values
                    bool originalMtoDto = serviceInformationBasicInformationGateway.GetMtoDtoOriginal(serviceId);
                    string originalDescription = serviceInformationBasicInformationGateway.GetServiceDescriptionOriginal(serviceId);
                    string originalState = serviceInformationBasicInformationGateway.GetServiceStateOriginal(serviceId);
                    DateTime? originalAssignDateTime = null; if (serviceInformationBasicInformationGateway.GetAssignmentDateTimeOriginal(serviceId).HasValue) originalAssignDateTime = (DateTime)serviceInformationBasicInformationGateway.GetAssignmentDateTimeOriginal(serviceId);
                    DateTime? originalAssignDeadlineDate = null; if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDateOriginal(serviceId).HasValue) originalAssignDeadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDateOriginal(serviceId);
                    bool originalAssignTeamMember = serviceInformationBasicInformationGateway.GetToTeamMemberOriginal(serviceId);
                    int? originalAssignTeamMemberID = null; if (serviceInformationBasicInformationGateway.GetAssignTeamMemberIdOriginal(serviceId).HasValue) originalAssignTeamMemberID = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberIdOriginal(serviceId);
                    string originalAssignThirdPartyVendor = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendorOriginal(serviceId);
                    DateTime? originalAcceptDateTime = null; if (serviceInformationBasicInformationGateway.GetAcceptedDateTimeOriginal(serviceId).HasValue) originalAcceptDateTime = (DateTime)serviceInformationBasicInformationGateway.GetAcceptedDateTimeOriginal(serviceId);
                    DateTime? originalRejectDateTime = null; if (serviceInformationBasicInformationGateway.GetRejectedDateTimeOriginal(serviceId).HasValue) originalRejectDateTime = (DateTime)serviceInformationBasicInformationGateway.GetRejectedDateTimeOriginal(serviceId);
                    string originalRejectReason = serviceInformationBasicInformationGateway.GetRejectedReasonOriginal(serviceId);
                    DateTime? originalStartWorkDateTime = null; if (serviceInformationBasicInformationGateway.GetStartWorkDateTimeOriginal(serviceId).HasValue) originalStartWorkDateTime = (DateTime)serviceInformationBasicInformationGateway.GetStartWorkDateTimeOriginal(serviceId);
                    DateTime? originalStartWorkOutOfServiceDate = null; if (serviceInformationBasicInformationGateway.GetUnitOutOfServiceDateOriginal(serviceId).HasValue) originalStartWorkOutOfServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitOutOfServiceDateOriginal(serviceId);
                    string originalStartWorkOutOfServiceTime = serviceInformationBasicInformationGateway.GetUnitOutOfServiceTimeOriginal(serviceId);
                    DateTime? originalCompleteWorkDateTime = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDateTimeOriginal(serviceId).HasValue) originalCompleteWorkDateTime = (DateTime)serviceInformationBasicInformationGateway.GetCompleteWorkDateTimeOriginal(serviceId);
                    DateTime? originalCompleteWorkBackToServiceDate = null; if (serviceInformationBasicInformationGateway.GetUnitBackInServiceDateOriginal(serviceId).HasValue) originalCompleteWorkBackToServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitBackInServiceDateOriginal(serviceId);
                    string originalCompleteWorkBackToServiceTime = serviceInformationBasicInformationGateway.GetUnitBackInServiceTimeOriginal(serviceId);
                    string originalCompleteWorkDetailDescription = serviceInformationBasicInformationGateway.GetCompleteWorkDetailDescriptionOriginal(serviceId);
                    bool originalCompleteWorkDetailPreventable = serviceInformationBasicInformationGateway.GetCompleteWorkDetailPreventableOriginal(serviceId);
                    decimal? originalCompleteWorkDetailTMLabourHours = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMLabourHoursOriginal(serviceId).HasValue) originalCompleteWorkDetailTMLabourHours = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMLabourHoursOriginal(serviceId);
                    decimal? originalCompleteWorkDetailTMCost = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMCostOriginal(serviceId).HasValue) originalCompleteWorkDetailTMCost = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMCostOriginal(serviceId);
                    string originalCompleteWorkDetailTPVInvoiceNumber = serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumberOriginal(serviceId);
                    decimal? originalCompleteWorkDetailTPVInvoiceAmout = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmoutOriginal(serviceId).HasValue) originalCompleteWorkDetailTPVInvoiceAmout = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmoutOriginal(serviceId);
                    string originalNotes = serviceInformationBasicInformationGateway.GetNotesOriginal(serviceId);
                    int? originalRuleId = null; if (serviceInformationBasicInformationGateway.GetRuleIdOriginal(serviceId).HasValue) originalRuleId = (int)serviceInformationBasicInformationGateway.GetRuleIdOriginal(serviceId);
                    string originalMileage = serviceInformationBasicInformationGateway.GetMileageOriginal(serviceId);
                    string originalStartWorkMileage = serviceInformationBasicInformationGateway.GetStartWorkMileageOriginal(serviceId);
                    string originalCompleteWorkMileage = serviceInformationBasicInformationGateway.GetCompleteWorkMileageOriginal(serviceId);
                    bool originalDeleted = serviceInformationBasicInformationGateway.GetDeletedOriginal(serviceId);
                    int? originalLibraryCategoriesId = null; if (serviceInformationBasicInformationGateway.GetLibraryCategoriesIdOriginal(serviceId).HasValue) originalLibraryCategoriesId = serviceInformationBasicInformationGateway.GetLibraryCategoriesIdOriginal(serviceId).Value;

                    // New variables
                    bool newMtoDto = serviceInformationBasicInformationGateway.GetMtoDto(serviceId);
                    string newDescription = serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);
                    string newState = serviceInformationBasicInformationGateway.GetServiceState(serviceId);
                    DateTime? newAssignDateTime = null; if(serviceInformationBasicInformationGateway.GetAssignmentDateTime(serviceId).HasValue) newAssignDateTime = (DateTime)serviceInformationBasicInformationGateway.GetAssignmentDateTime(serviceId);
                    DateTime? newAssignDeadlineDate = null; if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue) newAssignDeadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                    bool newAssignTeamMember = serviceInformationBasicInformationGateway.GetToTeamMember(serviceId);
                    int? newAssignTeamMemberId = null; if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue) newAssignTeamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                    string newAssignThirdPartyVendor = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                    DateTime? newAcceptDateTime = null; if(serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId).HasValue) newAcceptDateTime = (DateTime)serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId);
                    DateTime? newRejectDateTime = null; if(serviceInformationBasicInformationGateway.GetRejectedDateTime(serviceId).HasValue) newRejectDateTime = (DateTime)serviceInformationBasicInformationGateway.GetRejectedDateTime(serviceId);
                    string newRejectReason = serviceInformationBasicInformationGateway.GetRejectedReason(serviceId);
                    DateTime? newStartWorkDateTime = null;  if( serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId).HasValue) newStartWorkDateTime = (DateTime) serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId);
                    DateTime? newStartWorkOutOfServiceDate = null; if (serviceInformationBasicInformationGateway.GetUnitOutOfServiceDate(serviceId).HasValue) newStartWorkOutOfServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitOutOfServiceDate(serviceId);
                    string newStartWorkOutOfServiceTime = serviceInformationBasicInformationGateway.GetUnitOutOfServiceTime(serviceId);
                    DateTime? newCompleteWorkDateTime = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId).HasValue) newCompleteWorkDateTime = (DateTime)serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId);
                    DateTime? newCompleteWorkBackToServiceDate = null; if (serviceInformationBasicInformationGateway.GetUnitBackInServiceDate(serviceId).HasValue) newCompleteWorkBackToServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitBackInServiceDate(serviceId);
                    string newCompleteWorkBackToServiceTime = serviceInformationBasicInformationGateway.GetUnitBackInServiceTime(serviceId);
                    string newCompleteWorkDetailDescription = serviceInformationBasicInformationGateway.GetCompleteWorkDetailDescription(serviceId);
                    bool newCompleteWorkDetailPreventable = serviceInformationBasicInformationGateway.GetCompleteWorkDetailPreventable(serviceId);
                    decimal? newCompleteWorkDetailTMLabourHours = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMLabourHours(serviceId).HasValue) newCompleteWorkDetailTMLabourHours = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMLabourHours(serviceId);
                    decimal? newCompleteWorkDetailTMCost = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMCost(serviceId).HasValue) newCompleteWorkDetailTMCost = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMCost(serviceId);
                    string newCompleteWorkDetailTPVInvoiceNumber = serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumber(serviceId);
                    decimal? newCompleteWorkDetailTPVInvoiceAmout = null; if (serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmout(serviceId).HasValue) newCompleteWorkDetailTPVInvoiceAmout = (decimal)serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmout(serviceId);
                    string newNotes = serviceInformationBasicInformationGateway.GetNotes(serviceId);
                    int? newRuleId = null; if (serviceInformationBasicInformationGateway.GetRuleId(serviceId).HasValue) newRuleId = (int)serviceInformationBasicInformationGateway.GetRuleId(serviceId);
                    string newMileage = serviceInformationBasicInformationGateway.GetMileage(serviceId);
                    string newStartWorkMileage = serviceInformationBasicInformationGateway.GetStartWorkMileage(serviceId);
                    string newCompleteWorkMileage = serviceInformationBasicInformationGateway.GetCompleteWorkMileage(serviceId);
                    int? newLibraryCategoriesId = null; if (serviceInformationBasicInformationGateway.GetLibraryCategoriesId(serviceId).HasValue) newLibraryCategoriesId = serviceInformationBasicInformationGateway.GetLibraryCategoriesId(serviceId).Value;
                    bool newDeleted = serviceInformationBasicInformationGateway.GetDeleted(serviceId);

                    // ... Update
                    UpdateService(serviceId, number, dateTime_, originalMtoDto, originalDescription, unitId, type, originalState, ownerId, originalAssignDateTime, originalAssignDeadlineDate, originalAssignTeamMember, originalAssignTeamMemberID, originalAssignThirdPartyVendor, originalAcceptDateTime, originalRejectDateTime, originalRejectReason, originalStartWorkDateTime, originalStartWorkOutOfServiceDate, originalStartWorkOutOfServiceTime, originalCompleteWorkDateTime, originalCompleteWorkBackToServiceDate, originalCompleteWorkBackToServiceTime, originalCompleteWorkDetailDescription, originalCompleteWorkDetailPreventable, originalCompleteWorkDetailTMLabourHours, originalCompleteWorkDetailTMCost, originalCompleteWorkDetailTPVInvoiceNumber, originalCompleteWorkDetailTPVInvoiceAmout, originalDeleted, companyId, originalNotes, originalRuleId, originalMileage, originalStartWorkMileage, originalCompleteWorkMileage, originalLibraryCategoriesId, number, dateTime_, newMtoDto, newDescription, unitId, type, newState, ownerId, newAssignDateTime, newAssignDeadlineDate, newAssignTeamMember, newAssignTeamMemberId, newAssignThirdPartyVendor, newAcceptDateTime, newRejectDateTime, newRejectReason, newStartWorkDateTime, newStartWorkOutOfServiceDate, newStartWorkOutOfServiceTime, newCompleteWorkDateTime, newCompleteWorkBackToServiceDate, newCompleteWorkBackToServiceTime, newCompleteWorkDetailDescription, newCompleteWorkDetailPreventable, newCompleteWorkDetailTMLabourHours, newCompleteWorkDetailTMCost, newCompleteWorkDetailTPVInvoiceNumber, newCompleteWorkDetailTPVInvoiceAmout, newDeleted, companyId, newNotes, newRuleId, newMileage, newStartWorkMileage, newCompleteWorkMileage, newLibraryCategoriesId);

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

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

                        // ... Update
                        Checklist checklist = new Checklist();
                        checklist.UpdateDirect((int)unitId, (int)originalRuleId, originalAssociatedChecklistLastService, originalAssociatedChecklistNextDue, originalAssociatedChecklistDone, originalAssociatedChecklistRuleState, originalAssociatedChecklistDeleted, originalAssociatedChecklistCompanyId, (int)unitId, (int)originalRuleId, newAssociatedChecklistLastService, newAssociatedChecklistNextDue, newAssociatedChecklistDone, newAssociatedChecklistRuleState, originalAssociatedChecklistDeleted, originalAssociatedChecklistCompanyId);
                    }
                }
            }
        }
        /// <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);
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// UpdateUnitChecklists
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyLevelId">companyLevelId</param>
        /// <param name="companyId">companyId</param>
        private void UpdateUnitChecklists(int unitId, int companyLevelId, int companyId)
        {
            UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway();
            unitsCategoryGateway.LoadByUnitId(unitId, companyId);

            foreach (UnitsTDS.LFS_FM_UNIT_CATEGORYRow row in (UnitsTDS.LFS_FM_UNIT_CATEGORYDataTable)unitsCategoryGateway.Table)
            {
                int categoryId = row.CategoryID;

                RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway();
                ruleCategoryGateway.LoadByCategoryId(categoryId, companyId);

                foreach (RuleTDS.LFS_FM_RULE_CATEGORYRow rowRuleCategory in (RuleTDS.LFS_FM_RULE_CATEGORYDataTable)ruleCategoryGateway.Table)
                {
                    int ruleId = rowRuleCategory.RuleID;

                    RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null);

                    if (ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, companyLevelId))
                    {
                        ChecklistGateway checklistGateway = new ChecklistGateway(null);

                        if (checklistGateway.IsUsedInChecklist(unitId, ruleId, true))
                        {
                            Checklist checklist = new Checklist(null);
                            checklist.UnDeleteDirect(ruleId, unitId, companyId);
                        }
                        else
                        {
                            Checklist checklist = new Checklist(null);
                            checklist.InsertDirect(unitId, ruleId, null, null, false, "Unknown", false, companyId);
                        }
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        public void Save(int unitId, int companyId)
        {
            UnitInformationChecklistDetailsGateway unitInformationChecklistDetailsGateway = new UnitInformationChecklistDetailsGateway(Data);

            foreach (UnitInformationTDS.ChecklistDetailsRow row in (UnitInformationTDS.ChecklistDetailsDataTable)Data.Tables["ChecklistDetails"])
            {
                if (!row.Deleted)
                {
                    // Unchanged values
                    int ruleId = row.RuleID;
                    bool deleted = false;

                    // Original values
                    DateTime? originalLastService = null; if (unitInformationChecklistDetailsGateway.GetLastServiceOriginal(ruleId).HasValue) originalLastService = (DateTime)unitInformationChecklistDetailsGateway.GetLastServiceOriginal(ruleId);
                    DateTime? originalNextDue = null; if (unitInformationChecklistDetailsGateway.GetNextDueOriginal(ruleId).HasValue) originalNextDue = (DateTime)unitInformationChecklistDetailsGateway.GetNextDueOriginal(ruleId);
                    bool originalDone = unitInformationChecklistDetailsGateway.GetDoneOriginal(ruleId);
                    string originalState = unitInformationChecklistDetailsGateway.GetStateOriginal(ruleId);

                    // New values
                    DateTime? newLastService = null; if (unitInformationChecklistDetailsGateway.GetLastService(ruleId).HasValue) newLastService = (DateTime)unitInformationChecklistDetailsGateway.GetLastService(ruleId);
                    DateTime? newNextDue = null; if (unitInformationChecklistDetailsGateway.GetNextDue(ruleId).HasValue) newNextDue = (DateTime)unitInformationChecklistDetailsGateway.GetNextDue(ruleId);
                    bool newDone = unitInformationChecklistDetailsGateway.GetDone(ruleId);
                    string newState = unitInformationChecklistDetailsGateway.GetState(ruleId);

                    if (row.Frequency != "Only once")
                    {
                        if (newLastService.HasValue)
                        {
                            // Get next due
                            DateTime timeToAdded = new DateTime(((DateTime)newLastService).Year, ((DateTime)newLastService).Month, ((DateTime)newLastService).Day);

                            if (row.Frequency == "Monthly") newNextDue = timeToAdded.AddMonths(1);
                            if (row.Frequency == "Every 2 months") newNextDue = timeToAdded.AddMonths(2);
                            if (row.Frequency == "Every 3 months") newNextDue = timeToAdded.AddMonths(3);
                            if (row.Frequency == "Every 4 months") newNextDue = timeToAdded.AddMonths(4);
                            if (row.Frequency == "Every 6 months") newNextDue = timeToAdded.AddMonths(6);
                            if (row.Frequency == "Yearly") newNextDue = timeToAdded.AddYears(1);
                        }
                    }

                    // Update
                    Checklist checklist = new Checklist(null);
                    checklist.UpdateDirect(unitId, ruleId, originalLastService, originalNextDue, originalDone, originalState, deleted, companyId, unitId, ruleId, newLastService, newNextDue, newDone, newState, deleted, companyId);
                }
                else
                {
                    int ruleId = row.RuleID;
                    Checklist checklist = new Checklist(null);
                    checklist.DeleteDirect(ruleId, unitId, companyId);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// DeleteChecklists
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="companyId">companyId</param>
        private void DeleteChecklists(int ruleId, int companyId)
        {
            ChecklistGateway checklistGateway = new ChecklistGateway(null);

            if (checklistGateway.IsRuleUsedInChecklist(ruleId))
            {
                // Delete all checklists for ruleId
                Checklist checklist = new Checklist(null);
                checklist.DeleteDirectByRuleId(ruleId, companyId);
            }
        }
コード例 #10
0
        /// <summary>
        /// UpdateRuleCategoryUnits
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyLevelsSelected">companyLevelsSelected</param>
        /// <param name="unitsSelected">unitsSelected</param>
        private void UpdateRuleCategoryUnits(int ruleId, int companyId, ArrayList categoriesSelected, ArrayList companyLevelsSelected, ArrayList unitsSelected)
        {
            // At each category
            CategoryGateway categoryGateway = new CategoryGateway();
            categoryGateway.Load(companyId);

            foreach (CategoriesTDS.LFS_FM_CATEGORYRow row in (CategoriesTDS.LFS_FM_CATEGORYDataTable)categoryGateway.Table)
            {
                int categoryId = row.CategoryID;

                // At each unit
                UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway();
                unitsCategoryGateway.LoadByCategoryId(categoryId, companyId);

                foreach (UnitsTDS.LFS_FM_UNIT_CATEGORYRow rowUnitCategory in (UnitsTDS.LFS_FM_UNIT_CATEGORYDataTable)unitsCategoryGateway.Table)
                {
                    int unitId = rowUnitCategory.UnitID;

                    RuleCategoryUnitsGateway ruleCategoryUnitsGateway = new RuleCategoryUnitsGateway(null);

                    // If it already exists and it's not deleted
                    if (ruleCategoryUnitsGateway.IsUsedInRuleCategoryUnits(ruleId, categoryId, unitId))
                    {
                        // Verify if it's at the current selection
                        if ((!categoriesSelected.Contains(categoryId)) || (categoriesSelected.Contains(categoryId) && (!unitsSelected.Contains(unitId))))
                        {
                            // Delete
                            RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                            ruleCategoryUnits.DeleteDirect(ruleId, categoryId, unitId, companyId);
                        }
                        else
                        {
                            RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                            ruleCategoryUnits.UnDeleteDirect(ruleId, categoryId, unitId, companyId);

                            // Insert checklist
                            foreach (int companyLevelId in companyLevelsSelected)
                            {
                                UnitsGateway unitsGateway = new UnitsGateway(null);

                                if (unitsGateway.IsUsedInUnitsAndNotIsDisposed(unitId, companyLevelId))
                                {
                                    ChecklistGateway checklistGateway = new ChecklistGateway(null);

                                    if (checklistGateway.IsUsedInChecklist(unitId, ruleId, true))
                                    {
                                        Checklist checklist = new Checklist(null);
                                        checklist.UnDeleteDirect(ruleId, unitId, companyId);
                                    }
                                    else
                                    {
                                        Checklist checklist = new Checklist(null);
                                        checklist.InsertDirect(unitId, ruleId, null, null, false, "Unknown", false, companyId);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // If it already exists and it's deleted
                        if (ruleCategoryUnitsGateway.IsUsedInRuleCategoryUnitsAsDeleted(ruleId, categoryId, unitId))
                        {
                            // Verify if it's at the current selection
                            if (categoriesSelected.Contains(categoryId) && (unitsSelected.Contains(unitId)))
                            {
                                // UnDelete
                                RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                                ruleCategoryUnits.UnDeleteDirect(ruleId, categoryId, unitId, companyId);

                                // Insert checklist
                                foreach (int companyLevelId in companyLevelsSelected)
                                {
                                    UnitsGateway unitsGateway = new UnitsGateway(null);

                                    if (unitsGateway.IsUsedInUnitsAndNotIsDisposed(unitId, companyLevelId))
                                    {
                                        ChecklistGateway checklistGateway = new ChecklistGateway(null);

                                        if (checklistGateway.IsUsedInChecklist(unitId, ruleId, true))
                                        {
                                            Checklist checklist = new Checklist(null);
                                            checklist.UnDeleteDirect(ruleId, unitId, companyId);
                                        }
                                        else
                                        {
                                            Checklist checklist = new Checklist(null);
                                            checklist.InsertDirect(unitId, ruleId, null, null, false, "Unknown", false, companyId);
                                        }
                                    }
                                }
                            }
                        }
                        // If it's not at bd
                        else
                        {
                            // Verify if it's at the current selection
                            if (categoriesSelected.Contains(categoryId) && (unitsSelected.Contains(unitId)))
                            {
                                // Insert rule category units
                                RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                                ruleCategoryUnits.InsertDirect(ruleId, categoryId, unitId, false, companyId);

                                // Insert checklist
                                foreach (int companyLevelId in companyLevelsSelected)
                                {
                                    UnitsGateway unitsGateway = new UnitsGateway(null);

                                    if (unitsGateway.IsUsedInUnitsAndNotIsDisposed(unitId, companyLevelId))
                                    {
                                        ChecklistGateway checklistGateway = new ChecklistGateway(null);

                                        if (checklistGateway.IsUsedInChecklist(unitId, ruleId, true))
                                        {
                                            Checklist checklist = new Checklist(null);
                                            checklist.UnDeleteDirect(ruleId, unitId, companyId);
                                        }
                                        else
                                        {
                                            Checklist checklist = new Checklist(null);
                                            checklist.InsertDirect(unitId, ruleId, null, null, false, "Unknown", false, companyId);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }