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

📄 addtelnum.aspx.cs

📁 ASP.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 System.Data.OleDb;

public partial class Addtelnum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            OleDbConnection con = DB.mycon();
            con.Open();
            OleDbCommand cmm = new OleDbCommand("select distinct bmID,bmName from bmTable", con);
            OleDbDataReader ddr = cmm.ExecuteReader();
            this.DropDownList1.DataSource = ddr;
            this.DropDownList1.DataTextField = "bmName";
            this.DropDownList1.DataValueField = "bmID";
            this.DropDownList1.DataBind();
            ddr.Close();

            OleDbCommand com = new OleDbCommand("select bsID,bsName from bmTable where bmID = '" + DropDownList1.Text.ToString().Trim() + "'", con);
            OleDbDataReader ddrr = com.ExecuteReader();
            this.DropDownList2.DataSource = ddrr;
            this.DropDownList2.DataTextField = "bsName";
            this.DropDownList2.DataValueField = "bsID";
            this.DropDownList2.DataBind();
            ddrr.Close();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        OleDbConnection con = DB.mycon();
        con.Open();
        OleDbCommand com = new OleDbCommand("select bsID,bsName from bmTable where bmID = '" + DropDownList1.Text.ToString().Trim() + "'", con);
        OleDbDataReader ddrr = com.ExecuteReader();
        this.DropDownList2.DataSource = ddrr;
        this.DropDownList2.DataTextField = "bsName";
        this.DropDownList2.DataValueField = "bsID";
        this.DropDownList2.DataBind();
        ddrr.Close();
        con.Close();
    }
    protected void btnok_Click(object sender, EventArgs e)
    {
        if (DropDownList1.Text.Trim() != "" || DropDownList2.Text.Trim() != ""|| TextBox1.Text.Trim() != "" || TextBox2.Text.Trim() != "")
        {
            DB.SqlDo("insert into telph(bmID,bsID,telnumber,telperson) values('" + DropDownList1.Text.ToString().Trim() + "','" + DropDownList2.Text.ToString().Trim() + "','" + TextBox2.Text.ToString().Trim() + "','" + TextBox1.Text.ToString().Trim() + "')");
            TextBox1.Text = "";
            TextBox2.Text = "";
        }
    }
}

⌨️ 快捷键说明

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