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

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

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource = "";
            this.label1.Text = "请输入日期:";
            this.label1.Show();
            this.label2.Hide();
            this.textBox2.Hide();
            this.dateTimePicker1.Show(); 
            this.textBox1.Hide();
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource="" ;
            this.label1.Show();
            this.label2.Show();
            this.textBox1.Text = "";
            this.textBox2.Text = "";
            this.textBox1.Show();
            this.textBox2.Show();
            this.dateTimePicker1.Hide();
            this.label1.Text = "请输入栋号:";
           
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource = "";
            this.label1.Text = "请输入姓名:";
            this.label1.Show();
            this.label2.Hide();
            this.dateTimePicker1.Hide();
            this.textBox1.Text = "";
            this.textBox1.Show();
            this.textBox2.Hide();
            

        }

        private void button1_Click(object sender, EventArgs e)
        {
            MyData mydata=new MyData ();
            if (radioButton1.Checked)
            {
                string s1 = "select 日期, 来访人,来访人性别,证件号码,被访人姓名,栋号,被访人房间,来访原因,来访时间,离开时间,宿管员,备注 from 来访登记表 where 日期=#" +dateTimePicker1.Text + "#";
                DataSet ds = mydata.getDataSet(s1, "来访登记表");
                dataGridView1.DataSource = ds.Tables["来访登记表"];
            }
            else if (radioButton3.Checked)
            {
                string s2 = "select 日期, 来访人,来访人性别,证件号码,被访人姓名,栋号,被访人房间,来访原因,来访时间,离开时间,宿管员,备注 from 来访登记表 where 栋号='" + textBox1.Text + "'and 被访人房间='" + textBox2.Text + "'";
                if (textBox1.Text == "")
                {   MessageBox.Show("请输入栋号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else if (textBox2.Text == "")
                {
                    MessageBox.Show("请输入房间号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    DataSet ds = mydata.getDataSet(s2, "来访登记表");
                    dataGridView1.DataSource = ds.Tables["来访登记表"];
                }

            }
            else if (radioButton2.Checked)
            {
                string s3 = "select 日期, 来访人,来访人性别,证件号码,被访人姓名,栋号,被访人房间,来访原因,来访时间,离开时间,宿管员,备注 from 来访登记表 where 被访人姓名 Like'" + textBox1.Text + "%'";
               if (textBox1.Text == "")
               {
                   MessageBox.Show("被访人不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   return;
               }
                DataSet ds = mydata.getDataSet(s3, "来访登记表");
               dataGridView1.DataSource = ds.Tables["来访登记表"];
            }
            mydata.closeConnection();     
        }

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

        private void textBox1_MouseEnter(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
                this.label3.Show();
        }

        private void textBox1_MouseLeave(object sender, EventArgs e)
        {
            this.label3.Hide();
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView2.DataSource = null;
            this.label4.Text = "请输入学号:";
            this.label5.Hide();
            this.label4.Show();
            this.textBox4.Hide();
            this.textBox3.Text = "";
            
            this.textBox3.Show();
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView2.DataSource = null;
            this.label4.Text = "请输入栋号:";
            this.label4.Show();
            this.textBox3.Text = "";
            this.textBox3.Show();
            this.label5.Show();
            this.textBox4.Text = "";
            this.textBox4.Show();
        }

        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            dataGridView2.DataSource = null;
            this.label4.Text = "请输入姓名:";
            this.label4.Show();
            this.textBox3.Text = "";
            this.textBox3.Show();
            this.label5.Hide();
            this.textBox4.Hide();
        }

        private void textBox3_MouseEnter(object sender, EventArgs e)
        {
            if (this.radioButton6.Checked)
                this.label6.Show();
        }

        private void textBox3_MouseLeave(object sender, EventArgs e)
        {
            this.label6.Hide();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MyData mydata = new MyData();
            if (radioButton4.Checked)
            {
                string s1 = "select 栋号,房间号码,床位号码,学号,姓名,性别,所属学院,班级,年度,联系电话,入住日期 from 入住登记表 where 学号='" + textBox3 .Text + "'";
                if (textBox3.Text == "")
                {
                    MessageBox.Show("请输入学号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                DataSet ds = mydata.getDataSet(s1, "入住登记表");
                dataGridView2.DataSource = ds.Tables["入住登记表"];
            }
            else if (radioButton5.Checked)
            {
                string s2 = "select 栋号,房间号码,床位号码,学号,姓名,性别,所属学院,班级,年度,联系电话,入住日期 from 入住登记表  where 栋号='" + textBox3.Text + "'and 房间号码='" + textBox4.Text + "'";
                if (textBox3.Text == "")
                {
                    MessageBox.Show("请输入栋号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else if (textBox4.Text == "")
                {
                    MessageBox.Show("请输入房间号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    DataSet ds = mydata.getDataSet(s2, "入住登记表");
                    dataGridView2.DataSource = ds.Tables["入住登记表"];
                }

            }
            else if (radioButton6.Checked)
            {
                string s3 = "select 栋号,房间号码,床位号码,学号,姓名,性别,所属学院,班级,年度,联系电话,入住日期 from 入住登记表 where 姓名 Like'" + textBox3.Text + "%'";
                if (textBox3.Text == "")
                {
                    MessageBox.Show("请输入姓名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                DataSet ds = mydata.getDataSet(s3, "入住登记表");
                dataGridView2.DataSource = ds.Tables["入住登记表"];
            }
            mydata.closeConnection();     
        }

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

⌨️ 快捷键说明

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