private void BindGrid() { string constr = ConfigurationManager.ConnectionStrings["CS414_FasTestConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { HttpCookie SelectedClassID = new HttpCookie("SelectedClassID"); // Convert.ToInt32(Request.Cookies["SelectedClassID"].Value) using (SqlCommand cmd = new SqlCommand(@"SELECT DISTINCT ClassStudent.StudentID, CONCAT(FasTestUser.FirstName , ' ' , FasTestUser.LastName) AS NAME, ClassStudent.IsEnrolled FROM ClassStudent right join FasTestUser on FasTestUser.IDNumber = ClassStudent.StudentID where (FasTestUser.CredentialLevel = 3) and (ClassStudent.ClassID = " + Convert.ToInt32(Request.Cookies["SelectedClassID"].Value) + ")")) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); StudentList.DataSource = dt; StudentList.DataBind(); } } } } }
protected void StudentList_SelectedIndexChanged(object sender, EventArgs e) { Person person = (Person)Session["personDetail"]; int rowindex = StudentList.SelectedRow.RowIndex; string id = AssessmentQuestion.SelectedValue; string email = (String)StudentList.DataKeys[rowindex].Value; string databaseConnectUpdate = ConfigurationManager.ConnectionStrings["AssignmentEntities"].ConnectionString.ToString(); SqlConnection conUpdate = new SqlConnection(databaseConnectUpdate); conUpdate.Open(); string CompletionValue = "INCOMPLETE"; string AssignmentValue = "ASSIGNED"; string insertQuery = "insert into MCQAssessmentList" + "(Email,MCQAssessmentID,Completion,Assignment) values (@Email,@MCQAssessmentID,@Completion,@Assignment);"; SqlCommand InsertComm = new SqlCommand(insertQuery, conUpdate); InsertComm.Parameters.AddWithValue("@Email", email); InsertComm.Parameters.AddWithValue("@MCQAssessmentID", "" + id); InsertComm.Parameters.AddWithValue("@Completion", CompletionValue); InsertComm.Parameters.AddWithValue("@Assignment", AssignmentValue); try { InsertComm.ExecuteNonQuery(); conUpdate.Close(); TypeOfQuestion.SelectedValue = "MCQ"; AssessmentQuestion.SelectedValue = id; StudentList.DataBind(); ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You Had Assigned The Assessment To The Student!');", true); } catch (System.Data.SqlClient.SqlException ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('The student has been assigned!');", true); } }
private void Bind() { StudentList.DataSource = bllStudent.GetAll(); StudentList.DataBind(); if (CheckAdmin()) { AdminList.DataSource = bllAdmin.GetNotAdmin(); AdminList.DataBind(); } else { AdminPanel.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { int courseID = Convert.ToInt32(Request.QueryString["CourseID"]); SqlConnection conn; SqlCommand comm_students; SqlCommand comm_course; SqlDataReader reader1; SqlDataReader reader2; // read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings["Students"].ConnectionString; // Initialize connection conn = new SqlConnection(connectionString); //create command comm_students = new SqlCommand("SELECT Students.StudentID,Students.FirstMidName,Students.LastName FROM Enrollments JOIN Students on Enrollments.StudentID = Students.StudentID WHERE Enrollments.CourseID = @CourseID", conn); // add parameter into command comm_course = new SqlCommand("SELECT CourseID,Title FROM Courses WHERE CourseID = @CourseID", conn); comm_students.Parameters.Add("@CourseID", System.Data.SqlDbType.Int); comm_students.Parameters["@CourseID"].Value = courseID; comm_course.Parameters.Add("@CourseID", System.Data.SqlDbType.Int); comm_course.Parameters["@CourseID"].Value = courseID; try { //open connection conn.Open(); //execute the command reader1 = comm_students.ExecuteReader(); // bind the reader to DataList StudentList.DataSource = reader1; StudentList.DataBind(); reader1.Close(); reader2 = comm_course.ExecuteReader(); CourseInfo.DataSource = reader2; CourseInfo.DataBind(); //Close the reader reader2.Close(); } finally { //close connection conn.Close(); } }
protected void BindStudentList() { try { //code here StudentController sysmgr = new StudentController(); List <Student> info = null; info = sysmgr.List(); info.Sort((x, y) => x.StudentName.CompareTo(y.StudentName)); StudentList.DataSource = info; StudentList.DataTextField = nameof(Student.StudentName); StudentList.DataValueField = nameof(Student.StudentID); StudentList.DataBind(); StudentList.Items.Insert(0, "select..."); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } }
// Building the connection from a string; for an example using the ConnectionStrings in web.config, go to line 29 // private SqlConnection connection = new SqlConnection("Server=NGAN-PC\\SQLEXPRESS;Initial Catalog=Comp229Assign03;Integrated Security=True"); protected void Page_Load(object sender, EventArgs e) { // Only build the list on the initial arrival, not after button presses /* * if (!IsPostBack) * { * GetClasses(); * } */ SqlConnection conn; SqlCommand comm; SqlDataReader reader; // read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings["Students"].ConnectionString; // Initialize connection conn = new SqlConnection(connectionString); //create command comm = new SqlCommand("Select * from Students;", conn); try { //open connection conn.Open(); //execute the command reader = comm.ExecuteReader(); // bind the reader to DataList StudentList.DataSource = reader; StudentList.DataBind(); //Close the reader reader.Close(); } finally { //close connection conn.Close(); } }
protected void BindStudentList() { try { //Add code here to get all the Student records and bind to the "StudentList" dropdown StudentController sysmgr = new StudentController(); List <Student> info = null; info = sysmgr.List(); info.Sort((x, y) => x.StudentName.CompareTo(y.StudentName)); StudentList.DataSource = info; StudentList.DataTextField = nameof(Student.StudentName); StudentList.DataValueField = nameof(Student.StudentID); StudentList.DataBind(); ListItem myitem = new ListItem(); myitem.Value = "0"; myitem.Text = "select..."; StudentList.Items.Insert(0, myitem); } catch (Exception ex) { ShowMessage(GetInnerException(ex).ToString(), "alert alert-danger"); } }
private void BindList() { ListControl.DataBind(StudentLogic.GetAll().ToList()); }
protected void Page_Load(object sender, EventArgs e) { //Rebecca - If no session exists, or if not a Senior University Manager, redirect to default page. if (Session["user"] == null || (Convert.ToInt32(Session["typeID"]) != 3)) { Response.Redirect("../Default.aspx"); } else { //Otherwise, store session in username field. string user = Session["user"].ToString(); username.Text = user; username1.Text = user; // Rebecca: //////////////////////////////////////////////// CALCULATIONS ///////////////////////////////////////////////// //1 Student Count //Databinding the completed listview StudentList.DataBind(); //Counting number of students int sum = StudentList.Items.Count(); //Placing student count in label if (sum == 0) { studentCount.Text = "No students on record"; } else { studentCount.Text = Convert.ToString(sum); } //2 Dropped Out Count //Databinding the completed listview DroppedOutStudents.DataBind(); //Counting number of students dropped out int droppedOut = DroppedOutStudents.Items.Count(); //If no students are dropped out set the label to 0, otherwise put the number of students counted in the label. if (droppedOut == 0) { studentDropped.Text = "0"; } else { studentDropped.Text = Convert.ToString(droppedOut) + " students have left a course."; } //Calculating drop out rate: decimal DropOut = Decimal.Divide(droppedOut, sum) * 100; double dropOutRate = Convert.ToInt32(DropOut); PercentageDroppedOut.Text = Convert.ToString(dropOutRate) + "%"; //3 Caculating Retention: int retention = sum - droppedOut; Retention.Text = Convert.ToString(retention) + " students have remained on course."; //Retention Rate: decimal retent = Decimal.Divide(retention, sum) * 100; double RetentionRate = Convert.ToInt32(retent); retentionRate.Text = Convert.ToString(RetentionRate) + "%"; //4 Enrolled Count //Databinding the completed listview EnrolledStudents.DataBind(); //Counting number of students enrolled int enrolled = EnrolledStudents.Items.Count(); //If no students are counted set the label to 0, otherwise put the number of students counted in the label. if (enrolled == 0) { studentEnrolled.Text = "0"; } else { studentEnrolled.Text = Convert.ToString(enrolled); } //Calculating enrolled rate: decimal Enrolled = Decimal.Divide(enrolled, sum) * 100; double EnrolledRate = Convert.ToInt32(Enrolled); enrolledRate.Text = Convert.ToString(EnrolledRate) + "%"; //5 Counting all results on record results.DataBind(); int resultnum = results.Items.Count(); //6 Results Passed Count //Databinding the completed listview Passed.DataBind(); //Counting number of pass results int passnum = Passed.Items.Count(); //Placing pass count in label if (passnum == 0) { pass.Text = "No pass results on record."; } else { pass.Text = Convert.ToString(passnum) + " students have pass results."; } //Calculating pass rate: decimal PassedRate = Decimal.Divide(passnum, resultnum) * 100; double PassRate = Convert.ToInt32(PassedRate); passrate.Text = Convert.ToString(PassRate) + "%"; //7 Results Failed Count //Databinding the completed listview Failed.DataBind(); //Counting number of fail results int failnum = Failed.Items.Count(); //Placing pass count in label if (failnum == 0) { fail.Text = "No fail results on record."; } else { fail.Text = Convert.ToString(failnum) + " students have fail results."; } //Calculating pass rate: decimal FailedRate = Decimal.Divide(failnum, resultnum) * 100; double FailRate = Convert.ToInt32(FailedRate); failrate.Text = Convert.ToString(FailRate) + "%"; //8 Fees Unpaid Count //Databinding the completed listview unpaidlist.DataBind(); //Counting number of unpaid fees int unpaidnum = unpaidlist.Items.Count(); //Placing unpaid fee count in label if (unpaidnum == 0) { feesunpaid.Text = "No records"; } else { feesunpaid.Text = Convert.ToString(unpaidnum) + " students have no payments."; } //Calculating unpaid rate: decimal UnpaidRate = Decimal.Divide(unpaidnum, sum) * 100; double unpaidrate = Convert.ToInt32(UnpaidRate); feesunpaidrate.Text = Convert.ToString(unpaidrate) + "%"; //9 Fees Paid Count //Databinding the completed listview paidlist.DataBind(); //Counting number of fail results int paidnum = paidlist.Items.Count(); //Placing paid count in label if (unpaidnum == 0) { feespaid.Text = "No records"; } else { feespaid.Text = Convert.ToString(paidnum) + " students have paid off their fees."; } //Calculating paid rate: decimal PaidRate = Decimal.Divide(paidnum, sum) * 100; double paidrate = Convert.ToInt32(PaidRate); feespaidrate.Text = Convert.ToString(paidrate) + "%"; //10 Payments Made Count //Databinding the completed listview paymentlist.DataBind(); //Counting number of payments int paymentnum = paymentlist.Items.Count(); //Placing payments count in label if (paymentnum == 0) { paymade.Text = "No records"; } else { paymade.Text = Convert.ToString(paymentnum) + " students have made a payment."; } //Calculating payments rate: decimal paymentRate = Decimal.Divide(paymentnum, sum) * 100; double Payrate = Convert.ToInt32(paymentRate); paymentsrate.Text = Convert.ToString(Payrate) + "%"; //4 Progression Count //Databinding the completed listview firstyearlist.DataBind(); //Counting number of students dropped out int first = firstyearlist.Items.Count(); if (first == 0) { FirstPercent.Text = "0"; } else { FirstPercent.Text = Convert.ToString(first) + " first years."; } //Calculating first year rate: decimal firstP = Decimal.Divide(first, sum) * 100; double firstRate = Convert.ToInt32(firstP); FirstCount.Text = Convert.ToString(firstRate) + "%"; //Databinding the completed listview secondyearlist.DataBind(); //Counting number of students dropped out int second = secondyearlist.Items.Count(); if (second == 0) { SecondPercent.Text = "0"; } else { SecondPercent.Text = Convert.ToString(second) + " second years."; } //Calculating second year rate: decimal secondP = Decimal.Divide(second, sum) * 100; double secondRate = Convert.ToInt32(secondP); SecondCount.Text = Convert.ToString(secondRate) + "%"; //Databinding the completed listview thirdyearlist.DataBind(); //Counting number of students dropped out int third = thirdyearlist.Items.Count(); if (third == 0) { ThirdPercent.Text = "0"; } else { ThirdPercent.Text = Convert.ToString(third) + " third years."; } //Calculating third year rate: decimal thirdP = Decimal.Divide(third, sum) * 100; double thirdRate = Convert.ToInt32(thirdP); ThirdCount.Text = Convert.ToString(thirdRate) + "%"; ////////////////////////////////// CHARTS: /////////////////////////////////////////////// //Chart 1 - Enrolled & not enrolled student values for x & y axis: int notenrolled = sum - enrolled; int[] chart1yValues = { notenrolled, enrolled }; string[] chart1xValues = { "Unregistered", "Enrolled" }; //Adding values above to chart: Chart1.Series["Series1"].Points.DataBindXY(chart1xValues, chart1yValues); //Styling Chart: Chart1.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); Chart1.Series["Series1"]["PointWidth"] = "5"; Chart1.Series["Series1"].Points[0].Color = Color.CadetBlue; Chart1.Series["Series1"].Points[1].Color = Color.DarkCyan; //Chart 2 - Student Results values for x & y axis: int[] resultyValues = { passnum, failnum }; string[] resultxValues = { "Passed", "Failed" }; //Adding values above to chart: ResultsChart.Series["Series1"].Points.DataBindXY(resultxValues, resultyValues); //Styling Chart: ResultsChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); ResultsChart.Series["Series1"]["PointWidth"] = "0.1"; ResultsChart.Series["Series1"].Points[0].Color = Color.MediumSeaGreen; ResultsChart.Series["Series1"].Points[1].Color = Color.Firebrick; //Chart 3 - bar chart drop out/retention values for x & y axis: int[] dropyValues = { sum, retention, droppedOut }; string[] dropxValues = { "Total Students", "Retention", "Dropped out" }; //Adding values above to chart: DropChart.Series["Series1"].Points.DataBindXY(dropxValues, dropyValues); //Styling Chart: DropChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); DropChart.Series["Series1"].Points[0].Color = Color.Goldenrod; DropChart.Series["Series1"].Points[1].Color = Color.DarkGray; DropChart.Series["Series1"].Points[2].Color = Color.Peru; //Chart 4 - Finance values for x & y axis: int[] financeyValues = { paidnum, unpaidnum, paymentnum }; string[] financexValues = { "Fees Paid", "Fees Unpaid", "Payments Made" }; //Adding values above to chart: FinanceChart.Series["Series1"].Points.DataBindXY(financexValues, financeyValues); //Styling Chart: FinanceChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); FinanceChart.Series["Series1"]["PointWidth"] = "0.1"; FinanceChart.Series["Series1"].Points[0].Color = Color.Thistle; FinanceChart.Series["Series1"].Points[1].Color = Color.RosyBrown; FinanceChart.Series["Series1"].Points[2].Color = Color.LightGoldenrodYellow; //Chart 5 - Progression values for x & y axis: int[] progressyValues = { first, second, third }; string[] progressxValues = { "First", "Second", "Third" }; //Adding values above to chart: ProgressChart.Series["Series1"].Points.DataBindXY(progressxValues, progressyValues); //Styling Chart: ProgressChart.Series["Series1"].Font = new Font("Calibri", 11, FontStyle.Bold); ProgressChart.Series["Series1"]["PointWidth"] = "0.1"; ProgressChart.Series["Series1"].Points[0].Color = Color.SlateGray; ProgressChart.Series["Series1"].Points[1].Color = Color.DarkSlateBlue; ProgressChart.Series["Series1"].Points[2].Color = Color.Lavender; } }