点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 尚未分类>> Asp.net学生信息管理系统源码>> 源文件浏览
[免费版 Free] WebForm,下载次数:27939 次 | 关键字: 学生信息 存储过程 课程设计

源码截图

源码目录树

当前路径:coursetype.aspx.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;

public partial class coursetype: System.Web.UI.Page
{
    SqlConnection sms_conn;
    string sqlstr;
    protected void Page_Load(object sender, EventArgs e)
    { 
        string sms_connstr = ConfigurationSettings.AppSettings["sms_dbconn"];
        // 建立连接
        sms_conn = new SqlConnection(sms_connstr); 
          
        if (!IsPostBack)
        {
            SMS_BindRepeater();
            sqlstr = "select * from coursetype";
            SqlDataAdapter cmd = new SqlDataAdapter(sqlstr, sms_conn);
            //创建填充 DataSet.
            DataSet ds = new DataSet();
            cmd.Fill(ds, "T");        
            for (int i = 0; i < ds.Tables["T"].Rows.Count; i++)
            {
                DropDownList1.Items.Add(new ListItem(ds.Tables["T"].Rows[i]["typename"].ToString(), ds.Tables["T"].Rows[i]["coursetypeid"].ToString()));
            }
            ds.Clear();
            ds.Dispose();
            sms_conn.Close();
            sms_conn.Dispose();
        }
        
    }
    private void SMS_BindRepeater()
    {
        sqlstr = "select * from coursetype";
        SqlDataAdapter cmd = new SqlDataAdapter(sqlstr,sms_conn);
        //创建填充 DataSet.
        DataSet ds = new DataSet();
        cmd.Fill(ds, "TD1");
        RepeaterD.DataSource = ds.Tables["TD1"];
        RepeaterD.DataBind();
        ds.Clear();
        ds.Dispose();         
    }
    public void RepeaterIC(object sender,RepeaterCommandEventArgs e)
    {
            System.Web.UI.WebControls.LinkButton  update = (LinkButton)e.Item.FindControl("LinkButton2");//找到这个按钮
            System.Web.UI.WebControls.LinkButton  cancel = (LinkButton)e.Item.FindControl("LinkButton1");//找到这个按钮
            System.Web.UI.WebControls.LinkButton edit = (LinkButton)e.Item.FindControl("LinkButton3");
            System.Web.UI.WebControls.LinkButton delete = (LinkButton)e.Item.FindControl("LinkButton4");
            System.Web.UI.WebControls.Label LabDepid = (Label)e.Item.FindControl("LabDepid");
            System.Web.UI.WebControls.Label LabDepname = (Label)e.Item.FindControl("LabDepname");      
            System.Web.UI.WebControls.TextBox TetDepid = (TextBox)e.Item.FindControl("TxtDepid");
            System.Web.UI.WebControls.TextBox TetDepname = (TextBox)e.Item.FindControl("TxtDepname");                
        if (e.CommandName == "edit")
        {           
            update.Visible = true;          
            cancel.Visible = true;
            edit.Visible = false;
            LabDepname.Visible = false;    
            TetDepname.Visible = true;           
      
        }
        if (e.CommandName == "cancel")
        {
            SMS_BindRepeater();
        }
        if (e.CommandName == "update")
        {
            sqlstr = "update coursetype set typename='" + TetDepname.Text + "'where coursetypeid='" + LabDepid.Text + "'";

            SqlCommand sqlcom = new SqlCommand(sqlstr, sms_conn);
            sms_conn.Open();
            sqlcom.ExecuteNonQuery();            
            SMS_BindRepeater();
            sms_conn.Close();
        }
        if (e.CommandName == "delete")
        {
            sqlstr = "delete coursetype where coursetypeid='" + LabDepid.Text + "'";
            SqlCommand sqlcom = new SqlCommand(sqlstr, sms_conn);
            sms_conn.Open();
            sqlcom.ExecuteNonQuery();
            SMS_BindRepeater();
            sms_conn.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        sqlstr = "select * from coursetype where coursetypeid='"+DropDownList1.SelectedValue.ToString() +"'";
        SqlDataAdapter cmd = new SqlDataAdapter(sqlstr, sms_conn);
        //创建填充 DataSet.
        DataSet ds = new DataSet();
        cmd.Fill(ds, "TD1");
        RepeaterD.DataSource = ds.Tables["TD1"];
        RepeaterD.DataBind();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        SMS_BindRepeater();
    }
    protected void LinkButtonADD_Click(object sender, EventArgs e)
    {
        Response.Redirect("addcoursetype.aspx");
    }    
}


关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:4000410510
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
在线客服
分享该页面
关闭侧边栏