续证管理.cs

来自「图书管理系统源代码,很图书管理系统源代码,很不错,有参考作用不错,有参考作用」· CS 代码 · 共 66 行

CS
66
字号
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
    {
        public 续证管理()
        {
            InitializeComponent();
        }

        private void 续证管理_Load(object sender, EventArgs e)
        {
            sqlDataAdapter1.Fill(dataSet91,"读者信息");
            this.toolTip1.SetToolTip(this.textBox1,"根据查询字段设置查询值,此查询为精确查询!");
        }

        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:
                   str = "select * from 读者信息 where " + comboBox1.Text + "='" +textBox1.Text+ "'"; break;
                default:
                    str = "select * from 读者信息"; break;
            }
            SqlDataAdapter myda = new SqlDataAdapter(str, sqlConnection1);
            dataSet91.Clear();
            myda.Fill(dataSet91, "读者信息");
            sqlConnection1.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            sqlConnection1.Open();
            SqlCommand mycom = new SqlCommand("update 读者信息 set 有限期至='"+textBox7.Text+"' where "+comboBox1.Text+"="+textBox1.Text.ToString().Trim(),sqlConnection1);
           // mycom.ExecuteNonQuery();
            int num = mycom.ExecuteNonQuery();
            if (num == 1)
            {
                MessageBox.Show("更新成功!");
            }
            mycom.CommandText = "select * from 读者信息";
            dataSet91.Clear();
            SqlDataAdapter myda = new SqlDataAdapter();
            myda.SelectCommand = mycom;
            myda.Fill(dataSet91,"读者信息");
            sqlConnection1.Close();


        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?