📄 借书证件管理.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 图书馆管理系统
{
public partial class 借书证件管理 : Form
{
private BindingManagerBase naivegate;
public SqlDataReader myda;
public 借书证件管理()
{
InitializeComponent();
}
//------------搜索--------------
private void button1_Click(object sender, EventArgs e)
{
sqlConnection1.Open();
string str = "";
switch (comboBox1.SelectedIndex)
{
case 0:
str = "select * from 读者信息"; break;
case 1:
case 2:
case 3:
str = "select * from 读者信息 where " + comboBox1.Text + "='" + textBox1.Text + "'"; break;
default:
str = "select * from 读者信息"; break;
}
SqlDataAdapter myda = new SqlDataAdapter(str, sqlConnection1);
dataSet81.Clear();
myda.Fill(dataSet81, "读者信息");
sqlConnection1.Close();
}
//---------------------填数据---------------
private void 借书证件管理_Load(object sender, EventArgs e)
{
sqlDataAdapter1.Fill(dataSet81, "读者信息");
naivegate = this.BindingContext[dataSet81, "读者信息"];
this.toolTip1.SetToolTip(this.textBox1, "根据查询的字段设置查询的值且此查寻为精确查询!");
}
private void button2_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
// dataGrid1.Select(naivegate.Position);
// sqlConnection1.Open();
//// SqlDataReader myda = mycom.ExecuteReader();
// if (myda["是否挂失"].ToString().Trim() == "0")
// {
// MessageBox.Show("对不起你已经挂失过了!", "提示");
// }
// // else
// {
sqlConnection1.Open();
string str;
str = "update 读者信息 set 是否挂失='0' where "+comboBox1.Text+"='"+textBox1.Text+"'";
SqlCommand mycom = new SqlCommand(str, sqlConnection1);
int num = mycom.ExecuteNonQuery();
if (num == 1)
{
MessageBox.Show("更新成功!");
}
mycom.CommandText = "select * from 读者信息";
dataSet81.Clear();
SqlDataAdapter myda1= new SqlDataAdapter();
myda1.SelectCommand = mycom;
myda1.Fill(dataSet81, "读者信息");
sqlConnection1.Close();
//}
// myda.Close();
}
if(radioButton2.Checked==true)
{
// dataGrid1.Select(naivegate.Position);
// sqlConnection1.Open();
// SqlDataReader myda = mycom.ExecuteReader();
// if (myda["是否挂失"].ToString().Trim() == "1")
// {
// MessageBox.Show("对不起!你的证件没有挂失!", "提示");
// }
// else
// {
sqlConnection1.Open();
string str;
str = "update 读者信息 set 是否挂失='1' where " + comboBox1.Text + "='" + textBox1.Text + "'";
SqlCommand mycom = new SqlCommand(str, sqlConnection1);
int num = mycom.ExecuteNonQuery();
if (num == 1)
{
MessageBox.Show("更新成功!");
}
mycom.CommandText = "select * from 读者信息";
dataSet81.Clear();
SqlDataAdapter myda2 = new SqlDataAdapter();
myda2.SelectCommand = mycom;
myda2.Fill(dataSet81,"读者信息");
sqlConnection1.Close();
// }
// myda.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -