程序超市管理系统Word格式文档下载.docx
- 文档编号:17497761
- 上传时间:2022-12-06
- 格式:DOCX
- 页数:22
- 大小:79.54KB
程序超市管理系统Word格式文档下载.docx
《程序超市管理系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《程序超市管理系统Word格式文档下载.docx(22页珍藏版)》请在冰豆网上搜索。
装有Visualstudio2010和sql数据库的计算机一台。
三、实验过程及内容
1、课题分析及要求:
利用C#编程语言,结合数据库完成本系统开发。
需包含模块:
进货登记、销售记录管理、库存管理、商品查询、人员管理。
2、程序分析:
本系统根据要求可分为:
登录模块,管理员模块和普通用户模块,其中,管理员模块中又可分为:
3、程序流程图(如上图所示)
4、程序代码:
连接数据库的类Sjk的代码
usingSystem;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Data;
namespacechaoshiguanlixitong
{
classSjk
{
publicstrings="
"
;
publicSqlConnectionconn=newSqlConnection("
DataSource=(local);
InitialCatalog=csgl;
IntegratedSecurity=SSPI"
);
publicstringcx(stringsql)
DataTabledt=newDataTable();
using(SqlDataAdapteradapter=newSqlDataAdapter(sql,conn))
s="
try
adapter.Fill(dt);
foreach(DataRowdrindt.Rows)
{s=dr[0].ToString();
}
}
catch(Exceptionex)
s=ex.ToString();
returns;
publicstringcx(stringsql,inti)
for(intk=0;
k<
i;
k++)
s+=dr[k].ToString()+"
"
{s=ex.ToString();
publicstringtj(stringsql)
SqlCommandmyupdater=newSqlCommand(sql,conn);
{
conn.Open();
myupdater.ExecuteNonQuery();
conn.Close();
s=ex.ToString();
publicintqh(stringsql)
inti=0;
DataTabledt1=newDataTable();
adapter.Fill(dt1);
foreach(DataRowdr1indt1.Rows)
i+=int.Parse(dr1[0].ToString());
finally{}
returni;
publicintxg(stringsql)
inti=-1;
using(SqlCommandcmd=newSqlCommand(sql,conn))
i=cmd.ExecuteNonQuery();
catch(Exception)
{conn.Close();
登录窗体Form1的代码:
usingSystem.ComponentModel;
usingSystem.Drawing;
publicpartialclassForm1:
Form
publicstaticstringyhm;
publicForm1()
{InitializeComponent();
privatevoidbutton1_Click(objectsender,EventArgse)
if(textBox1.Text=="
||textBox2.Text=="
)
{label3.Text="
账号或密码不能为空!
else
stringm="
select密码fromdengluwhere账号='
+textBox1.Text+"
'
stringg="
select管理员fromdengluwhere账号='
Sjkd=newSjk();
if(d.cx(m).Trim()==textBox2.Text)
yhm=textBox1.Text;
if(d.cx(g).Trim()=="
t"
Form2f2=newForm2();
f2.Show();
Form3f3=newForm3();
f3.Show();
this.Hide();
账号或密码错误,请重新输入!
管理员窗口Form2的代码:
publicpartialclassForm2:
Sjkshujuku=newSjk();
//定义一个数据库的对象
publicstaticstringhh,hl;
//想xinhuo窗体传递参数
publicForm2()
InitializeComponent();
privatevoidForm2_Load(objectsender,EventArgse)
//TODO:
这行代码将数据加载到表“csglDataSet1.xsb”中。
您可以根据需要移动或删除它。
这行代码将数据加载到表“csglDataSet1.spxx”中。
这行代码将数据加载到表“csglDataSet.denglu”中。
这行代码将数据加载到表“csglDataSet.spxx”中。
stringh="
select用户名fromdengluwhere账号='
+Form1.yhm+"
label2.Text=Form1.yhm;
this.Text=shujuku.cx(h)+"
(管理员用户)"
DialogResultk1=MessageBox.Show("
你确定要退出当前用户切换到另一用户?
"
MessageBoxButtons.YesNo);
if(k1==DialogResult.Yes)
this.Close();
Form1f1=newForm1();
f1.Show();
privatevoidbutton2_Click(objectsender,EventArgse)
你确定要退出当前用户?
{Application.Exit();
privatevoidbutton3_Click(objectsender,EventArgse)
intsl=0;
if(jhspbh.Text=="
||jhsl.Text=="
{MessageBox.Show("
商品编号或数量不能为空!
try//判断输入的进货数量是否为数字
{sl=int.Parse(jhsl.Text);
catch
MessageBox.Show("
请输入正确的商品数量!
(商品数量必须为大于0的数字)"
jhsl.Text="
if(sl>
0)
stringsql="
updatespxxset数量=数量+"
+jhsl.Text+"
where商品编号='
+jhspbh.Text+"
inti=shujuku.xg(sql);
if(i>
=0)
if(i==0)
hh=jhspbh.Text;
hl=jhsl.Text;
xinhuoxh=newxinhuo();
xh.Show();
xh.Visible=false;
if(xh.ShowDialog()==DialogResult.OK)
{}
商品添加成功!
jhspbh.Text="
打开数据库失败,请重试!
privatevoidbutton4_Click(objectsender,EventArgse)//商品查询中的“查询”按钮
if(spcx.Text=="
你还没输入要查询的商品编号呢!
select*fromspxxwhere商品编号='
+spcx.Text+"
string[]j=shujuku.cx(sql,7).Split('
'
label12.Text=j[0].ToString();
label13.Text=j[1].ToString();
label15.Text=j[2].ToString();
label17.Text=j[3].ToString();
label19.Text=j[4].ToString();
label21.Text=j[5].ToString();
label23.Text=j[6].ToString();
sql="
select出售数量fromxsbwhere商品编号='
label25.Text=shujuku.qh(sql).ToString();
privatevoidbutton7_Click(objectsender,EventArgse)//人员管理中的删除按钮
if(ryglxm.Text=="
你还没输入要删除的账号呢,不能删除!
if(ryglxm.Text==label2.Text)///判断要删除的是不是当前登陆用户
{MessageBox.Show("
你不能删除当前登陆的账号哦!
else
deletefromdengluwhere账号='
+ryglxm.Text+"
privatevoidbutton8_Click(objectsender,EventArgse)//人员管理中的提交按钮
chars='
f'
if(radioButton1.Checked)
{s='
t'
||textBox3.Text=="
||textBox4.Text=="
用户名,账号和密码不能为空哦!
if(textBox3.Text!
=textBox4.Text)
确认密码和密码不一样哦!
insertintodenglu(用户名,账号,密码,管理员)values('
+textBox2.Text+"
+textBox3.Text+"
+
s+"
)"
stringi=shujuku.tj(sql);
if(i=="
添加用户成功!
{MessageBox.Show(i);
privatevoidbutton5_Click(objectsender,EventArgse)//新货上架
if(tjhh.Text=="
货号不能为空!
stringsql="
+tjhh.Text+"
strings1=shujuku.cx(sql);
if(s1!
="
这件货物存在了哦!
hh=tjhh.Text;
添加新货成功!
privatevoidbutton6_Click(objectsender,EventArgse)//货物下架
if(xjhh.Text=="
+xjhh.Text+"
if(s1=="
这个货物不存在哦!
不能删除!
DialogResultxh=MessageBox.Show("
你确定要删除这件货物?
\n如果是请点击确定按钮。
MessageBoxButtons.YesNo);
if(xh==DialogResult.OK)
deletefromspxxwhere商品编号='
+ryglxm.Texti+"
shujuku.cx(sql);
privatevoiddataGridView4_RowPrePaint(objectsender,DataGridViewRowPrePaintEventArgse)
Intnumber=Convert.ToInt32(dataGridView4.Rows[e.RowIndex].Cells["
数量DataGridViewTextBoxColumn2"
].Value);
if(number>
100)
dataGridView4.Rows[e.RowIndex].DefaultCellStyle.BackColor=Color.Red;
elseif(number<
50)
dataGridView4.Rows[e.RowIndex].DefaultCellStyle.BackColor=Color.Blue;
dataGridView4.Rows[e.RowIndex].DefaultCellStyle.BackColor=Color.White;
privatevoidbutton9_Click(objectsender,EventArgse)
selectsum(销售量)fromspxx"
label39.Text=shujuku.cx(sql);
selectsum(销售金额)fromspxx"
label40.Text=shujuku.cx(sql);
普通用户的窗口Form3的代码:
publicpartialclassForm3:
publicstaticstringwhe="
string[]s=newstring[50];
publicintk=0;
publicForm3()
privatevoidForm3_Load(objectsender,EventArgse)
SqlConnectionconn=newSqlConnection("
//连接对象
select用户名,账号fromdengluwhere账号='
label2.Text=dr[1].ToString();
this.Text=dr[0].ToString()+"
(普通用户)"
finally
Application.Exit();
s[k]=textBox1.Text;
whe+="
商品编号='
+textBox
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 程序 超市 管理 系统