using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class student_fbnewmsg : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
private int commentid = 1;
protected System.Web.UI.WebControls.Label lbl_status;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator4;
protected System.Web.UI.WebControls.TextBox txt_name;
protected System.Web.UI.WebControls.TextBox txt_email;
protected System.Web.UI.WebControls.TextBox txt_reply;
protected System.Web.UI.WebControls.TextBox txt_title;
protected System.Web.UI.HtmlControls.HtmlInputRadioButton br_feedback;
protected System.Web.UI.HtmlControls.HtmlInputRadioButton br_suggetion;
protected System.Web.UI.HtmlControls.HtmlInputRadioButton br_general;
private int articleid = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["id"] != null)
articleid = Convert.ToInt32(Request.QueryString["id"]);
if (Request.QueryString["Test"] != null)
{
if (String.Compare(Request.QueryString["Test"].ToLower(), "true") == 0)
{
int mParentId = 0;
int mArticleId = articleid;
string mTitle = "Test Message - This Forum Rocks";
string mUserName = "quartz";
string mUserEmail = "quartz@msn.com";
string mDescription = "Original Message - Test Description";
int mIndent = 0;
try
{
SqlConnection myC = new SqlConnection("Data Source=EN12-2-24-WS07\\SQLEXPRESS; Initial Catalog=SchWeb; Integrated Security=SSPI");
string sqlQuery = "INSERT into tb_feedback (parentID,articleID,title,student_id,useremail,description,indent) VALUES ('" + mParentId + "','" + mArticleId + "','" + mTitle + "','" + mUserName + "','" + mUserEmail + "','" + mDescription + "','" + mIndent + "')";
myC.Open();
SqlCommand myCommand = new SqlCommand();
myCommand.CommandText = sqlQuery;
myCommand.Connection = myC;
int i = myCommand.ExecuteNonQuery();
myC.Close();
//lblStatus.ForeColor = Color.Green;
lbl_status.Text = "Status: Success";
Response.Redirect("Forum.aspx?id=" + articleid);
}
catch (Exception)
{
//lblStatus.ForeColor = Color.Red;
lbl_status=new Label();
lbl_status.Text = "Status: Error";
}
}
}
}
protected void btn_comment_Click1(object sender, EventArgs e)
{
int mParentId = 0;
int mArticleId = articleid;
string mTitle = "Test";
string mUserName = "quartz";
string mUserEmail = "quartz@msn.com";
string mDescription = "Test Description";
int mIndent = 0;
try
{
mTitle = txt_title.Text;
mUserName = txt_name.Text;
mUserEmail = txt_email.Text;
mDescription = txt_reply.Text;
int mCommentType = 1;
if (br_feedback.Checked)
mCommentType = 2;
//if (MsgType_3.Checked)
// mCommentType = 3;
if (br_suggetion.Checked)
mCommentType = 4;
if (br_general.Checked)
mCommentType = 5;
if (IsValid)
{
SqlConnection myC = new SqlConnection("Data Source=EN12-2-24-WS07\\SQLEXPRESS; Initial Catalog=SchWeb; Integrated Security=SSPI");
string sqlQuery = "INSERT into tb_feedback (parentID,articleID,title,student_id,useremail,description,indent,comment_type) VALUES ('" + mParentId + "','" + mArticleId + "','" + mTitle + "','" + mUserName + "','" + mUserEmail + "','" + mDescription + "','" + mIndent + "','" + mCommentType + "')";
myC.Open();
SqlCommand myCommand = new SqlCommand();
myCommand.CommandText = sqlQuery;
myCommand.Connection = myC;
int i = myCommand.ExecuteNonQuery();
myC.Close();
//lblStatus.ForeColor = Color.Green;
lbl_status.Text = "Status: Success";
Response.Redirect("Forum.aspx?id=" + articleid);
}
}
catch (Exception)
{
// lblStatus.ForeColor = Color.Red;
lbl_status.Text = "Status: Error";
}
}
}