frmwjcx.cs

来自「学生宿舍管理系统 学生宿舍管理系统」· CS 代码 · 共 118 行

CS
118
字号
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 FrmWJCX : Form
    {
        public FrmWJCX()
        {
            InitializeComponent();
        }

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

        }

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

        }

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

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

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

        private void button1_Click(object sender, EventArgs e)
        {
            string s1 = "select  学号,学号,姓名,栋号,房间号码,院系,班级,违纪时间,违纪行为,处理结果,宿管员 from 违章登记表 where 学号='" + textBox1.Text + "'";
            string s2 = "select  学号,学号,姓名,栋号,房间号码,院系,班级,违纪时间,违纪行为,处理结果,宿管员 from 违章登记表 where 姓名 Like'" + textBox1.Text + "%'";
            string s3 = "select  学号,学号,姓名,栋号,房间号码,院系,班级,违纪时间,违纪行为,处理结果,宿管员 from 违章登记表 where 栋号='" + textBox1.Text + "'and 房间号码='" + textBox2.Text + "'";
            MyData mydata = new MyData();
            if (radioButton1.Checked)
            {
                DataSet ds = mydata.getDataSet(s1, "违章登记表");
                if (ds.Tables["违章登记表"].Rows.Count != 0)
                {
                    dataGridView1.DataSource = ds.Tables["违章登记表"];
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    textBox1.Text = "";
                }
            }
            else if (radioButton2.Checked)
            {
                DataSet ds = mydata.getDataSet(s2, "违章登记表");
                if (ds.Tables["违章登记表"].Rows.Count != 0)
                {
                    dataGridView1.DataSource = ds.Tables["违章登记表"];
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    textBox1.Text = "";
                }
            }
            else if (radioButton3.Checked)
            {
                DataSet ds = mydata.getDataSet(s3, "违章登记表");
                if (ds.Tables["违章登记表"].Rows.Count != 0)
                {
                    dataGridView1.DataSource = ds.Tables["违章登记表"];
                
                }
                else
                {
                    MessageBox.Show("不存在此信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    textBox1.Text = "";
                    textBox2.Text = "";
                }
            }
        }

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

⌨️ 快捷键说明

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