在线 图书网上购物系统

源代码在线查看: ucteachergivepapers.ascx.cs

软件大小: 4488 K
上传用户: siclj
关键词: 图书 网上购物
下载地址: 免注册下载 普通下载 VIP

相关代码

				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;
				        }
				
				    }
				}
							

相关资源