📄 subject_list.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class SubjectBuild_SubjectList : System.Web.UI.Page
{
PersonRecordClass prObj = new PersonRecordClass();
SubjectBuildClass sbObj = new SubjectBuildClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if ((Session["isOpen"] == null) && (Session["Admin"] == null))
{
Response.Write("<script>parent.location='../Default.aspx';</script>");
}
else
{
tabList.Visible = false;
tabAdd.Visible = false;
tabUpdate.Visible = false;
btnAddList.Visible = false;
if (Convert.ToInt32(Session["isOpen"]) == 1 || Convert.ToInt32(Session["Admin"]) == 1)
{
tabList.Visible = true;
btnAddList.Visible = true;
gvListBind();
}
else
{
tabList.Visible = true;
btnAddList.Visible = false;
gvListBind();
gvList.Columns[0].Visible = false;
gvList.Columns[1].Visible = false;
}
}
}
}
//=============================================================
// 方 法 名: gvListBind()
// 功能描述: 对GridView进行绑定,显示教学工作资料
// 输入参数: 无
// 返 回 值: 无
// ==============================================================
public void gvListBind()
{
if ((Session["isOpen"] == null) && (Session["Admin"] == null))
{
Response.Write("<script>parent.location='../Default.aspx';</script>");
}
else
{
if (Convert.ToInt32(Session["Admin"]) == 1)
{
SqlCommand myCmd = sbObj.GetASLCmd();
prObj.GVBind(myCmd, gvList, "ASL");
}
else
{
SqlCommand myCmd = sbObj.GetSSLCmd(Convert.ToInt32(Session["UID"]));
prObj.GVBind(myCmd, gvList, "SSL");
}
}
}
//=============================================================
// 事 件 名: gvList_RowDeleting()
// 功能描述: 对GridView中的某行进行删除
// ==============================================================
protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int P_Int_id = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);
sbObj.DeleteSLInfo(P_Int_id);
gvListBind();
}
//=============================================================
// 事 件 名: gvList_RowUpdating()
// 功能描述: 对GridView中的某行进行修改时,修改表显示其修改内容
// ==============================================================
protected void gvList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
tabUpdate.Visible = true;
tabList.Visible = false;
tabAdd.Visible = false;
prObj.DDLBind(ddlUYearInfo);
int P_Int_id = Convert.ToInt32(gvList.DataKeys[e.RowIndex].Value);
labValue.Text = P_Int_id.ToString();
DataSet ds = sbObj.ReturnSLDs(P_Int_id, "SLInfo");
txtName.Text = ds.Tables["SLInfo"].Rows[0][0].ToString();
txtUStartEndTime.Text = ds.Tables["SLInfo"].Rows[0][1].ToString();
txtUWorkContent.Text = ds.Tables["SLInfo"].Rows[0][2].ToString();
txtULessonName.Text = ds.Tables["SLInfo"].Rows[0][3].ToString();
txtUClass.Text = ds.Tables["SLInfo"].Rows[0][4].ToString();
txtUPeriod.Text = ds.Tables["SLInfo"].Rows[0][5].ToString();
txtUPersons.Text = ds.Tables["SLInfo"].Rows[0][6].ToString();
ddlUYearInfo.SelectedItem.Text = ds.Tables["SLInfo"].Rows[0][7].ToString();
}
//=============================================================
// 事 件 名: btnReset_Click()
// 功能描述: 在添加表上,单击重置按钮时,重新填写教师的教学工作资料
// ==============================================================
protected void btnReset_Click(object sender, EventArgs e)
{
txtAStartEndTime.Text = "";
txtAWorkContent.Text = "";
txtAClass.Text = "";
txtALessonName.Text = "";
txtAPeriod.Text = "";
txtAPersons.Text = "";
ddlAYearInfo.SelectedIndex = 0;
}
//=============================================================
// 事 件 名: btnUpdate_Click()
// 功能描述: 在修改表上,单击修改按钮时,修改教师的教学工作资料
// ==============================================================
protected void btnUpdate_Click(object sender, EventArgs e)
{
if (Session["Username"] == null)
{
Response.Write("<script>parent.location='../Default.aspx';</script>");
}
else
{
if (txtUStartEndTime.Text.Trim() == "")
{
Response.Write("<script>alert('请填写起止年月!');</script>");
}
else if (txtUWorkContent.Text.Trim() == "")
{
Response.Write("<script>alert('请填写工作内容!');</script>");
}
else if (txtULessonName.Text.Trim() == "")
{
Response.Write("<script>alert('请填写课程或实验、实习名称!');</script>");
}
else if (txtUClass.Text.Trim() == "")
{
Response.Write("<script>alert('请填写授课专业!');</script>");
}
else if (txtUPeriod.Text.Trim() == "")
{
Response.Write("<script>alert('请填写学时或周数!');</script>");
}
else if (txtUPersons.Text.Trim() == "")
{
Response.Write("<script>alert('请填写人数!');</script>");
}
else
{
sbObj.UpdateSLInfo(Convert.ToInt32(labValue.Text.Trim()), txtUStartEndTime.Text.Trim(), txtUWorkContent.Text.Trim(), txtULessonName.Text.Trim(), txtUClass.Text.Trim(), txtUPeriod.Text.Trim(), txtUPersons.Text.Trim(), Convert.ToString(Session["Username"]), Convert.ToInt32(ddlUYearInfo.SelectedItem.ToString()), Convert.ToInt32(Session["UID"]));
Response.Redirect("~/SubjectBuild/Subject_List.aspx");
}
}
}
//=============================================================
// 事 件 名: btnAdd_Click()
// 功能描述: 在添加表上,单击添加按钮时,将教学工作资料添加到表tb_teaching中
// ==============================================================
protected void btnAdd_Click(object sender, EventArgs e)
{
if (Session["Username"] == null)
{
Response.Write("<script>parent.location='../Default.aspx';</script>");
}
else
{
if (ddlAName.SelectedIndex == 0)
{
Response.Write("<script>alert('请选择需要添加资料的姓名!');</script>");
}
else if (txtAStartEndTime.Text.Trim() == "")
{
Response.Write("<script>alert('请填写起止时间!');</script>");
}
else if (txtAWorkContent.Text.Trim() == "")
{
Response.Write("<script>alert('请填写工作内容!');</script>");
}
else if (txtALessonName.Text.Trim() == "")
{
Response.Write("<script>alert('请填写课程或实验、实习名称!');</script>");
}
else if (txtAClass.Text.Trim() == "")
{
Response.Write("<script>alert('请填写授课专业!');</script>");
}
else if (txtAPeriod.Text.Trim() == "")
{
Response.Write("<script>alert('请填写学时或周数!');</script>");
}
else if (txtAPersons.Text.Trim() == "")
{
Response.Write("<script>alert('请填写人数!');</script>");
}
else if (ddlAYearInfo.SelectedIndex == 0)
{
Response.Write("<script>alert('请选择填写年度!');</script>");
}
else
{
sbObj.AddSLInfo(txtAStartEndTime.Text.Trim(),txtAWorkContent.Text.Trim(),txtALessonName.Text.Trim(),txtAClass.Text.Trim(),txtAPeriod.Text.Trim(),txtAPersons.Text.Trim(), Convert.ToInt32(ddlAName.SelectedValue), Convert.ToString(Session["Username"]), "", Convert.ToInt32(ddlAYearInfo.SelectedItem.ToString()),Convert.ToInt32(Session["UID"]));
Response.Redirect("~/SubjectBuild/Subject_List.aspx");
}
}
}
//=============================================================
// 事 件 名: btnAddList_Click()
// 功能描述: 当用户单击添加按钮,添加表显示
// ==============================================================
protected void btnAddList_Click(object sender, EventArgs e)
{
tabAdd.Visible = true;
tabList.Visible = false;
tabUpdate.Visible = false;
prObj.DDLBind(ddlAYearInfo);
prObj.DDLNameBind(ddlAName, "userInfo");
if ((Session["isOpen"] == null) && (Session["Admin"] == null))
{
Response.Write("<script>parent.location='../Default.aspx';</script>");
}
else
{
if (Convert.ToInt32(Session["Admin"]) == 1)
{ }
else
{
ddlAName.SelectedValue = Convert.ToString(Session["UID"]);
ddlAName.Enabled = false;
}
}
}
protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvList.PageIndex = e.NewPageIndex;
gvListBind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -