/// <summary> /// Update /// </summary> /// <param name="serviceId">serviceId</param> /// <param name="serviceState">serviceState</param> /// <param name="mtoDto">mtoDto</param> /// <param name="serviceDescription">serviceDescription</param> /// <param name="mileage">mileage</param> /// <param name="assignmentDateTime">assignmentDateTime</param> /// <param name="assignmentDeadlineDate"></param> /// <param name="toTeamMember">toTeamMember</param> /// <param name="assignTeamMemberID">assignTeamMemberID</param> /// <param name="thirdPartyVendor">thirdPartyVendor</param> /// <param name="assignmentAcceptedDateTime">assignmentAcceptedDateTime</param> /// <param name="assignmentRejectedDateTime">assignmentRejectedDateTime</param> /// <param name="assignmentRejectedReason">assignmentRejectedReason</param> /// <param name="startWorkDateTime">startWorkDateTime</param> /// <param name="unitOutOfServiceDate">unitOutOfServiceDate</param> /// <param name="unitOutOfServiceTime">unitOutOfServiceTime</param> /// <param name="startWorkMileage">startWorkMileage</param> /// <param name="completeWorkDateTime">completeWorkDateTime</param> /// <param name="unitBackInServiceDate">unitBackInServiceDate</param> /// <param name="unitBackInServiceTime">unitBackInServiceTime</param> /// <param name="completeWorkMileage">completeWorkMileage</param> /// <param name="completeWorkDetailDescription">completeWorkDetailDescription</param> /// <param name="completeWorkDetailPreventable">completeWorkDetailPreventable</param> /// <param name="completeWorkDetailTMLabourHours">completeWorkDetailTMLabourHours</param> /// <param name="completeWorkDetailTPVInvoiceNumber">completeWorkDetailTPVInvoiceNumber</param> /// <param name="completeWorkDetailTPVInvoiceAmout">completeWorkDetailTPVInvoiceAmout</param> /// <param name="newAssociatedChecklistRuleState">newAssociatedChecklistRuleState</param> /// <param name="libraryCategoriesId">libraryCategoriesId</param> public void Update(int serviceId, string serviceState, bool mtoDto, string serviceDescription, string mileage, DateTime? assignmentDateTime, DateTime? assignmentDeadlineDate, bool toTeamMember, int? assignTeamMemberID, string thirdPartyVendor, DateTime? assignmentAcceptedDateTime, DateTime? assignmentRejectedDateTime, string assignmentRejectedReason, DateTime? startWorkDateTime, DateTime? unitOutOfServiceDate, string unitOutOfServiceTime, string startWorkMileage, DateTime? completeWorkDateTime, DateTime? unitBackInServiceDate, string unitBackInServiceTime, string completeWorkMileage, string completeWorkDetailDescription, bool completeWorkDetailPreventable, decimal? completeWorkDetailTMLabourHours, string completeWorkDetailTPVInvoiceNumber, decimal? completeWorkDetailTPVInvoiceAmout, string newAssociatedChecklistRuleState, int? libraryCategoriesId) { ServiceInformationTDS.BasicInformationRow row = GetRow(serviceId); // General Data string originalServiceState = row.ServiceState; DateTime? originalUnitBackInServiceDate = null; if (!row.IsUnitBackInServiceDateNull()) originalUnitBackInServiceDate = row.UnitBackInServiceDate; row.ServiceState = serviceState; row.MtoDto = mtoDto; if (serviceDescription.Trim() != "") row.ServiceDescription = serviceDescription; else row.SetServiceDescriptionNull(); if (mileage.Trim() != "") row.Mileage = mileage; else row.SetMileageNull(); if (assignmentDateTime.HasValue) row.AssignmentDateTime = (DateTime)assignmentDateTime; else row.SetAssignmentDateTimeNull(); if (assignmentDeadlineDate.HasValue) row.AssignedDeadlineDate = (DateTime)assignmentDeadlineDate; row.ToTeamMember = toTeamMember; if (assignTeamMemberID.HasValue) row.AssignTeamMemberID = (int)assignTeamMemberID; else row.SetAssignTeamMemberIDNull(); if (thirdPartyVendor != "") row.AssignedThirdPartyVendor = thirdPartyVendor; else row.SetAssignedThirdPartyVendorNull(); if (assignmentAcceptedDateTime.HasValue) row.AcceptedDateTime = (DateTime)assignmentAcceptedDateTime; else row.SetAcceptedDateTimeNull(); if (assignmentRejectedDateTime.HasValue) row.RejectedDateTime = (DateTime)assignmentRejectedDateTime; else row.SetRejectedDateTimeNull(); if (assignmentRejectedReason != "") row.RejectedReason = assignmentRejectedReason; else row.SetRejectedReasonNull(); if (startWorkDateTime.HasValue) row.StartWorkDateTime = (DateTime)startWorkDateTime; else row.SetStartWorkDateTimeNull(); if (unitOutOfServiceDate.HasValue) row.UnitOutOfServiceDate = (DateTime)unitOutOfServiceDate; else row.SetUnitOutOfServiceDateNull(); if (unitOutOfServiceTime != "") row.UnitOutOfServiceTime = unitOutOfServiceTime; else row.SetUnitOutOfServiceTimeNull(); if (startWorkMileage != "") row.StartWorkMileage = startWorkMileage; else row.SetStartWorkMileageNull(); if (completeWorkDateTime.HasValue) row.CompleteWorkDateTime = (DateTime)completeWorkDateTime; else row.SetCompleteWorkDateTimeNull(); if (unitBackInServiceDate.HasValue) row.UnitBackInServiceDate = (DateTime)unitBackInServiceDate; else row.SetUnitBackInServiceDateNull(); if (unitBackInServiceTime != "") row.UnitBackInServiceTime = unitBackInServiceTime; else row.SetUnitBackInServiceTimeNull(); if (completeWorkMileage != "") row.CompleteWorkMileage = completeWorkMileage; else row.SetCompleteWorkMileageNull(); if (completeWorkDetailDescription != "") row.CompleteWorkDetailDescription = completeWorkDetailDescription; else row.SetCompleteWorkDetailDescriptionNull(); row.CompleteWorkDetailPreventable = completeWorkDetailPreventable; if (completeWorkDetailTMLabourHours.HasValue) row.CompleteWorkDetailTMLabourHours = (Decimal)completeWorkDetailTMLabourHours; else row.SetCompleteWorkDetailTMLabourHoursNull(); if (completeWorkDetailTPVInvoiceNumber != "") row.CompleteWorkDetailTPVInvoiceNumber = completeWorkDetailTPVInvoiceNumber; else row.SetCompleteWorkDetailTPVInvoiceNumberNull(); if (completeWorkDetailTPVInvoiceAmout.HasValue) row.CompleteWorkDetailTPVInvoiceAmout = (Decimal)completeWorkDetailTPVInvoiceAmout; else row.SetCompleteWorkDetailTPVInvoiceAmoutNull(); if (libraryCategoriesId.HasValue) row.LIBRARY_CATEGORIES_ID = libraryCategoriesId.Value; else row.SetLIBRARY_CATEGORIES_IDNull(); if (row.Type == "Checklist") { if ((originalServiceState != "Completed") && (serviceState == "Completed")) { RuleGateway ruleGateway = new RuleGateway(); ruleGateway.LoadAllByRuleId(row.RuleID, row.COMPANY_ID); DateTime? lastService = (DateTime)unitBackInServiceDate; DateTime? nextDue = null; string frecuency = ruleGateway.GetFrequency(row.RuleID); if (!ruleGateway.GetMto(row.RuleID)) { if (ruleGateway.GetFrequency(row.RuleID) != "Only once") { // Get next due DateTime timeToAdded = new DateTime(((DateTime)lastService).Year, ((DateTime)lastService).Month, ((DateTime)lastService).Day); if (frecuency == "Monthly") nextDue = timeToAdded.AddMonths(1); if (frecuency == "Every 2 months") nextDue = timeToAdded.AddMonths(2); if (frecuency == "Every 3 months") nextDue = timeToAdded.AddMonths(3); if (frecuency == "Every 4 months") nextDue = timeToAdded.AddMonths(4); if (frecuency == "Every 6 months") nextDue = timeToAdded.AddMonths(6); if (frecuency == "Yearly") nextDue = timeToAdded.AddYears(1); row.AssociatedChecklistLastService = (DateTime)lastService; row.AssociatedChecklistNextDue = (DateTime)nextDue; row.AssociatedChecklistDone = false; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } else { row.AssociatedChecklistLastService = (DateTime)lastService; row.SetAssociatedChecklistNextDueNull(); row.AssociatedChecklistDone = true; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } } else { ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(); serviceInformationBasicInformation.LoadInProgressByServiceIdUnitIdRuleId(row.ServiceID, row.UnitID, row.RuleID, row.COMPANY_ID); if (serviceInformationBasicInformation.Table.Rows.Count > 1) { row.AssociatedChecklistRuleState = "In Progress"; } else { row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; } if (frecuency != "Only once") { row.AssociatedChecklistDone = false; } else { row.AssociatedChecklistDone = true; } } } else { if ((originalServiceState == "Completed") && (originalUnitBackInServiceDate != unitBackInServiceDate)) { RuleGateway ruleGateway = new RuleGateway(); ruleGateway.LoadAllByRuleId(row.RuleID, row.COMPANY_ID); DateTime? lastService = (DateTime)unitBackInServiceDate; DateTime? nextDue = null; string frecuency = ruleGateway.GetFrequency(row.RuleID); if (!ruleGateway.GetMto(row.RuleID)) { if (ruleGateway.GetFrequency(row.RuleID) != "Only once") { // Get next due DateTime timeToAdded = new DateTime(((DateTime)lastService).Year, ((DateTime)lastService).Month, ((DateTime)lastService).Day); if (frecuency == "Monthly") nextDue = timeToAdded.AddMonths(1); if (frecuency == "Every 2 months") nextDue = timeToAdded.AddMonths(2); if (frecuency == "Every 3 months") nextDue = timeToAdded.AddMonths(3); if (frecuency == "Every 4 months") nextDue = timeToAdded.AddMonths(4); if (frecuency == "Every 6 months") nextDue = timeToAdded.AddMonths(6); if (frecuency == "Yearly") nextDue = timeToAdded.AddYears(1); row.AssociatedChecklistLastService = (DateTime)lastService; row.AssociatedChecklistNextDue = (DateTime)nextDue; row.AssociatedChecklistDone = false; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } else { row.AssociatedChecklistLastService = (DateTime)lastService; row.SetAssociatedChecklistNextDueNull(); row.AssociatedChecklistDone = true; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } } else { ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(); serviceInformationBasicInformation.LoadInProgressByServiceIdUnitIdRuleId(row.ServiceID, row.UnitID, row.RuleID, row.COMPANY_ID); if (serviceInformationBasicInformation.Table.Rows.Count > 1) { row.AssociatedChecklistRuleState = "In Progress"; } else { row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; } if (frecuency != "Only once") { row.AssociatedChecklistDone = false; } else { row.AssociatedChecklistDone = true; } } } } } }
/// <summary> /// Update a Service /// </summary> /// <param name="serviceId">serviceId</param> /// <param name="serviceState">serviceState</param> /// <param name="assignDateTime">assignDateTime</param> /// <param name="assignedDeadlineDate">assignedDeadlineDate</param> /// <param name="assignTeamMember">assignTeamMember</param> /// <param name="assignTeamMemberId">assignTeamMemberId</param> /// <param name="assignThirdPartyVendor">assignThirdPartyVendor</param> /// <param name="acceptDateTime">acceptDateTime</param> /// <param name="startWorkDateTime">startWorkDateTime</param> /// <param name="unitOutOfServiceDate">unitOutOfServiceDate</param> /// <param name="unitOutOfServiceTime">unitOutOfServiceTime</param> /// <param name="completeWorkDateTime">completeWorkDateTime</param> /// <param name="unitBackInServiceDate">unitBackInServiceDate</param> /// <param name="unitBackInServiceTime">unitBackInServiceTime</param> /// <param name="completeWorkDetailDescription">completeWorkDetailDescription</param> /// <param name="completeWorkDetailPreventable">completeWorkDetailPreventable</param> /// <param name="completeWorkDetailTMLabourHours">completeWorkDetailTMLabourHours</param> /// <param name="completeWorkDetailTMCost">completeWorkDetailTMCost</param> /// <param name="completeWorkInvoiceNumber">completeWorkInvoiceNumber</param> /// <param name="completeWorkInvoiceAmount">completeWorkInvoiceAmount</param> /// <param name="startWorkMileage">startWorkMileage</param> /// <param name="completeWorkMileage">completeWorkMileage</param> /// <param name="newAssociatedChecklistRuleState">newAssociatedChecklistRuleState</param> /// <param name="deleted">deleted</param> /// <param name="companyId">companyId</param> /// <param name="libraryCategoriesId">libraryCategoriesId</param> public void Update(int serviceId, string serviceState, DateTime? assignDateTime, DateTime? assignedDeadlineDate, bool assignTeamMember, int? assignTeamMemberId, string assignThirdPartyVendor, DateTime? acceptDateTime, DateTime? startWorkDateTime, DateTime? unitOutOfServiceDate, string unitOutOfServiceTime, DateTime? completeWorkDateTime, DateTime? unitBackInServiceDate, string unitBackInServiceTime, string completeWorkDetailDescription, bool completeWorkDetailPreventable, Decimal? completeWorkDetailTMLabourHours, Decimal? completeWorkDetailTMCost, string completeWorkInvoiceNumber, decimal? completeWorkInvoiceAmount, string startWorkMileage, string completeWorkMileage, string newAssociatedChecklistRuleState, bool deleted, int companyId, int? libraryCategoriesId) { ServiceRequestsManagerToolTDS.BasicInformationRow row = GetRow(serviceId); row.ServiceState = serviceState; // Assignment information if (assignDateTime.HasValue) row.AssignmentDateTime = (DateTime)assignDateTime; if (assignedDeadlineDate.HasValue) row.AssignedDeadlineDate = (DateTime)assignedDeadlineDate; row.AssignTeamMember = assignTeamMember; if (assignTeamMemberId.HasValue) row.AssignTeamMemberID = (int)assignTeamMemberId; else row.SetAssignTeamMemberIDNull(); if (assignThirdPartyVendor != "") row.AssignThirdPartyVendor = assignThirdPartyVendor; else row.SetAssignThirdPartyVendorNull(); // Accept information if (acceptDateTime.HasValue) row.AcceptDateTime = (DateTime)acceptDateTime; else row.SetAcceptDateTimeNull(); // Start work information if (startWorkDateTime.HasValue) row.StartWorkDateTime = (DateTime)startWorkDateTime; else row.SetStartWorkDateTimeNull(); if (unitOutOfServiceDate.HasValue) row.UnitOutOfServiceDate = (DateTime)unitOutOfServiceDate; else row.SetUnitOutOfServiceDateNull(); if (unitOutOfServiceTime != "") row.UnitOutOfServiceTime = unitOutOfServiceTime; else row.SetUnitOutOfServiceTimeNull(); // Complete work information if (completeWorkDateTime.HasValue) row.CompleteWorkDateTime = (DateTime)completeWorkDateTime; else row.SetCompleteWorkDateTimeNull(); if (unitBackInServiceDate.HasValue) row.UnitBackInServiceDate = (DateTime)unitBackInServiceDate; else row.SetUnitBackInServiceDateNull(); if (unitBackInServiceTime != "") row.UnitBackInServiceTime = unitBackInServiceTime; else row.SetUnitBackInServiceTimeNull(); if (completeWorkDetailDescription != "") row.CompleteWorkDetailDescription = completeWorkDetailDescription; else row.SetCompleteWorkDetailDescriptionNull(); row.CompleteWorkDetailPreventable = completeWorkDetailPreventable; if (completeWorkDetailTMLabourHours.HasValue) row.CompleteWorkDetailTMLabourHours = (Decimal)completeWorkDetailTMLabourHours; else row.SetCompleteWorkDetailTMLabourHoursNull(); if (completeWorkDetailTMCost.HasValue) row.CompleteWorkDetailTMCost = (Decimal)completeWorkDetailTMCost; else row.SetCompleteWorkDetailTMCostNull(); if (completeWorkInvoiceNumber != "") row.CompleteWorkInvoiceNumber = completeWorkInvoiceNumber; else row.IsCompleteWorkInvoiceNumberNull(); if (completeWorkInvoiceAmount.HasValue) row.CompleteWorkInvoiceAmount = (decimal)completeWorkInvoiceAmount; else row.IsCompleteWorkInvoiceAmountNull(); if (startWorkMileage != "") row.StartWorkMileage = startWorkMileage; else row.SetStartWorkMileageNull(); if (completeWorkMileage != "") row.CompleteWorkMileage = completeWorkMileage; else row.SetCompleteWorkMileageNull(); row.Deleted = deleted; row.COMPANY_ID = companyId; if (libraryCategoriesId.HasValue) row.LIBRARY_CATEGORIES_ID = libraryCategoriesId.Value; else row.SetLIBRARY_CATEGORIES_IDNull(); if (row.Type == "Checklist") { if (serviceState == "Completed") { RuleGateway ruleGateway = new RuleGateway(); ruleGateway.LoadAllByRuleId(row.RuleID, row.COMPANY_ID); DateTime? lastService = (DateTime)unitBackInServiceDate; DateTime? nextDue = null; string frecuency = ruleGateway.GetFrequency(row.RuleID); if (!ruleGateway.GetMto(row.RuleID)) { if (frecuency != "Only once") { // Get next due DateTime timeToAdded = new DateTime(((DateTime)lastService).Year, ((DateTime)lastService).Month, ((DateTime)lastService).Day); if (frecuency == "Monthly") nextDue = timeToAdded.AddMonths(1); if (frecuency == "Every 2 months") nextDue = timeToAdded.AddMonths(2); if (frecuency == "Every 3 months") nextDue = timeToAdded.AddMonths(3); if (frecuency == "Every 4 months") nextDue = timeToAdded.AddMonths(4); if (frecuency == "Every 6 months") nextDue = timeToAdded.AddMonths(6); if (frecuency == "Yearly") nextDue = timeToAdded.AddYears(1); row.AssociatedChecklistLastService = (DateTime)lastService; row.AssociatedChecklistNextDue = (DateTime)nextDue; row.AssociatedChecklistDone = false; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } else { row.AssociatedChecklistLastService = (DateTime)lastService; row.SetAssociatedChecklistNextDueNull(); row.AssociatedChecklistDone = true; if (newAssociatedChecklistRuleState != "") row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; else row.SetAssociatedChecklistRuleStateNull(); } } else { ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(); serviceInformationBasicInformation.LoadInProgressByServiceIdUnitIdRuleId(row.ServiceID, row.UnitID, row.RuleID, row.COMPANY_ID); if (serviceInformationBasicInformation.Table.Rows.Count > 1) { row.AssociatedChecklistRuleState = "In Progress"; } else { row.AssociatedChecklistRuleState = newAssociatedChecklistRuleState; } if (frecuency != "Only once") { row.AssociatedChecklistDone = false; } else { row.AssociatedChecklistDone = true; } } } } }