十四章
来源:互联网 发布:mac usr local 编辑:程序博客网 时间:2024/04/29 06:24
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data.SqlClient;namespace ConsoleApplication1{ class DOB { string strconn = "Data Source=.;Initial Catalog=MySchool;Integrated Security=True"; public bool CheckUserInfo(string name,string pwd) { bool b = true; SqlConnection conn = new SqlConnection(strconn); try { string str = "select count(*) from Admin where LoginId='" + name + "' and LoginPwd='" + pwd + "'"; Console.WriteLine(str); conn.Open(); SqlCommand comm = new SqlCommand(str, conn); int iRet = (int)comm.ExecuteScalar(); if (iRet == 1) { b = true; } else { b = false; } } catch (Exception) { Console.WriteLine("发生异常"); } finally { conn.Close(); } return b; } public int GetStudentAmount() { SqlConnection conn = new SqlConnection(strconn); try { string strsql = "select count(*) from Student"; conn.Open(); SqlCommand comm = new SqlCommand(strsql, conn); int iRet = (int)comm.ExecuteScalar(); return iRet; } catch (Exception) { return -1; throw; } finally { conn.Close(); } } } }
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data.SqlClient;namespace ConsoleApplication1{ class SchoolManager { DOB d = new DOB(); public void Login() { Console.WriteLine("请输入用户名:"); string name = Console.ReadLine(); Console.WriteLine("请输入密码:"); string pwd = Console.ReadLine(); bool r = d.CheckUserInfo(name, pwd); if (r) { Console.WriteLine("登陆成功!"); caidan(); } else { Console.WriteLine("登陆失败!"); } } public void caidan() { Console.WriteLine("=================请选择操作数=================="); Console.WriteLine("1. 统计学生人数"); Console.WriteLine("2. 查看学生名单"); Console.WriteLine("3. 按单号查询学生的姓名"); Console.WriteLine("4. 按姓名查询学生信息"); Console.WriteLine("5. 修改学生的出生日期"); Console.WriteLine("6. 删除学生记录"); Console.WriteLine("7. 新增年级记录"); Console.WriteLine("0.退出"); Console.WriteLine("==============================================="); int z = int.Parse(Console.ReadLine()); switch (z) { case 1: Console.WriteLine("在校学生人数:" + d.GetStudentAmount()); caidan(); break; case 2: caidan(); break; case 3: caidan(); break; case 4: caidan(); break; case 5: caidan(); break; case 6: caidan(); break; case 7: caidan(); break; case 0: Console.WriteLine("谢谢使用"); break; default: Console.WriteLine("输入错误"); break; } } }}
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data.SqlClient;namespace ConsoleApplication1{ class Class1 { static void Main(string[] args) { SchoolManager s = new SchoolManager(); s.Login(); Console.ReadLine(); } }}
0 0
- 十四章
- 十四章
- 第二十四章 动名词
- 十四章 第二题
- 十四章第五题
- 十四章(例四)
- 十四章示例4
- 十四章上机1
- 十四章上机2
- 十四章 事例四
- 十四章示例4
- 十四章 小练习
- 《道德经》第二十四章
- 《道德经》第三十四章
- 《道德经》第四十四章
- 《道德经》第五十四章
- 十四
- 十四
- xmapp整合的Apache服务器更改端口号
- 内存泄漏
- 什么是Java的抽象类
- js格式化数字(金额--每隔三位加逗号)
- sass笔记-1|Sass是如何帮你又快又好地搞定CSS的
- 十四章
- thinkcmf中使用iframe
- R语言的数据类型和对象类型
- tornado协程(coroutine)
- mesos - 运维的革命
- 学习C++Primer第五版,课后练习。
- 常用集合之间的区别
- springmvc 配置jdbc 使用DruidDataSource
- 根据包名判断是否存在某个应用