Пример #1
0
        protected void getDepartments()
        {
            // connect to db
            var conn = new gurbhejEntities();

            // run the query using LINQ
            var Departments = from d in conn.Departments
                              select d;

            // display query result in gridview
            grdDepartments.DataSource = Departments.ToList();
            grdDepartments.DataBind();
        }
Пример #2
0
        protected void getStudents()
        {
            // connect to db
            var conn = new gurbhejEntities();

            // run the query using LINQ
            var Students = from s in conn.Students
                           select s;

            // display query result in gridview
            grdStudents.DataSource = Students.ToList();
            grdStudents.DataBind();
        }
Пример #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // connect
            var conn = new gurbhejEntities();

            //use the Student class to create a new Student Object
            Student s = new Student();

            // Fill the properties of the new student object
            s.LastName       = txtLastName.Text;
            s.FirstMidName   = txtFirstMidName.Text;
            s.EnrollmentDate = Convert.ToDateTime(txtEnrollment.Text);

            //save the new object to the database
            conn.Students.Add(s);
            conn.SaveChanges();

            //redirect to the students page
            Response.Redirect("students.aspx");
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // connect
            var conn = new gurbhejEntities();

            //use the Student class to create a new department Object
            Department d = new Department();

            // Fill the properties of the new department object
            d.Name   = txtName.Text;
            d.Budget = Convert.ToDecimal(txtBudget.Text);


            //save the new object to the database
            conn.Departments.Add(d);
            conn.SaveChanges();

            //redirect to the departments page
            Response.Redirect("departments.aspx");
        }