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

📄 std_result.aspx

📁 学生成绩管理系统c#vs2005.rar
💻 ASPX
字号:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="std_result.aspx.cs" Inherits="_Default" %>
<%@ import Namespace= "System.Data" %>
<%@ import Namespace= "System.Data.SqlClient" %>
<%@ import Namespace= "System.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>学生成绩管理系统</title>
        <script runat="server">
       public SqlConnection con;
     protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(ConfigurationManager.AppSettings["con"]);        
        if (!Page.IsPostBack)
            BindGrid();
    }
        public void BindGrid()
        {
            string sql = "select * from TERM_TABLE";
            SqlCommand sc = new SqlCommand(sql, con);
            sc.Connection.Open();
            gv.DataSource = sc.ExecuteReader(CommandBehavior.CloseConnection);
            gv.DataBind();
        }
        protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
        {
            //gv.ColumnHeadersDefaultCellStyle 
            gv.EditIndex = (int)e.NewEditIndex;
            BindGrid();
        }
        protected void gv_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gv.EditIndex = -1;
            BindGrid();
        }
        protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int i = e.RowIndex;
            string aa = ((TextBox)gv.Rows[i].Cells[0].Controls[0]).Text;            
            string updateset = "update TERM_TABLE SET TERM_C=@C语言, TERM_SQL=@SQL,TERM_VB=@VB, TERM_PROJECT=@项目,TERM_HTML=@HTML where STD_ID='"+aa+"'";
            SqlCommand mysqlcon = new SqlCommand(updateset,con);  
            //int index = gv.SelectedIndex;         
           // for (int i=0;i<gv.Rows.Count;i++)
            //{
           // mysqlcon.Parameters.Add(new SqlParameter("@学号", SqlDbType.VarChar, 50));
           // mysqlcon.Parameters["@学号"].Value = gv.DataKeys[(int)e.RowIndex].Value.ToString();
            mysqlcon.Parameters.Add(new SqlParameter("@C语言", SqlDbType.VarChar, 20));
            mysqlcon.Parameters["@C语言"].Value =((TextBox)gv.Rows[i].Cells[1].Controls[0]).Text  ;
            mysqlcon.Parameters.Add(new SqlParameter("@SQL", SqlDbType.VarChar, 20));
            mysqlcon.Parameters["@SQL"].Value = ((TextBox)gv.Rows[i].Cells[2].Controls[0]).Text;
            mysqlcon.Parameters.Add(new SqlParameter("@VB", SqlDbType.VarChar, 20));
            mysqlcon.Parameters["@VB"].Value = ((TextBox)gv.Rows[i].Cells[3].Controls[0]).Text;
            mysqlcon.Parameters.Add(new SqlParameter("@项目", SqlDbType.VarChar, 20));
            mysqlcon.Parameters["@项目"].Value = ((TextBox)gv.Rows[i].Cells[4].Controls[0]).Text;
            mysqlcon.Parameters.Add(new SqlParameter("@HTML", SqlDbType.VarChar, 20));
            mysqlcon.Parameters["@HTML"].Value = ((TextBox)gv.Rows[i].Cells[5].Controls[0]).Text;
            mysqlcon.Connection.Open();                       
            mysqlcon.ExecuteNonQuery();
            mysqlcon.Connection.Close(); 
             gv.EditIndex = -1;
            BindGrid();   
        }
        protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string myinsertcmd = "delete from TERM_TABLE where STD_ID=@学号";
            SqlCommand mysqlcom = new SqlCommand(myinsertcmd, con);
            int index = e.RowIndex;
            GridViewRow gvr = gv.Rows[index];
            mysqlcom.Parameters.Add(new SqlParameter("@学号", SqlDbType.VarChar, 50));
            mysqlcom.Parameters["@学号"].Value = gvr.Cells[0].Text;
            mysqlcom.Connection.Open();           
            mysqlcom.ExecuteNonQuery();
            gv.EditIndex = -1;
            mysqlcom.Connection.Close();
            BindGrid();
        }       
        protected void bt1_Click(object sender, EventArgs e)
    {
        this.Panel1.Visible = true;
        TextBox1.Focus();
    }
     protected void b1_Click(object sender, EventArgs e)
    {
        
            if (TextBox1.Text.Length != 8)
            {
                Label8.Text = "输入不正确";
            }
            else
            {
            string sql = "select STD_ID FROM TERM_TABLE WHERE STD_ID='"+TextBox1.Text+"'";
            SqlDataAdapter sda = new SqlDataAdapter(sql,con);
            DataSet ds = new DataSet();
            sda.Fill(ds,"ye");
            if (ds.Tables["ye"].Rows.Count != 0)
            {
                Label8.Visible = true;
                Label8.Text = "这条记录已存在";
            }
            else
            {
                string myinsertcmd = "insert into TERM_TABLE(STD_ID,TERM_C,TERM_SQL,TERM_VB,TERM_HTML,TERM_PROJECT)values(@学号,@C语言,@SQL,@VB,@HTML,@项目)";
                SqlCommand mysqlcom = new SqlCommand(myinsertcmd, con);
                mysqlcom.Parameters.Add(new SqlParameter("@学号", SqlDbType.VarChar, 50));
                mysqlcom.Parameters["@学号"].Value = TextBox1.Text;
                mysqlcom.Parameters.Add(new SqlParameter("@C语言", SqlDbType.VarChar, 20));
                mysqlcom.Parameters["@C语言"].Value = TextBox2.Text;
                mysqlcom.Parameters.Add(new SqlParameter("@SQL", SqlDbType.VarChar, 20));
                mysqlcom.Parameters["@SQL"].Value = TextBox3.Text;
                mysqlcom.Parameters.Add(new SqlParameter("@VB", SqlDbType.VarChar, 20));
                mysqlcom.Parameters["@VB"].Value = TextBox4.Text;
                mysqlcom.Parameters.Add(new SqlParameter("@项目", SqlDbType.VarChar, 20));
                mysqlcom.Parameters["@项目"].Value = TextBox5.Text;
                mysqlcom.Parameters.Add(new SqlParameter("@HTML", SqlDbType.VarChar, 20));
                mysqlcom.Parameters["@HTML"].Value = TextBox6.Text;
                mysqlcom.Connection.Open();
                mysqlcom.ExecuteNonQuery();
                gv.EditIndex = -1;
                mysqlcom.Connection.Close();
                BindGrid();
                this.Panel1.Visible = false;
            }
            }
           TextBox1.Text = "STD"; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = "";
    }     
    </script>   
</head>
<body bgcolor="#99ccff">
    <form id="form1" runat="server">
    <div>
        &nbsp;
        <div style="z-index: 101; left: 111px; width: 784px; position: absolute; top: 121px;
            height: 102px">
            &nbsp;&nbsp;
            <div style="z-index: 102; left: 4px; width: 486px; position: absolute; top: -10px;
                height: 31px">
                <asp:Panel ID="Panel2" runat="server" BorderColor="White" Height="27px" Width="777px" BackImageUrl="~/image/11.gif">
                    <asp:Button ID="Button1" runat="server" BorderStyle="None" Height="25px"
                        OnClick="Button1_Click" Text="首页" Width="52px" BackColor="BurlyWood" />|<asp:Button ID="Button2" runat="server"
                            BorderStyle="None" Height="24px" OnClick="Button2_Click" Text="編輯第一學期" Width="84px" BackColor="BurlyWood" />|<asp:Button
                                ID="Button3" runat="server" BorderStyle="None" Height="23px" OnClick="Button3_Click"
                                Text="編輯第二學期" Width="89px" BackColor="BurlyWood" />|<asp:Button ID="Button4" runat="server" BorderStyle="None"
                                    Height="25px" OnClick="Button4_Click" Text="編輯第二學年 " Width="79px" BackColor="BurlyWood" />|<asp:Button
                                        ID="Button5" runat="server" BorderStyle="None" Height="23px" OnClick="Button5_Click"
                                        Text="查看學生信息" Width="82px" BackColor="BurlyWood" />|<asp:Button ID="Button6" runat="server" BorderStyle="None"
                                            Height="24px" OnClick="Button6_Click" Text="留言" Width="43px" BackColor="BurlyWood" />
                </asp:Panel>
            </div>
            &nbsp;&nbsp;<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" Width="781px" OnRowEditing="gv_RowEditing" OnRowUpdating="gv_RowUpdating" OnRowCancelingEdit="gv_RowCancelingEdit" OnRowDeleting="gv_RowDeleting">
                <Columns>
                    <asp:BoundField DataField="STD_ID" HeaderText="学号">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TERM_C" HeaderText="C语言">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TERM_SQL" HeaderText="SQL">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TERM_VB" HeaderText="VB">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TERM_PROJECT" HeaderText="项目">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TERM_HTML" HeaderText="HTML">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:BoundField>                    
                    <asp:CommandField CancelText="取消" DeleteText="删除" EditText="编辑" HeaderText="编辑" ShowDeleteButton="True"
                        ShowEditButton="True" ShowHeader="True" UpdateText="更新">
                        <ItemStyle Font-Size="12px" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="BurlyWood" Font-Size="12px" HorizontalAlign="Center" />
                    </asp:CommandField>
                </Columns>
            </asp:GridView>
            <asp:Button ID="bt1" runat="server"  Text="增加" Width="48px" OnClick="bt1_Click" />&nbsp;
            &nbsp;
            <asp:Button ID="Button7" runat="server" OnClick="Button7_Click" Text="查询" Width="53px" />
            <asp:Panel ID="Panel1" runat="server" BorderColor="#400040" BorderStyle="Double"
                Height="92px" Width="772px" Visible="False">
                <asp:Label ID="Label1" runat="server" Text="学号:"></asp:Label>
                <asp:TextBox ID="TextBox1" runat="server" Width="129px" TabIndex="1">STD</asp:TextBox>
                &nbsp; &nbsp;
                <asp:Label ID="Label8" runat="server" Width="114px" ForeColor="#C000C0"></asp:Label><br />
                <asp:Label ID="Label2" runat="server" Text="C语言:"></asp:Label>
                <asp:TextBox ID="TextBox2" runat="server" Width="120px" TabIndex="2"></asp:TextBox>
                &nbsp; &nbsp;
                <asp:Label ID="Label3" runat="server" Text="HTML:"></asp:Label>
                <asp:TextBox ID="TextBox3" runat="server" Width="106px" TabIndex="3"></asp:TextBox>
                <asp:Label ID="Label5" runat="server" Text="VB:"></asp:Label>
                <asp:TextBox ID="TextBox6" runat="server" Width="111px" TabIndex="4"></asp:TextBox><br />
                <asp:Label ID="Label4" runat="server" Text="SQL:"></asp:Label>
                <asp:TextBox ID="TextBox4" runat="server" Width="133px" TabIndex="5"></asp:TextBox>
                &nbsp; &nbsp;&nbsp;
                <asp:Label ID="Label6" runat="server" Text="项目:"></asp:Label>
                <asp:TextBox ID="TextBox5" runat="server" Width="114px" TabIndex="6"></asp:TextBox>
                &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<asp:Button ID="b1" runat="server" Text="提交" Width="71px" OnClick="b1_Click" TabIndex="7" />&nbsp;&nbsp;&nbsp;
            </asp:Panel>
            <div style="z-index: 101; left: 4px; width: 100px; position: absolute; top: -124px;
                height: 108px">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/image/01.bmp" /></div>
        </div>
        &nbsp;&nbsp;<br />
        <br />
        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
        
            </div>
    </form>
</body>
</html>

⌨️ 快捷键说明

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