示例#1
0
        protected void EventListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            String sqlQuery  = "select * from Event where EventID = " + EventListBox.SelectedItem.Value;
            String sqlQuery1 = "select S.StaffID, S.FirstName + ' ' + S.LastName as Name from Staff S inner join EventAttendees E on E.StaffID = S.StaffID where EventID = " + EventListBox.SelectedItem.Value;

            //Get connection string from web.config file
            string strcon = ConfigurationManager.ConnectionStrings["CARESconnection"].ConnectionString;
            //create new sqlconnection and connection to database by using connection string from web.config file
            SqlConnection con = new SqlConnection(strcon);

            con.Open();
            SqlDataAdapter sqlAdapter  = new SqlDataAdapter(sqlQuery, con);
            SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(sqlQuery1, con);

            DataSet ds = new DataSet();

            sqlAdapter.Fill(ds);

            FormView4.DataSource = ds;
            FormView4.DataBind();
            DataTable dt = new DataTable();

            sqlAdapter1.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                WorkerListLabel.Text        = "Employees Attending Event: ";
                WorkerListBox.DataSource    = dt;
                EventListBox.DataValueField = "StaffID";
                WorkerListBox.DataTextField = "Name";
                WorkerListBox.DataBind();
            }
            con.Close();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true);
        }
示例#2
0
        protected void LocationViewDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Queries Relevant to home page, fetching event info student info and more
            String sqlQuery =
                "Select * from Location where LocationID = " +
                LocationViewDDL.SelectedItem.Value;
            String sqlQuery1 =
                "SELECT StaffID, FirstName + ' ' + LastName as Name from Staff " +
                "where LocationID = " + LocationViewDDL.SelectedItem.Value;
            String sqlQuery3 =
                "select * from Event where LocationID = " +
                LocationViewDDL.SelectedItem.Value;
            String sqlQuery2 =
                "select StaffID, FirstName + ' ' + LastName as Name from Staff where Type = 'Admin' and LocationID = " +
                LocationViewDDL.SelectedItem.Value;

            //Get connection string from web.config file
            string strcon = ConfigurationManager.ConnectionStrings["CARESconnection"].ConnectionString;
            //create new sqlconnection and connection to database by using connection string from web.config file
            SqlConnection con = new SqlConnection(strcon);

            con.Open();
            SqlDataAdapter sqlAdapter  = new SqlDataAdapter(sqlQuery, con);
            SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(sqlQuery1, con);
            SqlDataAdapter sqlAdapter2 = new SqlDataAdapter(sqlQuery2, con);
            SqlDataAdapter sqlAdapter3 = new SqlDataAdapter(sqlQuery3, con);

            var items = new List <string>();

            using (SqlCommand command = new SqlCommand(sqlQuery2, con))
            {
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //Read info into List
                        items.Add(reader.GetString(1));
                    }
                }
            }

            Repeater1.DataSource = items;
            Repeater1.DataBind();
            //Fill table with data
            DataTable dt = new DataTable();

            sqlAdapter1.Fill(dt);

            if (dt.Rows.Count > 0)
            {
                WorkerListLabel.Text = "Employees At This Location: ";

                WorkerListBox.DataSource     = dt;
                WorkerListBox.DataValueField = "StaffID";

                WorkerListBox.DataTextField = "Name";
                WorkerListBox.DataBind();
            }
            DataTable dt2 = new DataTable();

            sqlAdapter3.Fill(dt2);

            if (dt2.Rows.Count > 0)
            {
                EventListBox.DataSource     = dt2;
                EventListBox.DataValueField = "EventID";
                EventListBox.DataTextField  = "EventName";
                EventListBox.DataBind();
            }
            DataSet ds = new DataSet();

            sqlAdapter.Fill(ds);

            FormView2.DataSource = ds;
            FormView2.DataBind();
            con.Close();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal1();", true);
        }