コード例 #1
0
        /// <summary>
        /// UnDeleteDirect
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="categoryId">categoryId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>True</returns>
        public bool UnDeleteDirect(int ruleId, int categoryId, int companyId)
        {
            RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(Data);
            ruleCategoryGateway.UnDelete(ruleId, categoryId, companyId);

            return true;
        }
コード例 #2
0
        /// <summary>
        /// CategoryIsUsed
        /// </summary>
        /// <param name="categoryId">categoryId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>True or False</returns>
        public bool CategoryIsUsed(int categoryId, int companyId)
        {
            bool inUse = false;
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.Load(companyId);

            foreach (UnitsTDS.LFS_FM_UNITRow row in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table)
            {
                int unitId = row.UnitID;

                UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);
                if (unitsCategoryGateway.IsUsedInUnitCategory(unitId, categoryId))
                {
                    inUse = true;
                }
            }

            LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway();
            ruleGateway.Load(companyId);

            foreach (RuleTDS.LFS_FM_RULERow row in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table)
            {
                int ruleId = row.RuleID;

                RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
                if (ruleCategoryGateway.IsUsedInRuleCategory(ruleId, categoryId))
                {
                    inUse = true;
                }
            }

            return inUse;
        }
コード例 #3
0
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// InsertDirect
 /// </summary>
 /// <param name="ruleId">ruleId</param>
 /// <param name="categoryId">categoryId</param>
 /// <param name="deleted">deleted</param>
 /// <param name="companyId">companyId</param>
 public void InsertDirect(int ruleId, int categoryId, bool deleted, int companyId)
 {
     RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
     ruleCategoryGateway.Insert(ruleId, categoryId, deleted, companyId);
 }
コード例 #4
0
        /// <summary>
        /// UpdateUnitCategory
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyLevelId">companyLevelId</param>
        private void UpdateUnitCategory(int unitId, int companyId, ArrayList categoriesSelected, int companyLevelId)
        {
            RuleCategoryUnitsGateway ruleCategoryUnitsGateway = new RuleCategoryUnitsGateway(null);

            CategoryGateway categoryGateway = new CategoryGateway();
            categoryGateway.Load(companyId);

            if (categoryGateway.Table.Rows.Count > 0)
            {
                foreach (CategoriesTDS.LFS_FM_CATEGORYRow row in (CategoriesTDS.LFS_FM_CATEGORYDataTable)categoryGateway.Table)
                {
                    int categoryId = row.CategoryID;

                    UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);

                    // Exists in DB
                    if (unitsCategoryGateway.IsUsedInUnitCategory(unitId, categoryId, true))
                    {
                        if (!categoriesSelected.Contains(categoryId))
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);
                            unitsCategory.DeleteDirect(unitId, categoryId, companyId);

                            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;

                                if (ruleCategoryUnitsGateway.IsUsedInRuleCategoryUnits(ruleId, categoryId, unitId))
                                {
                                    // Delete
                                    RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
                                    ruleCategoryUnits.DeleteDirect(ruleId, categoryId, unitId, companyId);
                                }
                            }
                        }
                        else
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);
                            unitsCategory.UnDeleteDirect(unitId, categoryId, companyId);
                        }
                    }
                    else
                    {
                        if (categoriesSelected.Contains(categoryId))
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);
                            unitsCategory.InsertDirect(unitId, categoryId, false, companyId);
                        }
                    }
                }
            }
        }
コード例 #5
0
        private void GetNodeForCategory(TreeNodeCollection nodes, int parentId)
        {
            Int32 thisId;
            String thisName;
            RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);

            DataRow[] children = categoriesTDS.Tables["LFS_FM_CATEGORY"].Select("ParentID='" + parentId + "'");

            // No child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // Step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // Step 2
                thisName = Convert.ToString(child.ItemArray[2]);

                // Step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                // Step 4
                if (ruleCategoryGateway.IsUsedInRuleCategory(Int32.Parse(hdfRuleId.Value), thisId))
                {
                    newNode.Checked = true;
                    arrayCategoriesSelected.Add(int.Parse(newNode.Value));
                }

                // Step 5
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // Step 6
                GetNodeForCategory(newNode.ChildNodes, thisId);
            }
        }
コード例 #6
0
        /// <summary>
        /// GetRulesAndUnitsByCategoryId
        /// </summary>
        /// <param name="categoryId">categoryId</param>
        /// <param name="companyId">companyId</param>
        /// <returns></returns>
        public string GetRulesAndUnitsByCategoryId(int categoryId, int companyId)
        {
            string rules = "";
            string units = "";

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.Load(companyId);

            foreach (UnitsTDS.LFS_FM_UNITRow rowUnits in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table)
            {
                int unitId = rowUnits.UnitID;

                UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);
                if (unitsCategoryGateway.IsUsedInUnitCategory(unitId, categoryId))
                {
                    if (units.Length > 0)
                    {
                        units += "\t" + rowUnits.UnitCode + " - " + rowUnits.Description + "\n";
                    }
                    else
                    {
                        units += "Units:\n\n";
                        units += "\t" + rowUnits.UnitCode + " - " + rowUnits.Description + "\n";
                    }
                }
            }

            if (units.Length > 0)
            {
                units += "\n\n";
            }

            LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway();
            ruleGateway.Load(companyId);

            foreach (RuleTDS.LFS_FM_RULERow rowChecklistRules in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table)
            {
                int ruleId = rowChecklistRules.RuleID;

                RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
                if (ruleCategoryGateway.IsUsedInRuleCategory(ruleId, categoryId))
                {
                    if (rules.Length > 0)
                    {
                        rules += "\t" + rowChecklistRules.Name + " - " + rowChecklistRules.Description + "\n";
                    }
                    else
                    {
                        rules += "Checklist Rules:\n\n";
                        rules += "\t" + rowChecklistRules.Name + "\n";
                    }
                }
            }

            return units + rules;
        }
コード例 #7
0
        /// <summary>
        /// UpdateUnitsAndRulesCategories
        /// </summary>
        /// <param name="originalCategoryId">originalCategoryId</param>
        /// <param name="newCategoryId">newCategoryId</param>
        /// <param name="companyId">companyId</param>
        private void UpdateUnitsAndRulesCategories(int originalCategoryId, int? newCategoryId, int companyId)
        {
            // Update rules categories
            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;

                    RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);

                    if ((ruleCategoryGateway.IsUsedInRuleCategory(ruleId, originalCategoryId)) && (newCategoryId.HasValue))
                    {
                        if (!ruleCategoryGateway.IsUsedInRuleCategory(ruleId, (int)newCategoryId, true))
                        {
                            RuleCategory ruleCategory = new RuleCategory(null);

                            // Insert new rule category
                            ruleCategory.InsertDirect(ruleId, (int)newCategoryId, false, companyId);

                            // Delete old rule category
                            ruleCategory.DeleteDirect(ruleId, originalCategoryId, companyId);
                        }
                        else
                        {
                            RuleCategory ruleCategory = new RuleCategory(null);

                            // Undelete nee rule category
                            ruleCategory.UnDeleteDirect(ruleId, (int)newCategoryId, companyId);

                            // Delete old rule category
                            ruleCategory.DeleteDirect(ruleId, originalCategoryId, companyId);
                        }
                    }
                }
            }

            // Update units categories
            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;
                    int companyLevelId = row.CompanyLevelID;

                    UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);
                    if ((unitsCategoryGateway.IsUsedInUnitCategory(unitId, originalCategoryId)) && (newCategoryId.HasValue) )
                    {
                        if (!unitsCategoryGateway.IsUsedInUnitCategory(unitId, (int)newCategoryId, true))
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);

                            // Insert new unit category
                            unitsCategory.InsertDirect(unitId, (int)newCategoryId, false, companyId);

                            // Delete old unit category
                            unitsCategory.DeleteDirect(unitId, originalCategoryId, companyId);

                            // Delete all checklist for unitId
                            DeleteChecklists(unitId, companyId);

                            // Update checklist
                            UpdateUnitChecklists(unitId, row.CompanyLevelID, companyId);
                        }
                        else
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);

                            // Undelete new category
                            unitsCategory.UnDeleteDirect(unitId, (int)newCategoryId, companyId);

                            // Delete old category
                            unitsCategory.DeleteDirect(unitId, originalCategoryId, companyId);

                            // Delete all checklist for unitId
                            DeleteChecklists(unitId, companyId);

                            // Update checklist
                            UpdateUnitChecklists(unitId, row.CompanyLevelID, companyId);
                        }
                    }
                }
            }
        }
コード例 #8
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);
                        }
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// UpdateRuleCategory
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyLevelsSelected">companyLevelsSelected</param>
        private void UpdateRuleCategory(int ruleId, int companyId, ArrayList categoriesSelected, ArrayList companyLevelsSelected)
        {
            CategoryGateway categoryGateway = new CategoryGateway();
            categoryGateway.Load(companyId);

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

                RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
                if (ruleCategoryGateway.IsUsedInRuleCategory(ruleId, categoryId, true))
                {
                    // Delete
                    if (!categoriesSelected.Contains(categoryId))
                    {
                        RuleCategory ruleCategory = new RuleCategory(null);
                        ruleCategory.DeleteDirect(ruleId, categoryId, companyId);
                    }
                    else // Undelete
                    {
                        RuleCategory ruleCategory = new RuleCategory(null);
                        ruleCategory.UnDeleteDirect(ruleId, categoryId, companyId);
                    }
                }
                else
                {
                    if (categoriesSelected.Contains(categoryId))
                    {
                        RuleCategory ruleCategory = new RuleCategory(null);
                        ruleCategory.InsertDirect(ruleId, categoryId, false, companyId);
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// DeleteRuleCategory
        /// </summary>
        /// <param name="ruleId">ruleId</param>
        /// <param name="companyId">companyId</param>
        private void DeleteRuleCategory(int ruleId, int companyId)
        {
            // Delete RuleCategoryUnits
            RuleCategoryUnits ruleCategoryUnits = new RuleCategoryUnits(null);
            RuleCategoryUnitsGateway ruleCategoryUnitsGateway = new RuleCategoryUnitsGateway(null);

            if (ruleCategoryUnitsGateway.IsRuleUsed(ruleId))
            {
                ruleCategoryUnits.DeleteDirectByRuleId(ruleId, companyId);
            }

            // Load all categories
            CategoryGateway categoryGateway = new CategoryGateway();
            categoryGateway.Load(companyId);

            // Delete rule categories
            if (categoryGateway.Table.Rows.Count > 0)
            {
                foreach (CategoriesTDS.LFS_FM_CATEGORYRow row in (CategoriesTDS.LFS_FM_CATEGORYDataTable)categoryGateway.Table)
                {
                    int categoryId = row.CategoryID;
                    RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
                    if (ruleCategoryGateway.IsUsedInRuleCategory(ruleId, categoryId))
                    {
                        RuleCategory ruleCategory = new RuleCategory(null);
                        ruleCategory.DeleteDirect(ruleId, categoryId, companyId);
                    }
                }
            }
        }