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

📄 tianjiaduzhexinxi.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 tianjiaduzhexinxi : Form
    {
        public tianjiaduzhexinxi()
        {
            InitializeComponent();
        }
        DB.ClsSQL sql=new DB.ClsSQL(".","mylw","sa","",3);
        DataSet ds;
        private void tianjiaduzhexinxi_Load(object sender, EventArgs e)
        {

        }

        private void textBbh_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar==13)
            {
                if (textBbh.Text == "")
                {
                    MessageBox.Show("读者编号不能为空,请输入读者编号!!!", "提示");
                    textBbh.Focus();
                }
                else
                {
                    string s = "select * from reader where duzhebianhao='" + textBbh.Text + "'";
                    ds = sql.DBToDS(s, "reader");
                    int n = ds.Tables["reader"].Rows.Count;
                    if (n != 0)
                    {
                        MessageBox.Show("已存在该编号的读者信息,请输入编码另外的编号!!", "信息");
                        buttqx_Click(null, null);
                    }
                    else
                    {
                        textBbh.Enabled = false;
                        textBxm.Enabled = true;
                        textBxm.Focus();
                    }
                }
            }
        }

        private void textBbh_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBbh.Text == "")
                {
                    MessageBox.Show("读者编号不能为空,请输入读者编号!!!", "提示");
                    textBbh.Focus();
                }
                else
                {
                    string s = "select * from reader where duzhebianhao='" + textBbh.Text + "'";
                    ds = sql.DBToDS(s, "reader");
                    int n = ds.Tables["reader"].Rows.Count;
                    if (n != 0)
                    {
                        MessageBox.Show("已存在该编号的读者信息,请输入编码另外的编号!!", "信息");

                    }
                    else
                    {
                        textBbh.Enabled = false;
                        textBxm.Enabled = true;
                        textBxm.Focus();
                    }
                }
            }
            //if (e.KeyCode.ToString() == "Up")
            //{
            //    if (textBbh.Text == "")
            //    {
            //        MessageBox.Show("读者编号不能为空,请输入读者编号!!!", "提示");
            //        textBbh.Focus();
            //    }
            //    else
            //    {
            //        string s = "select * from reader where duzhebianhao='" + textBbh.Text + "'";
            //        ds = sql.DBToDS(s, "reader");
            //        int n = ds.Tables["reader"].Rows.Count;
            //        if (n != 0)
            //        {
            //            MessageBox.Show("已存在该编号的读者信息,请输入编码另外的编号!!", "信息");

            //        }
            //        else
            //        {
            //            textBbh.Enabled = false;
            //            textBE.Enabled = true;
            //            textBE.Focus();
            //        }
            //    }
            //}
           
        }

        private void buttqx_Click(object sender, EventArgs e)
        {
            textBbh.Text = "";
            textBbh.Focus();
            textBbh.Enabled=true;
            textBdh.Text = "";
            textBdh.Enabled = false;
            textBdw.Text = "";
            textBdw.Enabled=false;
            textBE.Text = "";
            textBE.Enabled=false;
            textBxm.Text = "";
            textBxm.Enabled=false;
            textBzht.Text = "";
            textBzht.Enabled = false;
            comboBlb.Text = "";
            comboBlb.Enabled = false;
            //comboBxb.Text = "";
            comboBxb.Enabled = false;
            buttbc.Enabled = false;
            buttqx.Enabled = false;

        }

        private void textBxm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBxm.Text == "")
                {
                    MessageBox.Show("读者姓名不能为空,请输入读者姓名!!!", "提示");
                    textBxm.Focus();
                }
                else
                {

                    textBxm.Enabled = false;
                    comboBlb.Enabled = true;
                    comboBlb.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                //textBxm.Text = "";
                textBxm.Enabled = false;
                textBbh.Enabled = true;
                textBbh.Focus();
            }
            
        }

        private void textBxm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBxm.Text == "")
                {
                    MessageBox.Show("读者姓名不能为空,请输入读者姓名!!!", "提示");
                    textBxm.Focus();
                }
                else
                {

                    textBxm.Enabled = false;

                    comboBlb.Enabled = true;
                    comboBlb.Focus();
                }
            }
        }

        private void comboBlb_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString()=="Down")
            {
                if (comboBlb.Text == "")
                {
                    MessageBox.Show("读者类别不能为空,请输入读者类别!!!", "提示");
                    comboBlb.Focus();
                }
                else
                {

                    comboBlb.Enabled = false;
                    textBzht.Enabled = true;
                    textBzht.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                comboBlb.Enabled = false;
                textBxm.Enabled = true;
                textBxm.Focus();
            }

        }

        private void comboBlb_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (comboBlb.Text == "")
                {
                    MessageBox.Show("读者类别不能为空,请输入读者类别!!!", "提示");
                    comboBlb.Focus();
                }
                else
                {

                    comboBlb.Enabled = false;
                    textBzht.Enabled = true;
                    textBzht.Focus();
                }
            }
        }

        private void textBzht_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar==13)
            {
                if (textBzht.Text == "")
                {
                    MessageBox.Show("书证状态不能为空,请输入书证状态!!!", "提示");
                    textBzht.Focus();
                }
                else
                {

                    textBzht.Enabled = false;
                    comboBxb.Enabled = true;
                    comboBxb.Focus();
                }
            }
        }

        private void textBzht_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBzht.Text == "")
                {
                    MessageBox.Show("书证状态不能为空,请输入书证状态!!!", "提示");
                    textBzht.Focus();
                }
                else
                {

                    textBzht.Enabled = false;
                    comboBxb.Enabled = true;
                    comboBxb.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                //textBxm.Text = "";
                textBzht.Enabled = false;
                comboBlb.Enabled = true;
                comboBlb.Focus();
            }
        }

        private void comboBxb_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (comboBxb.Text == "")
                {
                    MessageBox.Show("读者性别不能为空,请输入读者性别!!!", "提示");
                    comboBxb.Focus();
                }
                else
                {

                    comboBxb.Enabled = false;
                    textBdw.Enabled = true;
                    textBdw.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                comboBxb.Enabled = false;
                textBzht.Enabled = true;
                textBzht.Focus();
            }
        }

        private void comboBxb_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (comboBxb.Text == "")
                {
                    MessageBox.Show("读者性别不能为空,请输入读者性别!!!", "提示");
                    comboBxb.Focus();
                }
                else
                {

                    comboBxb.Enabled = false;
                    textBdw.Enabled = true;
                    textBdw.Focus();
                }
            }
        }

        private void textBdw_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBdw.Text == "")
                {
                    MessageBox.Show("读者单位不能为空,请输入读者单位!!!", "提示");
                    textBdw.Focus();
                }
                else
                {

                    textBdw.Enabled = false;
                    textBdh.Enabled = true;
                    textBdh.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                comboBxb.Enabled = true;
                textBdw.Enabled = false;
                textBdw.Focus();
            }

        }

        private void textBdw_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar==13)
            {
                if (textBdw.Text == "")
                {
                    MessageBox.Show("读者单位不能为空,请输入读者单位!!!", "提示");
                    textBdw.Focus();
                }
                else
                {

                    textBdw.Enabled = false;
                    textBdh.Enabled = true;
                    textBdh.Focus();
                }
            }
        }

        private void textBdh_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBdh.Text == "")
                {
                    MessageBox.Show("读者电话不能为空,请输入读者电话!!!", "提示");
                    textBdh.Focus();
                }
                else
                {

                    textBdh.Enabled = false;
                    textBE.Enabled = true;
                    textBE.Focus();
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                textBdw.Enabled = true;
                textBdh.Enabled = false;
                textBdw.Focus();
            }
         
        }

        private void textBdh_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBdh.Text == "")
                {
                    MessageBox.Show("读者电话不能为空,请输入读者电话!!!", "提示");
                    textBdh.Focus();
                }
                else
                {

                    textBdh.Enabled = false;
                    textBE.Enabled = true;
                    textBE.Focus();
                }
            }
        }

        private void textBE_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down")
            {
                if (textBE.Text == "")
                {
                    MessageBox.Show("读者Email不能为空,请输入读者Email!!!", "提示");
                    textBE.Focus();
                }
                else
                {

                    textBE.Enabled = false;
                    //textBbh.Enabled = true;
                    //textBbh.Focus();
                    buttbc.Enabled = true;
                    buttqx.Enabled = true;
                }
            }
            if (e.KeyCode.ToString() == "Up")
            {
                textBdh.Enabled = true;
                textBE.Enabled = false;
                textBdh.Focus();
                buttbc.Enabled = false;
                buttqx.Enabled = false;
            }
        }

        private void textBE_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar==13)
            {
                if (textBE.Text == "")
                {
                    MessageBox.Show("读者Email不能为空,请输入读者Email!!!", "提示");
                    textBE.Focus();
                }
                else
                {

                    textBE.Enabled = false;
                    //textBbh.Enabled = true;
                    //textBbh.Focus();
                    buttbc.Enabled = true;
                    buttqx.Enabled = true;
                   
                }
            }
        }

        private void buttbc_Click(object sender, EventArgs e)
        {
            string s1 = "insert into reader values('" + textBbh.Text.Trim() + "','" + textBxm.Text.Trim() + "','" + comboBlb.Text.Trim() + "','" + textBzht.Text.Trim() + "','" + comboBxb.Text.Trim() + "','" + textBdw.Text.Trim() + "','" + textBdh.Text.Trim() + "','" + textBE.Text.Trim() + "')";
            sql.SQLCommand(s1);
            MessageBox.Show("已成功保存读者信息。", "提示");
            buttqx_Click(null, null);
       
        }

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

    }
}

⌨️ 快捷键说明

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