C#程序超市管理系统

上传人:工**** 文档编号:511694524 上传时间:2023-01-23 格式:DOC 页数:20 大小:444KB
返回 下载 相关 举报
C#程序超市管理系统_第1页
第1页 / 共20页
C#程序超市管理系统_第2页
第2页 / 共20页
C#程序超市管理系统_第3页
第3页 / 共20页
C#程序超市管理系统_第4页
第4页 / 共20页
C#程序超市管理系统_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《C#程序超市管理系统》由会员分享,可在线阅读,更多相关《C#程序超市管理系统(20页珍藏版)》请在金锄头文库上搜索。

1、河南机电高等专科学校学生课程设计报告实验课程名称C#程序设计及应用教程开课实验室实字3号楼301系、部计科系 年级11专业班 软件111 (对口学生姓名 胡玉祥 学号开课时 间 2012 至2013 学年第 一 学期总成绩教师签名C#程序设计课程设计报告系部计科系年级、专业、班软件111姓名课程名称C#程序设计项目名称超市管理系统指导教师教 师 评 语教师签名:年 月日一、课程设计目的经过一学期对C#开发语言的学习,利用本学期所学的知识进行一次简单的检测,因此 做了本系统。二、实验环境2013年1月15日装有 Visual studio 2010和sql数据库的计算机一台三、实验过程及内容1、

2、课题分析及要求:利用C#编程语言,结合数据库完成本系统开发。需包含模块: 进货登记、销售记录管理、库存管理、商品查询、人员管理。2、程序分析:本系统根据要求可分为:登录模块,管理员模块和普通用户模块,其用户登录中,管理员模块中又可分为:进货登记、销售记录管理、库存管理、商品查询、人员 管理。3、程序流程图(如上图所示)4、程序代码:连接数据库的类Sjk的代码using System;using System.Collectio ns.Ge neric;using System丄inq;using System.Text;using System.Data.SqlClie nt;using Sy

3、stem.Data;n amespace chaoshigua nlixit ongclass Sjkpublic stri ng s =;publicSqlC onn ecti onconn = newSource=(local);l nitial Catalog=csgl; I ntegrated Security=SSP I);public stri ng cx(stri ng sql)DataTable dt = new DataTable();SqlCo nn ectio n( Datausing (SqlDataAdapter adapter = new SqlDataAdapte

4、r(sql, conn) s =;tryadapter.Fill(dt);foreach (DataRow dr in dt.Rows) s = drO.ToStri ng();catch (Exceptio n ex)s = ex.ToStri ng();return s;public stri ng cx(stri ng sql, i nt i)Illi DataTable dt =new DataTable();using (SqlDataAdapter adapter = new SqlDataAdapter(sql, conn) try adapter.Fill(dt); forea

5、ch (DataRow dr in dt.Rows) for (int k = 0; k i; k+)s += drk.ToStri ng() + ,;catch (Exceptio n ex) s = ex.ToStri ng();return s;public stri ng tj(stri ng sql)s =;SqlComma nd myupdater = new SqlComma nd(sql, conn);tryconn. Ope n();myupdater.ExecuteN on Query();conn .Close();catch (Excepti on ex)s = ex.

6、ToStri ng ();conn .Close();return s;public int qh(stri ng sql)int i = 0;DataTable dt1 = new DataTable();using (SqlDataAdapter adapter = new SqlDataAdapter(sql, conn) tryadapter.Fill(dt1);foreach (DataRow dr1 in dt1.Rows)i += in t.Parse(dr1O.ToStri ng();kfin ally return i;public int xg(stri ng sql)in

7、t i=-1;using (SqlComma nd cmd = new SqlComma nd(sql, conn) tryconn. Ope n();i = cmd.ExecuteN on Query(); conn .Close();catch (Exceptio n ) conn .Close(); return i;登录窗体Form1的代码:using System;using System.Collectio ns.Ge neric;using System.Comp onen tModel;using System.Drawi ng;using System丄inq;using S

8、ystem.Text;using System.Wi ndows.Forms;n amespace chaoshigua nlixit ongpublic partial class Form1 : Formpublic static stri ng yhm;public Form1() In itializeComp onen t();private void butt on 1_Click(object sen der, Eve ntArgs e) if (textBox1.Text = | textBox2.Text =) label3.Text =账号或密码不能为空!; elsestr

9、ingm = select 密 码 from denglu where 账 号=+textBoxl.Text + ;stringg = select 管理员 from denglu where 账 号=+textBoxl.Text + ;Sjk d = new Sjk();if (d.cx(m).Trim() = textBox2.Text)yhm = textBox1.Text;if (d.cx(g).Trim() = t)Form2 f2 = new Form2();f2.Show();elseForm3 f3 = new Form3();f3.Show();this.Hide();els

10、e label3.Text =账号或密码错误,请重新输入!; 管理员窗口 Form2的代码: using System;using System.Collectio ns.Ge neric;using System.Comp onen tModel;using System.Drawi ng;using System丄inq;using System.Text;using System.Wi ndows.Forms; n amespace chaoshigua nlixit ong 定义一个数据库的对象想xinhuo窗体传递参数public partial class Form2 : Form

11、 Sjk shujuku = new Sjk(); / public static stri ng hh, hl;/ public Form2()In itializeComp onen t();private void Form2_Load(object sen der. Eve ntArgs e) _/ TODO:这行代码将数据加载到表“ csglDataSet1.xsb ”中。您可以根据需要移动或删除它。this.xsbTableAdapter1.Fill(this.csglDataSet1.xsb);/TODO:这行代码将数据加载到表“ csglDataSet1.spxx ”中。您可以

12、根据需要移动或删除它。this.spxxTableAd apter1.Fill(this.csglDataSet1.spxx);/ TODO:这行代码将数据加载到表“ csglDataSet.de nglu ”中。您可以根据需要移动或删除它。this.de ngluTableAdapter.Fill(this.csglDataSet.de nglu);/ TODO:这行代码将数据加载到表“ csglDataSet.spxx ”中。您可以根据需要移动或删除它。this.spxxTableAdapter.Fill(this.csglDataSet.spxx);string h= select用户名

13、 from denglu where 账号=+ Form1.yhm+ J Jlabel2.Text = Form1.yhm ;this.Text = shujuku .cx(h)+ (管理员用户);private void butt on 1_Click(object sen der, Eve ntArgs e)DialogResult k1 = MessageBox.Show(”你确定要退出当前用户切换到另一用户? , , MessageBoxButtons.YesNo);if (k1 = DialogResult.Yes)this.Close();Form1 f1 = new Form1(

14、);f1.Show();private void butt on 2_Click(object sen der, Eve ntArgs e) _DialogResultk1 = MessageBox.Show(你确定要退出当前用户?,MessageBoxButto ns.YesNo);if (k1 = DialogResult.Yes) Applicatio n.Exit();private void butt on 3_Click(object sen der, Eve ntArgs e) _int sl=0;if (jhspbh.Text = | jhsl.Text =) MessageBox.Show(商品编号或数量不能为空!); elsetry /判断输入的进货数量是否为数字 si = int.Parse(jhsl.Text); catch

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号