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

📄 t_expbooking.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 T_ExpBooking : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Admin aAdmin = (Admin)this.Master;
            aAdmin.ManageTitle = "学生预约情况管理";
            aAdmin.MenuSelectedValue = "TCalendar";

            
            ExpReserve.Batch aBatch = SingleInitials.DbAccess.GetABatch(CurrentBatchID);
            //legendList.InnerText = string.Format("实验项目\"{0}\"的预约学生名单", aBatch.CourseDetailName);
            lblDetailName.Text = aBatch.CourseDetailName; 
            lblExpTime.Text = aBatch.Date.ToString("yyyy-MM-dd") + " " + UIControls.CaculateWeekDay(aBatch.Date) + " " + aBatch.ClassNo;
            lblExpAddress.Text = aBatch.Address;
            lblTeacher.Text = aBatch.TeacherName;
            
            BindDisplayList(0,"");
            this.lbMsg.Text = "";
        }
    }


    #region 属性
    static int m_ColID = 0;
    static int m_ColClass = 3;
    public long CurrentBatchID 
    {
        get
        {
            try
            {
                return JKLib.Utility.MyConvert.ToInt32IgnErr(Request.QueryString["BatchID"].ToString());
            }
            catch
            {
                return 0;
            }
        }

    }
    #endregion


   
    /// <summary>
    /// 返回所有的实验项目批次
    /// </summary>
    /// <param name="pageIndex"></param>
    /// <param name="sortExpression">要排序的字段</param>
    private void BindDisplayList(int pageIndex, string sortExpression)
    {
        StudentList.Columns[m_ColID].Visible = true;
        StudentList.SelectedIndex = -1;

        DataTable dt = SingleInitials.DbAccess.GetBookingList(this.CurrentBatchID).Tables[0];//返回所有列表
        if (sortExpression == null || sortExpression == string.Empty)
        {
            JKLib.Web.GridViewOperation.BindPagingGridView(StudentList, dt.DefaultView, pageIndex);
        }
        else
        {
            JKLib.Web.GridViewOperation.BindPagingGridView(StudentList, dt.DefaultView, pageIndex, sortExpression, true, JKLib.Web.GridViewOperation.BindPagingGridViewType.Sorting);
        }
        StudentList.Columns[m_ColID].Visible = false;
        this.fsItem.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 == "GiveMark")
        {
            StudentList.SelectedIndex = int.Parse(e.CommandArgument.ToString());
            string theID = StudentList.Rows[int.Parse(e.CommandArgument.ToString())].Cells[m_ColID].Text;
            string theClass = StudentList.Rows[int.Parse(e.CommandArgument.ToString())].Cells[m_ColClass].Text.Trim();
            long aStudentID = long.Parse(theID);
            this.tbxKeyID.Text = aStudentID.ToString();


            Booking aBooking = SingleInitials.DbAccess.GetABooking(aStudentID, this.CurrentBatchID);
            Student aStudent = SingleInitials.DbAccess.GetAStudent(aStudentID);

            this.lblClass.Text = theClass;
            this.lblName.Text = aStudent.Name;

            this.ddlGrade.SelectedValue = aBooking.Grade;
            this.tbxMark.Text = aBooking.Mark.ToString("###0.#");

            this.legendItem.InnerText = "评分";
            this.fsItem.Visible = true;
        }
    }
    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(StudentList.PageIndex, e.SortExpression);
    }
    #endregion



    private bool EditInputCheck(ref string strError)
    {
        strError = "";
        bool result = true;

        if (0 == CurrentBatchID)
        {
            strError += "非法的批次ID";
            result = false;
        }

        if (this.tbxMark.Text == "")
        {
            strError += "分数不能为空";
            result = false;
        }

        if (!JKLib.Utility.MyJudge.IsNumber(this.tbxMark.Text))
        {
            strError += "分数中含有非法字符";
            result = false;
        }

        return result;
    }

    private bool Save()
    {
        if (this.tbxKeyID.Text == "-1")//添加
        {
            return true;  
        }
        else//修改
        {
            string errStr = "";
            if (!EditInputCheck(ref errStr))
            {
                lbMsg.Text = errStr;
                return false;
            }
            try
            {
                long aStudentID = long.Parse(this.tbxKeyID.Text);
                Booking aBooking = SingleInitials.DbAccess.GetABooking(aStudentID, this.CurrentBatchID);
                aBooking.Grade = this.ddlGrade.SelectedValue;
                aBooking.Mark = float.Parse(this.tbxMark.Text);

                return SingleInitials.DbAccess.EditABooking(aBooking);
            }
            catch (Exception ex)
            {
                return false;
            }

        }

    }



    protected void btn_Save_Click(object sender, EventArgs e)
    {
        int lastPageIndex = this.StudentList.PageIndex;
        if (Save())
        {
            if ("-1" == this.tbxKeyID.Text)//添加
            {
            }
            else//修改
            {
                this.BindDisplayList(lastPageIndex, "");//更新列表
            }
            this.fsItem.Visible = false;//隐藏添加列表
        }
    }
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        UIControls.ExportExcelFromDataGrid("预约学生.xls", this.StudentList, this);
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
        //base.VerifyRenderingInServerForm(control);
    }
}

⌨️ 快捷键说明

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