⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tianjia.cs

📁 Vs2005C#图书管理系统初学的看看有好处的
💻 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 tsh
{
    public partial class tianjia : Form
    {
        public tianjia()
        {
            InitializeComponent();
        }
         DB.ClsSQL sql = new DB.ClsSQL(".", "mylw", "sa", "", 3);
        DataSet ds;
        private void button1_Click(object sender, EventArgs e)
        {
            string s1="insert into readerc values('"+textBox1.Text.Trim()+"','"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"')";
            sql.SQLCommand(s1);
            MessageBox.Show("添加读者类别成功!!","提示");
            this.Close();
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("读者类别不能为空!!", "提示");
                    textBox1.Focus();
                }
                else
                {
                    string s = "select * from readerc where duzheleibie='" + textBox1.Text + "'";
                    ds = sql.DBToDS(s, "readerc");
                    int n = ds.Tables["readerc"].Rows.Count;
                    if (n != 0)
                    {
                        MessageBox.Show("读者类别已经存在,请添加新的类别!!", "提示");
                        textBox1.Text = "";
                        textBox1.Focus();
                    }
                    else
                    {
                        textBox1.Enabled = false;
                        textBox2.Enabled = true;
                        textBox2.Focus();
                    }
                }
            }

        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("可借书数不能为空!!!", "信息提示");
                    textBox2.Focus();
                }
                else
                {
                    textBox2.Enabled = false;
                    textBox3.Enabled = true;
                    textBox3.Focus();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = true;
            textBox1.Text = "";
            textBox1.Focus();
            textBox2.Text = "";
            textBox2.Enabled = false;
            textBox3.Text = "";
            textBox3.Enabled = false;
            button1.Enabled = false;
        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBox3.Text == "")
                {
                    MessageBox.Show("可借天数不能为空!!", "信息提示");
                    textBox3.Focus();
                }
                else
                {
                    textBox3.Enabled = false;
                    button1.Enabled = true;
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

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