武汉生物工程学院学士学位论文
MessageBox.Show(\请根据销售单号修改!\ } }
catch { MessageBox.Show(\请正确操作!\ }
7.1.5权限登录代码
public partial class Form1 : Form {
public Form1() {
InitializeComponent(); }
//权限管理
public static int limits=1;
private void button1_Click(object sender, EventArgs e) {
try {
string UserName = textBox2.Text; string pwd = textBox1.Text; string bm = \
if (radioButton3.Checked == true) {
limits = 3;//系统 bm = \系统员\ }
if (radioButton2.Checked == true) {
limits = 1;//销售员 bm = \库管部\ }
if (radioButton1.Checked == true) {
limits = 2;//仓库员 bm = \销售部\ }
string sql =
\department=@c\
SqlParameter[] pm = new SqlParameter[3]; pm[0] = new SqlParameter(\
35
武汉生物工程学院学士学位论文
pm[1] = new SqlParameter(\ pm[2] = new SqlParameter(\
//登录到窗体2界面
if (Convert.ToInt32(SqlHelper.GetOneValue(sql, false, pm)) > 0) {
this.Hide();
Form2 f = new Form2(); f.Show(); } else {
MessageBox.Show(\用户名和密码不匹配\ } }
catch { MessageBox.Show(\您的输入有误!\ }
//获取移动窗口的位置 int x = 0; int y = 0;
private void Form1_MouseDown(object sender, MouseEventArgs e) {
MouseButtons b = e.Button; if (b == MouseButtons.Left) {
x = e.X; y = e.Y; } }
private void Form1_MouseMove(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
int xLen = e.X - x; int yLen = e.Y - y; this.Left += xLen; this.Top += yLen; } } } }
7.1.6数据库代码:
36
武汉生物工程学院学士学位论文
--创建数据库
if exists(select * from sysdatabases where name='CarSales') drop database CarSales go
create database CarSales go
--创建一张用户表 use CarSales go
if exists(select *from sysobjects where name='UserTable') drop table UserTable create table UserTable (
UserId int identity(1001,1) primary key, UserName varchar(50), PassWord varchar(50), limits int,
department varchar(50) ) go
insert into UserTable values('aaa','aaa',3,'系统员'); insert into UserTable values('唐小么','123',2,'销售部'); insert into UserTable values('提莫','123',1,'库管部');
select *from UserTable
--创建汽车表
--,(sNo),用户编号(uNo),用户名称(uName), --身份证号(uId),车辆颜色(carCo),
-- 底盘号(doNo),车辆用途(carUse),成交价(price),业务员(saleMan) use CarSales go
if exists(select *from sysobjects where name='sale') drop table sale create table sale (
sNo int identity(20141201,1) primary key, --销售单号 carNo int, --车辆编号(carNo) storageNo int, --仓库号
sTime datetime, --销售日期(sTime) uNo int,
37
武汉生物工程学院学士学位论文
uName varchar(50), uId varchar(50), carco varchar(50), doNo int,
carUse varchar(50), price money,
saleMan varchar(50) )
insert into sale values
(1,1101,2014-6-12,1,'老马','42900619940523021','红色',20,'个人需要','180000','小张');
insert into sale values
(2,1102,2014-1-11,2,'婉儿','42900619940523021','白色',16,'公司需要','2010000','鸿雁');
insert into sale values
(3,1103,2014-6-12,3,'扎哈','42900619940523021','黑色',33,'商业需要','50000','琪琪');
select*from sale
--创建仓库管理表 use CarSales go
if exists (select*from sysobjects where name='Storage' and xtype='s') drop table Storage go
create table Storage (
storageNo int identity(1101,1),--仓库号 stoSite varchar(200), --仓库位置 stoMax int, --最大库存 stoTel bigint, --联系电话 stoNum int --当前数量 ) go
--添加数据
insert into Storage values ('武汉',200,15677770888,100) insert into Storage values ('襄阳',200,15967970888,50) insert into Storage values ('天门',200,15837770888,50) insert into Storage values ('荆门',200,13257270888,50) delete from Storage where storageNo=1104
update Storage set stoSite='荆州',stoMax=500,stoTel=145252222,stoNum=22 where storageNo=1104
select distinct storageNo from Storage --编号一样的去除
select distinct storageNo,stoSite,stoMax,stoTel,stoNum from Storage
38
武汉生物工程学院学士学位论文
select *from Storage
use CarSales go
--创建库存管理表
if exists (select * from sysobjects where name='carInfo') drop table carInfo go
create table carInfo (
storageNo int identity(1101,1), --仓库号 fcId int,--厂商编号 keyId int,--钥匙号 inPrice float,--进价
stoMan varchar(50),--仓库管理员 rkId int,--入库单号
linkMan varchar(50),--联系人 rkDate datetime--入库日期 ) go
--添加数据
insert into carinfo values(1001,1101,120000,'王某',0001,'杨某','2004.01.21') insert into carinfo values(1002,1102,213464,'赵某',0002,'李某','2003.05.15') insert into carinfo values(1003,1103,324560,'孙某',0003,'朱某','2005.04.19') --select *from carInfo where cType='卡车' or color='' or fcName=''
insert into carInfo values(1001,1101,120000,'王某',0004,'杨某','2004.01.21') delete from carInfo where storageNo=1103 select*from carInfo
--创建销售管理表 use CarSales
if exists(select*from sysobjects where name='sWork') drop table swork go
create table sWork (
sNo int identity(20141201,1) primary key, saleMan varchar(50), price money ) go
insert into sWork values('糖糖糖','2000') delete from sWork where sNo=20141201
39
武汉生物工程学院学士学位论文
update swork set saleMan='小星星', price='4000' where sNo=20141202 select *from sWork
这个是在Vs里面创建一个app.config,然后写与数据库的连接 app.config
server= ip uid=登录名 pwd=登录密码 database=数据库
7.2参考文献: 1.罗福强 杨剑 张敏辉/C#程序设计经典教程 北京:清华大学出版社 2012. 2.陈维兴 林小茶/C++面向对象程序设计 北京:铁道出版社 2009 3.王晓敏 邝孔武/信息系统分析与设计 北京:清华大学出版社 2013 4. 黄梯云 李一军/管理信息系统 北京:高等教育出版社 2013 5.张海藩/软件工程 北京:清华大学出版社 2009 6.刘红军/信息管理概论 北京:科学出版社2008 7.张建伟,梁树军./数据库技术与应用—SQL Server北京:人民邮电出版社,2008 8.王珊,萨师煊. 数据库系统概论 北京:高等教育出版社,2004 40