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

📄 student_course.aspx.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;
using System.Data.SqlClient;

using jianke;
public partial class student_course : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Course_choiceBind();
    }

    public void Course_choiceBind()
    {
        SqlConnection Conn = DB.creatconnection();
        Conn.Open();


        SqlDataAdapter da = new SqlDataAdapter("Select * from Class  ", Conn); // 绑定到满足条件的 数据上  ?
        DataSet ds = new DataSet();
        da.Fill(ds);
        dg.DataSource = ds;
        dg.DataBind();
      Conn.Close();
       ShowStats();
    }

  
  
               //SqlConnection Conn = DB.creatconnection();
               //Conn.Open();
               //string str = "insert into (dept_name)values('" + this.TextBox1.Text + "')";
               //SqlCommand cmd = new SqlCommand(str, Conn);
               //cmd.ExecuteNonQuery();
               //Conn.Close();
               //Response.Write("<script>alert('录入成功!');</script>");




    protected void PageChange(object source, DataGridPageChangedEventArgs e)
    {
        dg.CurrentPageIndex = e.NewPageIndex;
        Course_choiceBind();
        ShowStats();
    }
    private void ShowStats()
    {
        lblCurrentIndex.Text = "第 " + (dg.CurrentPageIndex + 1).ToString() + " 页";
        lblPageCount.Text = "总共 " + dg.PageCount.ToString() + " 页";
    }
    public void PagerButtonClick(object sender, EventArgs e)
    {
        string arg = ((LinkButton)sender).CommandArgument.ToString();
        switch (arg)
        {
            case "next":
                if (dg.CurrentPageIndex < (dg.PageCount - 1))
                {
                    dg.CurrentPageIndex += 1;
                }
                break;
            case "prev":
                if (dg.CurrentPageIndex > 0)
                {
                    dg.CurrentPageIndex -= 1;
                }
                break;
            case "last":
                dg.CurrentPageIndex = (dg.PageCount - 1);
                break;
            default:
                dg.CurrentPageIndex = System.Convert.ToInt32(arg);
                break;
        }
        Course_choiceBind();
        ShowStats();
    }








        
  //      protected void  Select(object sender, DataGridItemEventArgs e)
  //{

  //    SqlConnection Conn = DB.creatconnection();
  //    Conn.Open();
  //    string str = "insert into student_course_choice(student_sno,grade,course_name,teacher_name)values('" + this.TextBox1.Text + "','" + this.DropDownList1.SelectedItem.Text + "','" + ((TextBox)e.Item.Cells[0].Controls[0]).Text + "','" + ((TextBox)e.Item.Cells[1].Controls[0]).Text + "')";
  //    SqlCommand cmd = new SqlCommand(str, Conn);
  //    cmd.ExecuteNonQuery();
  //    Conn.Close();
  //    Response.Write("<script>alert('录入成功!');</script>");

  //}
    //protected void select1(object source, DataGridSortCommandEventArgs e)
    //{
    //    SqlConnection Conn = DB.creatconnection();
    //    Conn.Open();
    //    string str = "insert into student_course_choice(student_sno,grade,course_name,teacher_name)values('" + this.TextBox1.Text + "','" + this.DropDownList1.SelectedItem.Text + "'," + 3+"," +6+")";
    //    SqlCommand cmd = new SqlCommand(str, Conn);
    //    cmd.ExecuteNonQuery();
    //    Conn.Close();
    //    Response.Write("<script>alert('录入成功!');</script>");

    //}
   


    protected void select(object source, DataGridCommandEventArgs e)
    {
        TableRow row = e.Item;
        //    DataGrid row = e.Item;
        SqlConnection Conn = DB.creatconnection();
        Conn.Open();
        string str = "insert into student_course_choice(student_sno,grade,course_name,teacher_name)values('" +Session["Users_id"].ToString() + "','" + this.DropDownList1.SelectedItem.Text + "','" + row.Cells[0].Text + "','" + row.Cells[1].Text + "')";//'" + ((TextBox)e.Item.Cells[2].Controls[0]).Text + "'
        //  string str = "insert into student_course_choice(student_sno,grade,course_name,teacher_name)values('" + this.TextBox1.Text + "','" + this.DropDownList1.SelectedItem.Text + "','" + row.Cells[0].Controls[0].Text + "','" + row.Cells[1].Controls[0].Text + "')";//'" + ((TextBox)e.Item.Cells[2].Controls[0]).Text + "'
        SqlCommand cmd = new SqlCommand(str, Conn);
        cmd.ExecuteNonQuery();
        Conn.Close();
        Response.Write("<script>alert('录入成功!');</script>");
    }
    protected void ChangeRowColour(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            e.Item.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#80FF80'");
            //当鼠标移开时还原背景色
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

        }
    }
}
    

⌨️ 快捷键说明

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