📄 sub__start_rpt.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration ;
using System.Data .OleDb ;
using System.Data.SqlClient ;
namespace graduate.stu
{
/// <summary>
/// sub__start_rpt 的摘要说明。
/// </summary>
public class sub__start_rpt : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lab_title;
protected System.Web.UI.WebControls.TextBox textbox_mean;
protected System.Web.UI.WebControls.TextBox textbox_cont;
protected System.Web.UI.WebControls.TextBox textbox_diff;
protected System.Web.UI.WebControls.TextBox textbox_outl;
protected System.Web.UI.WebControls.Button tj;
string sql="";
string studentid="";
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label lab_mes;
protected System.Web.UI.HtmlControls.HtmlTable table_message;
protected System.Web.UI.HtmlControls.HtmlTable table_start_rpt;
protected System.Web.UI.HtmlControls.HtmlTableRow tr_btn;
string myConnString=ConfigurationSettings.AppSettings ["SQLconnectionString"];
string meaning="",content="",diff="",outl="",suresubjectid="",flag="";
protected System.Web.UI.WebControls.Button btn_temp;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Session["studentid"] = "10001";
studentid=Convert.ToString (Session["studentid"]);
if(!IsPostBack)
{
SqlConnection conn = new SqlConnection(myConnString);
sql="select subjectname ,suresubjectid from bysj.suresubject a ,bysj.submitsubject b where a.subjectid=b.subjectid and a.studentid='"+studentid+"'";
try
{
conn.Open();
SqlDataAdapter adapter1 = new SqlDataAdapter(sql, conn);
DataSet cla=new DataSet ();
adapter1.Fill(cla);
if (cla.Tables ["table"].Rows .Count !=0)
{
lab_title.Text = Convert.ToString (cla.Tables ["table"].Rows [0].ItemArray [0]);
ViewState["suresubjectid"] = Convert.ToString (cla.Tables ["table"].Rows [0].ItemArray [1]);
table_start_rpt.Visible =true;
table_message.Visible =false;
string sql1="select draftflag ,researchmeaning,basiccontent,emphasis,outline from bysj.buildreport a, bysj.suresubject b where a.suresubjectid=b.suresubjectid and b.studentid='"+studentid+"'";
SqlDataAdapter adapter2 = new SqlDataAdapter(sql1, conn);
DataSet cla1=new DataSet ();
adapter2.Fill(cla1);
if(cla1.Tables ["table"].Rows.Count !=0)
{
ViewState["flag"] = "1";//表明该生开题报告中已有信息
bool draftflag=Convert.ToBoolean (cla1.Tables ["table"].Rows [0].ItemArray [0]);
textbox_mean.Text = Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [1]);
textbox_cont.Text = Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [2]);
textbox_diff.Text = Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [3]);
textbox_outl.Text = Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [4]);
if (draftflag == true)//已提交
{
tr_btn.Visible =false;
}
}
else
ViewState["flag"] = "0";//表明该生开题报告中没有信息
}
else
{
table_start_rpt.Visible =false;
table_message.Visible =true;
}
}
catch(SqlException ex)
{
Response.Write ("<script>");
Response.Write ("alert('数据库连接出错!')");
Response.Write ("</script>");
}
finally
{
conn.Close ();
}
tj.Attributes .Add ("onclick","return confirm_1();");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textbox_mean.TextChanged += new System.EventHandler(this.textbox_mean_TextChanged);
this.btn_temp.Click += new System.EventHandler(this.btn_temp_Click);
this.tj.Click += new System.EventHandler(this.tj_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void tj_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection(myConnString);
try
{
conn.Open();
meaning = textbox_mean.Text .Trim ();
content = textbox_cont.Text .Trim ();
diff = textbox_diff.Text .Trim ();
outl = textbox_outl.Text .Trim ();
DateTime dt=new DateTime ();
dt=DateTime.Now ;
flag = Convert.ToString (ViewState["flag"]);
suresubjectid = Convert.ToString (ViewState["suresubjectid"]);
if (flag == "1")
sql = "update bysj.buildreport set researchmeaning='"+meaning+"',basiccontent='"+content+"',emphasis='"+diff+"',outline='"+outl+"',date_time='"+dt+"',draftflag='1' where suresubjectid='"+suresubjectid+"'";
else if (flag=="0")
sql="insert into bysj.buildreport (suresubjectid,researchmeaning,basiccontent,emphasis,outline,draftflag,date_time)values('"+suresubjectid+"','"+meaning+"','"+content+"','"+diff+"','"+outl+"','1','"+dt+"')";
SqlCommand cmd = new SqlCommand (sql,conn);
cmd.CommandText =sql;
cmd.ExecuteNonQuery ();
sql="select * from bysj.flowmonitor where suresubjectid='"+suresubjectid+"'";
SqlDataAdapter adapter3 = new SqlDataAdapter(sql, conn);
DataSet cla2=new DataSet ();
adapter3.Fill(cla2);
if (cla2.Tables ["table"].Rows.Count ==0)
sql="insert into bysj.flowmonitor (suresubjectid,buildreportflag,buildreportcommittime)values('"+suresubjectid+"','"+1+"','"+dt+"')";
else
sql="update bysj.flowmonitor set buildreportflag='1' ,buildreportcommittime='"+dt+"' where suresubjectid='"+suresubjectid+"'";
cmd.CommandText =sql;
cmd.ExecuteNonQuery ();
Response.Write ("<script>");
Response.Write ("alert('提交成功!');");
Response.Write("</script>");
}
catch(SqlException ex)
{
Response.Write ("<script>");
Response.Write ("alert('数据库连接出错!')");
Response.Write ("</script>");
}
finally
{
conn.Close ();
}
}
private void textbox_mean_TextChanged(object sender, System.EventArgs e)
{
}
private void btn_temp_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection(myConnString);
try
{
conn.Open();
meaning = textbox_mean.Text .Trim ();
content = textbox_cont.Text .Trim ();
diff = textbox_diff.Text .Trim ();
outl = textbox_outl.Text .Trim ();
DateTime dt=new DateTime ();
dt=DateTime.Now ;
flag = Convert.ToString (ViewState["flag"]);
suresubjectid = Convert.ToString (ViewState["suresubjectid"]);
if (flag == "1")
sql = "update bysj.buildreport set researchmeaning='"+meaning+"',basiccontent='"+content+"',emphasis='"+diff+"',outline='"+outl+"',date_time='"+dt+"' where suresubjectid='"+suresubjectid+"'";
else if (flag=="0")
sql="insert into bysj.buildreport (suresubjectid,researchmeaning,basiccontent,emphasis,outline,draftflag,date_time)values('"+suresubjectid+"','"+meaning+"','"+content+"','"+diff+"','"+outl+"','0','"+dt+"')";
SqlCommand cmd = new SqlCommand (sql,conn);
cmd.CommandText =sql;
cmd.ExecuteNonQuery ();
Response.Write ("<script>");
Response.Write ("alert('提交成功!');");
Response.Write("</script>");
}
catch(SqlException ex)
{
Response.Write ("<script>");
Response.Write ("alert('数据库连接出错!')");
Response.Write ("</script>");
}
finally
{
conn.Close ();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -