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

📄 parameterform.aspx.cs

📁 一个房屋中介系统的源码
💻 CS
字号:
//文件名:ParameterForm.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;
//do u know 51aspx?
using System.Data.SqlClient;
public partial class CompanyManage_ParameterForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("A1") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        this.Button1.OnClientClick = "return confirm('请检查房源参数值是否正确并符合规范,否则保存后发生意外的结果!是否继续?')";
        this.Button2.OnClientClick = "return confirm('请检查其他参数值是否正确并符合规范,否则保存后发生意外的结果!是否继续?')";    
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {//显示房源参数值
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString;
        string MySQL = "Select * From 房源参数 Where 自编号='CQ001'";
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        DataTable MyHouseTable = new DataTable();
        SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
        MyAdapter.Fill(MyHouseTable);
        string MyName = this.DropDownList1.SelectedValue.ToString();
        string MyValue = MyHouseTable.Rows[0][MyName].ToString();
        String[] MyData = MyValue.Split(new char[1] { '、' });
        this.TextBox1.Text = "";
        foreach (string MyLine in MyData)
        {
            if (MyLine.Length > 0)
            {
                this.TextBox1.Text += MyLine + "、";
            }
        }
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//新增房源参数值
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MyName = this.DropDownList1.SelectedValue.ToString();       
        string MyValue = this.TextBox1.Text;
        string MySQL = "Update 房源参数 Set " + MyName + "='" + MyValue + "' Where 自编号='CQ001'";
        SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {//显示其他参数值
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString;
        string MySQL = "Select * From 其他参数 Where 自编号='CQ001'";
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        DataTable MyHouseTable = new DataTable();
        SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
        MyAdapter.Fill(MyHouseTable);
        string MyName = this.DropDownList2.SelectedValue.ToString();
        string MyValue = MyHouseTable.Rows[0][MyName].ToString();
        String[] MyData = MyValue.Split(new char[1] { '、' });
        this.TextBox2.Text = "";
        foreach (string MyLine in MyData)
        {
            if (MyLine.Length > 0)
            {
                this.TextBox2.Text += MyLine + "、";
            }
        }
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//新增其他参数值
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        string MyName = this.DropDownList2.SelectedValue.ToString();
        string MyValue = this.TextBox2.Text;
        string MySQL = "Update 其他参数 Set " + MyName + "='" + MyValue + "' Where 自编号='CQ001'";
        SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
}

⌨️ 快捷键说明

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