学生信息管理系统小结

ASP.NET+Access

一、登入部分

主界面 Fm = new 主界面();
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "select*from 登录信息表 where 用户名='" + this.ttbName.Text + "' and 密码 ='" + ttbPwd.Text + "'and 身份='" + cbbId.Text + "'";
            if (ttbName.Text == "" || ttbName.Text == "")
            {
                MessageBox.Show("信息不完整,请输入密码和用户名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ttbName.Clear();
                ttbPwd.Clear();
                ttbName.Focus();
                return;
            }
            if (cbbId.Text == "")
            {
                MessageBox.Show("信息错误,请选择身份", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            OleDbConnection cn = new OleDbConnection(s1);
            cn.Open();//打开数据库
            OleDbCommand cm = new OleDbCommand(s2, cn);
            OleDbDataReader dr = cm.ExecuteReader();//执行oledatacommand命令,
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    string strname = dr["用户名"].ToString().Trim();
                    string username = this.ttbName.Text;
                    string shenfen = dr["身份"].ToString().Trim();
                    if (username == strname)
                    {
                        string strmima = dr["密码"].ToString().Trim();
                        string mima = this.ttbPwd.Text;
                        if (strmima == mima)
                        {
                            if (shenfen == this.cbbId.Text)
                            {
                                Fm.UserName = strname;
                                Fm.PassWord = strmima;
                                Fm.gly = shenfen;
                                Fm.Show();
                                ttbName.Text = "";
                                ttbPwd.Text = "";
                                cbbId.Text = "";
                                this.Hide();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("对不起,输入错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ttbName.Text = "";
                ttbPwd.Text = "";
                cbbId.Text = "";
                ttbName.Focus();
            }
            cn.Close();


二、查询部分

string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string strSql = "select * from 学生信息表";


            FindValue = "";    //清空存储查询语句的变量
            string Find_SQL = strSql;  //存储显示数据表中所有信息的SQL语句
            if (ttbName.Text == "" && ttbNumber.Text == "" && ttbSex.Text == "" && ttbSch.Text == "" && ttbPlace.Text == "" && ttbBrith.Text == "")
            {
                OleDbConnection cn;
                cn = new OleDbConnection(s1);
                cn.Open();
                OleDbDataAdapter da = new OleDbDataAdapter(strSql, cn);
                DataSet ds = new DataSet();
                da.Fill(ds, "学生信息表");
                dataGridView1.DataSource = ds.Tables[0];
                cn.Close();
            }
            else
            {
                if (FindValue.Length > 0)
                    FindValue = FindValue + "and";
                if (ttbNumber.Text != "")
                    FindValue += "(学号='" + ttbNumber.Text + "') and";
                if (ttbName.Text != "")
                    FindValue += "(姓名='" + ttbName.Text + "') and";
                if (ttbPlace.Text != "")
                    FindValue += "(籍贯='" + ttbPlace.Text + "') and";
                if (ttbSex.Text != "")
                    FindValue += "(性别='" + ttbSex.Text + "') and";
                if (ttbSch.Text != "")
                    FindValue += "(院系='" + ttbSch.Text + "') and";
                if (ttbBrith.Text != "")
                    FindValue += "(生日='" + ttbBrith.Text + "') and";


                if (FindValue.Length > 0)   //当存储查询条件的变量不为空时,删除逻辑运算符AND
                {
                    if (FindValue.IndexOf("and") > -1)  //判断是否用AND连接条件
                        FindValue = FindValue.Substring(0, FindValue.Length - 4);
                }
                else
                    FindValue = "";
                if (FindValue != "")   //如果FindValue字段不为空
                    //将查询条件添加到SQL语句的尾部
                    Find_SQL = Find_SQL + " where " + FindValue;
                //按照指定的条件进行查询
                OleDbConnection cn;
                cn = new OleDbConnection(s1);
                cn.Open();
                OleDbDataAdapter da = new OleDbDataAdapter(Find_SQL, cn);
                DataSet ds = new DataSet();
                da.Fill(ds, "信息表");
                dataGridView1.DataSource = ds.Tables[0];
                cn.Close();
            }
        }


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


三、修改删除部分

public partial class 用户管理 : Form
    {
        public 用户管理()
        {
            InitializeComponent();
            panel1.Hide();
        }

        public void f()
        {
            cbbId.Items.Clear();
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "select 用户名 from 登录信息表 ";
            OleDbConnection cn = new OleDbConnection(s1);
            cn.Open();
            OleDbCommand cm = new OleDbCommand(s2, cn);
            OleDbDataReader dr = cm.ExecuteReader();
            while (dr.Read())
            {
                cbbId.Items.Add(dr["用户名"].ToString().Trim());
            }
            cn.Close();
        }
        
        //检查用户
        public bool dgResult_load()
        {
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "select*from 登录信息表 where 用户名='" + ttbUserName.Text + "'";
            string userName = "";
            OleDbConnection cn = new OleDbConnection(s1);
            cn.Open();//打开数据库
            OleDbCommand cm = new OleDbCommand(s2, cn);
            OleDbDataReader dr = cm.ExecuteReader();//执行oledatacommand命令,
            while (dr.Read())
            {
                userName = dr["用户名"].ToString().Trim();
                if (userName == ttbUserName.Text)
                {  
                    return true;
                }
                else
                {
                    panel1.Hide();
                    continue;
                }
            }
            return false;
            
        }
        //查询用户是否存在
        private void ttbSearch_Click(object sender, EventArgs e)
        {
            if (ttbUserName.Text=="")
            {
                MessageBox.Show("输入信息不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            } 
            else
            {
                if (dgResult_load())
                {
                    panel1.Show();
                }
                
            }
        }
        //确定之后录入数据库
        private void button5_Click(object sender, EventArgs e)
        {
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "update 登录信息表 set 用户名='" + ttbUserName.Text + "',密码='" + textBox4.Text + "',身份='" + comboBox1.Text + "'where 用户名='" + ttbUserName.Text + "'";
            if (textBox4.Text == ""&& comboBox1.Text=="")
            {
                MessageBox.Show("输入信息不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                OleDbConnection cn = new OleDbConnection(s1);
                cn.Open();
                OleDbCommand cm = new OleDbCommand(s2, cn);
                cm.ExecuteNonQuery();
                cn.Close();
                MessageBox.Show("信息更改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ttbUserName.Text = ""; textBox4.Text = ""; comboBox1.Text = "";
            }
        }


        private void button6_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //删除用户
        private void btnDel_Click(object sender, EventArgs e)
        {
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "delete * from 登录信息表 where 用户名='" + cbbId.Text + "'";
            if (ttbUserName.Text == "")
            {
                MessageBox.Show("删除用户不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                if (dgResult_load())
                {
                    OleDbConnection cn = new OleDbConnection(s1);
                    cn.Open();
                    OleDbCommand cmd = new OleDbCommand(s2, cn);
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("用户删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ttbUserName.Text = "";
                    panel1.Hide();
                }
                else
                {
                    MessageBox.Show("该用户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    ttbUserName.Text = "";
                    ttbUserName.Focus();
                }
            }
            
        }
        //用户添加的取消
        private void btnCal_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //用户添加的OK
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ttbUName.Text == "")
            {
                MessageBox.Show("请输入名字!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                ttbUserName.Focus();
                return;
            }
            if (ttbUPwd.Text == "")
            {
                MessageBox.Show("请输入密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                ttbUPwd.Focus();
                return;
            }
            if(cbbId.Text=="")
            {
                MessageBox.Show("请输入身份!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                cbbId.Focus();
                return;
            }
            string s1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb";
            string s2 = "insert into 登录信息表 (用户名,密码,身份) values('" + ttbUName.Text + "','" + ttbUPwd.Text + "','" + cbbId.Text + "')";
            OleDbConnection cn = new OleDbConnection(s1);
            cn.Open();
            OleDbCommand cm = new OleDbCommand(s2, cn);
            cm.ExecuteNonQuery();
            cn.Close();
            MessageBox.Show("用户添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ttbUName.Text = ""; ttbUPwd.Text = ""; cbbId.Text = "";
        }
    }


详细源码及注释:http://download.csdn.net/detail/s10141303/5649101





















本文转自蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366784,如需转载请自行联系原作者


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/285993.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ArcGIS实验教程——实验三十:地图注记与标注(标注转注记)用法案例详解

ArcGIS实验视频教程合集:《ArcGIS实验教程从入门到精通》(附配套实验数据)》 实验目录 一、实验描述二、地图标注1. 标注工具2. 标注属性默认设置3. 标注分类4. 多属性字段标注5. 标注转换6. 显示地图提示三、地图文档注记1. 注记组2. 创建地图文档注记3. 编辑地图文档注记一…

Android之实现多桌面图标app入口进入不同的页面,像2个独立运行的app一样,互不干扰。

1、需求 Android实现2个图标app入口进入不同的页面,一个图标点击进去主app页面,一个图标点击直接进入app页面的里面一个子页面,两个图标功能点击效果独立,不能乱跳,副桌面图标然后返回也是直接返回,不能先返回到本地,就是感觉像2个独立运行的app一样,互不干扰。 问题:…

启动obiee

启动obiee:1.启动数据库第一步:打开Oracle监听$ lsnrctl start第二步:使用sysdab角色登录sqlplussqlplus / as sysdba第三步:启动数据库SQL> startup 2.启动WebLogic:nohup /home/oracle/obiee11g/user_projects/domains/bifou…

ASP.NET中IsPostBack详解

1、IsPostBack介绍Page.IsPostBack是一个标志:当前请求是否第一次打开。 调用方法为:Page.IsPostBack或者IsPostBack或者this.IsPostBack或者this.Page.IsPostBack,它们都等价。  1)当通过IE的地址栏等方式打开一个URL时是第一次打开, 当通…

05 tp6 的数据添加 助手函数、 save、insert、strict、replace、insertGetId、insertAll《ThinkPHP6 入门到电商实战》

文章目录(更新中…) 01 thinkphp6的前期开发准备《ThinkPHP6 入门到电商实战》 02 控制器《ThinkPHP6 入门到电商实战》 03 数据库查询、模型查询、多库查询《ThinkPHP6 入门到电商实战》 04 tp6 的查数据《ThinkPHP6 入门到电商实战》 05 tp6 的数据添…

利用bat修复office文件图标

如果电脑上安装了office,再安装wps,卸载wps后office文件图标会丢失。利用下边的代码,另存为bat文件,运行后可以快速修复图标问题。 rem 修复office文件默认图标.bat:: office图标文件路径,请根据自己电脑上的安装目录设…

VS2019如何创建C++项目?没有找到空项目(C++)完全解决方案

在使用Visual Studio 2019创建C++空项目时,没有空白项目可选,如下图所示,原因是在安装VS2019时没有选择C++对应的模块。本文讲解如何使用VS2019创建C++空项目,并使用C语言输出Hello World。 运行Visual Studio Installer,点击【修改】。 勾选【使用C++的桌面开发】,点击…

CentOS7.2 忘记root密码解决

CentOS 7 root密码的重置方式和CentOS 6完全不一样,以进入单用户模式修改root密码为例。 1.重启开机按esc,在第一行按e,进行编辑 2.编辑修改两处:ro改为rw,在LANGen_US.UFT-8后面添加init/bin/sh 3.按CtrlX重启,并修改…

Android之解决NestedScrollView嵌套RecyclerView部分手机返回到这个页面Recyclerview顶部,而不是页面NestedScrollView顶部

1、问题 NestedScrollView嵌套Recyclerview部分手机返回到这个页面Recyclerview顶部,而不是页面NestedScrollView顶部 部分布局大致如下 <androidx.core.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent…

词法分析程序的功能

词法分析程序的功能其实就是对所输入的字段进行词法分析任务&#xff0c;对用户的源程序从左到右进行扫描&#xff0c;按照语言的词法规则识别各类单词&#xff0c;并产生相应单词的属性字&#xff0c;并随之显现出来&#xff0c;成为词法分析程序的功能 转载于:https://www.cn…

android:制作 Nine-Patch 图片

它是一种被特殊处理过的 png 图片&#xff0c;能够指定哪些区域可以被拉伸而 哪些区域不可以。 那么 Nine-Patch 图片到底有什么实际作用呢&#xff1f;我们还是通过一个例子来看一下吧。比如 说项目中有一张气泡样式的图片 message_left.png&#xff0c;如图 3.38 所示。 图 …

08 获取器 withAttr、多连缀、whereRaw、事务、数据集《ThinkPHP6 入门到电商实战》

知识点&#xff1a;获取器 withAttr、多连缀、whereRaw、事务、数据集 文章目录&#xff08;更新中…&#xff09; 01 thinkphp6的前期开发准备《ThinkPHP6 入门到电商实战》 02 控制器《ThinkPHP6 入门到电商实战》 03 数据库查询、模型查询、多库查询《ThinkPHP6 入门到电商…

Chrome 双击关闭标签,新窗口打开新地址,一个插件搞定,安装方便,自带hosts

对&#xff0c;没错&#xff0c;就这它&#xff1a; 下载地址&#xff1a;https://shuax.com/project/greenchrome/ 一、插件安装 下载后&#xff0c;将下载的压缩包解压&#xff0c;根据自己Chreom浏览器是32位还是64位找到对应的 winmm.dll 文件&#xff0c;复制到Chome安装…

【ArcGIS遇上Python】从入门到精通系列之第二章:ArcGIS Python基本语法基础速递

Python的语法和其它编程语言的语法有所不同,编写Python程序之前需要对语法有所了解,才能编写规范的Python程序。本篇介绍Python标识符的同时,也讨论了Python变量的声明和赋值。通过本章的学习,将对python的数据类型、操作符、变量与赋值、代码块及缩进对齐、控制结构、函数…

C#中的闭包和意想不到的坑

虽然闭包主要是函数式编程的玩意儿&#xff0c;而C#的最主要特征是面向对象&#xff0c;但是利用委托或lambda表达式&#xff0c;C#也可以写出具有函数式编程风味的代码。同样的&#xff0c;使用委托或者lambda表达式&#xff0c;也可以在C#中使用闭包。根据WIKI的定义&#xf…

C语言试题五十八之请编写函数fun,:计算并输出下列多项式的值(sn=1+1/1!+1/2!+1/3!+1/4!+…+1/n! )

📃个人主页:个人主页 🔥系列专栏:C语言试题200例目录 💬推荐一款刷算法、笔试、面经、拿大公司offer神器 👉 点击跳转进入网站 ✅作者简介:大家好,我是码莎拉蒂,CSDN博客专家(全站排名Top 50),阿里云博客专家、51CTO博客专家、华为云享专家 1、题目 请编写函数…

投票彰显电信合约机诺基亚Lumia 800C受热捧

49元可以做什么&#xff1f;与朋友吃顿便饭、买几包好烟&#xff0c;同时也能参加中国电信Lumia 800C的合约购机计划&#xff0c;其中选择49元是最低套餐&#xff0c;选择并预存600元话费&#xff0c;便可以以2999元购买Lumia 800C。 对于Lumia 800C&#xff0c;它可是新一代诺…

07查询表达式 及 page分页、order 排序《ThinkPHP6 入门到电商实战》

文章目录&#xff08;更新中…&#xff09; 01 thinkphp6的前期开发准备《ThinkPHP6 入门到电商实战》 02 控制器《ThinkPHP6 入门到电商实战》 03 数据库查询、模型查询、多库查询《ThinkPHP6 入门到电商实战》 04 tp6 的查数据《ThinkPHP6 入门到电商实战》 05 tp6 的数据添…

msSql 利用 xp_cmdshell 删除 创建目录

DECLARE DATABakPath VARCHAR(500) ND:\DataBak\ DECLARE RemoteComand VARCHAR(500)SET RemoteComand rd /s /qDATABakPath\dbname EXEC xp_cmdshell RemoteComand,no_output --删除文件夹,为了清理旧备份 SET RemoteComand mkdir DATABakPath\dbname EXEC xp_…

基于netty的微服务架构

基于netty的微服务架构 微服务一篇好文章 http://san-yun.iteye.com/blog/1693759 教程 http://udn.yyuap.com/doc/essential-netty-in-action/GETTING%20STARTED/Introducing%20Netty.html netty原理 http://www.infoq.com/cn/articles/netty-server-create netty方面专家 李林…