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

📄 dictionaryform.cs

📁 C++编写的房产中介管理系统
💻 CS
字号:
//文件名:DictionaryForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace MyHouse
{
    public partial class DictionaryForm : Form
    {
        public DictionaryForm()
        {
            InitializeComponent();
        }

        private void 房源参数名称ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyHouse.Properties.Settings.Default.MyHouseConnectionString;
            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.房源参数名称ListBox.Text;
            string MyValue = MyHouseTable.Rows[0][MyName].ToString();
            String[] MyData = MyValue.Split(new char[1] { '、'});
            this.房源参数值TextBox.Lines = MyData;
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 保存Button_Click(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyHouse.Properties.Settings.Default.MyHouseConnectionString;
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            string MyName = this.房源参数名称ListBox.Text;
            string MyValue = "";
            foreach (String MyLine in this.房源参数值TextBox.Lines)
            {
                MyValue += MyLine + "、";
            }
            string MySQL = "Update 房源参数字典 Set "+MyName+"='"+MyValue+"' Where 自编号='CQ001'";
            SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
            int MyCount=MyCommand.ExecuteNonQuery();
            MessageBox.Show("成功修改房源参数字典:"+MyName, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 其他参数名称ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyHouse.Properties.Settings.Default.MyHouseConnectionString;
            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.其他参数名称ListBox.Text;
            string MyValue = MyHouseTable.Rows[0][MyName].ToString();
            String[] MyData = MyValue.Split(new char[1] { '、' });
            this.其他参数值TextBox.Lines = MyData;
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }

        private void 重置Button_Click(object sender, EventArgs e)
        {
            String MySQLConnectionString = global::MyHouse.Properties.Settings.Default.MyHouseConnectionString;
            SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
            MyConnection.Open();
            string MyName = this.其他参数名称ListBox.Text;
            string MyValue = "";
            foreach (String MyLine in this.其他参数值TextBox.Lines)
            {
                MyValue += MyLine + "、";
            }
            string MySQL = "Update 其他参数字典 Set " + MyName + "='" + MyValue + "' Where 自编号='CQ001'";
            SqlCommand MyCommand = new SqlCommand(MySQL, MyConnection);
            int MyCount = MyCommand.ExecuteNonQuery();
            MessageBox.Show("成功修改其他参数字典:" + MyName, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            if (MyConnection.State == ConnectionState.Open)
            {
                MyConnection.Close();
            }
        }
    }
}

⌨️ 快捷键说明

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