/// <summary> /// UpdateUnitsAndRulesCompanyLevels /// </summary> /// <param name="originalCompanyLevelId">originalCompanyLevelId</param> /// <param name="newCompanyLevelId">newCompanyLevelId</param> /// <param name="companyId">companyId</param> private void UpdateUnitsAndRulesCompanyLevels(int originalCompanyLevelId, int? newCompanyLevelId, int companyId) { // Update units UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.Load(companyId); if (unitsGateway.Table.Rows.Count > 0) { foreach (UnitsTDS.LFS_FM_UNITRow row in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table) { int unitId = row.UnitID; if (originalCompanyLevelId == row.CompanyLevelID) { if (newCompanyLevelId.HasValue) { UnitsGateway unitsGatewayToUpdate = new UnitsGateway(null); unitsGatewayToUpdate.UpdateCompanyLevel(row.UnitID, row.Deleted, row.COMPANY_ID, (int)newCompanyLevelId); } } } } // Update rules company levels LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway(); ruleGateway.Load(companyId); if (ruleGateway.Table.Rows.Count > 0) { foreach (RuleTDS.LFS_FM_RULERow row in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table) { int ruleId = row.RuleID; RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null); if ((ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, originalCompanyLevelId)) && (newCompanyLevelId.HasValue)) { if (!ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, (int)newCompanyLevelId)) { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.InsertDirect(ruleId, (int)newCompanyLevelId, false, companyId); ruleCompanyLevel.DeleteDirect(ruleId, originalCompanyLevelId, companyId); } else { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.DeleteDirect(ruleId, originalCompanyLevelId, companyId); } } } } }
/// <summary> /// UpdateRuleCompanyLevel /// </summary> /// <param name="ruleId">ruleId</param> /// <param name="companyId">companyId</param> /// <param name="companyLevelsSected">companyLevelsSected</param> private void UpdateRuleCompanyLevel(int ruleId, int companyId, ArrayList companyLevelsSelected) { CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway(); companyLevelGateway.Load(companyId); if (companyLevelGateway.Table.Rows.Count > 0) { foreach (CompanyLevelsTDS.LFS_FM_COMPANYLEVELRow row in (CompanyLevelsTDS.LFS_FM_COMPANYLEVELDataTable)companyLevelGateway.Table) { int companyLevelId = row.CompanyLevelID; RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null); if (ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, companyLevelId, true)) { if (!companyLevelsSelected.Contains(companyLevelId)) { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.DeleteDirect(ruleId, companyLevelId, companyId); } else { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.UnDeleteDirect(ruleId, companyLevelId, companyId); } } else { if (companyLevelsSelected.Contains(companyLevelId)) { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.InsertDirect(ruleId, companyLevelId, false, companyId); } } } } }
/// <summary> /// UpdateRuleCompanyLevel /// </summary> /// <param name="ruleId">ruleId</param> /// <param name="companyId">companyId</param> /// <param name="companyLevelsSelected">companyLevelsSelected</param> private void UpdateRuleCompanyLevel(int ruleId, int companyId, ArrayList companyLevelsSelected) { // Insert CompanyLevels selected foreach (int companyLevelId in companyLevelsSelected) { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.InsertDirect(ruleId, companyLevelId, false, companyId); } }
/// <summary> /// DeleteRuleCompanyLevel /// </summary> /// <param name="ruleId">ruleId</param> /// <param name="companyId">companyId</param> private void DeleteRuleCompanyLevel(int ruleId, int companyId) { CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway(); companyLevelGateway.Load(companyId); if (companyLevelGateway.Table.Rows.Count > 0) { foreach (CompanyLevelsTDS.LFS_FM_COMPANYLEVELRow row in (CompanyLevelsTDS.LFS_FM_COMPANYLEVELDataTable)companyLevelGateway.Table) { int companyLevelId = row.CompanyLevelID; RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null); if (ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, companyLevelId)) { RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null); ruleCompanyLevel.DeleteDirect(ruleId, companyLevelId, companyId); } } } }