📄 zlxg.cs
字号:
this.ResumeLayout(false);
}
#endregion
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void zlxg_Load(object sender, System.EventArgs e)
{
this.textBox1.Focus();
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
MySelect.CommandText="SELECT * FROM ygxxb";
this.oleDbDataAdapter1.SelectCommand=MySelect;
this.dataSet21.Clear();
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");
this.oleDbConnection1.Close();
}
catch(Exception Exc)
{
MessageBox.Show(Exc.Message);
this.oleDbConnection1.Close();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
string ComStr="";
try
{
System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
if( this.textBox1.Text != "")
{
ComStr="SELECT * FROM ygxxb WHERE 用户名='"+this.textBox1.Text+"'";
}
else
{
if(this.textBox2.Text != "")
{
if(ComStr=="")
{
ComStr="SELECT * FROM ygxxb WHERE 姓名='"+this.textBox2.Text+"'";
}
else
{
ComStr+=" AND 姓名='"+this.textBox2.Text+"'";
}
}
if(this.textBox3.Text != "")
{
if(ComStr=="")
{
ComStr="SELECT * FROM ygxxb WHERE 手机='"+this.textBox3.Text+"'";
}
else
{
ComStr+=" AND 手机='"+this.textBox3.Text+"'";
}
}
if(ComStr=="")
{
MessageBox.Show("无查询条件,默认查找所有记录.","查找提示: ",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
ComStr="SELECT * FROM ygxxb";
}
}
MySelect.CommandText=ComStr;
this.oleDbDataAdapter1.SelectCommand=MySelect;
this.dataSet21.Clear();
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Fill(dataSet21,"ygxxb");
this.oleDbConnection1.Close();
}
catch(Exception Exc)
{
MessageBox.Show(Exc.Message);
this.oleDbConnection1.Close();
}
}
private void button3_Click_1(object sender, System.EventArgs e)
{
try
{
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Update(this.dataSet21,"ygxxb");
this.oleDbConnection1.Close();
MessageBox.Show("信息已经保存.","保存提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.dataSet21.Clear();
}
catch(Exception Exc)
{
MessageBox.Show(Exc.Message);
this.oleDbConnection1.Close();
}
}
private void button2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch((int)e.KeyCode)
{
case 27:
this.Close();
break;
case 13:
if(this.button1.Focused || this.textBox1.Focused || this.textBox2.Focused || this.textBox3.Focused)
{
button1_Click(null,null);
}
if(this.button2.Focused)
{
button2_Click(null,null);
}
if(this.button3.Focused)
{
button3_Click(null,null);
}
if(this.button4.Focused)
this.Close();
break;
case 38:
case 37:
if(this.textBox3.Focused)
{
this.textBox2.Focus();
}
else
{
if(this.textBox2.Focused)
{
this.textBox1.Focus();
}
else
{
if(this.textBox1.Focused)
{
this.textBox3.Focus();
}
}
}
break;
case 40:
case 39:
if(this.textBox1.Focused)
{
this.textBox2.Focus();
}
else
{
if(this.textBox2.Focused)
{
this.textBox3.Focus();
}
else
{
if(this.textBox3.Focused)
{
this.textBox1.Focus();
}
}
}
break;
}
}
private void textBox3_TextChanged(object sender, System.EventArgs e)
{
string s="";
for(int i=0;i<textBox3.Text.Length;i++)
if(Char.IsDigit(textBox3.Text[i])==true)
s=s+textBox3.Text[i].ToString();
textBox3.Text=s;
textBox3.SelectionStart=textBox3.Text.Length;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -