📄 xiugaiduzhexinxi.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tsh
{
public partial class xiugaiduzhexinxi : Form
{
public xiugaiduzhexinxi()
{
InitializeComponent();
}
DB.ClsSQL sql = new DB.ClsSQL(".", "mylw", "sa", "", 3);
DataSet ds, ds1;
private string textb;
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
if (textBox1.Text == "")
{
MessageBox.Show("读者编号不能为空!!!", "提示");
}
else
{
textb = textBox1.Text;
string s = "select * from reader where duzhebianhao='" + textb + "'";
ds = sql.DBToDS(s, "reader");
int n = ds.Tables["reader"].Rows.Count;
dataGridView1.DataSource = ds.Tables["reader"];
if (n == 0)
{
MessageBox.Show("无此读者编号!!!", "提示");
buttgx.Enabled = false;
dataGridView1.ReadOnly = true;
}
else
{
string s1 = "select * from borrow where duzhebianhao='" + textb + "'";
ds1 = sql.DBToDS(s1, "borrow");
int i = ds1.Tables["borrow"].Rows.Count;
if (i != 0)
{
MessageBox.Show("该读者已从本馆借了书,不允许修改其数据!!", "提示");
buttgx.Enabled = false;
dataGridView1.ReadOnly = true;
}
else
{
buttgx.Enabled = true;
dataGridView1.ReadOnly = false;
}
}
}
textBox1.Text = "";
textBox1.Focus();
}
}
private void buttgx_Click(object sender, EventArgs e)
{
try
{
string s3 = "update reader set duzhexingming ='" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "',duzheleibie='" + dataGridView1.CurrentRow.Cells[2].Value.ToString() + "',shuzhengzhuangtai='" + dataGridView1.CurrentRow.Cells[3].Value.ToString() + "',xingbie='" + dataGridView1.CurrentRow.Cells[4].Value.ToString() + "',danwei='" + dataGridView1.CurrentRow.Cells[5].Value.ToString() + "',dianhua='" + dataGridView1.CurrentRow.Cells[6].Value.ToString() + "',Email='" + dataGridView1.CurrentRow.Cells[7].Value.ToString() + "' where duzhebianhao='" + textb + "'";
sql.SQLCommand(s3);
MessageBox.Show("已成功更新记录!!", "提示");
buttgx.Enabled = false;
dataGridView1.ReadOnly = true;
}
catch (Exception Exc)
{
MessageBox.Show(Exc.Message, "警告");
}
}
private void butttch_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -