Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string CS = ConfigurationManager.ConnectionStrings["oacConnectionString"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                if (!IsPostBack)
                {
                    SqlCommand cmd2 = new SqlCommand("SELECT [OrgName], [OrgID] FROM [Organizations]", con);
                    con.Open();
                    OrgName.DataSource     = cmd2.ExecuteReader();
                    OrgName.DataTextField  = "OrgName"; //Column name
                    OrgName.DataValueField = "OrgID";   //column name
                    OrgName.DataBind();
                    con.Close();
                }
            }

            if (Session["username"] == null)
            {
                Response.Redirect("index.aspx");
            }

            lblUserName.Text = "" + Session["username"];
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check the session the ensure user is valid
            if (Session["username"] == null)
            {
                Response.Redirect("index.aspx");
            }

            //Displays the username in the top navigation bar
            lblUserName.Text = "" + Session["username"];


            string CS = ConfigurationManager.ConnectionStrings["oacConnectionString"].ConnectionString;

            using (SqlConnection con = new SqlConnection(CS))
            {
                if (!IsPostBack)
                {
                    SqlCommand cmd = new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%City%'",
                                                    con);
                    con.Open();
                    City.DataSource     = cmd.ExecuteReader();
                    City.DataTextField  = "ItemName"; //Column name
                    City.DataValueField = "ItemName"; //column name
                    City.DataBind();
                    con.Close();

                    SqlCommand cmd2 = new SqlCommand("SELECT [OrgName], [OrgID] FROM [Organizations]", con);
                    con.Open();
                    OrgName.DataSource     = cmd2.ExecuteReader();
                    OrgName.DataTextField  = "OrgName"; //Column name
                    OrgName.DataValueField = "OrgID";   //column name
                    OrgName.DataBind();
                    con.Close();

                    SqlCommand cmdStreamOne =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Stream%'", con);
                    con.Open();
                    StreamOne.DataSource     = cmdStreamOne.ExecuteReader();
                    StreamOne.DataTextField  = "ItemName"; //Column name
                    StreamOne.DataValueField = "ItemName"; //column name
                    StreamOne.DataBind();
                    con.Close();

                    SqlCommand cmdStreamTwo =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Stream%'", con);
                    con.Open();
                    StreamTwo.DataSource     = cmdStreamTwo.ExecuteReader();
                    StreamTwo.DataTextField  = "ItemName"; //Column name
                    StreamTwo.DataValueField = "ItemName"; //column name
                    StreamTwo.DataBind();
                    con.Close();

                    SqlCommand cmdCategoryOne =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Category%'", con);
                    con.Open();
                    CategoryOne.DataSource     = cmdCategoryOne.ExecuteReader();
                    CategoryOne.DataTextField  = "ItemName"; //Column name
                    CategoryOne.DataValueField = "ItemName"; //column name
                    CategoryOne.DataBind();
                    con.Close();

                    SqlCommand cmdCategoryTwo =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Category%'", con);
                    con.Open();
                    CategoryTwo.DataSource     = cmdCategoryTwo.ExecuteReader();
                    CategoryTwo.DataTextField  = "ItemName"; //Column name
                    CategoryTwo.DataValueField = "ItemName"; //column name
                    CategoryTwo.DataBind();
                    con.Close();

                    SqlCommand cmdTargetOne =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Target%'", con);
                    con.Open();
                    TargetOne.DataSource     = cmdTargetOne.ExecuteReader();
                    TargetOne.DataTextField  = "ItemName"; //Column name
                    TargetOne.DataValueField = "ItemName"; //column name
                    TargetOne.DataBind();
                    con.Close();

                    SqlCommand cmdTargetTwo =
                        new SqlCommand("SELECT [ItemName] FROM [Handlers] WHERE Category LIKE '%Target%'", con);
                    con.Open();
                    TargetTwo.DataSource     = cmdTargetTwo.ExecuteReader();
                    TargetTwo.DataTextField  = "ItemName"; //Column name
                    TargetTwo.DataValueField = "ItemName"; //column name
                    TargetTwo.DataBind();
                    con.Close();
                }
            }
        }