Ejemplo n.º 1
0
        public CascadingDropDownNameValue[] GetTrafficAreas(string knownCategoryValues, string category, string contextKey)
        {
            int controlAreaID;
            //this stringdictionary contains has table with key value
            //pair of cooountry and countryID
            StringDictionary countryValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            controlAreaID = Convert.ToInt32(countryValues["ControlArea"]);

            Facade.ITrafficArea facTrafficArea = new Facade.Traffic();
            DataSet             dsTrafficAreas = facTrafficArea.GetForControlAreaId(controlAreaID);

            var ret = (from dr in dsTrafficAreas.Tables[0].AsEnumerable()
                       select new CascadingDropDownNameValue
            {
                name = dr.Field <string>("Description"),
                value = (dr.Field <int>("TrafficAreaId")).ToString()
            }).ToArray();

            foreach (var v in ret)
            {
                if (v.value == contextKey)
                {
                    v.isDefaultValue = true;
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        private void BindTrafficAreas(int controlAreaId)
        {
            cboControlArea.ClearSelection();
            cboControlArea.Items.FindByValue(controlAreaId.ToString()).Selected = true;

            Facade.ITrafficArea facTrafficArea = new Facade.Traffic();
            cboTrafficArea.DataSource = facTrafficArea.GetForControlAreaId(controlAreaId);
            cboTrafficArea.DataBind();

            cboTrafficArea.ClearSelection();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The user has selected a control area to configure traffic areas for.
        /// </summary>
        private void cboControlArea_SelectedIndexChanged(object sender, EventArgs e)
        {
            int controlAreaId = Convert.ToInt32(cboControlArea.SelectedValue);

            using (Facade.IControlArea facControlArea = new Facade.Traffic())
            {
                m_controlArea = facControlArea.GetForControlAreaId(controlAreaId);
                ViewState[C_CONTROL_AREA_VS] = m_controlArea;
            }

            ConfigureControlAreaManipulation(eControlAreaManipulation.ConfigureTrafficAreas);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The user has selected a control area to alter - allow them to change the description and code.
        /// </summary>
        private void btnAlterControlArea_Click(object sender, EventArgs e)
        {
            btnAlterControlArea.DisableServerSideValidation();

            if (Page.IsValid)
            {
                int controlAreaId = Convert.ToInt32(cboControlArea.SelectedValue);
                using (Facade.IControlArea facControlArea = new Facade.Traffic())
                {
                    m_controlArea = facControlArea.GetForControlAreaId(controlAreaId);
                    ViewState[C_CONTROL_AREA_VS] = m_controlArea;
                }

                ConfigureControlAreaManipulation(eControlAreaManipulation.AddControlArea);
            }
        }
Ejemplo n.º 5
0
        private void ConfigureControlAreaManipulation(eControlAreaManipulation manipulation)
        {
            pnlConfigureControlAreasTrafficAreas.Visible = false;
            pnlAddTrafficAreaToControlArea.Visible       = false;
            pnlConfigureControlArea.Visible = false;

            // Configure the manipulation panels
            switch (manipulation)
            {
            case eControlAreaManipulation.ConfigureTrafficAreas:
                pnlConfigureControlAreasTrafficAreas.Visible = true;

                cboControlAreaTrafficAreas.SelectedIndex = -1;
                using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic())
                    cboControlAreaTrafficAreas.DataSource = facTrafficArea.GetForControlAreaId(m_controlArea.ControlAreaId);
                cboControlAreaTrafficAreas.DataTextField  = "Description";
                cboControlAreaTrafficAreas.DataValueField = "TrafficAreaId";
                cboControlAreaTrafficAreas.DataBind();
                break;

            case eControlAreaManipulation.AddTrafficArea:
                pnlConfigureControlAreasTrafficAreas.Visible = true;
                pnlAddTrafficAreaToControlArea.Visible       = true;

                cboAddTrafficArea.SelectedIndex = -1;
                using (Facade.ITrafficArea facTrafficArea = new Facade.Traffic())
                    cboAddTrafficArea.DataSource = facTrafficArea.GetAll();
                cboAddTrafficArea.DataTextField  = "Description";
                cboAddTrafficArea.DataValueField = "TrafficAreaId";
                cboAddTrafficArea.DataBind();
                break;

            case eControlAreaManipulation.AddControlArea:
                pnlConfigureControlArea.Visible = true;

                if (m_controlArea != null)
                {
                    txtControlAreaDescription.Text = m_controlArea.ControlAreaName;
                    btnActionControlArea.Text      = "Update";
                }
                else
                {
                    txtControlAreaDescription.Text = String.Empty;
                    btnActionControlArea.Text      = "Add";
                }
                break;

            case eControlAreaManipulation.SelectControlArea:
                // Set the control area
                m_controlArea = null;
                ViewState[C_CONTROL_AREA_VS] = m_controlArea;

                // Set the drop down list
                cboControlArea.SelectedIndex = -1;
                using (Facade.IControlArea facControlArea = new Facade.Traffic())
                    cboControlArea.DataSource = facControlArea.GetAll();
                cboControlArea.DataTextField  = "Description";
                cboControlArea.DataValueField = "ControlAreaId";
                cboControlArea.DataBind();
                cboControlArea.Items.Insert(0, new ListItem("-- Select a Control Area -- ", "-1"));
                break;
            }
        }