protected void btnRegister_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvCourseRegistration.Rows) { CheckBox cb = (CheckBox)row.FindControl("RegisterThis"); if (cb != null && cb.Checked) { int id = Convert.ToInt32(gvCourseRegistration.DataKeys[row.RowIndex].Value); int cid = Convert.ToInt32(row.Cells[1].Text); RegistrationDAL rdal = new RegistrationDAL(); string email = Session["Course_Key"].ToString(); DataSet sid = rdal.getStudent(email); DataTable dt = sid.Tables[0]; DataRow dr = dt.Rows[0]; int stdid = (int)dr["Student_id"]; string fname = dr["first_name"].ToString(); string lname = dr["last_name"].ToString(); string name = fname + ' ' + lname; try { rdal.RegisterCourse(cid, stdid, name); gvCourseRegistration.Visible = false; btnRegister.Visible = false; heading1.InnerText = "Course has been Successfully registered"; } catch (Exception ex) { lblAlready.Text = " Course Already Registered"; } } } }
public void Page_Load(object sender, EventArgs e) { try { this.Master.name.Text = Session["User"].ToString(); } catch (Exception ex) { Response.Redirect("index.aspx"); } d.getcount(); count.Text = d.count.ToString(); ins(); venue(); vol(); hosp(); course(); registration(); atmosphere(); DataSet ds = cd.getOfferedCourse(); gvCourseRegistration.DataSource = ds; gvCourseRegistration.DataBind(); StringBuilder htmlTable = new StringBuilder(); RegistrationDAL rdal = new RegistrationDAL(); DataSet ds1 = rdal.getStudent(); htmlTable.Append("<table border='1' id='Table1' class='table table-bordered table-hover table-responsive' width='500px' height='80'>"); htmlTable.Append("<tr style='background-color:#591919; color: White; '><th style='text-align:center'>Course ID</th><th style='text-align:center'>Course Name</th><th style='text-align:center'>Total Enrolled Students</th></tr>"); int j = 1000; for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { int cid = Convert.ToInt32(ds1.Tables[0].Rows[i]["Course_id"]); int countt = rdal.getcount(cid); htmlTable.Append("<tr style='color: black;'>"); htmlTable.Append("<td>" + ds1.Tables[0].Rows[i]["Course_id"] + "</td>"); htmlTable.Append("<td>" + ds1.Tables[0].Rows[i]["Course_Name"] + "</td>"); htmlTable.Append("<td>" + countt + "</td>"); htmlTable.Append("</tr>"); } htmlTable.Append("</table>"); DBDataPlaceHolder.Controls.Add(new Literal { Text = htmlTable.ToString() }); }
protected void Page_Load(object sender, EventArgs e) { try { this.Master.name.Text = Session["User"].ToString(); } catch (Exception ex) { Response.Redirect("index.aspx"); } StringBuilder htmlTable = new StringBuilder(); RegistrationDAL rdal = new RegistrationDAL(); DataSet ds = rdal.getStudent(); htmlTable.Append("<table border='1' id='Table1' class='table table-bordered table-hover table-responsive' width='500px' height='80'>"); htmlTable.Append("<tr style='background-color:#591919; color: White; '><th style='text-align:center'>Course ID</th><th style='text-align:center'>Course Name</th><th style='text-align:center'>Total Enrolled Students</th></tr>"); int j = 1000; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int cid = Convert.ToInt32(ds.Tables[0].Rows[i]["Course_id"]); int count = rdal.getcount(cid); htmlTable.Append("<tr style='color: black;'>"); htmlTable.Append("<td>" + ds.Tables[0].Rows[i]["Course_id"] + "</td>"); htmlTable.Append("<td>" + ds.Tables[0].Rows[i]["Course_Name"] + "</td>"); htmlTable.Append("<td>" + count + "</td>"); htmlTable.Append("</tr>"); } htmlTable.Append("</table>"); DBDataPlaceHolder.Controls.Add(new Literal { Text = htmlTable.ToString() }); lblNo.Visible = false; if (ds.Tables[0].Rows.Count == 0) { DBDataPlaceHolder.Visible = false; lblNo.Visible = true; } }