📄 exercise_details.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 Teach_Manager.Common;
using Teach_Manager.Dao;
namespace Teach_Manager.teacher
{
/// <summary>
/// exercise_details 的摘要说明。
/// </summary>
public class exercise_details :PageBase
{
protected System.Web.UI.WebControls.TextBox exercise_name;
protected System.Web.UI.WebControls.TextBox exercise_solution;
protected System.Web.UI.WebControls.TextBox course_name;
protected System.Web.UI.WebControls.TextBox teacher_name;
protected System.Web.UI.WebControls.TextBox exercise_datetime;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.TextBox exercise_content;
protected System.Web.UI.WebControls.Button PutIn_sulution;
private static string str_link="";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
if (purview()&&(Request.Cookies["class_type"].Value.ToString()=="0"))
{
fillData();
}
else
{
Response.Write("<script>window.top.location.href('../WebForm1.aspx'); </script>");
}
}
}
private void fillData()
{
//习题Guid
string exercise_guid=Request.QueryString["exercise_guid"];
string str_frmType=Request.QueryString["frm_Type"];
if (str_frmType=="1")
{
//添加答案
exercise_solution.ReadOnly =false;
PutIn_sulution.Visible =true;
}
string str_where=" guid='"+exercise_guid+"'";
Search_DataGrid(str_where);
exercise_solution.Attributes.Add("onKeyDown","textCounter(this,800);");
exercise_solution.Attributes.Add("onKeyUp","textCounter(this,800);");
}
/// <summary>
/// 根据条件 填充DataGrid
/// </summary>
/// <param name="str_where">where 子句</param>
private void Search_DataGrid(string str_where)
{
string str_sql="select * from view_exercise where IsDelete='0' ";
if (str_where.Trim()!="")
{
str_sql+=" and "+str_where;
}
CommonInterface CIF=new CommonSql(str_conn_protected);
DataTable dt=CIF.ExeForDtl(str_sql);
CIF.Close();
//把相关数据填充进去
if (dt.Rows.Count>0)
{
//习题名称
exercise_name.Text =dt.Rows[0]["Name"].ToString();
//课程名称
course_name.Text =dt.Rows[0]["course_Table_name"].ToString();
//习题内容
exercise_content.Text =dt.Rows[0]["content"].ToString();
//习题答案
exercise_solution.Text =dt.Rows[0]["solution"].ToString();
//出题教师姓名
teacher_name.Text =dt.Rows[0]["teacher_table_name"].ToString();
//出题时间
exercise_datetime.Text =dt.Rows[0]["exercise_date"].ToString();
//图片链接地址
if (dt.Rows[0]["photo_name"].ToString()!="")
{
str_link=System.Configuration.ConfigurationSettings.AppSettings["DocOpenPath"].ToString()+ dt.Rows[0]["photo_name"].ToString();
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.PutIn_sulution.Click += new System.EventHandler(this.PutIn_sulution_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
//链接显示图片信息
if (str_link!="")
{
Response.Write("<script>window.open('"+str_link+"');</script>");
}
}
private void PutIn_sulution_Click(object sender, System.EventArgs e)
{
//提交答案
string str_solution=exercise_solution.Text.Trim().Replace("'","''");
if (str_solution=="")
{
Alert("答案没有内容,不能够提交");
}
//更新exercise_table表的solution字段
string str_sql=" update exercise_table set solution='"+str_solution+"' where guid='"+Request.QueryString["exercise_guid"]+"'";
try
{
CommonInterface CIF=new CommonSql(str_conn_protected);
CIF.Execute(str_sql);
CIF.Close();
Alert("答案提交成功");
}
catch
{
Alert("答案提交失败");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -