数据库轿车销售信息管理系统基于C和SQLserver

上传人:仙*** 文档编号:157486254 上传时间:2022-09-29 格式:DOC 页数:25 大小:1,006.04KB
收藏 版权申诉 举报 下载
数据库轿车销售信息管理系统基于C和SQLserver_第1页
第1页 / 共25页
数据库轿车销售信息管理系统基于C和SQLserver_第2页
第2页 / 共25页
数据库轿车销售信息管理系统基于C和SQLserver_第3页
第3页 / 共25页
资源描述:

《数据库轿车销售信息管理系统基于C和SQLserver》由会员分享,可在线阅读,更多相关《数据库轿车销售信息管理系统基于C和SQLserver(25页珍藏版)》请在装配图网上搜索。

1、沈阳理工大学课程设计专用纸NO.24目 录一、课程设计的目的和意义1二、需求分析1三、概念结构设计E-R图3四、逻辑结构设计4五、数据库实施4六、界面设计与代码6七、课程设计心得与体会23八、参考文献23 轿车销售信息管理系统一、课程设计的目的和意义数据库课程设计是在学生系统的学习了数据库原理课程后,按照关系型数据库的基本原理,综合运用所学的知识,以小组为单位,设计开发一个小型的数据库管理系统。通过对一个实际问题的分析、设计与实现,将原理与应用相结合,使学生学会如何把书本上学到的知识用于解决实际问题,培养学生的动手能力;另一方面,使学生能深入理解和灵活掌握教学内容。大型数据库课程设计是电脑专业

2、集中实践性教学环节之一,是学习完数据库原理及应用课程后进行的一次全面的综合练习。其目的在于加深对大型数据库课程理论和基本知识的理解,掌握使用数据库进行软件设计的基本方法,提高运用数据库解决实际问题的能力。培养学生正确的设计思想,理论联系实际的工作作风,严肃认真、实事求是的科学态度和勇于探索的创新精神。培养学生综合运用所学知识与生产实践经验,分析和解决工程技术问题的能力。二、需求分析轿车销售信息管理系统表达在对各种信息的插入、修改、查询。经过分析系统的需求之后得悉其主要功能如下:1、 可对轿车信息、职工信息、客户信息、轿车销售信息等基本表进行查询操作。2、 可对轿车信息、职工信息、客户信息、轿车

3、销售信息等基本表进行添加操作。3、 可对轿车信息、职工信息、客户信息、轿车销售信息等基本表进行修改操作。4、 可对轿车信息、职工信息、客户信息、轿车销售信息等基本表进行插入操作。5、打印输出销售报表。系统总体设计图如图1所示:汽车销售信息管理系统界面操作数据库管理 登轿车信息表职工信息表 录 删 除添 加查 询修 改客 轿 户 车 信 销 息 售 表 信职工信息表 轿车信息表 息客 轿 表 户 车 信 销 息 售 表 信 息 表 图1 整体设计图三、概念结构设计E-R图 型号轿车编号职工编号颜色生产厂家价格轿车名称学历籍贯年龄性别出厂日期销售汽车职工 服务购买客户客户名称联系方式客户编号业务记

4、录地址 E-R图四、逻辑结构设计将E-R图转换成关系模式:轿车信息轿车编号,型号,轿车颜色,生产厂家,出厂日期,价格;职工信息职工编号,性别,年龄,籍贯,学历;客户信息客户编号,客户名称,联系方式,地址,业务记录;轿车销售信息销售编号,销售日期,轿车类型,颜色,数量,职工编号,客户编号;五、数据库实施建立数据库,打开SQL Server 2008,建立数据库:轿车销售信息管理系统。 1.在轿车销售信息管理系统数据库中,添加轿车信息表,设置轿车编号为主键,不允许为空,如图1所示图1右键选择编辑前200行,输入数据,如图2所示图22.添加职工信息表,设置职工编号为主键,不允许为空,如图3所示:图3

5、右键选择编辑前200行,输入数据,如图4所示: 图43.添加客户信息表,设置客户编号主键,不允许为空,如图5所示: 图5右键选择编辑前200行,输入数据,如图8所示:图64. 添加汽车销售信息表,设置销售编号编号为主键,不允许为空,如图7所示 图7右键选择编辑前200行,输入数据,如图8所示: 图8六、界面设计与代码1.登录界面在界面输入框中输入已在数据库中的用户名和密码,点击登录按钮,如图9所示: 图9提示登录成功,单击确定进入主菜单,如图10所示 图10双击登录按钮,更新单击事件处理程序,主要代码如下:private void button1_Click(object sender, Ev

6、entArgs e) string username = textBox1.Text.Trim(); string password = textBox2.Text.Trim(); string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try string sql = String.Format(select count(*) from login_mes wher

7、e 账号=0 and 密码=1, username, password); conn.Open(); SqlCommand command = new SqlCommand(sql, conn); int num = (int)command.ExecuteScalar(); if (num 0) MessageBox.Show(登陆成功,欢送进入轿车销售管理系统!); Form1 forms = new Form1(); forms.Show(); this.Visible = false; else textBox2.Text = ; MessageBox.Show(您输入的账户名或密码错

8、误!, 登陆失败!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); catch (Exception ex) MessageBox.Show(ex.Message, 操作数据库出错!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally conn.Close(); private void button2_Click(object sender, EventArgs e) this.Visible = false; 2.主界面如图11所示: 图114.点击轿车信息,双击查询

9、按钮,编写程序代码如下: private void button2_Click(object sender, EventArgs e) string connString = Data Source=WIN-LH5EK84HEPR;Initial Catalog=大学生就业咨询系统 ;Integrated Security=True;Pooling=False; SqlConnection connection = new SqlConnection(connString); SqlCommand command = new SqlCommand(); string sql = String.

10、Format(select * FROM 学生信息表 WHERE 学号=0, textBox2.Text); try int i = 0; connection.Open(); / 打开数据库连接 command.Connection = connection; command.CommandText = sql;/设置 Command 对象要执行的SQL语句 SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read() i+; textBox8.Text = dataReader学号.ToString

11、(); textBox1.Text = dataReader.ToString(); textBox7.Text = dataReader性别.ToString(); textBox3.Text = dataReader专业.ToString(); textBox4.Text = dataReader学历.ToString(); textBox5.Text = dataReader毕业年份.ToString(); textBox6.Text = dataReader毕业学校.ToString(); if (i = 0) MessageBox.Show(该生不存在, 查询失败, MessageB

12、oxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(ex.Message, 操作数据库出错!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close();/ 关闭数据库连接 查询数据后,出现如图12:private void search_Click(object sender, EventArgs e) if (tabControl1.SelectedTab.Text.ToString()

13、 = 轿车信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string carnumber = carnumbox.Text.Trim(); string modelboxs = modelbox.Text.Trim(); string sql = String.Format(sel

14、ect * from car_mes where 轿车编号=0 or 型号=1, carnumber, modelboxs); SqlCommand command = new SqlCommand(sql, conn); SqlDataReader dataReader = command.ExecuteReader(); int i = 0; for (i = 0; dataReader.Read(); i+) show.Text += 轿车编号: + Convert.ToString(dataReader0) + n; show.Text += 型号: + Convert.ToStrin

15、g(dataReader1) + n; show.Text += 轿车名称: + Convert.ToString(dataReader2) + n; show.Text += 颜色: + Convert.ToString(dataReader3) + n; show.Text += 生产厂家: + Convert.ToString(dataReader4) + n; show.Text += 出厂日期: + Convert.ToString(dataReader5) + n; show.Text += 价格: + Convert.ToString(dataReader6) + nn; if

16、(i = 0) MessageBox.Show(无此查询信息!查询失败!); dataReader.Close(); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message); else if (tabControl1.SelectedTab.Text.ToString() = 客户信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnecti

17、on conn = new SqlConnection(connString); try conn.Open(); string clientnum = textBox16.Text.Trim(); string clientnam = textBox15.Text.Trim(); string sql = String.Format(select * from cus_mes where 客户编号=0 or 客户名称=1 , clientnum, clientnam); SqlCommand command = new SqlCommand(sql, conn); SqlDataReader

18、 dataReader = command.ExecuteReader(); int i = 0; for (i = 0; dataReader.Read(); i+) show.Text += 客户编号: + Convert.ToString(dataReader0) + n; show.Text += 客户: + Convert.ToString(dataReader1) + n; show.Text += 联系方式: + Convert.ToString(dataReader2) + n; show.Text += 地址: + Convert.ToString(dataReader3)

19、+ n; show.Text += 业务记录: + Convert.ToString(dataReader4) + nnn; if (i = 0) MessageBox.Show(无此查询信息!查询失败!); dataReader.Close(); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message); 查询成功,结果显示:双击添加按钮,程序代码如下:private void add_Click(object sender, EventArgs e) if (tabControl1.SelectedTab.Text.ToS

20、tring() = 轿车信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(insert into car_mes (编号,型号,轿车名称,颜色,生产厂家,出厂日期,价格) values(0,1,2,3,4,5,6) , carnum

21、box.Text, modelbox.Text, textBox17.Text, color.Text, textBox4.Text, textBox5.Text, textBox6.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(添加成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message,数据库操作有误!); else if (tab

22、Control1.SelectedTab.Text.ToString() = 职工信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(insert into staff_mes (职工编号,性别,年龄,籍贯,学历) values(0,

23、1,2,3,4,5) , textBox12.Text, textBox11.Text, textBox10.Text, textBox9.Text, textBox8.Text, textBox7.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(添加成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message, 数据库操作有误!); els

24、e if (tabControl1.SelectedTab.Text.ToString() = 客户信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(insert into cus_mes (客户编号,客户名称,联系方式,地址,业务

25、记录) values(0,1,2,3,4) , textBox16.Text, textBox15.Text, textBox14.Text, textBox13.Text, textBox18.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(添加成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message, 数据库操作有误!); else

26、if (tabControl1.SelectedTab.Text.ToString() = 轿车销售信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(insert into sell_mes (销售编号,销售日期,轿车类型,颜色,数

27、量,职工编号,客户编号) values(0,1,2,3,4,5,6) , textBox25.Text, textBox24.Text, textBox19.Text, textBox23.Text, textBox22.Text, textBox21.Text, textBox20.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(添加成功!); conn.Close(); catch (Exception ex)

28、 MessageBox.Show(ex.Message, 数据库操作有误!); 添加成功,提示:双击修改按钮,程序代码如下:private void change_Click(object sender, EventArgs e) if (tabControl1.SelectedTab.Text.ToString() = 轿车信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = ne

29、w SqlConnection(connString); try conn.Open(); string sql = String.Format(update car_mes set 价格=0 where 编号=1,textBox6.Text,carnumbox.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(修改成功!); conn.Close(); catch (Exception ex) MessageBox

30、.Show(ex.Message, 数据库操作有误!); else if (tabControl1.SelectedTab.Text.ToString() = 职工信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(update st

31、aff_mes set 学历=0 where 职工编号=1, textBox7.Text, textBox12.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(修改成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message, 数据库操作有误!); else if (tabControl1.SelectedTab.Text.ToString(

32、) = 客户信息) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(update cus_mes set 业务记录=0 where 客户编号=1,textBox18.Text, textBox16.Text); SqlCommand co

33、mmand = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (i 0) MessageBox.Show(修改成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message, 数据库操作有误!); else if (tabControl1.SelectedTab.Text.ToString() = 轿车销售信息) show.Text = null; string connString = Data Source=LENOVO-PC;Init

34、ial Catalog=MYCAR;Integrated Security =True; SqlConnection conn = new SqlConnection(connString); try conn.Open(); string sql = String.Format(update sell_mes set 数量=0 where 销售编号=1, textBox22.Text, textBox25.Text); SqlCommand command = new SqlCommand(sql, conn); int i = command.ExecuteNonQuery(); if (

35、i 0) MessageBox.Show(修改成功!); conn.Close(); catch (Exception ex) MessageBox.Show(ex.Message, 数据库操作有误!); 修改成功,显示如下:5.双击打印输出销售报表,添加程序代码如下:private void button1_Click(object sender, EventArgs e) show.Text = null; string connString = Data Source=LENOVO-PC;Initial Catalog=MYCAR;Integrated Security =True; S

36、qlConnection conn = new SqlConnection(connString); try conn.Open(); string carnumber = carnumbox.Text.Trim(); string modelboxs = modelbox.Text.Trim(); string sql = String.Format(select * from sell_mes,staff_mes where sell_mes.职工编号=staff_mes.职工编号 ); SqlCommand command = new SqlCommand(sql, conn); Sql

37、DataReader dataReader = command.ExecuteReader(); int i = 0; for (i = 0; dataReader.Read(); i+) show.Text += 销售编号: + Convert.ToString(dataReader0) + n; show.Text += 销售日期: + Convert.ToString(dataReader1) + n; show.Text += 轿车类型: + Convert.ToString(dataReader2) + n; show.Text += 颜色: + Convert.ToString(dataReader3) + n; show.Text += 数量: + Convert.ToString(dataReader4) + n; show.Text += 职工编号: + Convert.ToString(dataReader5) + n; show.Text += 客户编号: + Convert.ToString(da

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!