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

📄 s_expbooked.aspx.cs

📁 实验课预约系统。采用.net+access数据库实现。 管理员对学生教师有管理功能
💻 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 ExpReserve;

public partial class S_ExpBooked : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Admin aAdmin = (Admin)this.Master;
            aAdmin.ManageTitle = "已预约的实验";
            aAdmin.MenuSelectedValue = "SExpBooked";

            lblCurrentTerm.Text = SingleInitials.DbAccess.GetActiveTerm();
            BindDisplayList(0,""); 
            this.lbMsg.Text = "";

        }


    }


    #region 属性
    static int m_ColID = 0;
    static int m_ColPassed = 7;//是否过期
    public string CurrentTerm
    {
        get
        {
            return this.lblCurrentTerm.Text;
        }
    }
    public long CurrentStudentID
    {
        get
        {
            return long.Parse(Users.GetCurrentTableID());
        }
    }
    
    #endregion



    /// <summary>
    /// 返回所有的实验项目批次
    /// </summary>
    /// <param name="pageIndex"></param>
    /// <param name="sortExpression">要排序的字段</param>
    private void BindDisplayList(int pageIndex, string sortExpression)
    {
        lbMsg.Text = "";

        BatchList.Columns[m_ColID].Visible = true;

        BatchList.SelectedIndex = -1;


        DataTable dt = SingleInitials.DbAccess.GetStudentBookingList(this.CurrentStudentID,this.CurrentTerm).Tables[0];
        dt.Columns.Add("IsOverdue", typeof(string));
        foreach (DataRow iDataRow in dt.Rows)
        {
            DateTime iDate = DateTime.Parse(iDataRow["Date"].ToString());
            if (iDate >= DateTime.Now)
            {
                iDataRow["IsOverdue"] = "否";
            }
            else
            {
                iDataRow["IsOverdue"] = "是";
            }
        }

        if (sortExpression == null || sortExpression == string.Empty)
        {
            JKLib.Web.GridViewOperation.BindPagingGridView(BatchList, dt.DefaultView, pageIndex);
        }
        else
        {
            JKLib.Web.GridViewOperation.BindPagingGridView(BatchList, dt.DefaultView, pageIndex, sortExpression, true, JKLib.Web.GridViewOperation.BindPagingGridViewType.Sorting);
        }
        BatchList.Columns[m_ColID].Visible = false;
    }

   


    #region 表格处理
    protected void BatchList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        BindDisplayList(e.NewPageIndex, null);
    }
    protected void BatchList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "CancelBatch")
        {
            string theID = BatchList.Rows[int.Parse(e.CommandArgument.ToString())].Cells[m_ColID].Text;
            string PassedStr = BatchList.Rows[int.Parse(e.CommandArgument.ToString())].Cells[m_ColPassed].Text.Trim();
            if (PassedStr == "是")
            {
                this.lbMsg.Text = "不能取消已经过期的预约记录!";
                return; 
            }
            long aBatchID = long.Parse(theID);
            try
            {
                int lastPageIndex = BatchList.PageIndex;
                SingleInitials.DbAccess.DelABooking(this.CurrentStudentID,aBatchID);
                //更新列表
                BindDisplayList(0, "");
                if (lastPageIndex < BatchList.PageCount)
                {
                    BindDisplayList(lastPageIndex, "");
                }
                this.lbMsg.Text = "取消预约成功!";
            }
            catch (Exception ex)
            {
                this.lbMsg.Text = ex.Message;
            }
        }
    }
    protected void BatchList_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Pager)
            JKLib.Web.GridViewOperation.GridRowCreated(sender, e);
    }
    protected void BatchList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        ////Button   btn   =   (Button)e.Row.Cells[2].Controls[0]; 
        ////btn.Attributes.Add("onclick","return   confirm('您真的要删除吗?');");
        //LinkButton btn = (LinkButton)e.Row.Cells[2].Controls[0]; 
        //btn.Attributes.Add("onclick", "return   confirm('您真的要删除吗?');");    
    }
    protected void BatchList_Sorting(object sender, GridViewSortEventArgs e)
    {
        BindDisplayList(BatchList.PageIndex, e.SortExpression);
    }
    #endregion

    protected void BtnRefresh_Click(object sender, EventArgs e)
    {
        BindDisplayList(0,"");
    }
}

⌨️ 快捷键说明

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