Ejemplo n.º 1
0
 /// <summary>
 /// LoadAllUnitTypes
 /// </summary>
 /// <param name="companyId">companyId</param>
 public void LoadAllUnitTypes(int companyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(Data);
     categoryGateway.ClearBeforeFill = false;
     categoryGateway.LoadByUnitType("Equipment", companyId);
     categoryGateway.LoadByUnitType("Vehicle", companyId);
     categoryGateway.ClearBeforeFill = true;
     UpdateDataForView();
 }
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP6 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP6 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";
            hdfUpdate.Value = "yes";

            string mto = "No"; if (cbxMtoDot.Checked) mto = "Yes";
            string generateServiceRequest = tbxServicesRequestDaysBefore.Text + " days before";

            string categoriesSelected = "";

            foreach (int categoryId in arrayCategoriesSelected)
            {
                CategoryGateway categoryGateway = new CategoryGateway();
                categoryGateway.LoadByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value));
                categoriesSelected += categoryGateway.GetName(categoryId)+ ", ";
            }

            if (categoriesSelected.Length > 2)
            {
                categoriesSelected = categoriesSelected.Substring(0, categoriesSelected.Length - 2);
            }

            string unitsSelected = "";

            foreach (ListItem lst in cbxlUnitsSelected.Items)
            {
                if (lst.Selected)  unitsSelected += lst.Text + ", ";
            }

            if (unitsSelected.Length > 2)
            {
                unitsSelected = unitsSelected.Substring(0, unitsSelected.Length - 2);
            }

            string companyLevelsSelected = "";
            foreach (int companyLevelId in arrayCompanyLevelsSelected)
            {
                CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
                companyLevelGateway.LoadByCompanyLevelId(companyLevelId, Int32.Parse(hdfCompanyId.Value));
                companyLevelsSelected += companyLevelGateway.GetName(companyLevelId) + ", ";
            }

            if (companyLevelsSelected.Length > 2)
            {
                companyLevelsSelected = companyLevelsSelected.Substring(0, companyLevelsSelected.Length - 2);
            }

            tbxSummary.Text = "Name: " + tbxName.Text + "\nFixed Date: " + mto + "\nDescription: " + tbxDescription.Text + "\nFrequency: " + ddlFrequency.SelectedValue + "\nGenerate Service Request?: " + generateServiceRequest + "\nCompany Levels: " + companyLevelsSelected+ "\nCategories: " + categoriesSelected + "\nUnits: " + unitsSelected ;
        }
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP6 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP6 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";
            hdfUpdate.Value = "yes";

            if (rbtnAddCategory.Checked) tbxSummary.Text = "Operation: Add category";
            if (rbtnDeleteCategory.Checked) tbxSummary.Text = "Operation: Delete category";
            if (rbtnEditCategory.Checked) tbxSummary.Text = "Operation: Edit category";

            if (!rbtnDeleteCategory.Checked)
            {
                if (arrayCategoriesSelected.Count > 0)
                {
                    foreach (int categoryIdInArray in arrayCategoriesSelected)
                    {
                        CategoryGateway categoryGateway = new CategoryGateway();
                        categoryGateway.LoadByCategoryId(categoryIdInArray, int.Parse(hdfCompanyId.Value));

                        tbxSummary.Text += "\nParent category: " + categoryGateway.GetName(categoryIdInArray);
                    }
                }
                else
                {
                    tbxSummary.Text += "\nParent category: (Empty)";
                }
            }

            if (!rbtnDeleteCategory.Checked)
            {
                tbxSummary.Text += "\nName: " + tbxName.Text;
            }
            else
            {
                foreach (int categoryIdInArray in arrayCategoriesSelected)
                {
                    CategoryGateway categoryGateway = new CategoryGateway();
                    categoryGateway.LoadByCategoryId(categoryIdInArray, int.Parse(hdfCompanyId.Value));

                    tbxSummary.Text += "\nName: " + categoryGateway.GetName(categoryIdInArray);
                }
            }
        }
        private void LoadData(int ruleId)
        {
            RuleGateway ruleGateway = new RuleGateway(ruleTDS);

            if (ruleGateway.Table.Rows.Count > 0)
            {
                tbxName.Text = ruleGateway.GetName(ruleId);
                cbxMtoDot.Checked = ruleGateway.GetMto(ruleId);
                tbxDescription.Text = ruleGateway.GetDescription(ruleId);
                tbxFrecuency.Text = ruleGateway.GetFrequency(ruleId);
                tbxServicesRequestDaysBefore.Text = ""; if (ruleGateway.GetServiceRequestDays(ruleId).HasValue) tbxServicesRequestDaysBefore.Text = ((int)(ruleGateway.GetServiceRequestDays(ruleId))).ToString();

                // Load Trees
                GetNodeForCategory(tvCategoriesRoot.Nodes, 0);
                GetNodeForCompanyLevels(tvCompanyLevelsRoot.Nodes, 0);

                // Load Units
                int companyId = Int32.Parse(hdfCompanyId.Value);
                string category = "";
                UnitsList unitsList = new UnitsList(new DataSet());

                foreach (int categoryId in arrayCategoriesSelected)
                {
                    CategoryGateway categoryGateway = new CategoryGateway();

                    //Verify the location of the unit
                    foreach (int companyLevelId in arrayCompanyLevelsSelected)
                    {
                        // Load the unit if corresponds
                        categoryGateway.LoadByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value));
                        category = categoryGateway.GetName(categoryId);

                        unitsList.LoadAndAddItemByCategoryCompanyLevelId(category, companyLevelId, companyId);
                    }
                }

                if (unitsList.Table != null)
                {
                    cbxlUnitsSelected.DataSource = RemoveDuplicateRows(unitsList.Table, "UnitID");
                    cbxlUnitsSelected.DataValueField = "UnitID";
                    cbxlUnitsSelected.DataTextField = "UnitCode";
                    cbxlUnitsSelected.DataBind();

                    // Total units
                    lblTotalUnits.Text = "Total Units: " + cbxlUnitsSelected.Items.Count;
                }
                else
                {
                    // Total units
                    lblTotalUnits.Text = "Total Units: 0";
                }
            }
        }
        /// <summary>
        /// GetConditionForCategory
        /// </summary>
        /// <param name="category">category</param>
        /// <param name="companyId">companyId</param>
        /// <returns>categoriesId</returns>
        private ArrayList GetConditionForCategory(string category, int companyId)
        {
            CategoryGateway categoryGateway2 = new CategoryGateway();
            int categoryId = categoryGateway2.GetCategoryId(category);

            ArrayList categoriesId = new ArrayList();
            categoriesId.Add(categoryId);

            categoriesId = GetChilds(categoryId, categoriesId, companyId);

            return categoriesId;
        }
        /// <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);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// UpdateUnitCategory
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        /// <param name="categoriesSelected">categoriesSelected</param>
        private void UpdateUnitCategory(int unitId, int companyId, ArrayList categoriesSelected)
        {
            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);

                    if (unitsCategoryGateway.IsUsedInUnitCategory(unitId, categoryId))
                    {
                        if (!categoriesSelected.Contains(categoryId))
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);
                            unitsCategory.DeleteDirect(unitId, categoryId, companyId);
                        }
                    }
                    else
                    {
                        if (categoriesSelected.Contains(categoryId))
                        {
                            UnitsCategory unitsCategory = new UnitsCategory(null);
                            unitsCategory.InsertDirect(unitId, categoryId, false, companyId);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyId">companyId</param>
        public void Save(ArrayList categoriesSelected, int companyId)
        {
            UnitInformationTDS unitsInformationChanges = (UnitInformationTDS)Data.GetChanges();

            if (unitsInformationChanges.UnitDetails.Rows.Count > 0)
            {
                UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitsInformationChanges);

                // Update unit
                foreach (UnitInformationTDS.UnitDetailsRow unitDetailsRow in (UnitInformationTDS.UnitDetailsDataTable)unitsInformationChanges.UnitDetails)
                {
                    // Unchanged values
                    int unitId = unitDetailsRow.UnitID;
                    string state = unitInformationUnitDetailsGateway.GetState(unitId);
                    string type = unitInformationUnitDetailsGateway.GetType(unitId);
                    bool deleted = false;
                    string notes = ""; if (!unitDetailsRow.IsNotesNull()) notes = unitDetailsRow.Notes;
                    string originalCategories = ""; if (!unitDetailsRow.IsCategoriesNull()) originalCategories = unitDetailsRow.Categories;

                    // Original Unit values
                    string originalUnitCode = unitInformationUnitDetailsGateway.GetUnitCodeOriginal(unitId);
                    string originalDescription = unitInformationUnitDetailsGateway.GetDescriptionOriginal(unitId);
                    string originalVin = unitInformationUnitDetailsGateway.GetVinOriginal(unitId);
                    string originalManufacturer = unitInformationUnitDetailsGateway.GetManufacturerOriginal(unitId);
                    string originalModel = unitInformationUnitDetailsGateway.GetModelOriginal(unitId);
                    string originalYear_ = unitInformationUnitDetailsGateway.GetYear_Original(unitId);
                    bool originalIsTowable = unitInformationUnitDetailsGateway.GetIsTowableOriginal(unitId);
                    int originalCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelIdOriginal(unitId);
                    DateTime? originalAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId).HasValue) originalAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId);
                    DateTime? originalDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId).HasValue) originalDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId);
                    string originalDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReasonOriginal(unitId);
                    string originalOwnerType = unitInformationUnitDetailsGateway.GetOwnerTypeOriginal(unitId);
                    Int64? originalOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId).HasValue) originalOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId);
                    Int64? originalOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId).HasValue) originalOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId);
                    string originalOwnerName = unitInformationUnitDetailsGateway.GetOwnerNameOriginal(unitId);
                    string originalOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContactOriginal(unitId);
                    DateTime? originalQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId).HasValue) originalQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId);
                    DateTime? originalNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId).HasValue) originalNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId);
                    string originalNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplainOriginal(unitId);
                    string originalInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClassOriginal(unitId);
                    string originalInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecifiedOriginal(unitId);
                    decimal? originalPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).HasValue) originalPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).Value;
                    DateTime? originalScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId).HasValue) originalScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId);
                    decimal? originalSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).HasValue) originalSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).Value;
                    int? originalLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).HasValue) originalLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).Value;

                    // New Unit values
                    string newUnitCode = unitInformationUnitDetailsGateway.GetUnitCode(unitId);
                    string newDescription = unitInformationUnitDetailsGateway.GetDescription(unitId);
                    string newVin = unitInformationUnitDetailsGateway.GetVin(unitId);
                    string newManufacturer = unitInformationUnitDetailsGateway.GetManufacturer(unitId);
                    string newModel = unitInformationUnitDetailsGateway.GetModel(unitId);
                    string newYear_ = unitInformationUnitDetailsGateway.GetYear_(unitId);
                    bool newIsTowable = unitInformationUnitDetailsGateway.GetIsTowable(unitId);
                    int newCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId);
                    DateTime? newAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue) newAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId);
                    DateTime? newDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue) newDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDate(unitId);
                    string newDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReason(unitId);
                    string newOwnerType = unitInformationUnitDetailsGateway.GetOwnerType(unitId);
                    Int64? newOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue) newOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId);
                    Int64? newOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue) newOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId);
                    string newOwnerName = unitInformationUnitDetailsGateway.GetOwnerName(unitId);
                    string newOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContact(unitId);
                    DateTime? newQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue) newQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDate(unitId);
                    DateTime? newNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue) newNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId);
                    string newNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId);

                    string newCategories = "";

                    if (categoriesSelected.Count > 0)
                    {
                        foreach (int categoryId in categoriesSelected)
                        {
                            CategoryGateway categoryGateway = new CategoryGateway();
                            categoryGateway.LoadByCategoryId(categoryId, companyId);
                            newCategories = newCategories + categoryGateway.GetName(categoryId) + ", ";
                        }

                        if (newCategories.Length > 2)
                        {
                            newCategories = newCategories.Substring(0, newCategories.Length - 2);
                        }
                    }

                    string newInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClass(unitId);
                    string newInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecified(unitId);
                    decimal? newPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) newPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value;
                    DateTime? newScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) newScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDate(unitId);
                    decimal? newSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) newSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value;
                    int? newLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).HasValue) newLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).Value;

                    // Update unit
                    UpdateUnit(unitId, originalUnitCode, originalDescription, originalVin, originalManufacturer, originalModel, originalYear_, originalIsTowable, originalCompanyLevelId, originalAcquisitionDate, originalDispositionDate, originalDispositionReason,  originalOwnerType, originalOwnerCountry, originalOwnerState, originalOwnerName, originalOwnerContact, originalQualifiedDate, originalNotQualifiedDate, originalNotQualifiedExplain, state, type, deleted, companyId, notes, originalCategories, originalInsuranceClass, originalInsuranceClassRyderSpecified, originalPurchasePrice, originalScrapDate, originalSaleProceeds, originalLibraryCategoriesId, unitId, newUnitCode, newDescription, newVin, newManufacturer, newModel, newYear_, newIsTowable, newCompanyLevelId, newAcquisitionDate, newDispositionDate, newDispositionReason,  newOwnerType, newOwnerCountry, newOwnerState, newOwnerName, newOwnerContact, newQualifiedDate, newNotQualifiedDate, newNotQualifiedExplain, state, type, deleted, companyId, notes, newCategories, newInsuranceClass, newInsuranceClassRyderSpecified, newPurchasePrice, newScrapDate, newSaleProceeds, newLibraryCategoriesId);
                    UpdateUnitCategory(unitId, companyId, categoriesSelected, newCompanyLevelId);

                    if (type == "Vehicle")
                    {
                        // Original Unit Vehicle values
                        Int64? originalLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId).HasValue) originalLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId);
                        Int64? originalLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId).HasValue) originalLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId);
                        string originalLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbverOriginal(unitId);
                        string originalAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumberOriginal(unitId);
                        string originalActualWeight = unitInformationUnitDetailsGateway.GetActualWeightOriginal(unitId);
                        string originalRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeightOriginal(unitId);
                        string originalTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFrontOriginal(unitId);
                        string originalTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBackOriginal(unitId);
                        string originalNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxesOriginal(unitId);
                        string originalFuelType = unitInformationUnitDetailsGateway.GetFuelTypeOriginal(unitId);
                        string originalBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometerOriginal(unitId);
                        bool originalIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquippedOriginal(unitId);
                        bool originalIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquippedOriginal(unitId);

                        // New Unit Vehicle values
                        Int64? newLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue) newLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId);
                        Int64? newLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue) newLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseState(unitId);
                        string newLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId);
                        string newAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumber(unitId);
                        string newActualWeight = unitInformationUnitDetailsGateway.GetActualWeight(unitId);
                        string newRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId);
                        string newTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId);
                        string newTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId);
                        string newNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId);
                        string newFuelType = unitInformationUnitDetailsGateway.GetFuelType(unitId);
                        string newBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId);
                        bool newIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId);
                        bool newIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId);

                        UpdateUnitVehicle(unitId, originalLicenseCountry, originalLicenseState, originalLicensePlateNumber, originalAportionedTagNumber, originalActualWeight, originalRegisteredWeight, originalTireSizeFront, originalTireSizeBack, originalNumberOfAxes, originalFuelType, originalBeginningOdometer, originalIsReeferEquipped, originalIsPtoEquipped, deleted, companyId, unitId, newLicenseCountry, newLicenseState, newLicensePlateNumber, newAportionedTagNumber, newActualWeight, newRegisteredWeight, newTireSizeFront, newTireSizeBack, newNumberOfAxes, newFuelType, newBeginningOdometer, newIsReeferEquipped, newIsPtoEquipped, deleted, companyId);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// LoadByUnitType
 /// </summary>
 /// <param name="unitType">unitType</param>
 /// <param name="companyId">companyId</param>
 public void LoadByUnitType(string unitType, int companyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(Data);
     categoryGateway.LoadByUnitType(unitType, companyId);
     UpdateData();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// InsertDirect
 /// </summary>
 /// <param name="type">type</param>
 /// <param name="name">name</param>
 /// <param name="parentId">parentId</param>
 /// <param name="deleted">deleted</param>
 /// <param name="companyId">companyId</param>
 public void InsertDirect(string type, string name, int? parentId, bool deleted, int companyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(null);
     categoryGateway.Insert(type, name, parentId, deleted, companyId);
 }
Ejemplo n.º 11
0
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// Load
 /// </summary>
 /// <param name="companyId">companyId</param>
 public void Load(int companyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(Data);
     categoryGateway.Load(companyId);
     UpdateData();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// DeletedDirect
 /// </summary>
 /// <param name="categoryId">categoryId</param>
 /// <param name="companyId">companyId</param>
 public void DeletedDirect(int categoryId, int companyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(null);
     categoryGateway.Delete(categoryId, companyId);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// UpdateDirect
 /// </summary>
 /// <param name="originalCategoryId">originalCategoryId</param>
 /// <param name="originalType">originalType</param>
 /// <param name="originalName">originalName</param>
 /// <param name="originalParentId">originalParentId</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="newCategoryId">newCategoryId</param>
 /// <param name="newType">newType</param>
 /// <param name="newName">newName</param>
 /// <param name="newParentId">newParentId</param>
 /// <param name="newDeleted">newDeleted</param>
 /// <param name="newCompanyId">newCompanyId</param>
 public void UpdateDirect(int originalCategoryId, string originalType, string originalName, int? originalParentId, bool originalDeleted, int originalCompanyId, int newCategoryId, string newType, string newName, int? newParentId, bool newDeleted, int newCompanyId)
 {
     CategoryGateway categoryGateway = new CategoryGateway(null);
     categoryGateway.Update(originalCategoryId, originalType, originalName, originalParentId, originalDeleted, originalCompanyId, newCategoryId, newType, newName, newParentId, newDeleted, newCompanyId);
 }
        /// <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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP5 - UNITS - METHODS
        //        
        private void StepUnitsIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Please select the units to which the rule will be applied";

            // Load Units
            int companyId = Int32.Parse(hdfCompanyId.Value);
            string category = "";
            UnitsList unitsList = new UnitsList(new DataSet());

            foreach (int categoryId in arrayCategoriesSelected)
            {
                CategoryGateway categoryGateway = new CategoryGateway();

                //Verify the location of the unit
                foreach (int companyLevelId in arrayCompanyLevelsSelected)
                {
                    // Load the unit if corresponds
                    categoryGateway.LoadByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value));
                    category = categoryGateway.GetName(categoryId);

                    unitsList.LoadAndAddItemByCategoryCompanyLevelId(category, companyLevelId, companyId);
                }
            }

            // Select all units by default
            if (unitsList.Table != null)
            {
                cbxlUnitsSelected.DataSource = RemoveDuplicateRows(unitsList.Table, "UnitID");
                cbxlUnitsSelected.DataValueField = "UnitID";
                cbxlUnitsSelected.DataTextField = "UnitCode";
                cbxlUnitsSelected.DataBind();

                foreach (ListItem lst in cbxlUnitsSelected.Items)
                {
                    lst.Selected = true;
                }

                // Total units
                lblTotalUnits.Text = "Total Units: " + cbxlUnitsSelected.Items.Count;

                Session["arrayUnitsSelected"] = arrayUnitsSelected;
            }
            else
            {
                // Total units
                lblTotalUnits.Text = "Total Units: 0";
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Save
        /// </summary>
        public void Save()
        {
            foreach (CategoriesAddTDS.CategoriesAddNewRow row in (CategoriesAddTDS.CategoriesAddNewDataTable)Data.Tables["CategoriesAddNew"])
            {
                // Insert category
                if ((!row.Deleted) && (!row.InDatabase))
                {
                    int? parentId = null; if (!row.IsParentIDNull()) parentId = row.ParentID;
                    InsertCategory(row.Type, row.Name, parentId, row.Deleted, row.COMPANY_ID);
                }

                // Update category
                if ((!row.Deleted) && (row.InDatabase))
                {
                    int companyId = row.COMPANY_ID;
                    CategoryGateway categoryGateway = new CategoryGateway();
                    categoryGateway.LoadByCategoryId(row.CategoryID, companyId);

                    int categoryId = row.CategoryID;
                    string originalType = categoryGateway.GetType(categoryId);
                    string originalName = categoryGateway.GetName(categoryId);
                    int? originalParentId = null; if (categoryGateway.GetParentId(categoryId).HasValue) originalParentId = (int)categoryGateway.GetParentId(categoryId);
                    bool originalDeleted = categoryGateway.GetDeleted(categoryId);

                    UpdateCategory(categoryId, originalType, originalName, originalParentId, originalDeleted, companyId, row.CategoryID, row.Type, row.Name, originalParentId, row.Deleted, companyId);
                }

                // Delete category
                if ((row.Deleted) && (row.InDatabase))
                {
                    int categoryId = row.CategoryID;
                    int? newCategoryId = null; if (!row.IsNewCategoryIDNull()) newCategoryId = row.NewCategoryID;
                    int companyId = row.COMPANY_ID;

                    UpdateUnitsAndRulesCategories(categoryId, newCategoryId, companyId);
                    DeleteCategory(categoryId, companyId);
                }
            }
        }
        /// <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);
                        }
                    }
                }
            }
        }
        protected void tvCategoriesRoot_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
        {
            // Validate to load checked units
            hdfCheckUnitsFlag.Value = "No";

            // Get categories
            arrayCategoriesSelectedForEdit.Clear();
            foreach (TreeNode nodes in tvCategoriesRoot.Nodes)
            {
                GetCategoriesSelected(nodes);
            }

            // Load Units
            int companyId = Int32.Parse(hdfCompanyId.Value);
            string category = "";
            UnitsList unitsList = new UnitsList(new DataSet());

            foreach (int categoryId in arrayCategoriesSelectedForEdit)
            {
                CategoryGateway categoryGateway = new CategoryGateway();

                //Verify the location of the unit
                foreach (int companyLevelId in arrayCompanyLevelsSelectedForEdit)
                {
                    // Load the unit if corresponds
                    categoryGateway.LoadByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value));
                    category = categoryGateway.GetName(categoryId);

                    unitsList.LoadAndAddItemByCategoryCompanyLevelId(category, companyLevelId, companyId);
                }
            }

            if (unitsList.Table != null)
            {
                cbxlUnitsSelected.DataSource = RemoveDuplicateRows(unitsList.Table, "UnitID");
                cbxlUnitsSelected.DataValueField = "UnitID";
                cbxlUnitsSelected.DataTextField = "UnitCode";
                cbxlUnitsSelected.DataBind();

                // Total units
                lblTotalUnits.Text = "Total Units: " + cbxlUnitsSelected.Items.Count;
            }
            else
            {
                // Total units
                lblTotalUnits.Text = "Total Units: 0";
            }
        }
Ejemplo n.º 19
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP5 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP5 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";
            hdfUpdate.Value = "yes";

            string isTowable = "No"; if (cbxIsTowable.Checked) isTowable = "Yes"; else isTowable = "No";
            string unitType = (rbtnVehicle.Checked) ? unitType = "Vehicle" : unitType = "Equipment";
            string vinOrSerialNumber = (rbtnVehicle.Checked) ? vinOrSerialNumber = "VIN" : vinOrSerialNumber = "Serial Number";

            string categoriesSelected = "";
            foreach (int categoryId in arrayCategoriesSelected)
            {
                CategoryGateway categoryGateway = new CategoryGateway();
                categoryGateway.LoadByCategoryId(categoryId, Int32.Parse(hdfCompanyId.Value));
                categoriesSelected += categoryGateway.GetName(categoryId) + ", ";
            }

            if (categoriesSelected.Length > 2)
            {
                categoriesSelected = categoriesSelected.Substring(0, categoriesSelected.Length - 2);
            }

            string companyLevelsSelected = "";
            foreach (int companyLevelId in arrayCompanyLevelsSelected)
            {
                CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
                companyLevelGateway.LoadByCompanyLevelId(companyLevelId, Int32.Parse(hdfCompanyId.Value));
                companyLevelsSelected += companyLevelGateway.GetName(companyLevelId) + ", ";
            }

            if (companyLevelsSelected.Length > 2)
            {
                companyLevelsSelected = companyLevelsSelected.Substring(0, companyLevelsSelected.Length - 2);
            }

            tbxSummary.Text = "Unit Type: " + unitType + "\nCode: " + tbxCode.Text + "\nDescription: " + tbxDescription.Text + "\n" + vinOrSerialNumber + ": " + tbxVinSerialNumber.Text + "\nManufacturer: " + tbxManufacturer.Text + "\nModel: " + tbxModel.Text + "\nYear: " + tbxYear.Text + "\nIs Towable?: " + isTowable + "\nCategories: " + categoriesSelected + "\nCompany Levels: " + companyLevelsSelected;

            if (rbtnVehicle.Checked)
            {
                string licenseCountry = "";
                string licenceState = "";

                if (ddlLicenseCountry.SelectedValue != "-1")
                {
                    licenseCountry = ddlLicenseCountry.SelectedItem.Text;

                    if (ddlLicenseState.SelectedValue != "-1" && ddlLicenseState.SelectedValue != "")
                    {
                        licenceState = ddlLicenseState.SelectedItem.Text;
                    }
                }

                tbxSummary.Text += "\nLicense Country: " + licenseCountry + "\nLicense State: " + licenceState + "\nLicense Plate Number: " + tbxLicensePlateNumber.Text + "\nApportioned Tag Number: " + tbxApportionedTagNumber.Text;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// GetChilds
        /// </summary>
        /// <param name="categoryId">categoryId</param>
        /// <param name="currentCategoriesId">currentCategoriesId</param>
        /// <param name="companyId">companyId</param>
        /// <returns></returns>
        private ArrayList GetChilds(int categoryId, ArrayList currentCategoriesId, int companyId)
        {
            ArrayList categoriesId = currentCategoriesId;

            CategoryGateway categoryGateway = new CategoryGateway();
            categoryGateway.LoadByParentId(categoryId, companyId);

            foreach (CategoriesTDS.LFS_FM_CATEGORYRow row in ((CategoriesTDS.LFS_FM_CATEGORYDataTable)categoryGateway.Table))
            {
                categoriesId.Add(row.CategoryID);

                categoriesId = GetChilds(row.CategoryID, categoriesId, companyId);
            }

            return categoriesId;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="categoriesSelected">categoriesSelected</param>
        /// <param name="companyId">companyId</param>
        public void Save(ArrayList categoriesSelected, int companyId)
        {
            UnitsAddTDS unitsAddChanges = (UnitsAddTDS)Data.GetChanges();

            if (unitsAddChanges.UnitsAddNew.Rows.Count > 0)
            {
                foreach (UnitsAddTDS.UnitsAddNewRow row in (UnitsAddTDS.UnitsAddNewDataTable)unitsAddChanges.UnitsAddNew)
                {
                    string type = ""; if (!row.IsTypeNull()) type = row.Type;
                    string code = row.Code;
                    string description = ""; if (!row.IsDescriptionNull()) description = row.Description;
                    string vin = ""; if (!row.IsVINNull()) vin = row.VIN;
                    string manufacturer = ""; if (!row.IsManufacturerNull()) manufacturer = row.Manufacturer;
                    string model = ""; if (!row.IsModelNull()) model = row.Model;
                    string year_ = ""; if (!row.IsYear_Null()) year_ = row.Year_;
                    bool isTowable = row.IsTowable;
                    Int64? licenseCountry = null; if (!row.IsLicenseCountryNull()) licenseCountry = row.LicenseCountry;
                    Int64? licenseState = null; if (!row.IsLicenseStateNull()) licenseState = row.LicenseState;
                    string licensePlateNumber = ""; if (!row.IsLicensePlateNumberNull()) licensePlateNumber = row.LicensePlateNumber;
                    int companyLevelId = row.CompanyLevelID;
                    string apportionedTagNumber = ""; if (!row.IsApportionedTagNumberNull()) apportionedTagNumber = row.ApportionedTagNumber;

                    string categories = "";

                    if (categoriesSelected.Count > 0)
                    {
                        foreach (int categoryId in categoriesSelected)
                        {
                            CategoryGateway categoryGateway = new CategoryGateway();
                            categoryGateway.LoadByCategoryId(categoryId, companyId);
                            categories = categories + categoryGateway.GetName(categoryId) + ", ";
                        }

                        if (categories.Length > 2)
                        {
                            categories = categories.Substring(0, categories.Length - 2);
                        }
                    }

                    Units units = new Units(null);
                    int unitId = units.InsertDirect(code, description, vin, manufacturer, model, year_, isTowable, companyLevelId, null, null, "", "", null, null, "", "", null, null, "", "Active", type, false, companyId, "", categories, "", "", null, null, null, null);

                    // ... Insert vehicle info
                    if (type == "Vehicle")
                    {
                        new UnitsVehicle(null).InsertDirect(unitId, licenseCountry, licenseState, licensePlateNumber, apportionedTagNumber, "", "", "", "", "", "", "", false, false, false, companyId);
                    }

                    // Save UnitCategory
                    UpdateUnitCategory(unitId, companyId, categoriesSelected);

                    // Save Checklist
                    UnitsChecklistRulesTemp unitChecklistRulesTemp = new UnitsChecklistRulesTemp(Data);
                    unitChecklistRulesTemp.Save(unitId, companyId);
                }
            }
        }
        /// <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);
                    }
                }
            }
        }