protected void btnlogin_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(4000); ClsConnection obj=new ClsConnection(); SqlCommand cmd=new SqlCommand(); DataSet ds=new DataSet(); if (drpdwnrole.SelectedItem.Text == "Student") { cmd = new SqlCommand("SELECT S_ID, Name FROM Student_Table WHERE S_ID='" + txtuserid.Text + "' and Password='******'"); Session["Role"] = "Student"; } else if (drpdwnrole.SelectedItem.Text == "Staff") { cmd = new SqlCommand("SELECT SF_ID, Name FROM Staff_Table WHERE SF_ID='" + txtuserid.Text + "' and Password='******'"); Session["Role"] = "Staff"; } else { cmd = new SqlCommand("SELECT A_ID, Name FROM Admin_Table WHERE A_ID='" + txtuserid.Text + "' and Password='******'"); Session["Role"] = "Admin"; } ds = obj.retdata(cmd); if (ds.Tables[0].Rows.Count > 0) { Session["ID"] = Convert.ToString(ds.Tables[0].Rows[0][0]); Session["Name"] = Convert.ToString(ds.Tables[0].Rows[0][1]); lblmsg.Visible = false; pnlmsg.Visible = false; imgalert.Visible = false; Response.Redirect("default.aspx"); } else { lblmsg.Visible = true; pnlmsg.Visible = true; imgalert.Visible = true; pnlmsg.CssClass = "error"; imgalert.ImageUrl = "~/Images/alert red.png"; lblmsg.ForeColor = System.Drawing.Color.Red; lblmsg.Text = "Invalid Credentials, Try Again"; } }
protected void Page_Load(object sender, EventArgs e) { ClsConnection obj=new ClsConnection(); if (Convert.ToString(Session["ID"]) != "") { imgloggedin.Visible = true; lblloginname.Text = Convert.ToString(Session["Name"]); lblloggedin.Visible = true; lnkbtnlogout.Visible = true; btnvisit.Visible = true; if (Convert.ToString(Session["Role"]) == "Student") { btnvisit.Text = "Visit Student Section"; btnvisit.PostBackUrl = "~/student.aspx"; } else if (Convert.ToString(Session["Role"]) == "Staff") { btnvisit.Text = "Visit Staff Section"; btnvisit.PostBackUrl = "~/staff.aspx"; } else { btnvisit.Text = "Visit Admin Section"; btnvisit.PostBackUrl = "~/admin.aspx"; } } else { imgloggedin.Visible = false; lblloggedin.Visible = false; lblloginname.Visible = false; lnkbtnlogout.Visible = false; btnvisit.Text = ""; btnvisit.PostBackUrl = ""; btnvisit.Visible = false; } SqlCommand cmd = new SqlCommand("SELECT visitors FROM Visitors_Table WHERE V_ID=100"); DataSet ds = new DataSet(); ds = obj.retdata(cmd); if (ds.Tables[0].Rows.Count > 0) { lblvis.Text = ds.Tables[0].Rows[0]["visitors"].ToString(); } }
protected void btncheckname4_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(4000); if(txtname4.Text=="") { pnlmsg1.CssClass = "error"; imgalert1.ImageUrl = "~/Images/alert red.png"; lblmsg1.ForeColor = System.Drawing.Color.Red; lblmsg1.Text = "Please enter ID first"; txtname4.Text = ""; } else { ClsConnection obj=new ClsConnection(); SqlCommand cmd=new SqlCommand(); DataSet ds=new DataSet(); if (drpdwnlstrole4.SelectedItem.Text == "Student") { cmd = new SqlCommand("SELECT Name FROM Student_Table WHERE S_ID='" + txtid4.Text + "'"); } else if (drpdwnlstrole4.SelectedItem.Text == "Staff") { cmd = new SqlCommand("SELECT Name FROM Staff_Table WHERE SF_ID='" + txtid4.Text + "'"); } else { cmd = new SqlCommand("SELECT Name FROM Admin_Table WHERE A_ID='" + txtid4.Text + "'"); } ds = obj.retdata(cmd); if (ds.Tables[0].Rows.Count > 0) { txtname4.Text = ds.Tables[0].Rows[0][0].ToString(); } else { pnlmsg1.CssClass = "error"; imgalert1.ImageUrl = "~/Images/alert red.png"; lblmsg1.ForeColor = System.Drawing.Color.Red; lblmsg1.Text = "Invalid ID, Try Again"; txtname4.Text = ""; } } }