Beispiel #1
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string       strTemp = string.Empty;
            SQLConnector con     = new SQLConnector();
            object       obj     = con.Get(inputDropDownList.Text, Convert.ToInt32(inputTextBox.Text));

            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                strTemp += pi.Name + ": " + pi.GetValue(obj) + "<br />";
            }
            TestLabel.Text = strTemp;
        }
        protected void SelectedIndexChanged(object sender, EventArgs e)
        {
            //Update Number of Seats when value is selected in drop down
            string       SeatsTemp = string.Empty;
            SQLConnector con       = new SQLConnector();
            object       obj       = con.Get("Theater", Convert.ToInt32(TheaterDropDownList.Text));

            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                if (pi.Name == "NumberOfSeats")
                {
                    SeatsTemp        = Convert.ToString(pi.GetValue(obj));
                    InputSeats.Value = SeatsTemp;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ValidateEmployee val = new ValidateEmployee();

            if (!val.IsEmployee(Context.User.Identity.Name))
            {
                Response.Redirect("default.aspx");
            }

            //Create Dynamic drop down lists for Movie and Screening
            SQLConnector con = new SQLConnector();

            if (!Page.IsPostBack)
            {
                List <MovieDTO> lisMovies = new List <MovieDTO>();
                lisMovies = con.GetAll("Movie").Cast <MovieDTO>().ToList();

                MovieDropDownList.DataTextField  = "Title";
                MovieDropDownList.DataValueField = "Id";
                MovieDropDownList.DataSource     = lisMovies;
                MovieDropDownList.DataBind();

                List <TheaterDTO> lisTheaters = new List <TheaterDTO>();
                lisTheaters = con.GetAll("Theater").Cast <TheaterDTO>().ToList();

                TheaterDropDownList.DataTextField  = "Name";
                TheaterDropDownList.DataValueField = "Id";
                TheaterDropDownList.DataSource     = lisTheaters;
                TheaterDropDownList.DataBind();
                TheaterDropDownList.SelectedIndex = 0;

                //Give Number Of Seats textbox value from DB matching the Theater selected in drop down.
                string       SeatsTemp = string.Empty;
                SQLConnector sqlCon    = new SQLConnector();
                object       obj       = sqlCon.Get("Theater", Convert.ToInt32(TheaterDropDownList.Text));
                foreach (PropertyInfo pi in obj.GetType().GetProperties())
                {
                    if (pi.Name == "NumberOfSeats")
                    {
                        SeatsTemp        = Convert.ToString(pi.GetValue(obj));
                        InputSeats.Value = SeatsTemp;
                    }
                }
            }
        }