📄 jlxg.cs
字号:
this.label3.Text = "作者:";
//
// textBox3
//
this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox3.Location = new System.Drawing.Point(456, 38);
this.textBox3.MaxLength = 20;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(136, 26);
this.textBox3.TabIndex = 2;
this.textBox3.Text = "";
this.textBox3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// label4
//
this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.Location = new System.Drawing.Point(592, 41);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 4;
this.label4.Text = "出版社:";
//
// textBox4
//
this.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox4.Location = new System.Drawing.Point(664, 41);
this.textBox4.MaxLength = 20;
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(136, 26);
this.textBox4.TabIndex = 3;
this.textBox4.Text = "";
this.textBox4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.Location = new System.Drawing.Point(227, 30);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 40);
this.button1.TabIndex = 4;
this.button1.Text = "查 找";
this.button1.Click += new System.EventHandler(this.button1_Click);
this.button1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.Location = new System.Drawing.Point(323, 30);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 40);
this.button2.TabIndex = 5;
this.button2.Text = "更 新";
this.button2.Click += new System.EventHandler(this.button2_Click);
this.button2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.Location = new System.Drawing.Point(419, 30);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 40);
this.button3.TabIndex = 6;
this.button3.Text = "保 存";
this.button3.Click += new System.EventHandler(this.button3_Click);
this.button3.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button4.Location = new System.Drawing.Point(515, 30);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 40);
this.button4.TabIndex = 7;
this.button4.Text = "返 回";
this.button4.Click += new System.EventHandler(this.button4_Click);
this.button4.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox3_KeyDown);
//
// jlxg
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(816, 494);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "jlxg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "图书信息修改";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void button4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button3_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Update(this.dataSet21,"tsxxb");
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_Click(object sender, System.EventArgs e)
{
try
{
System.Data.OleDb.OleDbCommand MySelect = this.oleDbConnection1.CreateCommand();
MySelect.CommandText="SELECT * FROM tsxxb";
this.oleDbDataAdapter1.SelectCommand=MySelect;
this.dataSet21.Clear();
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Fill(this.dataSet21,"tsxxb");
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 tsxxb WHERE 编号='"+this.textBox1.Text+"'";
}
else
{
if(this.textBox2.Text != "")
{
if(ComStr=="")
{
ComStr="SELECT * FROM tsxxb WHERE 书名='"+this.textBox2.Text+"'";
}
else
{
ComStr+=" AND 书名='"+this.textBox2.Text+"'";
}
}
if(this.textBox3.Text != "")
{
if(ComStr=="")
{
ComStr="SELECT * FROM tsxxb WHERE 作者='"+this.textBox3.Text+"'";
}
else
{
ComStr+=" AND 作者='"+this.textBox3.Text+"'";
}
}
if(this.textBox4.Text != "")
{
if(ComStr=="")
{
ComStr="SELECT * FROM tsxxb WHERE 出版社='"+this.textBox4.Text+"'";
}
else
{
ComStr+=" AND 出版社='"+this.textBox4.Text+"'";
}
}
if(ComStr=="")
{
MessageBox.Show("无查询条件,默认查找所有记录.","查找提示: ",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
ComStr="SELECT * FROM tsxxb";
}
}
MySelect.CommandText=ComStr;
this.oleDbDataAdapter1.SelectCommand=MySelect;
this.dataSet21.Clear();
this.oleDbConnection1.Open();
this.oleDbDataAdapter1.Fill(dataSet21,"tsxxb");
this.oleDbConnection1.Close();
}
catch(Exception Exc)
{
MessageBox.Show(Exc.Message);
this.oleDbConnection1.Close();
}
}
private void textBox3_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 || this.textBox4.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.textBox4.Focused)
{
this.textBox3.Focus();
}
else
{
if(this.textBox3.Focused)
{
this.textBox2.Focus();
}
else
{
if(this.textBox2.Focused)
{
this.textBox1.Focus();
}
else
{
if(this.textBox1.Focused)
{
this.textBox4.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.textBox4.Focus();
}
else
{
if(this.textBox4.Focused)
{
this.textBox1.Focus();
}
}
}
}
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -