62,041
社区成员
发帖
与我相关
我的任务
分享
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["database"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select Flags,Retime from Question where id =@id",con);//查询主问题的状态与回复时间
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
string flag = dt.Rows[0][0].ToString().Trim();
string retime = dt.Rows[0][1].ToString().Trim();
if (flag.Equals("处理中"))//根据状态判断如何操作
{
if (retime.Trim().Length == 0 ) //如果问题为处理中,则判断问题的回复者是否为该次登陆者,如果是同一人或有权限,则可以进入处理页面,反之则不准回复
{
cmd = new SqlCommand("select Number from Question where id =@id", con);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
if (Session["userid"].ToString().Equals(cmd.ExecuteScalar()) || Session["power"].ToString().Equals("1"))
{
string url="online_edit.aspx?id=" + Request["id"].ToString();
//Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>window.open('" + url + "',''newwindow'') </script>");
//Response.Write(" <script>window.open('" + url + "') </script>");
Response.Redirect(url);
}
else
{
Response.Write("<script>alert('正在处理中。。。');</script>");
}
}
else
{
cmd = new SqlCommand("select Number from Discuss where QuestionID =@id and Retime is null", con);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
if (Session["userid"].ToString().Equals(cmd.ExecuteScalar()) || Session["power"].ToString().Equals("1"))
{
string url="online_edit.aspx?id=" + Request["id"].ToString();
//Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>window.open('" + url + "',''newwindow'') </script>");
//Response.Write(" <script>window.open('" + url + "') </script>");
Response.Redirect(url);
}
else
{
Response.Write("<script>alert('正在处理中。。。。。');</script>");
}
}
}
else if (flag.Equals("已处理"))
{
Response.Write("<script>alert('已处理完毕');</script>");
}
else if (flag.Equals("转强制结案"))
{
Response.Write("<script>alert('已强制结案');</script>");
}
else if (flag.Equals("未处理"))//问题类型为未处理时,任何gm均可处理
{
//Response.Write("<script>alert('未处理');</script>");
cmd = new SqlCommand("update Question set Flags='处理中' where id =@id", con);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
try
{
cmd.ExecuteNonQuery();
string url = "online_edit.aspx?id=" + Request["id"].ToString();
//Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", " <script>window.open('" + url + "',''newwindow'') </script>");
//Response.Write(" <script>window.open('" + url + "') </script>");
Response.Redirect(url);
}
catch (Exception ex)
{
//Response.Write(ex);
}
}
else
{
Response.Write("<script>alert("+flag+");</script>");
}
con.Close();
}
这个是显示页面的后置代码,点击这个页面的处理,会跳到另一个页面输入数据,在另一个页面处理后返回显示页面,下面是处理页面的代码
public partial class server_behind_Default2 : System.Web.UI.Page
{
static string tableid = "";
public sgc_kf sgc = new sgc_kf();
protected void Page_Load(object sender, EventArgs e)
{
// if (Session["userid"] == null) Response.Redirect("login.aspx");
if (!IsPostBack)
{
this.bind();
}
}
public void bind()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["database"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select * from Question where id=@cid",con);
cmd.Parameters.Add("@cid", SqlDbType.Int).Value = Request["id"].ToString();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
Label1.Text = dt.Rows[0]["Questions"].ToString();
if (dt.Rows[0][21].ToString().Trim().Length == 0)//根据回复时间判断本次处理回复的是哪张表里的内容
{
SqlCommand qcmd = new SqlCommand("update Question set Number=@userid where id=@uid", con);//获取gm工号,存入数据库
qcmd.Parameters.Add("@uid", SqlDbType.Int).Value = Request["id"].ToString();
qcmd.Parameters.Add("@userid", SqlDbType.VarChar).Value = Session["userid"].ToString();
qcmd.ExecuteNonQuery();
TextBox1.Text = dt.Rows[0]["Content"].ToString();
Label3.Text = dt.Rows[0][22].ToString();
tableid = "Question";
}
else
{
SqlCommand wcmd = new SqlCommand("update Discuss set Number=@userid where QuestionID=@uid and Retime is null", con);//获取gm工号,存入数据库
wcmd.Parameters.Add("@uid", SqlDbType.Int).Value = Request["id"].ToString();
wcmd.Parameters.Add("@userid", SqlDbType.VarChar).Value = Session["userid"].ToString();
wcmd.ExecuteNonQuery();
DataTable dtline = new DataTable();
cmd.CommandText = "select Content,AddTime from Discuss where ReTime is null and QuestionID=@sid";
cmd.Parameters.Add("@sid", SqlDbType.Int).Value = Request["id"].ToString();
dtline.Load(cmd.ExecuteReader());
TextBox1.Text = dtline.Rows[0][0].ToString();
Label3.Text = dtline.Rows[0][1].ToString();
tableid = "Discuss";
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (txta_transact.Value.Length > 0)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["database"].ToString());
con.Open();
SqlCommand cmd;
SqlCommand cmd1;
if (tableid.Equals("Question"))//添加处理内容和时间
{
SqlCommand cmd0 = new SqlCommand("select * from Question where id=@cid", con);
cmd0.Parameters.Add("@cid", SqlDbType.Int).Value = Request["id"].ToString();
DataTable dte = new DataTable();
dte.Load(cmd0.ExecuteReader());
if ((dte.Rows[0]["ReContent"].ToString() == null || dte.Rows[0]["ReContent"].ToString() == "") && (dte.Rows[0]["ReTime"].ToString().Length == 0))
{
cmd = new SqlCommand("update Question set ReContent=@txt,Retime=getdate() where id=@id", con);
cmd.Parameters.Add("@txt", SqlDbType.VarChar).Value = txta_transact.Value;
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
cmd.ExecuteNonQuery();
}
}
else//添加处理内容和时间
{
if (tableid.Equals("Discuss"))//如果操作的表为Discuss
{
cmd = new SqlCommand("update Discuss set ReContent=@txt,ReTime=getdate() where QuestionID=@id and ReTime is null", con);
cmd.Parameters.Add("@txt", SqlDbType.VarChar).Value = txta_transact.Value;
cmd.Parameters.Add("@id", SqlDbType.Int).Value = Request["id"].ToString();
cmd.ExecuteNonQuery();
}
}
cmd1 = new SqlCommand("update Question set Flags='已处理',isread=0 where id=@pid", con);//更改主问题状态
cmd1.Parameters.Add("@pid", SqlDbType.Int).Value = Request["id"].ToString();
try
{
cmd1.ExecuteNonQuery();
//Response.Write("<script>alert('处理成功');window.location='online.aspx?type=0'</script>");
}
catch (Exception ex)
{
Response.Write(ex);
}
调试了好几天也没发现哪里的问题,求大神们帮忙解决感激不尽