예제 #1
0
        protected void CategoryDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (CategoryDropdown.SelectedItem.Text.Equals("All Categories"))
            {
                SubCategoryDropdown.Items.Clear();
                SubCategoryDropdown.Items.Add("All SubCategories");
            }

            else
            {
                //Assumes categoryID is always in line with index. DOES NOT HOLD TRUE. Must change to fetch true categoryID from data base.
                int       selectedCategoryID = CategoryDropdown.SelectedIndex + 1;
                DataTable subCategoryTable   = new DataTable();

                using (SqlConnection connection = Utility.ServerConnection.Connection())
                {
                    connection.Open();

                    using (SqlCommand command = Utility.ServerConnection.GetSubCategories(connection, selectedCategoryID))
                    {
                        SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
                        dataAdapter.Fill(subCategoryTable);
                    }
                }

                SubCategoryDropdown.DataSource     = subCategoryTable;
                SubCategoryDropdown.DataTextField  = "SubCategoryName";
                SubCategoryDropdown.DataValueField = "SubCategoryID";
                SubCategoryDropdown.DataBind();
                SubCategoryDropdown.Items.Add(new ListItem("All SubCategories"));
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!IsPostBack)
            {
                DataTable      categoryTable          = new DataTable();
                DataTable      subCategoryTable       = new DataTable();
                SqlDataAdapter dataAdapter            = null;
                SqlDataAdapter subCategoryDataAdapter = null;

                using (SqlConnection connection = Utility.ServerConnection.Connection())
                {
                    connection.Open();

                    using (SqlCommand command = Utility.ServerConnection.GetAllCategories(connection))
                    {
                        dataAdapter = new SqlDataAdapter(command);
                        dataAdapter.Fill(categoryTable);
                    }

                    using (SqlCommand subCategoryCommand = Utility.ServerConnection.GetSubCategories(connection, 1))
                    {
                        subCategoryDataAdapter = new SqlDataAdapter(subCategoryCommand);
                        subCategoryDataAdapter.Fill(subCategoryTable);
                    }
                }

                CategoryDropdown.DataSource     = categoryTable;
                CategoryDropdown.DataTextField  = "CategoryName";
                CategoryDropdown.DataValueField = "CategoryID";
                CategoryDropdown.DataBind();
                CategoryDropdown.Items.Add(new ListItem("All Categories"));

                SubCategoryDropdown.DataSource     = subCategoryTable;
                SubCategoryDropdown.DataTextField  = "SubCategoryName";
                SubCategoryDropdown.DataValueField = "SubCategoryID";
                SubCategoryDropdown.DataBind();
                SubCategoryDropdown.Items.Add(new ListItem("All SubCategories"));

                if (Session["SearchResults"] != null)
                {
                    SearchBox.Text = (string)Session["Search"];
                    CategoryDropdown.SelectedIndex = (int)Session["SelectedCategory"];
                    CategoryDropdown_SelectedIndexChanged(null, null);
                    SubCategoryDropdown.SelectedIndex = (int)Session["SelectedSubcategory"];

                    SearchButton_Click(null, null);
                }
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                QuestionBox.Text = (string)Session["SelectedQuestion"];

                SqlConnection  connection             = Utility.ServerConnection.Connection();
                SqlCommand     command                = Utility.ServerConnection.GetAllCategories(connection);
                SqlCommand     subCategoryCommand     = Utility.ServerConnection.GetSubCategories(connection, 1);
                DataTable      categoryTable          = new DataTable();
                DataTable      subCategoryTable       = new DataTable();
                SqlDataAdapter dataAdapter            = new SqlDataAdapter(command);
                SqlDataAdapter subCategoryDataAdapter = new SqlDataAdapter(subCategoryCommand);

                connection.Open();
                dataAdapter.Fill(categoryTable);
                subCategoryDataAdapter.Fill(subCategoryTable);

                CategoryDropdown.DataSource     = categoryTable;
                CategoryDropdown.DataTextField  = "CategoryName";
                CategoryDropdown.DataValueField = "CategoryID";
                CategoryDropdown.DataBind();

                SubCategoryDropdown.DataSource     = subCategoryTable;
                SubCategoryDropdown.DataTextField  = "SubCategoryName";
                SubCategoryDropdown.DataValueField = "SubCategoryID";
                SubCategoryDropdown.DataBind();

                string question = (string)Session["SelectedQuestion"];

                SqlCommand getQuestionIDWithName = Utility.ServerConnection.GetQuestionIDWithName(connection, question);
                questionID = (int)getQuestionIDWithName.ExecuteScalar();

                string category    = (string)Utility.ServerConnection.GetCategory(connection, questionID).ExecuteScalar();
                string subcategory = (string)Utility.ServerConnection.GetSubcategory(connection, questionID).ExecuteScalar();

                SetDropDownByValue(CategoryDropdown, category);
                CategoryDropdown_SelectedIndexChanged(null, null);
                SetDropDownByValue(SubCategoryDropdown, subcategory);

                SqlCommand    checkSBS = Utility.ServerConnection.CheckRoleQuestion(connection, questionID, 2);
                SqlDataReader reader   = checkSBS.ExecuteReader();

                SBSCheckBox.Checked = SBSViewable = reader.Read();
                reader.Close();

                SqlCommand checkDealer = Utility.ServerConnection.CheckRoleQuestion(connection, questionID, 3);
                reader = checkDealer.ExecuteReader();
                DealerCheckBox.Checked = DealerViewable = reader.Read();
            }
        }
예제 #4
0
        protected void CategoryDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            int            selectedCategoryID = CategoryDropdown.SelectedIndex + 1;
            SqlConnection  connection         = Utility.ServerConnection.Connection();
            SqlCommand     command            = Utility.ServerConnection.GetSubCategories(connection, selectedCategoryID);
            DataTable      subCategoryTable   = new DataTable();
            SqlDataAdapter dataAdapter        = new SqlDataAdapter(command);

            connection.Open();
            dataAdapter.Fill(subCategoryTable);
            connection.Close();

            SubCategoryDropdown.DataSource     = subCategoryTable;
            SubCategoryDropdown.DataTextField  = "SubCategoryName";
            SubCategoryDropdown.DataValueField = "SubCategoryID";
            SubCategoryDropdown.DataBind();
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (!IsPostBack)
            {
                SqlConnection  connection             = Utility.ServerConnection.Connection();
                SqlCommand     command                = Utility.ServerConnection.GetAllCategories(connection);
                SqlCommand     subCategoryCommand     = Utility.ServerConnection.GetSubCategories(connection, 1);
                DataTable      categoryTable          = new DataTable();
                DataTable      subCategoryTable       = new DataTable();
                SqlDataAdapter dataAdapter            = new SqlDataAdapter(command);
                SqlDataAdapter subCategoryDataAdapter = new SqlDataAdapter(subCategoryCommand);

                connection.Open();
                dataAdapter.Fill(categoryTable);
                subCategoryDataAdapter.Fill(subCategoryTable);

                CategoryDropdown.DataSource     = categoryTable;
                CategoryDropdown.DataTextField  = "CategoryName";
                CategoryDropdown.DataValueField = "CategoryID";
                CategoryDropdown.DataBind();

                SubCategoryDropdown.DataSource     = subCategoryTable;
                SubCategoryDropdown.DataTextField  = "SubCategoryName";
                SubCategoryDropdown.DataValueField = "SubCategoryID";
                SubCategoryDropdown.DataBind();

                int    questionID = -1;
                string question   = (string)Session["SelectedQuestion"];

                SqlCommand getQuestionIDWithName = Utility.ServerConnection.GetQuestionIDWithName(connection, question);
                questionID = (int)getQuestionIDWithName.ExecuteScalar();

                string category    = (string)Utility.ServerConnection.GetCategory(connection, questionID).ExecuteScalar();
                string subcategory = (string)Utility.ServerConnection.GetSubcategory(connection, questionID).ExecuteScalar();

                SetDropDownByValue(CategoryDropdown, category);
                CategoryDropdown_SelectedIndexChanged(null, null);
                SetDropDownByValue(SubCategoryDropdown, subcategory);
            }
        }