private void StepChecklistRulesInformationProcessGrid()
        {
            UnitsAddTDS dataSet = new UnitsAddTDS();
            dataSet.UnitsChecklistRulesTemp.Merge(unitsChecklistRulesTempForAdd, true);
            UnitsChecklistRulesTemp model = new UnitsChecklistRulesTemp(dataSet);

            // Update rows
            if (Session["unitsChecklistRulesTempForAddDummy"] == null)
            {
                foreach (GridViewRow row in grdChecklistRulesInformation.Rows)
                {
                    int ruleId = int.Parse(grdChecklistRulesInformation.DataKeys[row.RowIndex].Values["RuleID"].ToString());
                    int count = int.Parse(grdChecklistRulesInformation.DataKeys[row.RowIndex].Values["Count"].ToString());
                    DateTime? lastService = null;
                    DateTime? nextDue = null;
                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                    bool done = ((CheckBox)row.FindControl("cbxDone")).Checked;
                    string state = "Healthy";

                    if (((RadDatePicker)row.FindControl("tkrdpLastService")).SelectedDate.HasValue)
                    {
                        lastService = ((RadDatePicker)row.FindControl("tkrdpLastService")).SelectedDate.Value;
                    }

                    if (((RadDatePicker)row.FindControl("tkrdpNextDue")).SelectedDate.HasValue)
                    {
                        nextDue = ((RadDatePicker)row.FindControl("tkrdpNextDue")).SelectedDate.Value;
                    }

                    model.Update(ruleId, count, lastService, nextDue, state, done, selected);
                }

                model.Table.AcceptChanges();

                unitsChecklistRulesTempForAdd = (UnitsAddTDS.UnitsChecklistRulesTempDataTable)model.Table;
                Session["unitsChecklistRulesTempForAdd"] = unitsChecklistRulesTempForAdd;
            }
        }
        /// <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);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP4 - CHECKLIST RULES INFORMATION - METHODS
        //
        private void StepChecklistRulesInformationIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Please review the checklist rules data that will be applied to the unit";

            // Load
            UnitsAddTDS dataSet = new UnitsAddTDS();
            dataSet.UnitsChecklistRulesTemp.Merge(unitsChecklistRulesTempForAdd, true);
            UnitsChecklistRulesTemp model = new UnitsChecklistRulesTemp(dataSet);
            int companyLevelIdSelected = 0;

            if (dataSet.UnitsChecklistRulesTemp.Rows.Count <= 0)
            {
                foreach (int companyLevelId in arrayCompanyLevelsSelected)
                {
                    companyLevelIdSelected = companyLevelId;
                }

                model.Load(arrayCategoriesSelected, companyLevelIdSelected, int.Parse(hdfCompanyId.Value));
            }
            else
            {
                if (Convert.ToBoolean(Session["arrayCategoriesSelectedChanged"]) || Convert.ToBoolean(Session["arrayCompanyLevelsSelectedChanged"]))
                {
                    model.Data.Clear();
                    foreach (int companyLevelId in arrayCompanyLevelsSelected)
                    {
                        companyLevelIdSelected = companyLevelId;
                    }

                    model.Load(arrayCategoriesSelected, companyLevelIdSelected, int.Parse(hdfCompanyId.Value));
                }
            }

            // Store tables
            unitsChecklistRulesTempForAdd = (UnitsAddTDS.UnitsChecklistRulesTempDataTable)model.Table;
            Session["unitsChecklistRulesTempForAdd"] = unitsChecklistRulesTempForAdd;

            grdChecklistRulesInformation.DataBind();
        }