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

📄 frmrzqk.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 FrmRZQk : Form
    {
        public FrmRZQk()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string s1 = "select 栋号,房间号码,入住性别,可住人数,入住人数,空缺人数,住宿费用 from 房间基本信息表 where 栋号='" + textBox1.Text + "' and 入住人数< 4";
            string s2 = "select 栋号,房间号码,入住性别,可住人数,入住人数,空缺人数,住宿费用 from 房间基本信息表 where 栋号='" + textBox1.Text + "' and 房间号码='" + textBox2.Text + "' and 入住人数< 4";
            if (textBox1.Text == "")
            {
                MessageBox.Show("栋号不能为空,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dataGridView1.DataSource = null;
                return;
            }
           else if (textBox2.Text !="") s1 =s2;
            
            MyData mydata = new MyData();
            DataSet ds = mydata.getDataSet(s1,"房间基本信息表");
            if(ds .Tables ["房间基本信息表"].Rows .Count !=0 )
             {
                dataGridView1 .DataSource =ds.Tables["房间基本信息表"];
             }
            else 
            {

                MessageBox.Show("不存在该房间信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBox1.Text = "";
                textBox2.Text = "";
                dataGridView1.DataSource = null;
            }
            mydata.closeConnection();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string s1 = "select 栋号,房间号码,入住性别,可住人数,入住人数,空缺人数,住宿费用 from 房间基本信息表 where 栋号='" + textBox3.Text + "' and 入住人数=4";
            if (textBox3.Text == "")
            {
                MessageBox.Show("栋号不能为空,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dataGridView1.DataSource = null;
                return;
            }
            MyData mydata = new MyData();
            DataSet ds = mydata.getDataSet(s1, "房间基本信息表");
            if (ds.Tables["房间基本信息表"].Rows.Count != 0)
            {
                dataGridView1.DataSource = ds.Tables["房间基本信息表"];
            }
            else
            {
                string str = "你要查询的" + textBox3.Text + "栋宿舍目前还没有住满的房间!";
                MessageBox.Show(str, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBox3.Text = "";
                dataGridView1.DataSource = null;
            }
            mydata.closeConnection();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string s = "select * from 入住登记表 where 栋号='" + textBox4.Text + "'and 房间号码='" + textBox5.Text + "'";
            if (textBox4.Text == "")
            {
                MessageBox.Show("栋号不能为空,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dataGridView1.DataSource = null;
                return;
            }
            if (textBox5.Text == "")
            {
                MessageBox.Show("房间号不能为空,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dataGridView1.DataSource = null;
                return;
            }
            MyData mydata = new MyData();
            DataSet ds = mydata.getDataSet(s, "入住登记表");
            if (ds.Tables["入住登记表"].Rows.Count != 0)
            {
                dataGridView1.DataSource = ds.Tables["入住登记表"];
            }
            else
            {
                string str = "你要查询的" + textBox4.Text + "栋"+textBox5 .Text +"房间目前没人入住或者没有此房间!";
                MessageBox.Show(str, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                dataGridView1.DataSource = null;
                textBox4.Text = "";
                textBox5.Text = "";
            }
            mydata.closeConnection();
        }

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

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

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

⌨️ 快捷键说明

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