⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucteachergivepapers.ascx.cs

📁 在线 图书网上购物系统
💻 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;

public partial class UserControls_ucTeacherGivePapers : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["LoginID"] == null)
        {
            lbMsg.Text = "该操作应由指导老师完成!";
            return;
        }
        BindData();
    }

    private void BindData()
    {
        DataTable dt = Global.GetFieldsFromTablesByCondiction("CandidatePaperID,title,description,reference,datetime,isbeselected", "candidatepaper", "teacherid='" + Session["LoginID"].ToString() + "'");
        dvCandidatePapers.DataKeyNames = new string[] { "CandidatePaperID" };
        Utilities.BindingDataGridView(this.dvCandidatePapers, dt);
        
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        CandidatePaper cp = new CandidatePaper();
        cp.Title = this.tbTitle.Text.Trim();
        cp.Description = this.tbDescription.Text.Trim();
        cp.Reference = this.tbReference.Text.Trim();
        cp.IsBeSelected = false;
        cp.DateTime = DateTime.Now;
        if (Session["LoginType"] == null || Session["LoginType"].ToString() != "Teacher")
        {
            lbMsg.Text = "该操作应由指导老师完成!";
            return;
        }
        cp.TeacherID = Session["LoginID"].ToString();
        if (CandidatePaper.Insert(cp) != -100)
        {
            lbMsg.Text = "添加成功";
        }
        else
        {
            lbMsg.Text = "添加失败";
        }
        BindData();
    }



    protected void dvCandidatePapers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "Display":
                int id = int.Parse(e.CommandArgument.ToString());
                CandidatePaper cp = CandidatePaper.GetCandidatePaper(id);
                this.tbDescription.Text = cp.Description.Trim();
                this.tbReference.Text = cp.Reference.Trim();
                this.tbTitle.Text = cp.Title.Trim();
                break;
            case "Del":
                int id2 = int.Parse(e.CommandArgument.ToString());
                if (DataAccess.ExecuteNonQuery("usp_DeleteCandidatePaper", false, new object[] { id2 }) != -100)
                {
                    lbMsg.Text = "删除成功";
                    BindData();
                }
                else
                {
                    lbMsg.Text = "删除失败";
                }
                break;
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -