技术标签: c# sqlserver 数据库开发 visualstudio 数据库
目录
二、具体实现:利用SQL Sever和 VS实现,使用C#连接数据库
1、新建一个名为MySchool的数据库
2、C#连接数据库,并实现对MySchool数据库的增、删、改、查操作
图1:程序流程图
图2:数据库连接
图3:MySchool数据库
USE MySchool;
DROP TABLE IF EXISTS SC /*成绩*/
DROP TABLE IF EXISTS Student /*学生信息*/
DROP TABLE IF EXISTS Course /*课程*/
DROP TABLE IF EXISTS StudentUser /*学生用户信息*/
DROP TABLE IF EXISTS Administrator /*管理员用户信息*/
DROP TABLE IF EXISTS SysLog /*注册日志*/
DROP TABLE IF EXISTS SysLog1 /*登陆日志*/
DROP TABLE IF EXISTS AVG1 /*登陆日志*/
CREATE TABLE StudentUser
(
ID NCHAR(20) PRIMARY KEY, /*学号*/
PassWord NCHAR(32) , /*密码*/
Sex CHAR(2) , /*性别*/
Birthday datetime, /*生日*/
UserMobile NCHAR(11), /*电话号码*/
);
CREATE TABLE Administrator
(
ID NCHAR(20) PRIMARY KEY, /*工号*/
PassWord NCHAR(32) , /*密码*/
Sex CHAR(2), /*性别*/
Birthday datetime, /*生日*/
UserMobile NCHAR(11), /*电话号码*/
);
CREATE TABLE SysLog
( [UserMobile]
UserID NCHAR(20) , /*id*/
dentity CHAR(20), /*学生或管理员*/
DateAndTime datetime, /*注册时间*/
UserOperation NCHAR(200) /*操作方式*/
);
CREATE TABLE SysLog1
(
UserID NCHAR(20) , /*id*/
dentity CHAR(20), /*学生或管理员*/
DateAndTime datetime, /*登陆时间*/
UserOperation NCHAR(200) /*登陆操作方式*/
);
CREATE TABLE Student
(
Sno CHAR(9) PRIMARY KEY, /* 列级完整性约束条件,Sno是主码*/
Sname CHAR(20) UNIQUE, /* Sname取唯一值*/
Ssex CHAR(2), /*性别*/
Sage SMALLINT, /*年龄*/
Sdept CHAR(20) /*专业*/
);
CREATE TABLE Course
(
Cno CHAR(4) PRIMARY KEY,
Cname CHAR(40),
Cpno CHAR(4),
Ccredit SMALLINT,
);
CREATE TABLE SC
(
Sno CHAR(9),
Cno CHAR(4),
Grade SMALLINT,
PRIMARY KEY (Sno,Cno), /* 主码由两个属性构成,必须作为表级完整性进行定义*/
FOREIGN KEY (Sno) REFERENCES Student(Sno), /* 表级完整性约束条件,Sno是外码,被参照表是Student */
FOREIGN KEY (Cno)REFERENCES Course(Cno) /* 表级完整性约束条件, Cno是外码,被参照表是Course*/
);
INSERT INTO StudentUser VALUES ('20181101111','123456','女',1999-1-1,'13812345678',NULL);
INSERT INTO Administrator VALUES ('2018110',substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','123456')),3,32),'女',1989-1-1,'13812345687',NULL);
INSERT INTO Administrator VALUES ('2018111',substring(sys.fn_sqlvarbasetostr(HashBytes('MD5','123456')),3,32),'女',1989-2-1,'13812655687',NULL);
INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) VALUES ('201215121','李勇','男','CS',20);
INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) VALUES ('201215122','刘晨','女','CS',19);
INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) VALUES ('201215123','王敏','女','MA',18);
INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) VALUES ('201215125','张立','男','IS',19);
INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) VALUES ('201215128','陈冬','男','IS',20);
SELECT * FROM Student
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('1','数据库',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('2','数学',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('3','信息系统',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('4','操作系统',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('5','数据结构',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('6','数据处理',NULL,4);
INSERT INTO Course(Cno,Cname,Cpno,Ccredit) VALUES ('7','Pascal语言',NULL,4);
UPDATE Course SET Cpno = '5' WHERE Cno = '1'
UPDATE Course SET Cpno = '1' WHERE Cno = '3'
UPDATE Course SET Cpno = '6' WHERE Cno = '4'
UPDATE Course SET Cpno = '7' WHERE Cno = '5'
UPDATE Course SET Cpno = '6' WHERE Cno = '7'
SELECT * FROM Course
INSERT INTO SC(Sno,Cno,Grade) VALUES ('201215121 ','1',92);
INSERT INTO SC(Sno,Cno,Grade) VALUES ('201215121 ','2',85);
INSERT INTO SC(Sno,Cno,Grade) VALUES ('201215121 ','3',88);
INSERT INTO SC(Sno,Cno,Grade) VALUES ('201215122 ','2',90);
INSERT INTO SC(Sno,Cno,Grade) VALUES ('201215122 ','3',80);
SELECT * FROM SC
--当学生用户信息更新,触发器启动,将更新的内容存至注册日志
IF(OBJECT_ID('regist_recorder1') is not null) -- 判断名为 regist_recorder 的触发器是否存在
DROP TRIGGER regist_recorder1 -- 删除触发器
GO
CREATE TRIGGER regist_recorder1
ON StudentUser
AFTER
INSERT
AS
declare @UserName nchar(20)
declare @DateTime datetime
declare @UserOperation nchar(200)
declare @dentity CHAR(20)
select @UserName = ID FROM StudentUser
select @DateTime = CONVERT(datetime,GETDATE(),120)
select @dentity ='StudentUser'
declare @op varchar(10)
select @op=case when exists(select 1 from inserted) and exists(select 1 from deleted)
then 'Update'
when exists(select 1 from inserted) and not exists(select 1 from deleted)
then 'Insert'
when not exists(select 1 from inserted) and exists(select 1 from deleted)
then 'Delete' end
select @UserOperation = @op
INSERT INTO SysLog(UserID,dentity,DateAndTime,UserOperation)
VALUES (@UserName,@dentity,@DateTime,@UserOperation)
--当管理员信息更新,触发器启动,将更新的内容存至注册日志
IF(OBJECT_ID('regist_recorder2') is not null) -- 判断名为 regist_recorder 的触发器是否存在
DROP TRIGGER regist_recorder2 -- 删除触发器
GO
CREATE TRIGGER regist_recorder2
ON Administrator
AFTER
INSERT
AS
declare @UserName nchar(20)
declare @DateTime datetime
declare @UserOperation nchar(200)
declare @dentity CHAR(20)
select @UserName = ID FROM Administrator
select @DateTime = CONVERT(datetime,GETDATE(),120)
select @dentity ='Administrator'
declare @op varchar(10)
select @op=case when exists(select 1 from inserted) and exists(select 1 from deleted)
then 'Update'
when exists(select 1 from inserted) and not exists(select 1 from deleted)
then 'Insert'
when not exists(select 1 from inserted) and exists(select 1 from deleted)
then 'Delete' end
select @UserOperation = @op
INSERT INTO SysLog(UserID,dentity,DateAndTime,UserOperation)
VALUES (@UserName,@dentity,@DateTime,@UserOperation)
--建一个表存储各科平均分
--建一个表存储各科平均分
CREATE TABLE AVG1
(
Cname CHAR(10), /* 科目*/
avg1 INT
);
INSERT INTO AVG1(Cname,avg1) VALUES ('数据库',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('数学',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('信息系统',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('操作系统',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('数据结构',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('数据处理',NULL);
INSERT INTO AVG1(Cname,avg1) VALUES ('Pascal语言',NULL);
--将成绩信息通过下列存储过程算出各科平均分并存储至AVG表
IF (exists (select * from sys.objects where name = 'COURSE_AVG1'))
DROP PROCEDURE COURSE_AVG1
GO
CREATE PROCEDURE COURSE_AVG1
AS
BEGIN TRANSACTION TRANS
DECLARE
@SX INT, /* 数学总分 */
@XXXT INT, /* 信息系统总分 */
@CZXT INT, /* 操作系统总分 */
@SJJG INT, /* 数据结构总分 */
@SJK_C INT, /* 数据库总分 */
@SJCL INT, /*数据处理总分*/
@P INT /*Pascal语言*/
SELECT @SX=AVG(Grade) FROM SC
WHERE Cno='2 '
SELECT @XXXT=AVG(Grade) FROM SC
WHERE Cno='3'
SELECT @CZXT=AVG(Grade) FROM SC
WHERE Cno='4'
SELECT @SJJG=AVG(Grade) FROM SC
WHERE Cno='5'
SELECT @SJK_C=AVG(Grade) FROM SC
WHERE Cno='1'
SELECT @SJCL=AVG(Grade) FROM SC
WHERE Cno='6'
SELECT @P=AVG(Grade) FROM SC
WHERE Cno='7'
BEGIN
UPDATE AVG1 SET avg1=@SJK_C WHERE Cname='数据库'
UPDATE AVG1 SET avg1=@SX WHERE Cname='数学'
UPDATE AVG1 SET avg1=@XXXT WHERE Cname='信息系统'
UPDATE AVG1 SET avg1=@CZXT WHERE Cname='操作系统'
UPDATE AVG1 SET avg1=@SJJG WHERE Cname='数据结构'
UPDATE AVG1 SET avg1=@SJCL WHERE Cname='数据处理'
UPDATE AVG1 SET avg1=@P WHERE Cname='Pascal语言'
COMMIT TRANSACTION TRANS;
END
图4:主界面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
private void buttonStuLogin_Click(object sender, EventArgs e)
{
FormStuLogin FormStuLogin = new FormStuLogin(); //学生登录窗体
FormStuLogin.Show();//跳转至学生登录窗体
this.Hide(); //隐藏原窗体
}
private void buttonManagerLogin_Click(object sender, EventArgs e)
{
FormManagerLogin FormManagerLogin = new FormManagerLogin(); //管理员登录窗体
FormManagerLogin.Show();//跳转至管理员登录窗体
this.Hide();
}
private void FormLogin_FormClosing_1(object sender, FormClosingEventArgs e)
{
}
private void FormLogin_FormClosed(object sender, FormClosedEventArgs e)
{
while (MessageBox.Show("即将退出系统,您确认退出吗?", "提示!", MessageBoxButtons.YesNo)== DialogResult.Yes)
{
System.Environment.Exit(System.Environment.ExitCode);
}
}
}
}
图5:学生登录页面
图6:学生登录成功
图7:学生登录失败
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class FormStuLogin : Form
{
public FormStuLogin()
{
InitializeComponent();
}
public string code;
private string EncryptWithMD5(string source)//MD5加密
{
byte[] sor = Encoding.UTF8.GetBytes(source);
MD5 md5 = MD5.Create();
byte[] result = md5.ComputeHash(sor);
StringBuilder strbul = new StringBuilder(40);
for (int i = 0; i < result.Length; i++)
{
strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
}
return strbul.ToString();
}
private void buttonLogin_Click(object sender, EventArgs e)
{
string username = tBUserName.Text.Trim(); //取出账号
string password = EncryptWithMD5(tBPassword.Text.Trim()); //取出密码并加密
string myConnString = "Data Source=.;Initial Catalog=MySchool;Persist Security Info=True;User ID=sa;Password=yourpassword";
SqlConnection sqlConnection = new SqlConnection(myConnString); //实例化连接对象
sqlConnection.Open();
string sql = "select ID,PassWord from StudentUser where ID = '" + username + "' and PassWord = '" + password + "'"; //编写SQL命令
SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();//读取数据
if (sqlDataReader.HasRows && tBVerifyCode.Text == code)//验证是否有该用户及密码且验证码正确
{
MessageBox.Show("欢迎使用!"); //登录成功
StuMain stuMain = new StuMain();
stuMain.GetId(username);
stuMain.Show();//显示下一界面
this.Hide();
}
else if (sqlDataReader.HasRows && tBVerifyCode.Text != code)
{
MessageBox.Show("验证码错误,登录失败!");
return;
}
else
{
MessageBox.Show("账号密码有误,登录失败!");
return;
}
sqlDataReader.Close();
sql = "insert into SysLog1 values ( '" + username + "' , 'Student','" + DateTime.Now + "' , '" + "Login" + "')"; //编写SQL命令,把登陆信息存入登录日志
SqlCommand sqlCommand1 = new SqlCommand(sql, sqlConnection);
sqlCommand1.ExecuteNonQuery();
sqlConnection.Close();
}
private void buttonReg_Click(object sender, EventArgs e)
{
this.Hide();
RegisterForm registerForm = new RegisterForm();
registerForm.Show();
}
private void FormStuLogin_Load_1(object sender, EventArgs e)
{
//随机实例化
Random ran = new Random();
int number;
char code1;
//取五个数
for (int i = 0; i < 5; i++)
{
number = ran.Next();
if (number % 2 == 0)
code1 = (char)('0' + (char)(number % 10));
else
code1 = (char)('A' + (char)(number % 26)); //转化为字符
this.code += code1.ToString();
}
lbVerifyCode.Text = code;
}
private void lbVerifyCode_Click(object sender, EventArgs e)
{
}
private void buttonCancel_Click_1(object sender, EventArgs e)
{
this.Close();
}
private void FormStuLogin_FormClosing_1(object sender, FormClosingEventArgs e)
{
FormLogin m2 = new FormLogin();
m2.Show();
}
private void lbPassword_Click(object sender, EventArgs e)
{
}
}
}
图8:个人主页——个人信息页
图9:个人主页——成绩单页
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class StuMain : Form
{
public StuMain()
{
InitializeComponent();
}
private void buttonExit_Click(object sender, EventArgs e)
{
this.Close();
}
string Id;
public void GetId(string id)//上个窗体调用此函数,将id值传过来
{
lbStuId.Text = id;
lbStuId.Refresh();
Id = id;
}
private void StuMain_Load_1(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet.Course”中。您可以根据需要移动或移除它。
this.courseTableAdapter.Fill(this.mySchoolDataSet.Course);
string name, sex, dept, tel;
int age;
string connString = "Data Source=.;Initial Catalog=MySchool;Persist Security Info=True;User ID=sa;Password=yourpassword";//数据库连接字符串
SqlConnection conn = new SqlConnection(connString);//创建connection对象
conn.Open();//打开数据库
//创建数据库命令
SqlCommand cmd = conn.CreateCommand();
//创建查询语句
cmd.CommandText = "select * from Student where Sno = '" + Id + "';select * from StudentUser where ID = '" + Id + "'";
//从数据库中读取数据流存入reader中
SqlDataReader reader = cmd.ExecuteReader();
//从reader中读取下一行数据,如果没有数据,reader.Read()返回flase
while (reader.Read())
{
name = reader.GetString(reader.GetOrdinal("Sname"));
sex = reader.GetString(reader.GetOrdinal("Ssex"));
age = reader.GetInt16(reader.GetOrdinal("Sage"));
dept = reader.GetString(reader.GetOrdinal("Sdept"));
lbStuName.Text = name;
lbStuName.Refresh();
lbStuSex.Text = sex;
lbStuAge.Text = age.ToString();
lbStuDept.Text = dept;
break;
}
reader.NextResult();//执行下一句操作
//从reader中读取下一行数据,如果没有数据,reader.Read()返回flase
while (reader.Read())
{
tel = reader.GetString(reader.GetOrdinal("UserMobile"));
lbPhone.Text = tel;
break;
}
reader.Close();
SqlDataAdapter dap = new SqlDataAdapter("select * from SC where Sno='" + Id + "'", conn);//查询
DataSet ds = new DataSet();//创建DataSet对象
dap.Fill(ds);//填充DataSet数据集
dataGridView1.DataSource = ds.Tables[0].DefaultView;//显示查询后的数据
conn.Close();
int i = 0;
int x = 0, h = 0;
int a;
for (; i < ds.Tables[0].Rows.Count; i++)//读取DataSet中的指定数据
{
x += int.Parse(ds.Tables[0].Rows[i][2].ToString());
if (int.Parse(ds.Tables[0].Rows[i][2].ToString()) > 59)
h++;
}
if (i == 0) a = 0;
else a = x / i;
lbPassnum.Text = h.ToString();
lbAvgSco.Text = a.ToString();
}
private void StuMain_FormClosing_1(object sender, FormClosingEventArgs e)
{
FormLogin m2 = new FormLogin();
m2.Show();
}
private void StuMain_FormClosed(object sender, FormClosedEventArgs e)
{
}
}
}
图10:注册页面
图11:注册成功
图12:注册失败
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class RegisterForm : Form
{
public RegisterForm()
{
InitializeComponent();
}
private void buttonRegister_Click(object sender, EventArgs e)
{
if (tBStuId.Text.Trim() != "" && tBPassword.Text.Trim() != "" && cBSex.Text.Trim() != "" && tBPhoneNum.Text.Trim() != "")
{//确认一些信息输入非空
try
{
string connString = "Data Source=.;Initial Catalog=MySchool;Persist Security Info=True;User ID=sa;Password=yourpassword";//数据库连接字符串
SqlConnection connection = new SqlConnection(connString);//创建connection对象
string username = tBStuId.Text.Trim(); //取出账号
string sex = cBSex.Text.Trim(); //取出性别
connection.Open();
string sql1 = "select Sno,Ssex from Student where Sno = '" + username + "' and Ssex = '" + sex + "'"; //编写SQL命令,查找学生信息中是否有该用户
SqlCommand sqlCommand1 = new SqlCommand(sql1, connection);//确认是否有该学员
SqlDataReader sqlDataReader1 = sqlCommand1.ExecuteReader();
bool a = sqlDataReader1.HasRows;
sqlDataReader1.Close();
if (a)
{
string sql2 = "select ID from StudentUser where ID = '" + username + "'"; //编写SQL命令
SqlCommand sqlCommand2 = new SqlCommand(sql2, connection);//确认是否已经注册过
SqlDataReader sqlDataReader2 = sqlCommand2.ExecuteReader();
if (!sqlDataReader2.HasRows)
{
string sql3 = "insert into StudentUser (ID, PassWord ,Sex, UserMobile, Birthday) " +
"values (@userid, @userpassword,@sex,@usermobile,@Birthday)";
SqlCommand command = new SqlCommand(sql3, connection);
SqlParameter sqlParameter = new SqlParameter("@userid", tBStuId.Text);
command.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@userpassword", EncryptWithMD5(tBPassword.Text));
command.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@sex", cBSex.Text);
command.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@usermobile", tBPhoneNum.Text);
command.Parameters.Add(sqlParameter);
sqlParameter = new SqlParameter("@Birthday", dateTimePicker1.Value);
command.Parameters.Add(sqlParameter);
sqlDataReader2.Close();
//打开数据库连接
command.ExecuteNonQuery();
connection.Close();
MessageBox.Show("注册成功");
}
else
{
MessageBox.Show("该用户已注册。");
}
}
else
{
MessageBox.Show("我校无该学员");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
this.Close();
}
else
{
MessageBox.Show("请将信息填写完整!");
}
}
public Byte[] mybyte = new byte[0];
public static string EncryptWithMD5(string source)
{
byte[] sor = Encoding.UTF8.GetBytes(source);
MD5 md5 = MD5.Create();
byte[] result = md5.ComputeHash(sor);
StringBuilder strbul = new StringBuilder(40);
for (int i = 0; i < result.Length; i++)
{
strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
}
return strbul.ToString();
}
private void tBPassword_Leave(object sender, EventArgs e)//校验密码格式
{
if (tBStuId.Text.Trim() != "")
{
//使用regex(正则表达式)进行格式设置 至少有数字、大写字母、小写字母各一个。最少3个字符、最长20个字符。
Regex regex = new Regex(@"(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{3,20}");
if (regex.IsMatch(tBPassword.Text))//判断格式是否符合要求
{
//MessageBox.Show("输入密码格式正确!");
}
else
{
MessageBox.Show("至少有数字、大写字母、小写字母各一个。最少3个字符、最长20个字符!");
tBPassword.Focus();
}
}
else
{
MessageBox.Show("请填写密码!");
}
}
private void RegisterForm_FormClosing(object sender, FormClosingEventArgs e)
{
FormStuLogin m2 = new FormStuLogin();
m2.Show();
}
private void buttonCancel_Click_1(object sender, EventArgs e)
{
this.Close();
}
}
}
图13:管理员登录页面
图14:管理员登录成功
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class FormManagerLogin : Form
{
public FormManagerLogin()
{
InitializeComponent();
}
public string code;
private void buttonLogin_Click(object sender, EventArgs e)
{
string username = tBWorknum.Text.Trim(); //取出账号
string password = EncryptWithMD5(tBPassword.Text.Trim()); //取出密码并加密
string myConnString = "Data Source=.;Initial Catalog=MySchool;Persist Security Info=True;User ID=sa;Password=yourpassword";
SqlConnection sqlConnection = new SqlConnection(myConnString); //实例化连接对象
sqlConnection.Open();
string sql = "select ID,PassWord from Administrator where ID = '" + username + "' and PassWord = '" + password + "'"; //编写SQL命令
SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
if (sqlDataReader.HasRows && tBVerifyCode.Text == code)
{
MessageBox.Show("欢迎使用!"); //登录成功
ManagerMain managerMain = new ManagerMain();
managerMain.Show();
this.Hide();
}
else if (sqlDataReader.HasRows && tBVerifyCode.Text != code)
{
MessageBox.Show("验证码错误,登录失败!");
return;
}
else
{
MessageBox.Show("账号密码有误,登录失败!");
return;
}
sqlDataReader.Close();
sql = "insert into SysLog1 values ( '" + username + "' , 'Administrator','" + DateTime.Now + "' , '" + "Login" + "')"; //编写SQL命令
SqlCommand sqlCommand1 = new SqlCommand(sql, sqlConnection);
sqlCommand1.ExecuteNonQuery();
sqlConnection.Close();
}
private string EncryptWithMD5(string source)
{
byte[] sor = Encoding.UTF8.GetBytes(source);
MD5 md5 = MD5.Create();
byte[] result = md5.ComputeHash(sor);
StringBuilder strbul = new StringBuilder(40);
for (int i = 0; i < result.Length; i++)
{
strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位
}
return strbul.ToString();
}
private void FormManagerLogin_Load_1(object sender, EventArgs e)
{
//随机实例化
Random ran = new Random();
int number;
char code1;
//取五个数
for (int i = 0; i < 5; i++)
{
number = ran.Next();
if (number % 2 == 0)
code1 = (char)('0' + (char)(number % 10));
else
code1 = (char)('A' + (char)(number % 26)); //转化为字符
this.code += code1.ToString();
}
lbVerifyCode.Text = code;
}
private void FormManagerLogin_FormClosing_1(object sender, FormClosingEventArgs e)
{
FormLogin m2 = new FormLogin();
m2.Show();
}
private void buttonCancel_Click_1(object sender, EventArgs e)
{
this.Close();
}
}
}
图15:管理员主页
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class ManagerMain : Form
{
public ManagerMain()
{
InitializeComponent();
}
private void buttonLog_Click(object sender, EventArgs e)
{
this.Hide();
LogMain m = new LogMain();
m.Show();
}
private void buttonStu_Click(object sender, EventArgs e)
{
this.Hide();
StuMessageMain m = new StuMessageMain();
m.Show();
}
private void buttonCourse_Click(object sender, EventArgs e)
{
this.Hide();
CourseMessageMain m = new CourseMessageMain();
m.Show();
}
private void buttonGrade_Click(object sender, EventArgs e)
{
this.Hide();
StuGradeMain m = new StuGradeMain();
m.Show();
}
private void buttonExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void ManagerMain_FormClosed(object sender, FormClosedEventArgs e)
{
//Application.Exit();
}
private void ManagerMain_FormClosing(object sender, FormClosingEventArgs e)
{
FormLogin m2 = new FormLogin();
m2.Show();
}
private void ManagerMain_Load(object sender, EventArgs e)
{
}
}
}
图16:登录日志页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class LogMain : Form
{
public LogMain()
{
InitializeComponent();
}
private void LogMain_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet1.SysLog1”中。您可以根据需要移动或移除它。
this.sysLog1TableAdapter.Fill(this.mySchoolDataSet1.SysLog1);
}
private void buttonReturn_Click(object sender, EventArgs e)
{
this.Close();
}
private void LogMain_FormClosing(object sender, FormClosingEventArgs e)
{
ManagerMain m2 = new ManagerMain();
m2.Show();
}
}
}
图17:学生信息页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class StuMessageMain : Form
{
public StuMessageMain()
{
InitializeComponent();
}
private void StuMessageMain_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet2.Student”中。您可以根据需要移动或移除它。
this.studentTableAdapter.Fill(this.mySchoolDataSet2.Student);
}
private void buttonReturn_Click(object sender, EventArgs e)
{
this.Close();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
String StuID = tBStuId.Text.Trim();//读取文本框的值
String StuName = tBStuName.Text.Trim();
String StuSex = tBStuSex.Text.Trim();
String StuSdept = tBStuDept.Text.Trim();
int StuAge = int.Parse(tBStuAge.Text.Trim());
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string insertStr = "INSERT INTO Student (Sno,Sname,Ssex,Sdept,Sage) " +
"VALUES ('" + StuID + "','" + StuName + "','" + StuSex + "','" + StuSdept + "'," + StuAge + ")";
SqlCommand cmd = new SqlCommand(insertStr, con);//通过sql语句对表添加数值
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("输入数据违反要求!");
}
finally
{
con.Dispose();
tBStuId.Text = "";
tBStuName.Text = "";
tBStuSex.Text = "";
tBStuAge.Text = "";
tBStuDept.Text = "";
}
this.studentTableAdapter.Fill(this.mySchoolDataSet2.Student);//刷新表
}
private void buttonDelete_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
string delete_by_id = "delete from Student where Sno=" + select_id;//sql删除语句
SqlCommand cmd = new SqlCommand(delete_by_id, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("请正确选择行!");
}
finally
{
con.Dispose();
}
this.studentTableAdapter.Fill(this.mySchoolDataSet2.Student);
}
private void buttonEdit_Click(object sender, EventArgs e)
{
String StuID = tBStuId.Text.Trim();
String StuName = tBStuName.Text.Trim();
String StuSex = tBStuSex.Text.Trim();
String StuSdept = tBStuDept.Text.Trim();
int StuAge = 0;
if (tBStuAge.Text != "")
{
StuAge = int.Parse(tBStuAge.Text.Trim());
}
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
if(StuName != "")
{
string insertStr = "UPDATE Student SET Sname = '" + StuName + "' WHERE Sno = '" + StuID + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if (StuSex != "")
{
string insertStr = "UPDATE Student SET Ssex = '" + StuSex + "' WHERE Sno = '" + StuID + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if (StuSdept != "")
{
string insertStr = "UPDATE Student SET Sdept = '" + StuSdept + "' WHERE Sno = '" + StuID + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if (tBStuAge.Text != "")
{
string insertStr = "UPDATE Student SET Sage = '" + StuAge + "' WHERE Sno = '" + StuID + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
}
catch
{
MessageBox.Show("输入数据违反要求!");
}
finally
{
con.Dispose();
tBStuId.Text = "";
tBStuName.Text = "";
tBStuSex.Text = "";
tBStuAge.Text = "";
tBStuDept.Text = "";
}
this.studentTableAdapter.Fill(this.mySchoolDataSet2.Student);
}
private void buttonSearch_Click(object sender, EventArgs e)
{
String StuID = tBStuId.Text.Trim();
String conn = "Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword";
SqlConnection sqlConnection = new SqlConnection(conn); //实例化连接对象
try
{
sqlConnection.Open();
String select_by_id = "select * from Student where Sno='" + StuID + "'";
SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = sqlDataReader;
dataGridView1.DataSource = bindingSource;
}
catch
{
MessageBox.Show("查询语句有误,请认真检查SQL语句!");
}
finally
{
sqlConnection.Close();
tBStuId.Text = "";
}
}
private void StuMessageMain_FormClosing(object sender, FormClosingEventArgs e)
{
ManagerMain m2 = new ManagerMain();
m2.Show();
}
}
}
图18:课程信息页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class CourseMessageMain : Form
{
public CourseMessageMain()
{
InitializeComponent();
}
private void CourseMessageMain_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet3.Course”中。您可以根据需要移动或移除它。
this.courseTableAdapter.Fill(this.mySchoolDataSet3.Course);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
String cno = tBCno.Text.Trim();
String cn = tBCname.Text.Trim();
String cpo = tBCpno.Text.Trim();
int cd = 0;
if(tBCcredit.Text != "")
{
cd = int.Parse(tBCcredit.Text.Trim());
}
if (cpo == "")
{
cpo = "NULL";
}
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
if(cno == "" || cn =="" || cd == 0)
{
MessageBox.Show("输入数据违反要求!");
}
else
{
con.Open();
string insertStr = "INSERT INTO Course (Cno,Cname,Cpno,Ccredit) " +
"VALUES ('" + cno + "','" + cn + "','" + cpo + "','" + cd + "')";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
}
catch
{
}
finally
{
con.Dispose();
tBCno.Text = "";
tBCname.Text = "";
tBCpno.Text = "";
tBCcredit.Text = "";
}
this.courseTableAdapter.Fill(this.mySchoolDataSet3.Course);
}
private void buttonDelete_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
string delete_by_id = "delete from Course where Cno=" + select_id;//sql删除语句
SqlCommand cmd = new SqlCommand(delete_by_id, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("请正确选择行!");
}
finally
{
con.Dispose();
}
this.courseTableAdapter.Fill(this.mySchoolDataSet3.Course);
}
private void buttonEdit_Click(object sender, EventArgs e)
{
String cno = tBCno.Text.Trim();
String cn = tBCname.Text.Trim();
String cpo = tBCpno.Text.Trim();
int cd = 0;
if(tBCcredit.Text != "")
{
cd = int.Parse(tBCcredit.Text.Trim());
}
if (cpo == "")
{
cpo = "NULL";
}
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
con.Open();
if(cn != "")
{
string insertStr = "UPDATE Course SET Cname = '" + cn + "' WHERE Cno = '" + cno + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if (cpo != "")
{
string insertStr = "UPDATE Course SET Cpno = '" + cpo + "' WHERE Cno = '" + cno + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if (tBCcredit.Text != "")
{
string insertStr = "UPDATE Course SET Ccredit = '" + cd + "' WHERE Cno = '" + cno + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
if(cno == "")
{
MessageBox.Show("输入数据违反要求!");
}
con.Dispose();
tBCno.Text = "";
tBCname.Text = "";
tBCpno.Text = "";
tBCcredit.Text = "";
this.courseTableAdapter.Fill(this.mySchoolDataSet3.Course);
}
private void buttonSearch_Click(object sender, EventArgs e)
{
String cno = tBCno.Text.Trim();
String conn = "Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword";
SqlConnection sqlConnection = new SqlConnection(conn); //实例化连接对象
try
{
sqlConnection.Open();
String select_by_id = "select * from Course where Cno='" + cno + "'";
SqlCommand sqlCommand = new SqlCommand(select_by_id, sqlConnection);
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = sqlDataReader;
dataGridView1.DataSource = bindingSource;
}
catch
{
MessageBox.Show("查询语句有误,请认真检查SQL语句!");
}
finally
{
sqlConnection.Close();
tBCno.Text = "";
}
}
private void buttonReturn_Click(object sender, EventArgs e)
{
this.Close();
}
private void CourseMessageMain_FormClosing(object sender, FormClosingEventArgs e)
{
ManagerMain m2 = new ManagerMain();
m2.Show();
}
}
}
图19:学生成绩信息页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class StuGradeMain : Form
{
public StuGradeMain()
{
InitializeComponent();
}
private void StuGradeMain_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet4.SC”中。您可以根据需要移动或移除它。
this.sCTableAdapter.Fill(this.mySchoolDataSet4.SC);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
String sno = tBSId.Text.Trim();
String cno = tBCno.Text.Trim();
int gra = int.Parse(tBGrade.Text.Trim());
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string insertStr = "INSERT INTO SC (Sno,Cno,Grade) " +
"VALUES ('" + sno + "','" + cno + "','" + gra + "')";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("输入数据违反要求!");
}
finally
{
con.Dispose();
tBSId.Text = "";
tBCno.Text = "";
tBGrade.Text = "";
}
this.sCTableAdapter.Fill(this.mySchoolDataSet4.SC);
}
private void buttonDelete_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string select_id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();//选择的当前行第一列的值,也就是ID
string select_cid = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();//选择的当前行第二列的值,也就是CID
string deletesql = "delete from SC where Sno='" + select_id + "' AND Cno='" + select_cid + "'";//sql删除语句
SqlCommand cmd = new SqlCommand(deletesql, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("请正确选择行!");
}
finally
{
con.Dispose();
}
this.sCTableAdapter.Fill(this.mySchoolDataSet4.SC);
}
private void buttonEdit_Click(object sender, EventArgs e)
{
String sno = tBSId.Text.Trim();
String cno = tBCno.Text.Trim();
int gra = int.Parse(tBGrade.Text.Trim());
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword");
try
{
con.Open();
string insertStr = "UPDATE SC SET Grade='" + gra + "' WHERE Sno = '" + sno + "' AND Cno = '" + cno + "'";
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show("输入数据违反要求!");
}
finally
{
con.Dispose();
tBSId.Text = "";
tBCno.Text = "";
tBGrade.Text = "";
}
this.sCTableAdapter.Fill(this.mySchoolDataSet4.SC);
}
private void buttonSearch_Click(object sender, EventArgs e)
{
String sno = tBSId.Text.Trim();
String cno = tBCno.Text.Trim();
String conn = "Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=yourpassword";
SqlConnection sqlConnection = new SqlConnection(conn); //实例化连接对象
try
{
String selectsql = "select * from SC where Sno='" + sno + "'";
sqlConnection.Open();
if(sno != "" && cno == "")
{
selectsql = "select * from SC where Sno='" + sno + "'";
}
if (sno != "" && cno != "")
{
selectsql = "select * from SC where Sno='" + sno + "' AND Cno='" + cno + "'";
}
SqlCommand sqlCommand = new SqlCommand(selectsql, sqlConnection);
SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = sqlDataReader;
dataGridView1.DataSource = bindingSource;
}
catch
{
MessageBox.Show("查询语句有误,请认真检查SQL语句!");
}
finally
{
sqlConnection.Close();
tBSId.Text = "";
tBCno.Text = "";
}
}
private void buttonMes_Click(object sender, EventArgs e)
{
string connString = "Data Source=.;Initial Catalog=MySchool;Persist Security Info=True;User ID=sa;Password=yourpassword";//数据库连接字符串
SqlConnection connection = new SqlConnection(connString);//创建connection对象
string sql1 = "EXEC COURSE_AVG1";//编写SQL命令
SqlCommand sqlCommand1 = new SqlCommand(sql1, connection);
connection.Open();
sqlCommand1.ExecuteNonQuery();
connection.Close();
this.Hide();
StatisiticMain m2 = new StatisiticMain();
m2.Show();
}
private void buttonReturn_Click(object sender, EventArgs e)
{
this.Close();
}
private void StuGradeMain_FormClosing(object sender, FormClosingEventArgs e)
{
ManagerMain m2 = new ManagerMain();
m2.Show();
}
}
}
图20:成绩统计页面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SchoolManage
{
public partial class StatisiticMain : Form
{
public StatisiticMain()
{
InitializeComponent();
}
private void StatisiticMain_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“mySchoolDataSet6.AVG1”中。您可以根据需要移动或移除它。
this.aVG1TableAdapter.Fill(this.mySchoolDataSet6.AVG1);
}
private void buttonReturn_Click(object sender, EventArgs e)
{
this.Close();
}
private void StatisiticMain_FormClosing(object sender, FormClosingEventArgs e)
{
StuGradeMain m2 = new StuGradeMain();
m2.Show();
}
}
}
图21:退出系统
以上就是本次数据库课程设计的全部内容啦,欢迎小伙伴们交流心得,批评指正。
文章浏览阅读2.1k次。FX3 JLINK调试是一个有些麻烦的事情,经常有些莫名其妙的问题。 设置参见 c:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\firmware 下的 EzUsbSuite_UG.pdf 文档。 常见问题: 1.装了多个版本的jlink,使用了未注册或不适当的版本 选择一个正确的版本。JLinkARM_V408l,JLinkA_ezusbsuite_qsg.pdf
文章浏览阅读2.6k次。** 本文仅通过用openGL+QT简单实现二进制stl文件读取显示并通过鼠标旋转缩放, 是比较入门的级别,由于个人能力有限,新手级别,所以未能施加光影灯光等操作, 未能让显示的stl文件更加真实。****效果图:**1. main.cpp```cpp#include "widget.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); _qopengl如何鼠标控制旋转
文章浏览阅读943次,点赞22次,收藏19次。以大规模预训练语言模型为基础的chatgpt成功出圈,在近几日已经给人工智能板块带来了多次涨停,这足够说明这一风口的到来。而作为曾经的风口“知识图谱”而言,如何找到其与chatgpt之间的区别,找好自身的定位显得尤为重要。形式化知识和参数化知识在表现形式上一直都是大家考虑的问题,两种技术都应该有自己的定位与价值所在。知识图谱构建往往是抽取式的,而且往往包含一系列知识冲突检测、消解过程,整个过程都能溯源。以这样的知识作为输入,能在相当程度上解决当前ChatGPT的事实谬误问题,并具有可解释性。
文章浏览阅读1.3k次。最重要的一点,一定是degbug的方式启动,不然热部署不会生效,注意,注意!_tomcat热部署
文章浏览阅读10w+次,点赞56次,收藏482次。html5 ,用css去修饰自己的个人主页代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xh..._个人主页源码
文章浏览阅读201次。开发者(KaiFaX)面向全栈工程师的开发者专注于前端、Java/Python/Go/PHP的技术社区来源:开源最前线链接:https://github.com/svenstaro/gen..._程序员怎么上班摸鱼
文章浏览阅读1.3k次。改变Block UI界面的尺寸_ug二次开发 调整 对话框大小
文章浏览阅读1.3w次,点赞18次,收藏291次。基于深度学习的股票预测数据获取数据转换LSTM模型搭建训练模型预测结果数据获取采用tushare的数据接口(不知道tushare的筒子们自行百度一下,简而言之其免费提供各类金融数据 , 助力智能投资与创新型投资。)python可以直接使用pip安装tushare!pip install tushareCollecting tushare Downloading https://files.pythonhosted.org/packages/17/76/dc6784a1c07ec040e74_基于深度学习的股票操纵识别研究python代码
文章浏览阅读2k次。【IT168 厂商动态】 近日,北京中科网威(NETPOWER)工业级防火墙通过了中国电力工业电力设备及仪表质量检验测试中心(厂站自动化及远动)测试,并成为中国首家通过电力协议访问控制专业测评的工业级防火墙生产厂商。 北京中科网威(NETPOWER)工业级防火墙专为工业及恶劣环境下的网络安全需求而设计,它采用了非X86的高可靠嵌入式处理器并采用无风扇设计,整机功耗不到22W,具备极_电力行业防火墙有哪些
文章浏览阅读206次。/*烟台大学计算机学院 作者:董玉祥 完成日期: 2017 12 3 问题描述:二叉树排序树中查找的路径 */#include #include #define MaxSize 100typedef int KeyType; //定义关键字类型typedef char InfoType;typedef struct node
文章浏览阅读775次。当时老师一定会告诉你,这个一个"warning"的报警,可以不用管它,也确实如此。不过,这条报警信息我们至少可以知道一点,就是scanf函数调用完之后是有一个返回值的,下面我们就要对scanf返回值进行详细的讨论。并给出在编程时利用scanf的返回值可以实现的一些功能。_c语言ignoring return value
文章浏览阅读9.6k次。十四五规划下,数据安全成为国家、社会发展面临的重要议题,《数据安全法》《个人信息保护法》《关键信息基础设施安全保护条例》已陆续施行。如何做好“数据安全建设”是数字时代的必答题。_数字医疗服务保障方案