protected void Button1_Click(object sender, EventArgs e) { /*SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string sql = "select * from Academic "; * cmd.CommandText = sql; * con.Open(); * SqlDataReader dr = cmd.ExecuteReader(); * // Dictionary<float, int> rank = new Dictionary<float, int>; * while(dr.Read()) * { * * }*/ admissionEntities ae = new admissionEntities(); var aca = from c in ae.Academics orderby(c.hsc_marks * 0.6 + c.competitive_exam_marks * 0.4) descending, c.ssc_marks descending select c; int rank = 0; foreach (var x in aca) { rank++; string stdid = x.std_id; StudentDetail s = ae.StudentDetails.Where(s1 => s1.std_id == stdid).FirstOrDefault <StudentDetail>(); s.rank = rank; } ae.SaveChanges(); /*Label1.Visible = true; * Label1.Text = "Rank Successfully Generated";*/ Button1.Enabled = false; Button1.Text = "Rank Successfully Generated"; }
protected void addbranchButton_Click(object sender, EventArgs e) { try { int cid = Int32.Parse(collegeDropDownList.SelectedValue); int bid = Int32.Parse(branchDropDownList.SelectedValue); int pid = Int32.Parse(programDropDownList.SelectedValue); int gen = Int32.Parse(generalTextBox.Text); int obc = Int32.Parse(obcTextBox.Text); int sc = Int32.Parse(scTextBox.Text); int st = Int32.Parse(stTextBox.Text); admissionEntities ae = new admissionEntities(); Branch_College bc = new Branch_College(); bc.branch_id = bid; bc.college_id = cid; bc.program_id = pid; bc.general = gen; bc.obc = obc; bc.sc = sc; bc.st = st; ae.Branch_College.Add(bc); ae.SaveChanges(); Response.Redirect(Request.RawUrl); errLabel.Text = ""; } catch (Exception err) { errLabel.Text = "some error"; } }
protected void Button1_Click(object sender, EventArgs e) { try { string username = usernameTxt.Text; string password = passwordTxt.Text; string role = "admin"; string captcha = captchaTxt.Text; if (captcha.ToLower() != Session["CaptchaVerify"].ToString()) { captchaLabel.Text = "Incorrect Captcha Code!!"; captchaLabel.ForeColor = System.Drawing.Color.Red; } admissionEntities ae = new admissionEntities(); Login l = ae.Logins.Where(s => s.username == username && s.password == password && s.role == role).FirstOrDefault <Login>(); if (l.username == null) { invalidLabel.Text = "Invalid username or password!!"; } else { Session["username"] = username; Session["role"] = "admin"; Response.Redirect("Home.aspx"); } } catch (Exception err) { } }
protected void removeButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; string CommandArgument = btn.CommandArgument; string username = (string)Session["username"]; int choiceid = Int32.Parse(CommandArgument); int[] r = (int[])Application["round"]; int course = (int)Session["course"]; int roundno = r[course]; int remp; try { admissionEntities ae = new admissionEntities(); Student_Choice sc = ae.Student_Choice.Where(s => s.choice_id == choiceid && s.std_id == username && s.round_id == roundno).FirstOrDefault <Student_Choice>(); remp = (int)sc.preference_no; ae.Student_Choice.Remove(sc); ae.SaveChanges(); var x = from c in ae.Student_Choice where c.preference_no > remp && c.std_id == username select c; if (x != null) { foreach (var x1 in x) { x1.preference_no -= 1; } } ae.SaveChanges(); Response.Redirect(Request.RawUrl); } catch (Exception err) { } }
protected void downButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; string CommandArgument = btn.CommandArgument; string username = (string)Session["username"]; int choiceid = Int32.Parse(CommandArgument); int[] r = (int[])Application["round"]; int course = (int)Session["course"]; int roundno = r[course]; int old, new1; try { admissionEntities ae = new admissionEntities(); var x = from c in ae.Student_Choice where c.std_id == username select c.preference_no; int maxp = 0; foreach (var x1 in x) { if (x1 > maxp) { maxp = (int)x1; } } /*if (x == null) * { * maxp = 0; * } * else * { * maxp = (int)x.Max(); * } */ Student_Choice scup = ae.Student_Choice.Where(s => s.choice_id == choiceid && s.std_id == username && s.round_id == roundno).FirstOrDefault <Student_Choice>(); old = (int)scup.preference_no; new1 = old + 1; if (old == maxp) { } else { Student_Choice scdn = ae.Student_Choice.Where(s => s.preference_no == new1 && s.std_id == username && s.round_id == roundno).FirstOrDefault <Student_Choice>(); scdn.preference_no = old; scup.preference_no = new1; } ae.SaveChanges(); Response.Redirect(Request.RawUrl); } catch (Exception err) { } }
protected void AddButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; btn.Enabled = false; string CommandArgument = btn.CommandArgument; string username = (string)Session["username"]; int choiceid = Int32.Parse(CommandArgument); int[] r = (int[])Application["round"]; int course = (int)Session["course"]; int roundno = r[course]; admissionEntities ae = new admissionEntities(); var x = from c in ae.Student_Choice where c.std_id == username select c.preference_no; int maxp = 0; /* if (x == null) * { * maxp = 0; * } * else { * maxp = (int)x.Max(); * } */ foreach (var x1 in x) { if (x1 > maxp) { maxp = (int)x1; } } maxp++; Student_Choice sc1 = ae.Student_Choice.Where(s => s.std_id == username && s.round_id == roundno && s.choice_id == choiceid).FirstOrDefault <Student_Choice>(); if (sc1 == null) { Student_Choice sc = new Student_Choice(); sc.choice_id = choiceid; sc.std_id = username; sc.round_id = r[course]; sc.preference_no = maxp; ae.Student_Choice.Add(sc); ae.SaveChanges(); // Response.Redirect(Request.RawUrl); } }
protected void lockButton_Click(object sender, EventArgs e) { string username = (string)Session["username"]; admissionEntities ae = new admissionEntities(); var x = from s in ae.Student_Choice where s.std_id == username select s; foreach (var x1 in x) { x1.status = "locked"; } ae.SaveChanges(); Response.Redirect("home.aspx?a=1"); }
protected void Page_Load(object sender, EventArgs e) { ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; //VALIDATION AND VERIFICATION REMAINING if (Session["username"] == null || Session["role"] == null) { Response.Redirect("index.aspx?nv=1"); } else { string role = (string)Session["role"]; if (!role.Equals("student")) { Response.Redirect("logout.aspx?nv=2"); } } string fnm = this.PreviousPage.AppRelativeVirtualPath; fnm = fnm.Substring(fnm.LastIndexOf("/") + 1); if (!fnm.Equals("feePayment.aspx")) { Response.Redirect("logout.aspx?nv=2"); } if (categoryDropDownList.Items.Count == 0) { try { categoryDropDownList.Items.Add(new ListItem("--SELECT--", "0")); comExamNameDropDownList.Items.Add(new ListItem("--SELECT--", "0")); admissionEntities ae = new admissionEntities(); var x = from a in ae.Categories orderby a.category_name select a; foreach (var x1 in x) { categoryDropDownList.Items.Add(new ListItem(x1.category_name, x1.category_id.ToString())); } var y = from a in ae.Competitive_Exam orderby a.exam_name select a; foreach (var x1 in y) { comExamNameDropDownList.Items.Add(new ListItem(x1.exam_name, x1.exam_id.ToString())); } } catch (Exception err) { } } usernameLabel.Text = (string)Session["username"]; pinLabel.Text = (string)Session["pin"]; }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["role"] == null) { Response.Redirect("index.aspx?nv=1"); } else { string role = (string)Session["role"]; if (!role.Equals("student")) { Response.Redirect("logout.aspx?nv=2"); } } string username = (string)Session["username"]; admissionEntities ae = new admissionEntities(); var x = from a in ae.Student_Choice where a.std_id == username select a; Boolean lockFlag = false; if (x.Count() > 0) { foreach (var x1 in x) { if (x1.status != null && x1.status.Equals("locked")) { lockFlag = true; } } if (lockFlag) { editButton.Enabled = false; lockButton.Enabled = false; //Response.Redirect("lockChoices.aspx?l=1"); } } if (Request.QueryString.HasKeys() && Request.QueryString["l"] != null) { string message = "Your Choices Are Locked!!"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); } }
protected void Button1_Click(object sender, EventArgs e) { branchaddButton.Enabled = false; ae = new admissionEntities(); College c = new College(); c.college_name = collegeTextBox.Text; c.contact_no = contactTextBox.Text; c.email_id = emailTextBox.Text; c.city = cityTextBox.Text; ae.Colleges.Add(c); ae.SaveChanges(); cid = c.college_id; // Branch_Program bp = new Branch_Program(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["role"] == null) { Response.Redirect("AdminLogin.aspx?nv=1"); } else { string role = (string)Session["role"]; if (!role.Equals("admin")) { Response.Redirect("logout.aspx?nv=2"); } } DateTime dt = (DateTime)Application["lastdateofregistration"]; int comparedates = DateTime.Compare(dt, DateTime.Now); if (comparedates >= 0) { Response.Redirect("Home.aspx?dt=1"); } admissionEntities ae = new admissionEntities(); var x = from y in ae.StudentDetails select y; foreach (var x1 in x) { if (x1.rank != null && x1.rank != 0) { Response.Redirect("Home.aspx?dt=2"); } } if (!IsPostBack) { Button1.Enabled = true; GridView1.Visible = false; Label1.Visible = false; Button1.Text = "Generate Rank"; } }
protected void Button1_Click(object sender, EventArgs e) { DateTime start = Calendar1.SelectedDate; DateTime end = Calendar2.SelectedDate; if (flag1 && flag2) { int comp = DateTime.Compare(start, end); if (comp > 0) { errLabel.Text = "Enter Valid Dates !!"; okLabel.Text = ""; } else { int pid = Int32.Parse(programDropDownList.SelectedValue); int rid = Int32.Parse(roundDropDownList.SelectedValue); try { admissionEntities ae = new admissionEntities(); Round r = ae.Rounds.Where(s => s.program_id == pid && s.round_id == rid).FirstOrDefault <Round>(); r.start_date = start; r.end_date = end; ae.SaveChanges(); errLabel.Text = ""; okLabel.Text = "-Dates set-"; } catch (Exception err) { errLabel.Text = "Error!!"; okLabel.Text = ""; } } } else { errLabel.Text = "Date Required"; } }
protected void Page_Load(object sender, EventArgs e) { ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; invalidLabel.Text = ""; if (DropDownList1.Items.Count == 0) { try { DropDownList1.Items.Add(new ListItem("--SELECT--", "0")); admissionEntities ae = new admissionEntities(); var x = from a in ae.Programs orderby a.program_name select a; foreach (var x1 in x) { DropDownList1.Items.Add(new ListItem(x1.program_name, x1.program_id.ToString())); } } catch (Exception err) { } } }
protected void Button3_Click(object sender, EventArgs e) { branchaddButton.Enabled = false; int gen = Int32.Parse(genTextBox.Text); int obc = Int32.Parse(obcTextBox.Text); int sc = Int32.Parse(scTextBox.Text); int st = Int32.Parse(stTextBox.Text); ae = new admissionEntities(); Branch_College bc = new Branch_College(); bc.college_id = cid; bc.branch_id = Int32.Parse(branchDropDownList.SelectedValue); bc.program_id = Int32.Parse(programDropDownList.SelectedValue); bc.general = gen; bc.obc = obc; bc.sc = sc; bc.st = st; ae.Branch_College.Add(bc); ae.SaveChanges(); }
protected void upButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; string CommandArgument = btn.CommandArgument; string username = (string)Session["username"]; int choiceid = Int32.Parse(CommandArgument); int[] r = (int[])Application["round"]; int course = (int)Session["course"]; int roundno = r[course]; int old, new1; try { admissionEntities ae = new admissionEntities(); Student_Choice scup = ae.Student_Choice.Where(s => s.choice_id == choiceid && s.std_id == username && s.round_id == roundno).FirstOrDefault <Student_Choice>(); old = (int)scup.preference_no; new1 = old - 1; if (old == 0) { } else { Student_Choice scdn = ae.Student_Choice.Where(s => s.preference_no == new1 && s.std_id == username && s.round_id == roundno).FirstOrDefault <Student_Choice>(); scdn.preference_no = old; scup.preference_no = new1; } ae.SaveChanges(); Response.Redirect(Request.RawUrl); } catch (Exception err) { } }
protected void Button1_Click(object sender, EventArgs e) { int course = Int32.Parse(DropDownList1.SelectedValue); if (course == 0) { invalidLabel.Text = "Please Select Course!"; } else { string username = usernameTxt.Text; string password = passwordTxt.Text; string cnfPassword = cnfPasswordTxt.Text; string captcha = captchaTxt.Text; if (!captcha.ToLower().Equals(Session["CaptchaVerify"].ToString())) { captchaLabel.Text = "Incorrect Captcha Code!!"; captchaLabel.ForeColor = System.Drawing.Color.Red; } else { if (!password.Equals(cnfPassword)) { invalidLabel.Text = "Both Passwords must match!!"; } else { /* * SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string sql = "select username from Login where username=@U"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@U", username); * con.Open(); * SqlDataReader dr = cmd.ExecuteReader(); */ admissionEntities ae = new admissionEntities(); var already = from x in ae.Logins where x.username == username select x; int count = 0; foreach (var a in already) { count++; } if (count > 0) { invalidLabel.Text = "You Have Already Registered, Please Login!!"; } else { /* cmd.Parameters.Clear(); * sql = "insert into Login values(@U1,@P1,@R)"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@U1", username); * cmd.Parameters.AddWithValue("@P1", password); * cmd.Parameters.AddWithValue("@R", "student"); * int n = cmd.ExecuteNonQuery();*/ Login l = new Login(); l.username = username; l.password = password; l.role = "student"; StudentDetail sd = new StudentDetail(); sd.std_id = username; sd.username = username; ae.Logins.Add(l); ae.StudentDetails.Add(sd); try { int n = ae.SaveChanges(); Session["username"] = username; Session["role"] = "student"; Session["course"] = course; Session["program"] = course; Response.Redirect("feePayment.aspx"); } catch (Exception err) { invalidLabel.Text = "Some Error Occured"; } /* * if (n == 1) * { * cmd.Parameters.Clear(); * sql = "insert into StudentDetails(std_id,username,registration_date,program) values(@SID,@U2,@RD,@PRG1)"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@SID", username); * cmd.Parameters.AddWithValue("@U2", username); * cmd.Parameters.AddWithValue("@RD", System.DateTime.Today.ToString("d")); * cmd.Parameters.AddWithValue("@PRG1", course); * n = cmd.ExecuteNonQuery(); * if (n == 1) * { * Session["username"] = username; * Session["program"] = course; * //PIN GENERATION GOES HERE * Response.Redirect("feePayment.aspx"); * //REDIRECT TO fillDetails.aspx PAGE WHERE GENERATED PIN IS DISPLAYED TO USER!!! * } * else * { * invalidLabel.Text = "Some Error Occured ,Please Try Again!!"; * } * * } * else * { * invalidLabel.Text = "Some Error Occured ,Please Try Again!!"; * }*/ } // con.Close(); } } } }
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { string category = categoryDropDownList.SelectedValue; string comexamid = comExamNameDropDownList.SelectedValue; if (category.Equals("0") || !dateFlag) { errorLabel.Text = "Select Category and Birthdate"; } else { if (comexamid.Equals("0")) { errorLabel2.Text = "select competitive exam"; } else { string username = (String)Session["username"]; string std_name = nameTxt.Text; string dob = DOBCalendar.SelectedDate.ToString(); DateTime dobdt = DOBCalendar.SelectedDate; string contactno = contactnoTxt.Text; string emailid = emailidTxt.Text; string sscyear = SSCDropDownList.SelectedValue; string sscschool = sscschoolTxt.Text; string sscboard = SSCBoardDropDownList.SelectedValue; string sscrollno = sscrollnoTxt.Text; string sscpercentage = sscpercentageTxt.Text; string hscyear = HSCDropDownList.SelectedValue; string hscschool = hscschoolTxt.Text; string hscboard = HSCBoardDropDownList.SelectedValue; string hscrollno = hscrollnoTxt.Text; string hscpercentile = hscpercentileTxt.Text; string comexamyear = comExamYearDropDownList.SelectedValue; string comexamrollno = comexamrollnoTxt.Text; string comexampercentile = comexampercentileTxt.Text; /*SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string sql = "update StudentDetails set std_name=@N,std_category=@C,dob=@DOB,contact_no=@CONT,email_id=@EMAIL where std_id=@SID"; * * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@SID", username); * cmd.Parameters.AddWithValue("@N",std_name); * cmd.Parameters.AddWithValue("@C", category); * cmd.Parameters.AddWithValue("@DOB", dob); * cmd.Parameters.AddWithValue("@CONT", contactno); * cmd.Parameters.AddWithValue("@EMAIL", emailid); * * int n = cmd.ExecuteNonQuery(); */ try { admissionEntities ae = new admissionEntities(); StudentDetail sd = ae.StudentDetails.Where(s => s.std_id == username).FirstOrDefault <StudentDetail>(); sd.std_name = std_name; sd.std_category = Int32.Parse(category); //sd.dob = DateTime.Parse(dob); sd.dob = dobdt; sd.contact_no = contactno; sd.email_id = emailid; int n = ae.SaveChanges(); if (n == 1) { if (Int32.Parse(hscyear) <= Int32.Parse(sscyear) || Int32.Parse(comexamyear) <= Int32.Parse(sscyear) || Int32.Parse(comexamyear) < Int32.Parse(hscyear)) { errorLabel2.Text = "Years Are Not Valid!!!"; } else { /* sql = "insert into Academic(std_id,ssc_year,ssc_school,ssc_board,ssc_rno,ssc_marks,hsc_year,hsc_school,hsc_board,hsc_rno,hsc_marks,competitive_exam_id,competitive_exam_year,competitive_exam_rno,competitive_exam_marks) Values(@SID,@SSCY,@SSCS,@SSCB,@SSCR,@SSCM,@HSCY,@HSCS,@HSCB,@HSCR,@HSCM,@CEID,@CEY,@CER,@CEM)"; * cmd.Parameters.Clear(); * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@SID", username); * cmd.Parameters.AddWithValue("@SSCY", sscyear); * cmd.Parameters.AddWithValue("@SSCS", sscschool); * cmd.Parameters.AddWithValue("@SSCB", sscboard); * cmd.Parameters.AddWithValue("@SSCR", sscrollno); * cmd.Parameters.AddWithValue("@SSCM", sscpercentage); * cmd.Parameters.AddWithValue("@HSCY", hscyear); * cmd.Parameters.AddWithValue("@HSCS", hscschool); * cmd.Parameters.AddWithValue("@HSCB", hscboard); * cmd.Parameters.AddWithValue("@HSCR", hscrollno); * cmd.Parameters.AddWithValue("@HSCM", hscpercentile); * cmd.Parameters.AddWithValue("@CEID", comexamid); * cmd.Parameters.AddWithValue("@CEY", comexamyear); * cmd.Parameters.AddWithValue("@CER", comexamrollno); * cmd.Parameters.AddWithValue("@CEM", comexampercentile); * * n = cmd.ExecuteNonQuery(); */ Academic a = new Academic(); a.std_id = username; a.ssc_year = sscyear; a.ssc_school = sscschool; a.ssc_board = sscboard; a.ssc_rno = sscrollno; a.ssc_marks = Int32.Parse(sscpercentage); a.hsc_year = hscyear; a.hsc_school = hscschool; a.hsc_board = hscboard; a.hsc_rno = hscrollno; a.hsc_marks = Int32.Parse(hscpercentile); a.competitive_exam_id = Int32.Parse(comexamid); a.competitive_exam_year = comexamyear; a.competitive_exam_rno = comexamrollno; a.competitive_exam_marks = Int32.Parse(comexampercentile); ae.Academics.Add(a); ae.SaveChanges();//both savechanges needed int aid = a.academic_id; StudentDetail sd2 = ae.StudentDetails.Where(s => s.std_id == username).FirstOrDefault <StudentDetail>(); sd2.academic_id = aid; ae.SaveChanges(); if (n == 1) { //details added successfully MailSender.sendMail(emailid, username, (string)Session["pin"]); Response.Redirect("home.aspx"); } else { errorLabel.Text = "Some Error In Adding Your Academic Details!!!"; } } } else { errorLabel.Text = "Some Error In Adding Your Details!!!"; } } catch (Exception err) { errorLabel.Text = "Some Error In Adding Your Details!!! try again"; } } } }
protected void Button1_Click(object sender, EventArgs e) { int course = Int32.Parse(DropDownList1.SelectedValue); if (course == 0) { invalidLabel.Text = "Please Select Course!"; } else { string username = usernameTxt.Text; string password = passwordTxt.Text; string pin = pinTxt.Text; string captcha = captchaTxt.Text; if (captcha.ToLower() != Session["CaptchaVerify"].ToString()) { captchaLabel.Text = "Incorrect Captcha Code!!"; captchaLabel.ForeColor = System.Drawing.Color.Red; } /*SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string sql = "select username from Login where username=@U and password=@P and role=@S"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@U", username); * cmd.Parameters.AddWithValue("@P", password); * cmd.Parameters.AddWithValue("@S", "student"); * con.Open(); * SqlDataReader dr = cmd.ExecuteReader(); */ // try // { admissionEntities ae = new admissionEntities(); Login l = ae.Logins.Where(s => s.username == username && s.password == password && s.role.Equals("student")).FirstOrDefault <Login>(); if (l == null) { invalidLabel.Text = "Incorrect Username or Password"; } else { StudentDetail sd = ae.StudentDetails.Where(s => s.std_id == username && s.pin == pin && s.program == course).FirstOrDefault <StudentDetail>(); if (sd == null) { invalidLabel.Text = "Incorrect Pin!!"; } else { Session["username"] = username; Session["role"] = "student"; Session["pin"] = pin; Session["program"] = course; Session["course"] = course; Response.Redirect("~/StudentAccess/home.aspx"); } } /* }catch(Exception err) * { * invalidLabel.Text = "ERROR!!"; * }*/ /* * if (dr.HasRows) * { * dr.Read(); * dr.Close(); * cmd.Parameters.Clear(); * sql = "select std_id,std_name from StudentDetails where username=@U1 and pin=@P1 and program=@PRG"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@U1", username); * cmd.Parameters.AddWithValue("@P1", pin); * cmd.Parameters.AddWithValue("@PRG", course); * dr = cmd.ExecuteReader(); * if (dr.HasRows) * { * Session["username"] = username; * Session["pin"] = pin; * Session["program"] = course; * Session["course"] = course; * HttpCookie c = new HttpCookie("username"); * c["username"] = username; * c.Expires = DateTime.Now.AddMinutes(5); * Response.Cookies.Add(c); * Response.Redirect("~/StudentAccess/home.aspx"); * } * else * { * invalidLabel.Text = "Incorrect Pin!!"; * } * } * else * { * invalidLabel.Text = "Incorrect Username or Password"; * } */ // con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["role"] == null) { Response.Redirect("index.aspx?nv=1"); } else { string role = (string)Session["role"]; if (!role.Equals("student")) { Response.Redirect("logout.aspx?nv=2"); } } //if querystring a=1 then alert=choices are locked; usernameLabel.Text = (string)Session["username"]; string username = (string)Session["username"]; try { admissionEntities ae = new admissionEntities(); if (Request.QueryString.HasKeys() && Request.QueryString["a"] != null) { string message; if (Request.QueryString["a"].Equals("1")) { message = "Your Choices Are Locked"; } else if (Request.QueryString["a"].Equals("2")) { message = "Not Allowed"; } else { message = ""; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); } StudentDetail sd = ae.StudentDetails.Where(s => s.std_id == username).FirstOrDefault <StudentDetail>(); nameLabel.Text = sd.std_name; categoryLabel.Text = sd.Category.category_name; emailLabel.Text = sd.email_id; dobLabel.Text = sd.dob.ToString(); contactLabel.Text = sd.contact_no; if (sd.rank == 0) { rankLabel.Text = "Rank Not Generated Yet"; } else { rankLabel.Text = ((int)sd.rank).ToString(); } pinLabel.Text = sd.pin; programLabel.Text = sd.Program1.program_name; if (sd.verified == 0) { verifiedLabel.ForeColor = System.Drawing.Color.Red; verifiedLabel.Text = "Not Verified"; } else { verifiedLabel.ForeColor = System.Drawing.Color.Green; verifiedLabel.Text = "Verified"; } } catch (Exception err) { } }
protected void Button1_Click(object sender, EventArgs e) { /* SqlConnection con = (SqlConnection)Application["connection"]; * SqlCommand cmd = (SqlCommand)Application["command"]; * string username = (string)Session["username"]; * string sql; * int n; * sql = "update StudentDetails set fees_paid=1 where std_id=@SIDNEW"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@SIDNEW",username); * n = cmd.ExecuteNonQuery(); */ string username = (string)Session["username"]; int course = (int)Session["course"]; admissionEntities ae = new admissionEntities(); StudentDetail sd1 = ae.StudentDetails.Where(s => s.std_id == username).FirstOrDefault <StudentDetail>(); sd1.fees_paid = 1; /* var s = from x in ae.StudentDetails where x.std_id == username select x; * foreach (var std in s) * { * std.fees_paid = 1; * } */ try { int count = ae.SaveChanges(); if (count == 1) { //PIN GENRATION Boolean pinFlag = true; while (pinFlag) { string pin = RandomGenerator.Generate(15); /*cmd.Parameters.Clear(); * sql = "select pin from StudentDetails where pin=@PIN"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@PIN", pin); * SqlDataReader sdr = cmd.ExecuteReader(); */ var p = from x in ae.StudentDetails where x.pin == pin select x; count = 0; foreach (var p1 in p) { count++; } if (count == 0) { pinFlag = false; /*cmd.Parameters.Clear(); * sql = "update Student set pin=@PIN2 where std_id=@SID2"; * cmd.CommandText = sql; * cmd.Parameters.AddWithValue("@PIN2", pin); * cmd.Parameters.AddWithValue("@SID2", username); * n = cmd.ExecuteNonQuery(); */ StudentDetail sd2 = ae.StudentDetails.Where(s => s.std_id == username).FirstOrDefault <StudentDetail>(); sd2.pin = pin; sd2.program = course; /*var sd = from x in ae.StudentDetails where x.std_id == username select x; * foreach (var std in sd) * { * std.pin = pin; * }*/ int n = ae.SaveChanges(); if (n == 1) { Session["pin"] = pin; Response.Redirect("fillDetails.aspx"); } else { } } } } else { errorLabel.Text = "Error in Fees Payment!!!!"; } } catch (Exception err) { errorLabel.Text = "Error in Fees Payment!!"; } }
protected void grButton_Click(object sender, EventArgs e) { int[] r = (int[])Application["round"]; int programno = Int32.Parse(progDropDownList.SelectedValue); int roundno = r[programno - 1]; try { admissionEntities ae = new admissionEntities(); Round r1 = ae.Rounds.Where(s => s.round_id == roundno && s.program_id == programno).FirstOrDefault <Round>(); if (r1 != null && r1.end_date != null) { DateTime today = DateTime.Now; int compare = DateTime.Compare((DateTime)r1.end_date, today); if (compare >= 0) { string message = "Round Is Not Yet Completed"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); } else { string resultstatus = r1.result_generated; if (resultstatus != null && resultstatus.Equals("yes")) { string message = "Result is alredy generated"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); } else { var choicelist = from y in ae.Available_Choice where y.program_id == programno select y; int size = choicelist.Count(); Dictionary <int, int> genlist = new Dictionary <int, int>(size); Dictionary <int, int> obclist = new Dictionary <int, int>(size); Dictionary <int, int> sclist = new Dictionary <int, int>(size); Dictionary <int, int> stlist = new Dictionary <int, int>(size); foreach (var cl in choicelist) { genlist.Add(cl.choice_id, (int)cl.gen); obclist.Add(cl.choice_id, (int)cl.obc); sclist.Add(cl.choice_id, (int)cl.sc); stlist.Add(cl.choice_id, (int)cl.st); } var studentlist = from c in ae.StudentDetails where c.program == programno orderby c.rank select c; foreach (var sl in studentlist) { string sid = sl.std_id; var sc = from x in ae.Student_Choice where x.std_id == sid orderby x.preference_no select x; var cat = from b in ae.StudentDetails where b.std_id == sid select b.std_category; int category = 0; foreach (var cat1 in cat) { category = cat1.Value; break; } Boolean addflag = false; Allotment al = ae.Allotments.Where(s => s.std_id == sid).FirstOrDefault <Allotment>(); if (al == null) { al = new Allotment(); addflag = true; al.std_id = sid; } Boolean okflag = false; foreach (var sc1 in sc) { int pref = (int)sc1.preference_no; int cid = sc1.choice_id; int noofseats; switch (category) { case 1: noofseats = genlist[cid]; if (noofseats > 0) { genlist[cid]--; al.alloted_choice_id = cid; al.preference_no = pref; al.confirm_status = 0; al.round_no = roundno; if (addflag) { ae.Allotments.Add(al); } okflag = true; } break; case 2: noofseats = obclist[cid]; if (noofseats > 0) { obclist[cid]--; al.alloted_choice_id = cid; al.preference_no = pref; al.confirm_status = 0; if (addflag) { ae.Allotments.Add(al); } okflag = true; } break; case 3: noofseats = sclist[cid]; if (noofseats > 0) { sclist[cid]--; al.alloted_choice_id = cid; al.preference_no = pref; al.confirm_status = 0; if (addflag) { ae.Allotments.Add(al); } okflag = true; } break; case 4: noofseats = stlist[cid]; if (noofseats > 0) { stlist[cid]--; al.alloted_choice_id = cid; al.preference_no = pref; al.confirm_status = 0; if (addflag) { ae.Allotments.Add(al); } okflag = true; } break; default: break; } if (okflag) { break; } } } } } } r1.result_generated = "yes"; ae.SaveChanges(); } catch (Exception err) { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null || Session["role"] == null) { Response.Redirect("index.aspx?nv=1"); } else { string role = (string)Session["role"]; if (!role.Equals("student")) { Response.Redirect("logout.aspx?nv=2"); } } try { string username = (string)Session["username"];; admissionEntities ae = new admissionEntities(); var x = from a in ae.Student_Choice where a.std_id == username select a; Boolean lockFlag = false; if (x.Count() > 0) { foreach (var x1 in x) { if (x1.status != null && x1.status.Equals("locked")) { lockFlag = true; } } if (lockFlag) { Response.Redirect("lockChoices.aspx?l=1"); } } usernameLabel.Text = username; int pid = (int)Session["course"]; var abc = from s in ae.Programs where s.program_id == pid select s; foreach (var abcd in abc) { if (abcd.program_name != null) { courseLabel.Text = abcd.program_name; } } programidLabel.Text = ((int)Session["course"]).ToString(); if (branchDropDownList.Items.Count == 0) { branchDropDownList.Items.Add(new ListItem("---SELECT---", "0")); var bd = (from b in ae.Branches join bp in ae.Branch_Program on b.branch_id equals bp.branch_id where bp.program_id == pid select b).Distinct(); foreach (var bd1 in bd) { branchDropDownList.Items.Add(new ListItem(bd1.branch_name, bd1.branch_id.ToString())); } } } catch (Exception err) { } //IF CHOICES ARE LOCKED THEN THIS PAGE IS NOT ACCESSIBLE }