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

📄 frmblqc.cs

📁 学生宿舍管理系统 学生宿舍管理系统
💻 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.OleDb ;
namespace 学生宿舍管理系统
{
    public partial class FrmBLQC : Form
    {
        public FrmBLQC()
        {
            InitializeComponent();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            label1.Text = "请输入学号";
            label1.Show();
            textBox1.Text = "";
            textBox1.Show();
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            label1.Text = "请输入姓名:";
            label1.Show();
            textBox1.Text = "";
            textBox1.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string a, b;
            MyData mydata = new MyData();
            if (radioButton1.Checked)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("请输入学号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                string s1 = "delete from 入住登记表 where 学号='" + textBox1.Text + "'";
                string str1 = "select 栋号,房间号码 from 入住登记表 where 学号='" + textBox1.Text + "'";
                DataSet ds = mydata.getDataSet(str1, "入住登记表");

                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    if (MessageBox.Show("一旦迁出,该人员的信息将被删除!\n\n        确定迁出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        a = ds.Tables["入住登记表"].Rows[0][0].ToString();
                        b = ds.Tables["入住登记表"].Rows[0][1].ToString();
                        string s = "update 房间基本信息表 set 入住人数=入住人数-1,空缺人数=空缺人数+1 where 栋号='" + a + "' and 房间号码='" + b + "'";
                        mydata.updateSql(s);
                        if (mydata.updateSql(s1))
                        {
                            MessageBox.Show("迁出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBox1.Text = "";
                        }
                    }
                    else
                    {
                        textBox1.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = "";
                }
            }
            else if (radioButton2.Checked)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("请输入姓名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                string s2 = "delete from 入住登记表 where 姓名='" + textBox1.Text + "'";
                string str2 = "select 栋号,房间号码 from 入住登记表 where 姓名='" + textBox1.Text + "'";
                DataSet ds = mydata.getDataSet(str2, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    if (MessageBox.Show("一旦迁出,该人员的信息将被删除!\n\n        确定迁出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        a = ds.Tables["入住登记表"].Rows[0][0].ToString();
                        b = ds.Tables["入住登记表"].Rows[0][1].ToString();
                        string ss = "update 房间基本信息表 set 入住人数=入住人数-1,空缺人数=空缺人数+1 where 栋号='" + a + "' and 房间号码='" + b + "'";
                        mydata.updateSql(ss);
                        if (mydata.updateSql(s2))
                        {
                            MessageBox.Show("迁出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBox1.Text = "";
                        }
                    }
                    else
                    {
                        textBox1.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = "";
                }
            }
            else
            {
                MessageBox.Show("请选择迁出信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            mydata.closeConnection();
            dataGridView1.DataSource = null;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MyData mydata = new MyData();
            if (radioButton1.Checked)
            {
                string s3 = "select * from 入住登记表 where 学号='" + textBox1.Text + "'";
                DataSet ds = mydata.getDataSet(s3, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    dataGridView1.DataSource = ds.Tables["入住登记表"];
                }

                else
                {
                    MessageBox.Show("学号不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = "";
                }
            }
            else if (radioButton2.Checked)
            {
                string s4 = "select * from 入住登记表 where 姓名='" + textBox1.Text + "'";
                DataSet ds = mydata.getDataSet(s4, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    dataGridView1.DataSource = ds.Tables["入住登记表"];
                }
                else
                {
                    MessageBox.Show("姓名不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = "";
                }
            }
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView2.DataSource = null;
            label3.Text = "请输入年度:";
            label4.Hide();
            textBox3.Hide();
            label3.Show();
            textBox2.Text = "";
            textBox2.Show();
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView2.DataSource = null;
            label3.Text = "请输入栋号:";
            label3.Show();
            label4.Show();
            textBox2.Text = "";
            textBox2.Show();
            textBox3.Text = "";
            textBox3.Show();

        }

        private void button5_Click(object sender, EventArgs e)
        {
            MyData mydata = new MyData();
            if (radioButton3.Checked)
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("请输入栋号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (textBox3.Text == "")
                {
                    MessageBox.Show("请输入房间号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                string str1 = "select * from 入住登记表 where 栋号='" + textBox2.Text + "' and 房间号码='" + textBox3.Text + "'";
                OleDbDataReader dr = mydata.getDataReader(str1);
                int i = 0;
                while (dr.Read())
                { i++; }
                DataSet ds = mydata.getDataSet(str1, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    if (MessageBox.Show("一旦迁出,该人员的信息将被删除!\n\n        确定迁出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        string s1 = "delete from 入住登记表 where 栋号='" + textBox2.Text + "' and 房间号码='" + textBox3.Text + "'";
                        string s = "update 房间基本信息表 set 入住人数=入住人数-" + i + ",空缺人数=空缺人数+" + i + " where 栋号='" + textBox2.Text + "' and 房间号码='" + textBox3.Text + "'";
                        if (mydata.updateSql(s1))
                        {
                            mydata.updateSql(s);
                            MessageBox.Show("迁出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBox2.Text = "";
                            textBox3.Text = "";

                        }
                    }
                    else
                    {
                        textBox2.Text = "";
                        textBox3.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox2.Text = "";
                    textBox3.Text = "";
                }
            }
            else if (radioButton4.Checked)
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("请输入年度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                string str1 = "select * from 入住登记表 where 年度='"+textBox2 .Text + "'";
               
                DataSet ds = mydata.getDataSet(str1, "入住登记表");
              
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    if (MessageBox.Show("一旦迁出,该人员的信息将被删除!\n\n        确定迁出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {  
                        String m, n;
                       
                        OleDbDataReader dr = mydata.getDataReader(str1);
                        while (dr.Read())
                        {
                           m = dr.GetString(0);
                           n = dr.GetString(1); 
                           string s = "update 房间基本信息表 set 入住人数=入住人数-1,空缺人数=空缺人数+1  where 栋号='" + m + "' and 房间号码='" +n+ "'"; 
                           mydata.updateSql(s);
                       }
                       string s1 = "delete from 入住登记表 where 年度='" + textBox2.Text + "'";
                       if (mydata.updateSql(s1))
                       {
                           MessageBox.Show("迁出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                           textBox2.Text = "";
                       }
                   }
                   else
                   {
                       textBox2.Text = "";
                     }
                 }
                 else
                 {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox2.Text = "";
                 }
                 mydata.closeConnection();
                dataGridView1.DataSource = null;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            MyData mydata = new MyData();
            if (radioButton3.Checked)
            {
                string s = "select * from 入住登记表 where 栋号='" + textBox2.Text + "' and 房间号码='" + textBox3.Text + "'";
                DataSet ds = mydata.getDataSet(s, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    dataGridView2.DataSource = ds.Tables["入住登记表"];
                }

                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox2.Text = "";
                    textBox3.Text = "";
                }
            }
            else if (radioButton4.Checked)
            {
                string s1 = "select * from 入住登记表 where 年度='" + textBox2.Text + "'";
                DataSet ds = mydata.getDataSet(s1, "入住登记表");
                if (ds.Tables["入住登记表"].Rows.Count != 0)
                {
                    dataGridView2.DataSource = ds.Tables["入住登记表"];
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox2.Text = "";
                }
            }
        }

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

⌨️ 快捷键说明

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