📄 guke.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.Threading;
namespace WindowsApplication2
{
public partial class GuKe : Form
{
public GuKe()
{
InitializeComponent();
}
private void GuKe_Load(object sender, EventArgs e)
{
Database db = new Database();
DataSet ds = db.query("select * from 顾客信息表", "per");
this.dataGridView1.DataSource = ds.Tables["per"];
DataColumnCollection dcc = ds.Tables["per"].Columns;//获得列的集合
foreach (DataColumn var in dcc)
{
string lieming = var.ColumnName;//获得列名
comboBox1.Items.Add(lieming);
comboBox1.SelectedIndex = 0;
}
}
private void button5_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(fun));
th.Start();
this.Close();
}
private void fun()
{
new Form2().ShowDialog();
}
private void dataGridView1_Click(object sender, EventArgs e)
{
dataGridView1.CurrentRow.Selected = true;
int index = dataGridView1.CurrentRow.Index;
textBox2.Text = dataGridView1[0, index].Value.ToString();
textBox3.Text = dataGridView1[1, index].Value.ToString();
textBox4.Text = dataGridView1[2, index].Value.ToString();
textBox5.Text = dataGridView1[3, index].Value.ToString();
textBox6.Text = dataGridView1[4, index].Value.ToString();
textBox7.Text = dataGridView1[5, index].Value.ToString();
textBox8.Text = dataGridView1[6, index].Value.ToString();
textBox9.Text = dataGridView1[7, index].Value.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
string sql = string.Format("select * from 顾客信息表 where {0} like '%{1}%' ",
comboBox1.Text, textBox1.Text);
DataSet ds = new Database().query(sql, "por");
dataGridView1.DataSource = ds.Tables["por"];
}
private void button2_Click(object sender, EventArgs e)
{
string sql = string.Format("insert into 顾客信息表 (顾客编号, 顾客姓名, 性别, 联系电话, 身份证号码, 电子邮箱,家庭住址, 邮政编码)" +
" values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text,
textBox8.Text, textBox9.Text
);
new Database().insert(sql);
GuKe_Load(sender, e);
}
private void button3_Click(object sender, EventArgs e)
{
int index = dataGridView1.CurrentRow.Index;
string sql = string.Format("delete from 顾客信息表 where 顾客编号={0}",
dataGridView1[0, index].Value.ToString());
new Database().insert(sql);
GuKe_Load (sender, e);
}
private void button4_Click(object sender, EventArgs e)
{
int index = dataGridView1.CurrentRow.Index;
string sql = string.Format(
"update 顾客信息表 set 顾客编号='{0}', 顾客姓名='{1}', 性别='{2}', 联系电话='{3}', 身份证号码='{4}', 电子邮箱='{5}', 家庭住址='{6}', 邮政编码='{7}'" +
" where 顾客编号={0}", textBox2.Text, textBox3.Text, textBox4.Text,
textBox5.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text,
dataGridView1[0, index].Value.ToString());
new Database().insert(sql);
GuKe_Load (sender, e);
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -