-
Notifications
You must be signed in to change notification settings - Fork 0
/
Print.aspx.cs
108 lines (78 loc) · 5.26 KB
/
Print.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration; //lets us access our webconfig file in C#
namespace CapstoneFinal
{
public partial class Print : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnLoadStudents(object sender, EventArgs e)
{
String sqlQuery = "Select student.FirstName, student.LastName, age, notes, student.gender, dietary, parentcoming, permission, tcheck, teacher.LastName AS " +
"Teacher, name AS School FROM Student INNER JOIN Teacher ON Teacher.TeacherID = Student.TeacherID INNER JOIN School ON Teacher.SchoolID = School.SchoolID";
sqlQuery += " where Teacher.SchoolID = " + ddlTeacher.SelectedValue;
SqlConnection sqlConnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlQuery, sqlConnect);
DataTable dtForGridView = new DataTable();
sqlAdapter.Fill(dtForGridView);
grdOrderResults.DataSource = dtForGridView;
grdOrderResults.DataBind();
sqlConnect.Close();
sqlQuery = "Select FirstName + ' ' + LastName AS Teacher, EmailAddress AS Email, grade AS Grade, Name AS School FROM School inner join Teacher ON Teacher.SchoolID = School.SchoolID ";
sqlQuery += " where School.SchoolID = " + ddlTeacher.SelectedValue;
SqlConnection sqlConnect1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(sqlQuery, sqlConnect1);
DataTable dtForGridView1 = new DataTable();
sqlAdapter1.Fill(dtForGridView1);
grdOrderResults2.DataSource = dtForGridView1;
grdOrderResults2.DataBind();
sqlConnect1.Close();
sqlQuery = "Select student.ParentName, student.ParentEmail, student.FirstName + ' ' + student.LastName AS Child, " +
"Teacher.lastname as ChildsTeacher, name AS School FROM Student INNER JOIN Teacher ON Teacher.TeacherID = Student.TeacherID INNER JOIN School ON Teacher.SchoolID = School.SchoolID ";
sqlQuery += " where School.SchoolID = " + ddlTeacher.SelectedValue + " and parentcoming=1 ";
SqlConnection sqlConnect2 = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter2 = new SqlDataAdapter(sqlQuery, sqlConnect2);
DataTable dtForGridView2 = new DataTable();
sqlAdapter2.Fill(dtForGridView2);
grdOrderResults3.DataSource = dtForGridView2;
grdOrderResults3.DataBind();
sqlConnect2.Close();
}
protected void BtnShowAll_Click(object sender, EventArgs e)
{
String sqlQuery = "Select student.FirstName, student.LastName, age, notes, student.gender, dietary, parentcoming, permission, tcheck, teacher.LastName AS " +
"Teacher, name AS School FROM Student INNER JOIN Teacher ON Teacher.TeacherID = Student.TeacherID INNER JOIN School ON Teacher.SchoolID = School.SchoolID ";
SqlConnection sqlConnect = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlQuery, sqlConnect);
DataTable dtForGridView = new DataTable();
sqlAdapter.Fill(dtForGridView);
grdOrderResults.DataSource = dtForGridView;
grdOrderResults.DataBind();
sqlConnect.Close();
sqlQuery = "Select FirstName + ' ' + LastName AS Teacher, EmailAddress AS Email, grade AS Grade, Name AS School FROM School inner join Teacher ON Teacher.SchoolID = School.SchoolID ";
SqlConnection sqlConnect1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(sqlQuery, sqlConnect1);
DataTable dtForGridView1 = new DataTable();
sqlAdapter1.Fill(dtForGridView1);
grdOrderResults2.DataSource = dtForGridView1;
grdOrderResults2.DataBind();
sqlConnect1.Close();
sqlQuery = "Select student.ParentName, student.ParentEmail, student.FirstName + ' ' + student.LastName AS Child, " +
"Teacher.lastname as ChildsTeacher, name AS School FROM Student INNER JOIN Teacher ON Teacher.TeacherID = Student.TeacherID INNER JOIN School ON Teacher.SchoolID = School.SchoolID where parentcoming = 1";
SqlConnection sqlConnect2 = new SqlConnection(WebConfigurationManager.ConnectionStrings["lab4"].ToString());
SqlDataAdapter sqlAdapter2 = new SqlDataAdapter(sqlQuery, sqlConnect2);
DataTable dtForGridView2 = new DataTable();
sqlAdapter2.Fill(dtForGridView2);
grdOrderResults3.DataSource = dtForGridView2;
grdOrderResults3.DataBind();
}
}
}