📄 duzhexinxichaxun.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 tsh
{
public partial class duzhexinxichaxun : Form
{
public duzhexinxichaxun()
{
InitializeComponent();
}
DB.ClsSQL sql=new DB.ClsSQL(".","mylw","sa","",3);
DataSet ds;
private void duzhexinxichaxun_Load(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox3.Text == "")
{
string s = "select * from reader ";
ds = sql.DBToDS(s, "reader");
dataGridView3.DataSource = ds.Tables["reader"];
}
else
{
string s = "select * from reader where duzheleibie='" + textBox3.Text.Trim() + "'";
ds = sql.DBToDS(s, "reader");
if (ds.Tables["reader"].Rows.Count == 0)
{
MessageBox.Show("无此读者类别!!", "查询信息");
textBox3.Text = "";
textBox3.Focus();
}
else
{
dataGridView3.DataSource = ds.Tables["reader"];
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
string s = "select * from reader ";
ds = sql.DBToDS(s, "reader");
dataGridView1.DataSource = ds.Tables["reader"];
}
else
{
string s = "select * from reader where duzhebianhao='" + textBox1.Text.Trim() + "'";
ds = sql.DBToDS(s, "reader");
if (ds.Tables["reader"].Rows.Count == 0)
{
MessageBox.Show("无此读者编号!!", "查询信息");
textBox1.Text = "";
textBox1.Focus();
}
else
{
dataGridView1.DataSource = ds.Tables["reader"];
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox2.Text == "")
{
string s = "select * from reader ";
ds = sql.DBToDS(s, "reader");
dataGridView2.DataSource = ds.Tables["reader"];
}
else
{
string s = "select * from reader where duzhexingming like '%" + textBox2.Text.Trim() + "%'";
ds = sql.DBToDS(s, "reader");
if (ds.Tables["reader"].Rows.Count == 0)
{
MessageBox.Show("无此读者姓名!", "查询信息");
textBox2.Text = "";
textBox2.Focus();
}
else
{
dataGridView2.DataSource = ds.Tables["reader"];
}
}
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox4.Text == "")
{
string s = "select * from reader ";
ds = sql.DBToDS(s, "reader");
dataGridView4.DataSource = ds.Tables["reader"];
}
else
{
string s = "select * from reader where danwei like '%" + textBox4.Text.Trim() + "%'";
ds = sql.DBToDS(s, "reader");
if (ds.Tables["reader"].Rows.Count == 0)
{
MessageBox.Show("无此读者单位!!", "查询信息");
textBox4.Text = "";
textBox4.Focus();
}
else
{
dataGridView4.DataSource = ds.Tables["reader"];
}
}
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox5.Text == "")
{
string s = "select * from reader ";
ds = sql.DBToDS(s, "reader");
dataGridView5.DataSource = ds.Tables["reader"];
}
else
{
string s = "select * from reader where dianhua like '%" + textBox5.Text.Trim() + "%'";
ds = sql.DBToDS(s, "reader");
if (ds.Tables["reader"].Rows.Count == 0)
{
MessageBox.Show("无此读者电话!!", "查询信息");
textBox5.Text = "";
textBox5.Focus();
}
else
{
dataGridView5.DataSource = ds.Tables["reader"];
}
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
e.Handled = true;
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
// if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
// {
// if (e.KeyChar == '.')
// {
// if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
// e.Handled = true;
// }
// else
// e.Handled = true;
// }
// else
// {
// if (e.KeyChar <= 31)
// {
// e.Handled = false;
// }
// else if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
// {
// if (((TextBox)sender).Text.Trim().Substring(((TextBox)sender).Text.Trim().IndexOf('.') + 1).Length >= 2)
// e.Handled = true;
// }
// }
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 0)
textBox1.Focus();
if (tabControl1.SelectedIndex == 1)
textBox2.Focus();
if(tabControl1.SelectedIndex == 2)
textBox3.Focus();
if (tabControl1.SelectedIndex == 3)
textBox4.Focus();
if (tabControl1.SelectedIndex ==4)
textBox5.Focus();
}
private void duzhexinxichaxun_Activated(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 0)
textBox1.Focus();
if (tabControl1.SelectedIndex == 1)
textBox2.Focus();
if (tabControl1.SelectedIndex == 2)
textBox3.Focus();
if (tabControl1.SelectedIndex == 3)
textBox4.Focus();
if (tabControl1.SelectedIndex == 4)
textBox5.Focus();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -