报了一大堆错……private void Button_Teacher_Click(object sender, System.EventArgs e)
{ //这是第208行,第一个错误的地方,让我在后面加“}”?
protected DateTime dt = DateTime.Now;
String str = dt.ToString("yyyy-MM-dd");
string sql="update student_work_info set grade="+DropDownListGrade.Items[DropDownListGrade.SelectedIndex].Value+",re='"+TextRe.Text+"',correcttime='"+str+"'";
Db.ExecuteSql(sql);
Button1.Enabled=false;
DropDownListGrade.Enabled=false;
TextRe.Enabled=false;
showMsg("操作成功!",Session["name"].ToString());
msg.Text += "<script>top.window.returnValue='loginOk';top.window.close();</script>";
} private void Button2_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=query");
}
private void showMsg(string msgStr,string focusObj)
{
msg.Text = "<script> alert('"+msgStr+"');document.getElementById('"+focusObj+"').focus();</script>";
} private void Button3_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=download");
}
e:\sw\studentwork.aspx.cs(208,4): error CS1513: 应输入 }
e:\sw\studentwork.aspx.cs(212,17): error CS1519: 类、结构或接口成员声明中的标记“(”无效
e:\sw\studentwork.aspx.cs(212,21): error CS1519: 类、结构或接口成员声明中的标记“)”无效
e:\sw\studentwork.aspx.cs(213,19): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(214,29): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(215,22): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(216,4): error CS1520: 类、结构或接口方法必须有返回类型
e:\sw\studentwork.aspx.cs(216,12): error CS1031: 应输入类型
e:\sw\studentwork.aspx.cs(216,28): error CS0270: 不能在变量声明中指定数组大小(请尝试使用“new”表达式初始化)
e:\sw\studentwork.aspx.cs(216,35): error CS1519: 类、结构或接口成员声明中的标记“.”无效
e:\sw\studentwork.aspx.cs(216,36): error CS1520: 类、结构或接口方法必须有返回类型
e:\sw\studentwork.aspx.cs(216,46): error CS1002: 应输入 ;
e:\sw\studentwork.aspx.cs(217,13): error CS1519: 类、结构或接口成员声明中的标记“+=”无效
e:\sw\studentwork.aspx.cs(220,11): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(222,14): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(224,11): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(233,2): error CS1022: 应输入类型、命名空间定义或文件尾
{ //这是第208行,第一个错误的地方,让我在后面加“}”?
protected DateTime dt = DateTime.Now;
String str = dt.ToString("yyyy-MM-dd");
string sql="update student_work_info set grade="+DropDownListGrade.Items[DropDownListGrade.SelectedIndex].Value+",re='"+TextRe.Text+"',correcttime='"+str+"'";
Db.ExecuteSql(sql);
Button1.Enabled=false;
DropDownListGrade.Enabled=false;
TextRe.Enabled=false;
showMsg("操作成功!",Session["name"].ToString());
msg.Text += "<script>top.window.returnValue='loginOk';top.window.close();</script>";
} private void Button2_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=query");
}
private void showMsg(string msgStr,string focusObj)
{
msg.Text = "<script> alert('"+msgStr+"');document.getElementById('"+focusObj+"').focus();</script>";
} private void Button3_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=download");
}
e:\sw\studentwork.aspx.cs(208,4): error CS1513: 应输入 }
e:\sw\studentwork.aspx.cs(212,17): error CS1519: 类、结构或接口成员声明中的标记“(”无效
e:\sw\studentwork.aspx.cs(212,21): error CS1519: 类、结构或接口成员声明中的标记“)”无效
e:\sw\studentwork.aspx.cs(213,19): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(214,29): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(215,22): error CS1519: 类、结构或接口成员声明中的标记“=”无效
e:\sw\studentwork.aspx.cs(216,4): error CS1520: 类、结构或接口方法必须有返回类型
e:\sw\studentwork.aspx.cs(216,12): error CS1031: 应输入类型
e:\sw\studentwork.aspx.cs(216,28): error CS0270: 不能在变量声明中指定数组大小(请尝试使用“new”表达式初始化)
e:\sw\studentwork.aspx.cs(216,35): error CS1519: 类、结构或接口成员声明中的标记“.”无效
e:\sw\studentwork.aspx.cs(216,36): error CS1520: 类、结构或接口方法必须有返回类型
e:\sw\studentwork.aspx.cs(216,46): error CS1002: 应输入 ;
e:\sw\studentwork.aspx.cs(217,13): error CS1519: 类、结构或接口成员声明中的标记“+=”无效
e:\sw\studentwork.aspx.cs(220,11): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(222,14): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(224,11): error CS1518: 应输入 class、delegate、enum、interface 或 struct
e:\sw\studentwork.aspx.cs(233,2): error CS1022: 应输入类型、命名空间定义或文件尾
private void Button_Teacher_Click(object sender, System.EventArgs e)
{ //这是第208行,第一个错误的地方,让我在后面加“}”?
protected DateTime dt = DateTime.Now;
String str = dt.ToString("yyyy-MM-dd");
string sql="update student_work_info set grade="+DropDownListGrade.Items[DropDownListGrade.SelectedIndex].Value+",re='"+TextRe.Text+"',correcttime='"+str+"'";
Db.ExecuteSql(sql);
Button1.Enabled=false;
DropDownListGrade.Enabled=false;
TextRe.Enabled=false;
showMsg("操作成功!",Session["name"].ToString());
msg.Text += "<script>top.window.returnValue='loginOk';top.window.close();</script>";
} private void Button2_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=query");
}
private void showMsg(string msgStr,string focusObj)
{
msg.Text = "<script> alert('"+msgStr+"');document.getElementById('"+focusObj+"').focus();</script>";
} private void Button3_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=download");
}
}
你没有写类名啊,老大
{
private readonly string SQLCONNECTIONSTRING = ConfigurationSettings.AppSettings["connStr"].ToString();
protected void Page_Load(object sender, System.EventArgs e)
{
Vali();
// 在此处放置用户代码以初始化页面
if(Session["role"].ToString()=="2")//学生身份
{
Button_Teacher.Visible=false;
if(Session["x"].ToString()=="download")
{
showDownload();
TextRe.Visible=false;
TextAnswer.Enabled=true;
Button2.Visible=false;//学生下载提交时不显示
}
if(Session["x"].ToString()=="query")
{
showQuery();
Button1.Visible=false;
Button3.Visible=false;//学生查询时不显示
}
}
else
if(!Page.IsPostBack)
{
BindSelectedData();
Button1.Visible=false;
Button3.Visible=false;
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{ }
#endregion
private void Vali()
{
if (Session["id"]==null || Session["id"].ToString()=="")
{
Response.Clear();
Response.Redirect("quit.aspx");
Response.End();
}
}
private void showDownload()
{
/////////////////
DataSet ds = Db.ExecuteToDataSet("SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p.id and t.id="+Request.Params["id"]);
TextId.Text=Request.Params["id"].ToString();
DataRow tempRow = ds.Tables[0].Rows[0];
TextTeacher.Text=tempRow["name"].ToString();
TextStudent.Text=Session["name"].ToString();
TextTitleCon.Text=tempRow["title"].ToString();
ds.Dispose();
TextId.Enabled=false;
TextTeacher.Enabled=false;
TextStudent.Enabled=false;
TextTitleCon.Enabled=false;
DropDownListGrade.Enabled=false; }
private void showQuery()
{
DataSet ds = Db.ExecuteToDataSet("SELECT p.name as name, s.id , s.title,s.content,s.re,s.grade FROM student_work_info s,person_info p,teacher_work_info t WHERE s.correcttime!='' and s.teacherid=t.teacherid and t.teacherid=p.id and s.id="+Request.Params["id"]);
TextId.Text=Request.Params["id"].ToString();
DataRow tempRow = ds.Tables[0].Rows[0];
TextTeacher.Text=tempRow["name"].ToString();
TextStudent.Text=Session["name"].ToString();
TextTitleCon.Text=tempRow["title"].ToString();
TextAnswer.Text=tempRow["content"].ToString();
TextRe.Text=tempRow["re"].ToString();
DropDownListGrade.SelectedIndex=Int32.Parse(tempRow["grade"].ToString());
ds.Dispose();
TextId.Enabled=false;
TextTeacher.Enabled=false;
TextStudent.Enabled=false;
TextTitleCon.Enabled=false;
TextAnswer.Enabled=false;
TextRe.Enabled=false;
DropDownListGrade.Enabled=false;
} protected void Button1_Click(object sender, System.EventArgs e)
{
////////////判断是否抄袭
DataSet ds2 = Db.ExecuteToDataSet("SELECT t.content FROM teacher_work_info t WHERE t.id="+Request.Params["id"]); DataRow tempRow1 = ds2.Tables[0].Rows[0];
if(TextAnswer.Text.Trim()==tempRow1["content"].ToString().Trim())
{
msg.Text="<script>alert('抄袭结果!');</script>";
ds2.Dispose();
return;
}
DateTime dt = DateTime.Now;
String str = dt.ToString("yyyy-MM-dd");
//选teacherid的SQL语句s
string s="select id from person_info where name='"+TextTeacher.Text+"'";
DataSet ds = Db.ExecuteToDataSet(s);
DataRow tempRow = ds.Tables[0].Rows[0];
int tid=Int32.Parse(tempRow["id"].ToString());
ds.Dispose(); //判断student_work_info中是否已经有提交记录
DataSet ds1=Db.ExecuteToDataSet("select * from student_work_info where id="+Int32.Parse(TextId.Text)+" and studentid="+Session["id"]);
if(ds1.Tables[0].Rows.Count ==1)
{
msg.Text="<script>alert('已经提交!');</script>";
ds1.Dispose();
} else
{
string sql="insert into student_work_info(id,studentid,teacherid,subtime,title,content) VALUES("+Int32.Parse(TextId.Text)+","+Session["id"]+","+tid+",'"+str+"','"+TextTitleCon.Text+"','"+TextAnswer.Text+"')";
Db.ExecuteSql(sql);
msg.Text="<script>alert('提交成功!');</script>";
msg.Text += "<script>window.location='index.aspx';</script>";
}
}
private void BindSelectedData()//教师
{
if(Request.Params["id"]==null)
{
} else
{//连接数据库
string getid=this.Request.Params["id"].ToString();
string strcmd="SELECT student_work_info.grade,student_work_info.title,student_work_info.content,student_work_info.re,person_info.name FROM person_info,student_work_info WHERE student_work_info.id='"+getid+" '"+"AND person_info.id=student_work_info.studentid";
SqlConnection myconnection=new SqlConnection(SQLCONNECTIONSTRING);
SqlCommand mycommand = new SqlCommand(strcmd,myconnection);
try
{
myconnection.Open();
SqlDataReader dr =mycommand.ExecuteReader();
while (dr.Read())
{
TextId.Text=this.Request.Params["id"].ToString();
TextTeacher.Text = Session["name"].ToString();
TextStudent.Text=dr["name"].ToString();
TextTitleCon.Text = dr["title"].ToString();
TextAnswer.Text = dr["content"].ToString();
TextRe.Text = dr["re"].ToString();
int grade;
if(dr["grade"].ToString()=="")
{
grade=0;
}
else
grade=Int32.Parse(dr["grade"].ToString());
DropDownListGrade.SelectedIndex=grade; }
}
catch(Exception ex)
{
throw new Exception(ex.Message,ex);
}
finally
{
myconnection.Close();
}
}
}
private void Button_Teacher_Click(object sender, System.EventArgs e)
{
protected DateTime dt = DateTime.Now;
String str = dt.ToString("yyyy-MM-dd");
string sql="update student_work_info set grade="+DropDownListGrade.Items[DropDownListGrade.SelectedIndex].Value+",re='"+TextRe.Text+"',correcttime='"+str+"'";
Db.ExecuteSql(sql);
Button1.Enabled=false;
DropDownListGrade.Enabled=false;
TextRe.Enabled=false;
showMsg("操作成功!",Session["name"].ToString());
msg.Text += "<script>top.window.returnValue='loginOk';top.window.close();</script>";
} private void Button2_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=query");
}
private void showMsg(string msgStr,string focusObj)
{
msg.Text = "<script> alert('"+msgStr+"');document.getElementById('"+focusObj+"').focus();</script>";
} private void Button3_Click(object sender, System.EventArgs e)
{
protected Response.Redirect("worklist.aspx?x=download");
}
}
[/code]
这里不能用关键字吧
{
DataSet ds = Db.ExecuteToDataSet("SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p.id and t.id="+Request.Params["id"]);
TextId.Text=Request.Params["id"].ToString();
DataRow tempRow = ds.Tables[0].Rows[0];//此处错误:在位置 0 处没有任何行。
TextTeacher.Text=tempRow["name"].ToString();
TextStudent.Text=Session["name"].ToString();
TextTitleCon.Text=tempRow["title"].ToString();
ds.Dispose();
TextId.Enabled=false;
TextTeacher.Enabled=false;
TextStudent.Enabled=false;
TextTitleCon.Enabled=false;
DropDownListGrade.Enabled=false; }
{
SqlDataAdapter da;
DataSet ds = new DataSet();
try
{
da = new SqlDataAdapter(sqlStr,conn);
da.Fill(ds);
da.Dispose();
ds.Dispose();
return ds;
}
catch(Exception e)
{
throw new Exception(e.Message);
}
}