Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Response.Redirect("Login");
            }
            if (getUser.getBenutzer(Int32.Parse(HttpContext.Current.User.Identity.Name)).RollenID != 4) // RollenID == 4 --> User == Rektor / Wenn User kein Rektor wird ihm die Seite nicht angezeigt
            {
                Response.Redirect("~/error?type=" + getUser.getBenutzer(Int32.Parse(HttpContext.Current.User.Identity.Name)).RollenID);
            }

            string connectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\SchulplanerDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"";

            //
            // In a using statement, acquire the SqlConnection as a resource.
            //
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //
                using (SqlCommand command = new SqlCommand("SELECT * FROM OeffentlicherKalender", con))
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // test.Text = reader.GetString(1);

                            OeffentlicherKalender ok = new OeffentlicherKalender();
                            ok.KalenderID   = reader.GetInt32(0);
                            ok.Name         = reader.GetString(1);
                            ok.Beschreibung = reader.GetString(2);
                            // eintrag.ErinnerungsID = reader.GetInt32(5); // Im moment no Null, wills noni gmacht isch

                            kalender.Add(ok);

                            DDL_Calendar.Items.Add(new ListItem(ok.Name));
                        }
                    }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string connectionString = @"data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\SchulplanerDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"";

            //
            // In a using statement, acquire the SqlConnection as a resource.
            //
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                //
                // Open the SqlConnection.
                //
                con.Open();
                //
                // The following code uses an SqlCommand based on the SqlConnection.
                //
                using (SqlCommand command = new SqlCommand("SELECT * FROM OeffentlicherKalender", con))
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            // test.Text = reader.GetString(1);

                            OeffentlicherKalender ok = new OeffentlicherKalender();
                            ok.KalenderID   = reader.GetInt32(0);
                            ok.Name         = reader.GetString(1);
                            ok.Beschreibung = reader.GetString(2);
                            // eintrag.ErinnerungsID = reader.GetInt32(5); // Im moment no Null, wills noni gmacht isch

                            kalender.Add(ok);

                            DDL_Calendar.Items.Add(new ListItem(ok.Name));
                        }
                    }
            }
        }