protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Redirect("~/redirect.aspx"); } else { var db = new DBCon(); string sql = "SELECT * FROM request"; var reader = db.Execute(sql); var sb = new StringBuilder(); while (reader.Read()) { sb.AppendLine("<tr>"); sb.AppendLine(string.Format("<td>{0}</td>", reader["ID"])); sb.AppendLine(string.Format("<td><a href=\"request details.aspx?id={1}\">{0}</a></td>", reader["Sender"], reader["ID"], reader["Email"], reader["FileName"])); sb.AppendLine(string.Format("<td>{0}</td>", reader["Email"])); sb.AppendLine(string.Format("<td>{0}</td>", reader["FileName"])); sb.AppendLine("</tr>"); } lbl_data.Text = sb.ToString(); db.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if ((Session["username"] != null || Session["password"] != null)) { Response.Redirect("~/back office.aspx"); } if (IsPostBack) { var con = new DBCon(); string username = txt_user.Text; string password = txt_pass.Text; string sql = string.Format("SELECT * FROM admin WHERE Username = \"{0}\" AND Password = \"{1}\"", username, password); var reader = con.Execute(sql); if (reader.HasRows) //if username and password match { Session["username"] = username; Session["password"] = password; Response.Redirect("~/back office.aspx"); } else { //fail, show error StringBuilder sb = new StringBuilder(); sb.AppendLine("<ul style=\"color:red\">"); sb.AppendLine("<li>Invalid Username or Password</li>"); sb.AppendLine("</ul>"); lbl_error.Text = sb.ToString(); } con.Close(); } }
protected void btn_submit_r_Click(object sender, EventArgs e) { if (name_r.Text.Length == 0) { Label1.Text = "* This field cannot be empty"; } else { if (name_r.Text.Length != 0) { Label1.Visible = false; } } if (email_r.Text.Length == 0) { Label2.Text = "* This field cannot be empty"; } else { if (email_r.Text.Length != 0) { Label2.Visible = false; } } if (filename_r.Text.Length == 0) { Label3.Text = "* This field cannot be empty"; } else { if (filename_r.Text.Length != 0) { Label3.Visible = false; } } if(name_r.Text.Length!=0 && filename_r.Text.Length!=0 && email_r.Text.Length!=0) { Label1.Visible = false; Label2.Visible = false; Label3.Visible = false; string name, email, other, filename; name = name_r.Text; email = email_r.Text; filename = filename_r.Text; other = other_r.Text; var con = new DBCon(); string sql = string.Format("INSERT INTO request ([Sender] , [Email] , [Other] , [FileName]) VALUES ('{0}', '{1}', '{2}' , '{3}')", name, email, other, filename); con.Execute(sql); con.Close(); lbl_msg.Text = "Request Delivered."; } }
protected void btn_submit_r_Click(object sender, EventArgs e) { if (name_r.Text.Length == 0) { Label1.Text = "* This field cannot be empty"; } else { if (name_r.Text.Length != 0) { Label1.Visible = false; } } if (email_r.Text.Length == 0) { Label2.Text = "* This field cannot be empty"; } else { if (email_r.Text.Length != 0) { Label2.Visible = false; } } if (filename_r.Text.Length == 0) { Label3.Text = "* This field cannot be empty"; } else { if (filename_r.Text.Length != 0) { Label3.Visible = false; } } if (name_r.Text.Length != 0 && filename_r.Text.Length != 0 && email_r.Text.Length != 0) { Label1.Visible = false; Label2.Visible = false; Label3.Visible = false; string name, email, other, filename; name = name_r.Text; email = email_r.Text; filename = filename_r.Text; other = other_r.Text; var con = new DBCon(); string sql = string.Format("INSERT INTO request ([Sender] , [Email] , [Other] , [FileName]) VALUES ('{0}', '{1}', '{2}' , '{3}')", name, email, other, filename); con.Execute(sql); con.Close(); lbl_msg.Text = "Request Delivered."; } }
protected void btn_delete_Click(object sender, EventArgs e) { int ID = Convert.ToInt32(Request.QueryString["id"].ToString()); string sql = string.Format("DELETE * FROM request Where ID = {0}" , ID.ToString()); var con = new DBCon(); var reader = con.Execute(sql); con.Close(); lbl_msg.Text = "Done!"; Thread.Sleep(2000); Response.Redirect("~/view requests.aspx"); }
protected void btn_delete_Click(object sender, EventArgs e) { int ID = Convert.ToInt32(Request.QueryString["id"].ToString()); string sql = string.Format("DELETE * FROM request Where ID = {0}", ID.ToString()); var con = new DBCon(); var reader = con.Execute(sql); con.Close(); lbl_msg.Text = "Done!"; Thread.Sleep(2000); Response.Redirect("~/view requests.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["username"] == null) { Response.Redirect("~/redirect.aspx"); } else { int ID = Convert.ToInt32(Request.QueryString["id"].ToString()); var db = new DBCon(); string sql = string.Format("SELECT * FROM feedback WHERE ID = {0}", ID.ToString()); var reader = db.Execute(sql); while (reader.Read()) { name_vfbd.Text = reader["Sender"].ToString(); email_vfbd.Text = reader["Email"].ToString(); feedback_vfbd.Text = reader["Other"].ToString(); } db.Close(); } }
protected void btn_submit_fb_Click(object sender, EventArgs e) { if (name_fb.Text.Length == 0) { Label1.Text = "* This field cannot be empty"; } else { if (name_fb.Text.Length != 0) { Label1.Visible = false; } } if (email_fb.Text.Length == 0) { Label2.Text = "* This field cannot be empty"; } else { if (email_fb.Text.Length != 0) { Label2.Visible = false; } } if (name_fb.Text.Length != 0 && email_fb.Text.Length != 0) { string name, email, other; name = name_fb.Text; email = email_fb.Text; other = other_fb.Text; var con = new DBCon(); string sql = string.Format("INSERT INTO feedback ([Sender] , [Email] , [Other]) VALUES ('{0}', '{1}', '{2}')", name, email, other); con.Execute(sql); con.Close(); lbl_msg.Text = "Feedback Delivered."; } }