selectbook.cs

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

CS
64
字号
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 Selectbook : Form
    {
        public Selectbook()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            sqlConnection1.Open();
            string str = "";
            if (textBox1.Text == "" && textBox2.Text == "")
            {
                str = "select * from 图书信息";
            }
            else
            {
                if (textBox1.Text != "" && textBox2.Text != "")
                {
                    str = "select * from 图书信息 where 书名='" + textBox1.Text + "' and 编号='" + textBox2.Text + "'";
                }
                if (textBox1.Text != "" && textBox2.Text == "")
                {
                    str = "select * from 图书信息 where 书名='" + textBox1.Text + "'";
                }
                if (textBox1.Text == "" && textBox2.Text != "")
                {
                    str = "select * from 图书信息 where 编号='" + textBox2.Text + "'";
                }

            }
            dataSet41.Clear();
            SqlDataAdapter myda = new SqlDataAdapter(str, sqlConnection1);
            myda.Fill(dataSet41, "图书信息");
            sqlConnection1.Close();
        }

        private void Selectbook_Load(object sender, EventArgs e)
        {
            sqlDataAdapter1.Fill(dataSet41,"图书信息");
        }

        private void dataGrid1_DoubleClick(object sender, EventArgs e)
        {
            int rows = dataGrid1.CurrentCell.RowNumber;
            图书征定.bookID = dataGrid1[rows, 1].ToString();
            图书征定.bookName = dataGrid1[rows, 2].ToString();
            图书档案管理.shuJiaName = dataGrid1[rows, 10].ToString();
            图书档案管理.leiXing = dataGrid1[rows, 3].ToString();
            this.Close();
        }
    }
}

⌨️ 快捷键说明

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