毕业设计视频监控系统代码汇编.docx
- 文档编号:1656239
- 上传时间:2023-05-01
- 格式:DOCX
- 页数:46
- 大小:23.33KB
毕业设计视频监控系统代码汇编.docx
《毕业设计视频监控系统代码汇编.docx》由会员分享,可在线阅读,更多相关《毕业设计视频监控系统代码汇编.docx(46页珍藏版)》请在冰点文库上搜索。
毕业设计视频监控系统代码汇编
附录一登录界面
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceMyVideo
{
publicpartialclassfrmLogin:
Form
{
publicfrmLogin()
{
InitializeComponent();
}
privatevoidfrmLogin_Load(objectsender,EventArgse)
{
this.timer1.Start();//启动时间
}
//确定
privatevoidbtQueding_Click(objectsender,EventArgse)
{
if(tbName.Text.Trim()!
=""&&tbPas.Text.Trim()!
="")//信息输入框都不为空
{
stringLJ=@"DataSource=PC-20150826CYWO;InitialCatalog=MyData;IntegratedSecurity=True";//建立连接
SqlConnectionconn=newSqlConnection(LJ);
SqlCommandcomm=conn.CreateCommand();//实例化数据库的操作命令
conn.Open();
if(rbStudent.Checked)//学生
{
stringsql="selectsno,spass,snamefromstudentwhere(sno='"+tbName.Text+"')";
comm.CommandText=sql;
SqlDataReaderdatar=comm.ExecuteReader();
//使SqlDataReader前进到下一条记录。
返回一个bool值,如果为真跳出循环
while(datar.Read())
{
//读取数据库的内容,并与输入的进行比较;判断用户输入是否正确
if(datar["spass"].ToString().Trim()!
=tbPas.Text.Trim())
{
MessageBox.Show("密码不正确,请重新输入!
");
tbPas.Focus();//焦点:
使光标聚焦在文本输入框
return;
}
else
{
Form1f1=newForm1();
this.Hide();
//this.Close();
f1.ShowDialog();//信息正确,界面跳转
}
}
datar.Close();
}
elseif(rbTeacher.Checked)//老师
{
stringsql="selecttno,tpass,tnamefromteacherwhere(tno='"+tbName.Text+"')";
comm.CommandText=sql;
SqlDataReaderdatar=comm.ExecuteReader();
while(datar.Read())
{
//判断用户输入是否正确
if(datar["tpass"].ToString().Trim()!
=tbPas.Text.Trim())
{
MessageBox.Show("用户名或密码不正确,请重新输入!
");
tbPas.Focus();
return;
}
else
{
Form1f1=newForm1();
this.Hide();
//this.Close();
f1.ShowDialog();
}
}
datar.Close();
}
elseif(rbAdmin.Checked)//管理员
{
stringsql="SELECTadminname,adminpass,adminIDFROMadminWHERE(adminID='"+tbName.Text+"')";
comm.CommandText=sql;
SqlDataReaderdatar=comm.ExecuteReader();
while(datar.Read())
{
if(datar["adminpass"].ToString().Trim()!
=tbPas.Text.Trim())
{
MessageBox.Show("密码不正确,请重新输入!
");
tbPas.Focus();
return;
}
else
{
AdminLoginf2=newAdminLogin();
this.Hide();
f2.ShowDialog();
}
}
datar.Close();
}
tbName.Text="";//用户信息错误,信息清除
tbPas.Text="";
}
else
{
MessageBox.Show("用户或密码不能为空!
");
tbName.Focus();
return;
}
}
//取消
privatevoidbtQuxiao_Click(objectsender,EventArgse)
{
if(MessageBox.Show("你确定退出系统吗?
","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation)==DialogResult.OK)
{
Application.Exit();
}
}
//时间显示
privatevoidtimer1_Tick(objectsender,EventArgse)
{
time.Text="当前时间为:
"+DateTime.Now.ToLongDateString()+""+DateTime.Now.ToLongTimeString();
//字幕滚动
#region
this.time.Left-=3;
if(this.time.Left<0)
{
this.time.Left=this.Width-200;
}
#endregion
}
}
}
附录二信息维护界面
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceMyVideo
{
publicpartialclassAdminLogin:
Form
{
publicAdminLogin()
{
InitializeComponent();
}
publicstaticstringsql="DataSource=PC-20150826CYWO;InitialCatalog=MyData;IntegratedSecurity=True";
inttab_num=1;
//学生工号改变选择tab1
privatevoidrbxsxh_CheckedChanged(objectsender,EventArgse)
{
this.tabControl1.SelectedIndex=0;
}
//教师工号改变选择tab2
privatevoidrbjsgh_CheckedChanged(objectsender,EventArgse)
{
this.tabControl1.SelectedIndex=1;
}
privatevoidtabControl1_SelectedIndexChanged(objectsender,EventArgse)
{
if(tabControl1.SelectedTab.Name=="tabPage1")
{
tab_num=1;
}
elseif(tabControl1.SelectedTab.Name=="tabPage2")
{
tab_num=2;
}
}
privatevoidAdminLogin_Load(objectsender,EventArgse)
{
this.teacherTableAdapter.Fill(this.myDataTeacher.teacher);
this.studentTableAdapter.Fill(this.myDataDataStudent.student);
}
//查询按钮
privatevoidbt_search_Click(objectsender,EventArgse)
{
if(tbSearch.Text.Trim()!
="")
{
search();
}
else
{
MessageBox.Show("查询条件不能为空");
}
}
//查询
privatevoidsearch()
{
stringsql_student="select*fromStudentwhere1=1";
stringsql_teacher="select*fromteacherwhere1=1";
if(rbxsxh.Checked)//学生学号
{
if(tbSearch.Text.Trim()!
="")
{
sql_student+="andsnolike'%"+tbSearch.Text.Trim()+"%'";
}
dataGridView1.DataSource=
MyMeans.GetDataset(sql_student,"Student").Tables["Student"];
}
elseif(rbjsgh.Checked)//教学工号
{
if(tbSearch.Text.Trim()!
="")
{
sql_teacher+="andtnolike'%"+tbSearch.Text.Trim()+"%'";
}
dataGridView2.DataSource=
MyMeans.GetDataset(sql_teacher,"teacher").Tables["teacher"];
}
}
//添加学生信息
privatevoidbutton3_Click(objectsender,EventArgse)
{
if(textBox2.Text==""&&textBox3.Text==""&&textBox4.Text=="")
{
MessageBox.Show("请完善学生信息");
}
else
{
SqlConnectionconn=newSqlConnection(sql);
conn.Open();
SqlCommandcomm=newSqlCommand(sql,conn);
if(tab_num==1)
{
stringsql1="selectsnofromStudentwheresno='"+textBox2.Text.Trim()+"'";
comm.CommandText=sql1;
SqlDataReaderdatar=comm.ExecuteReader();
if(datar.Read())
{
MessageBox.Show("该学生信息已经存在");
}
else
{
stringsql_xuan="InsertintoStudent(sno,sname,spass)values('"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"','"+textBox4.Text.Trim()+"')";
MyMeans.Sqlexcute(sql_xuan);
MessageBox.Show("数据保存成功","系统提示");
relogin();
}
}
elseif(tab_num==2)
{
stringsql2="selecttnofromteacherwheretno='"+textBox2.Text.Trim()+"'";
comm.CommandText=sql2;
SqlDataReaderdatar=comm.ExecuteReader();
if(datar.Read())
{
MessageBox.Show("该教师信息已经存在");
}
else
{
stringsql_xuan="Insertintoteacher(tno,tname,tpass)values('"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"','"+textBox4.Text.Trim()+"')";
MyMeans.Sqlexcute(sql_xuan);
MessageBox.Show("数据保存成功","系统提示");
relogin();
}
}
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
conn.Close();
}
}
//删除信息
privatevoidbutton4_Click(objectsender,EventArgse)
{
if(textBox2.Text=="")
{
MessageBox.Show("请填写删除学生学号或教师工号");
}
else
{
if(tab_num==1)
{
stringsql_tui="deletefromStudentwheresno='"+textBox2.Text+"'";
MyMeans.Sqlexcute(sql_tui);
}
elseif(tab_num==2)
{
stringsql_tui="deletefromteacherwheretno='"+textBox2.Text+"'";
MyMeans.Sqlexcute(sql_tui);
}
MessageBox.Show("数据删除成功","系统提示");
relogin();
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
}
}
//修改学生信息
privatevoidbutton5_Click(objectsender,EventArgse)
{
if(textBox2.Text==""&&textBox3.Text==""&&textBox4.Text=="")
{
MessageBox.Show("请完善所要修改的信息");
}
else
{
SqlConnectionconn=newSqlConnection(sql);
conn.Open();
SqlCommandcomm=newSqlCommand(sql,conn);
if(tab_num==1)
{
stringsql1="selectsno,sname,spassfromStudentwheresno='"+textBox2.Text.Trim()+"'andsname='"+textBox3.Text.Trim()+"'andspass='"+textBox4.Text.Trim()+"'";
comm.CommandText=sql1;
SqlDataReaderdatar=comm.ExecuteReader();
if(datar.Read())
{
MessageBox.Show("该学生信息一样,修改无效");
}
else
{
stringsql_tui="deletefromStudentwheresno='"+textBox2.Text+"'";
MyMeans.Sqlexcute(sql_tui);
stringsql_xuan="InsertintoStudent(sno,sname,spass)values('"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"','"+textBox4.Text.Trim()+"')";
MyMeans.Sqlexcute(sql_xuan);
relogin();
MessageBox.Show("数据保存成功","系统提示");
}
}
elseif(tab_num==2)
{
stringsql2="selecttno,tname,tpassfromteacherwheretno='"+textBox2.Text.Trim()+"'andtname='"+textBox3.Text.Trim()+"'andtpass='"+textBox4.Text.Trim()+"'";
comm.CommandText=sql2;
SqlDataReaderdatar=comm.ExecuteReader();
if(datar.Read())
{
MessageBox.Show("该教师信息一样,修改无效");
}
else
{
stringsql_tui="deletefromteacherwheretno='"+textBox2.Text+"'";
MyMeans.Sqlexcute(sql_tui);
stringsql_xuan="Insertintoteacher(tno,tname,tpass)values('"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"','"+textBox4.Text.Trim()+"')";
MyMeans.Sqlexcute(sql_xuan);
relogin();
MessageBox.Show("数据保存成功","系统提示");
}
}
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
conn.Close();
}
}
//删除多行信息
privatevoidbutton6_Click(objectsender,EventArgse)
{
stringsql="DataSource=PC-20150826CYWO;InitialCatalog=MyData;IntegratedSecurity=True";
SqlConnectionconn=newSqlConnection(sql);
conn.Open();//打開連接
SqlCommandcmd=conn.CreateCommand();
if(this.dataGridView1.SelectedRows.Count>0&&tab_num==1)
{
DialogResultdr=MessageBox.Show("确定删除选中的记录?
","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if(dr==DialogResult.OK)
{
//遍历所选中的dataGridView记录行
foreach(DataGridViewRowrowinthis.dataGridView1.SelectedRows)
{
//取dataGridView1中的第一列的值
stringstrN=row.Cells[0].Value.ToString();
stringsql1="deletefromstudentwheresno='"+strN+"'";
cmd.CommandText=sql1;
cmd.ExecuteNonQuery();//执行删除
}
}
}
elseif(this.dataGridView2.SelectedRows.Count>0&&tab_num==2)
{
DialogResultdr=MessageBox.Show("确定删除选中的记录?
","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if(dr==DialogResult.OK)
{
//遍历所选中的dataGridView记录行
foreach(DataGridViewRowrowinthis.dataGridView2.SelectedRows)
{
//取dataGridView1中的第一列的值
stringstrN=row.Cells[0].Value.ToString();
stringsql1="deletefromt
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 毕业设计 视频 监控 系统 代码 汇编
![提示](https://static.bingdoc.com/images/bang_tan.gif)