1、旅行社管理系统实训C#解析C#程序设计实训报告( 2012 2013 )学年第 2 学期)姓 名: 学 号: 专 业: 计算机科学与技术 班 级: 计科1101 指导教师: C#程序设计实训报告日 期 201371-201275地 点 67#206项目名称 旅行社管理系统实训目的能力目标 1、理解C#WinForm程序设计的风格,能设计合理的C#项目文件夹结构和公共类,注重代码的重用性,养成良好的标识符命名和代码编写习惯;2、熟练掌握各种常见的控件属性和事件方法;3、积累项目开发中常采用的设计模式和比较经典代码片段,并能在以后的项目开发中熟练地运用。实训要求:1、实训期间每天登记考勤,作为实训
2、成绩的一部分。2、实训期间不能玩游戏、看电影、小说等做与学习无关的事。如果有不遵守的同学将取消当天成绩。3、每天必须按照指导教师实训安排完成当天的实训项目,并经过老师的检查。4、完成整个实训以后,要求每人写出实训报告。5、实训报告要求有插图,模块关键代码及注释。实训内容-旅行社管理系统(过程及步骤)一、系统功能分析与设计二、数据库设计在电脑中找到access 用access建立数据库(1)操作员信息表(编号,姓名,密码,类别)(2)景点信息表(编号,景点名称,地址,门票价格,简介,级别) (3)用到连接access数据库知识using System.Data.OleDb; string str
3、 = Provider=Microsoft.Jet.OLEDB.4.0; str += access数据库地址; OleDbConnection myConn = new OleDbConnection(str); myConn.Open();三、项目文件夹及公共类的设计四、模块设计、编码与调试1. 登录模块: 1.1获取本地时间 private void timer1_Tick(object sender, EventArgs e)/添加的?动态?时钟 this.toolStripStatusLabel1.Text = DateTime.Now.ToString(); private voi
4、d statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) this.statusStrip1.Text = System.DateTime.Now.ToString(); 1.2设置背景音乐 public static uint SND_ASYNC = 0x0001; / play asynchronously public static uint SND_FILENAME = 0x00020000; / name is file name DllImport(winmm.dll) public sta
5、tic extern uint mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, uint hWndCallback);private void Form1_Load(object sender, EventArgs e)/添加背3景音?乐? mciSendString(close temp_alias, null, 0, 0); mciSendString(open 郭采洁 - 我的?未来式?.mp3 alias temp_alias,null, 0, 0); mciSendStr
6、ing(play temp_alias repeat, null, 0, 0); 1.2登录(此时需要连接数据库,从数据库中得到用户名和密码) private void button1_Click(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0; str += Data Source=liuhedongtravel.mdb; OleDbConnection myConn = new OleDbConnection(str); myConn.Open(); if (textBox1.Text !=
7、 & textBox2.Text != ) string sql = select * from login where userName= + textBox1.Text.Trim() + and userPass= + textBox2.Text.Trim() + ; adapter = new OleDbDataAdapter(sql, str); OleDbCommandBuilder buider = new OleDbCommandBuilder(adapter); adapter.InsertCommand = buider.GetInsertCommand(); table.C
8、lear(); adapter.Fill(table); if (table.Rows.Count 0) Form3 f3 = new Form3(); f3.Show(); else MessageBox.Show(登?录?失败); 登录密码为空或错误时显示最后设计的界面为:2、注册界面 private void button1_Click(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=liuhedongtravel.mdb; if (textBox1.Text.Tr
9、im() = | textBox2.Text.Trim() = | textBox3.Text.Trim() = ) MessageBox.Show(请?将?信?息填?写完整?!?); else if (textBox2.Text.Trim() != textBox3.Text.Trim() MessageBox.Show(两?次?输?入?的?密码?不?一?致?!?); else OleDbConnection myConn = new OleDbConnection(str); myConn.Open(); string sqll = INSERT INTO login(userName,u
10、serPass) values ( + textBox1.Text + , + textBox2.Text + ) ; OleDbCommand com = new OleDbCommand(sqll, myConn); com.CommandText = sqll; com.ExecuteNonQuery(); MessageBox.Show(注册成功|!?点?击确定,?返回?登?录?界?面?。); Form1 f1 = new Form1(); f1.Show(); this.Hide(); private void button2_Click(object sender, EventAr
11、gs e) this.Close(); *如果密码输入错误*如果输入正确*3、旅行社管理系统主界面(注册成功,在登陆界面中登录) 4、景点信息管理系统 5、操作员管理系统 private void button1_Click(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=liuhedongtravel.mdb; OleDbConnection myConn = new OleDbConnection(str); myConn.Open(); string sqll =
12、INSERT INTO login(userName,userPass) values ( + textBox1.Text.Trim() + , + textBox2.Text.Trim() + ) ; OleDbCommand com = new OleDbCommand(sqll, myConn); com.CommandText = sqll; com.ExecuteNonQuery(); MessageBox.Show(添加用?户成功|!?); this.Hide(); Form9 f99 = new Form9(); f99.Show(); 6、景点图片浏览单击景点图片浏览实现代码:
13、private void driveListBox1_SelectedIndexChanged(object sender, EventArgs e) dirListBox1.Path = driveListBox1.Text; private void dirListBox1_Change(object sender, EventArgs e) fileListBox1.Path = dirListBox1.Path; private void fileListBox1_SelectedIndexChanged(object sender, EventArgs e) String s; if
14、 (fileListBox1.FileName != null) s = dirListBox1.Path + + fileListBox1.FileName; pictureBox1.Image = System.Drawing.Image.FromFile(s); if (pictureBox1.Image.Width pictureBox1.Size.Width) button2.Enabled = true; else button2.Enabled = false; private void fileListBox1_PathChange(object sender, EventAr
15、gs e) button2.Enabled = false; pictureBox1.Image = null; private void radioButton1_CheckedChanged(object sender, EventArgs e) if (fileListBox1.Pattern != *.gif) fileListBox1_PathChange(sender, e); fileListBox1.Pattern = *.gif; private void radioButton2_CheckedChanged(object sender, EventArgs e) if (
16、fileListBox1.Pattern != *.jpg) fileListBox1_PathChange(sender, e); fileListBox1.Pattern = *.jpg; private void radioButton3_CheckedChanged(object sender, EventArgs e) if (fileListBox1.Pattern != *.bmp) fileListBox1_PathChange(sender, e); fileListBox1.Pattern = *.bmp; private void radioButton4_Checked
17、Changed(object sender, EventArgs e) if (fileListBox1.Pattern != *.ico) fileListBox1_PathChange(sender, e); fileListBox1.Pattern = *.ico; private void button2_Click(object sender, EventArgs e) Form11 myform = new Form11(); String s; s = dirListBox1.Path + + fileListBox1.FileName; myform.pictureBox1.I
18、mage = System.Drawing.Image.FromFile(s); myform.Show(); private void button1_Click(object sender, EventArgs e) Application.Exit(); 7、添加景点信息 private void button1_Click(object sender, EventArgs e) string str = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=liuhedongtravel.mdb; OleDbConnection myConn = n
19、ew OleDbConnection(str); myConn.Open(); string sqll = INSERT INTO sportInfo(id,sportName,address,price,introduce,grade) values ( + textBox6.Text.Trim() + , + textBox1.Text.Trim() + , + textBox2.Text.Trim() + , + textBox3.Text.Trim() + , + textBox4.Text.Trim() + , + textBox5.Text.Trim() + ) ; OleDbCo
20、mmand com = new OleDbCommand(sqll, myConn); com.CommandText = sqll; com.ExecuteNonQuery(); MessageBox.Show(添加用?户成功|!?); Form6 f6 = new Form6(); f6.Show(); 添加并单击添加,弹出景点信息8、系统维护9、其他 实训心得:1、通过本次实训,使我对C#的图形界面更加认识和理解.2、在开始做的时候对数据库连接不会使用,通过网络,让我对数据库连接有了深刻的认识和理解,一个标点不可马虎!3、在浏览图片界面设计时遇到了不少麻烦,通过图书和网络最终还是解决了4、在信息添加时,每个格式都是一定的,不可以马虎,当时在这用了好长时间,最终是标点和格式不对。5,、通过本次实训,让我对编程有了更大的信心,我会加倍努力,努力让自己做到最好分数: 教师签名: 年 月 日
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1