コード例 #1
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            // EF to connect to server
            using (DefaultConnection db = new DefaultConnection())
            {
                // Soccer Model to create new Soccer object
                Soccer newSoccer = new Soccer();
                int anInteger, anInteger2, anInteger3, anInteger4;
                anInteger = Convert.ToInt32(ScoreOneTextBox.Text);
                anInteger2 = Convert.ToInt32(ScoreTwoTextBox.Text);
                anInteger3 = Convert.ToInt32(AsistsOneTextBox.Text);
                anInteger4 = Convert.ToInt32(AsistsTwoTextBox.Text);

                newSoccer.teamName1 = TeamOneTextBox.Text;
                newSoccer.teamName2 = TeamTwoTextBox.Text;
                newSoccer.score1 = anInteger;
                newSoccer.score2 = anInteger2;
                newSoccer.asists1 = anInteger3;
                newSoccer.asists2 = anInteger4;

                //Linq to ADO.Net
                db.Soccers.Add(newSoccer);

                // save changes
                db.SaveChanges();

                //Redirect
                Response.Redirect("~/Default.aspx");

            }
        }
コード例 #2
0
        protected void GetPaintball()
        {
            // connect to ef
            using (DefaultConnection db = new DefaultConnection())
            {
                // Query basketball table using ef and linq
                var Paintball = (from allPaintball in db.Paintballs
                              select allPaintball);

                //bind the results to the GridView
                PaintballGridView.DataSource = Paintball.ToList();
                PaintballGridView.DataBind();
            }
        }
コード例 #3
0
        protected void GetSoccer()
        {
            // connect to ef
                using (DefaultConnection db = new DefaultConnection())
                {
                    // Query basketball table using ef and linq
                    var Soccer = (from allSoccer in db.Soccers
                                  select allSoccer);

                    //bind the results to the GridView
                    SoccerGridView.DataSource = Soccer.ToList();
                    SoccerGridView.DataBind();
                }
        }
コード例 #4
0
        protected void GetHockey()
        {
            // connect to ef
                using (DefaultConnection db = new DefaultConnection())
                {
                    // Query basketball table using ef and linq
                    var Hockey = (from allHockey in db.Hockeys
                                  select allHockey);

                    //bind the results to the GridView
                    HockeyGridView.DataSource = Hockey.ToList();
                    HockeyGridView.DataBind();
                }
        }