程序代码.docx
《程序代码.docx》由会员分享,可在线阅读,更多相关《程序代码.docx(81页珍藏版)》请在冰豆网上搜索。
程序代码
仓储管理系统代码
【李彩享、字朝龙】
一、窗体(frmLogin)登录的代码程序
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWMS
{
publicpartialclassfrmLogin:
Form
{
publicstaticstringM_str_name;//记录登录用户名字
publicstaticstringM_str_pwd;//记录登录用户密码
publicstaticstringM_str_right;//记录登录用户的权限
publicfrmLogin()
{
InitializeComponent();
}
privatevoidfrmLogin_Load(objectsender,EventArgse)//启动窗口时加载用户名
{
DbOperatordb=newDbOperator();
SqlConnectioncnn=db.GetCon();
SqlCommandcmd=newSqlCommand();
cmd.CommandType=CommandType.Text;
cmd.CommandText="selectUserNamefromtbUserInfo";//
cmd.Connection=cnn;
cnn.Open();
SqlDataReaderdr;
dr=cmd.ExecuteReader();
if(dr.HasRows)
{
while(dr.Read())
{
cmbUserList.Items.Add(dr["UserName"].ToString().Trim());//在控件中显示用户名
}
cmbUserList.Sorted=true;
}
else
{
MessageBox.Show("表中无记录!
","提示?
",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
}
dr.Close();
cnn.Close();
}
privatevoidbtnCancel_Click(objectsender,EventArgse)
{
if(MessageBox.Show("你确定要退出吗?
","提示?
",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
this.Close();
else
cmbUserList.Focus();
return;
}
privatevoidbtnLoad_Click(objectsender,EventArgse)//用存储过程实现验证登录
{
DbOperatordb=newDbOperator();
SqlConnectioncnn=db.GetCon();
SqlCommandcmd=newSqlCommand();
cmd.Connection=cnn;
cmd.CommandType=CommandType.StoredProcedure;
cmd.CommandText="proc_Login";
SqlParameterpaUser=newSqlParameter();
paUser.ParameterName="@User_Name";
paUser.SqlDbType=SqlDbType.VarChar;
paUser.Size=50;
paUser.Value=cmbUserList.Text.Trim();
cmd.Parameters.Add(paUser);
SqlParameterpaPwd=newSqlParameter();
paPwd.ParameterName="@User_Pwd";
paPwd.SqlDbType=SqlDbType.VarChar;
paPwd.Size=20;
paPwd.Value=txtPwd.Text.Trim();
cmd.Parameters.Add(paPwd);
SqlParameterpaRe=newSqlParameter();
paRe.ParameterName="@re";
paRe.SqlDbType=SqlDbType.Int;
paRe.Value=0;
paRe.Direction=System.Data.ParameterDirection.Output;//设置
cmd.Parameters.Add(paRe);
cnn.Open();
cmd.ExecuteNonQuery();
intRe=int.Parse(cmd.Parameters["@re"].Value.ToString());
if(Re==1)
{
frmMainfrm=newfrmMain();
frm.Show();
}
else
MessageBox.Show("用户名或密码错误!
","提示");
cnn.Close();
}
privatevoidcmbUserList_SelectedIndexChanged(objectsender,EventArgse)
{
DbOperatordb=newDbOperator();
SqlConnectioncnn=db.GetCon();
SqlCommandcmd=newSqlCommand();
SqlDataReadersqlread=db.getread("selectUserName,PowerfromtbUserInfowhereUserName='"+cmbUserList.Text.Trim().ToString()+"'");
if(sqlread.Read())
{
labPower.Text=sqlread["Power"].ToString();
M_str_right=labPower.Text;
}
sqlread.Close();
cnn.Close();
cnn.Dispose();
}
privatevoidfrmLogin_FormClosing(objectsender,FormClosingEventArgse)
{
Application.Exit();
}
privatevoidtxtPwd_KeyPress(objectsender,KeyPressEventArgse)
{
if(e.KeyChar==13)
btnLoad.Focus();
}
privatevoidcboxUName_KeyPress(objectsender,KeyPressEventArgse)
{
if(e.KeyChar==13)
txtPwd.Focus();
}
}
}
二、主界面系统代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWMS
{
publicpartialclassfrmMain:
Form
{
publicfrmMain()
{
InitializeComponent();
}
privatevoid商品采购查选ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmGoodsCGSelectfrm=newfrmGoodsCGSelect();
frm.Show();
}
privatevoid退ª?
出?
系¦Ì统ª3ToolStripMenuItem_Click(objectsender,EventArgse)
{
if(MessageBox.Show("你确定要退出吗?
","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
this.Close();
}
privatevoid重新登录ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmLoginfrm1=newfrmLogin();
frm1.ShowDialog();
}
privatevoid商品类别设置ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmGoodsClassSetfrm2=newfrmGoodsClassSet();
frm2.Show();
}
privatevoid商品信息设置ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmGoodsInfofrm3=newfrmGoodsInfo();
frm3.Show();
}
privatevoid供应商设置ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmSupplierInfofrm4=newfrmSupplierInfo();
frm4.Show();
}
privatevoid仓库设置ToolStripMenuItem1_Click(objectsender,EventArgse)
{
frmStoreInfofrm5=newfrmStoreInfo();
frm5.Show();
}
privatevoid库存盘点toolStripMenuItem23_Click(objectsender,EventArgse)
{
frmKCPDfrm6=newfrmKCPD();
frm6.Show();
}
privatevoid采购入库atoolStripMenuItem20_Click(objectsender,EventArgse)
{
frmCGRKfrm=newfrmCGRK();
frm.Show();
}
privatevoidtoolStripMenuItem12_Click(objectsender,EventArgse)
{
frmGoodsInfofrm=newfrmGoodsInfo();
frm.Text="商品信息查询";
frm.ShowDialog();
}
privatevoidtoolStripMenuItem22_Click(objectsender,EventArgse)
{
frmCKGLfrm=newfrmCKGL();
frm.Show();
}
privatevoidtoolStripMenuItem8_Click(objectsender,EventArgse)
{
frmGoodsCGSelectfrm=newfrmGoodsCGSelect();
frm.Text="商品采购统计";
frm.Show();
}
privatevoidtoolStripMenuItem15_Click(objectsender,EventArgse)
{
frmGoodsInfofrm=newfrmGoodsInfo();
frm.Text="当前库存查询";
frm.Show();
}
privatevoid更改密码ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmSetUserfrm=newfrmSetUser();
frm.Show();
}
privatevoid权限管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmSetUsersfrm=newfrmSetUsers();
frm.Show();
}
privatevoid用户管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
frmSetUsersfrm=newfrmSetUsers();
frm.Show();
}
privatevoidtoolStripMenuItem9_Click(objectsender,EventArgse)
{
frmSelectSupplierfrm=newfrmSelectSupplier();
frm.Show();
}
}
}
三、商品类别设置代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWMS
{
publicpartialclassfrmGoodsClassSet:
Form
{
publicfrmGoodsClassSet()
{
InitializeComponent();
}
privatevoidfrmGoodsClassSet_Load(objectsender,EventArgse)
{
LoadGC();
grpbClass.Enabled=false;
}
privatevoiddgvGClass_CellClick(objectsender,DataGridViewCellEventArgse)
{
ShowGC();
}
privatevoidLoadGC()//将客户表显示在DataGridView中
{
DbOperatorclsC=newDbOperator();
SqlConnectioncnn=clsC.GetCon();
SqlCommandcmd=newSqlCommand();
cmd.CommandText="selectClassIDas类别编号,ClassNameas类别名称,ClassUnitas参考单位,"+"KCSXas库存上限,KCXXas库存下限fromtbGoodsClass";
cmd.CommandType=CommandType.Text;
cmd.Connection=cnn;
SqlDataAdapterda=newSqlDataAdapter();
da.SelectCommand=cmd;
DataSetds=newDataSet();
da.Fill(ds,"tbGoods");
dgvGClass.DataSource=ds;
dgvGClass.DataSource=ds.Tables[0];
dgvGClass.Columns[0].Visible=true;//隐藏ID列
da.Dispose();
cmd.Dispose();
cnn.Dispose();
}
privatevoidShowGC()
{
if(dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[0].Value.ToString()!
="")
{
txtGoodsClassID.Text=dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[0].Value.ToString();
txtClassName.Text=dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[1].Value.ToString();
txtClassUnit.Text=dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[2].Value.ToString();
txtKCSX.Text=dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[3].Value.ToString();
txtKCXX.Text=dgvGClass.Rows[dgvGClass.CurrentCell.RowIndex].Cells[4].Value.ToString();
}
}
privatevoidOperateRecord(stringsSQL)//记录的添加、修改、删除
{
DbOperatorclsC=newDbOperator();
SqlConnectioncnn=clsC.GetCon();
SqlCommandcmd=newSqlCommand();
cmd.CommandText=sSQL;
cmd.CommandType=CommandType.Text;
cmd.Connection=cnn;
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
cnn.Dispose();
cmd.Dispose();
}
privatevoidbtnClear_Click(objectsender,EventArgse)//清空文本框
{
txtGoodsClassID.Text="";
txtClassName.Text="";
txtClassUnit.Text="";
txtKCSX.Text="";
txtKCXX.Text="";
txtGoodsClassID.Focus();
}
privatevoidbtnExit_Click(objectsender,EventArgse)//退出按钮
{
if(MessageBox.Show("你确定要退出吗?
","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
this.Close();
}
privatevoidbtnAdd_Click(objectsender,EventArgse)//实现添加功能
{
if(btnAdd.Text=="添加")//单击添加
{
grpbClass.Enabled=true;//允许编辑
btnAdd.Text="保存";
btnXG.Enabled=false;
btnDelete.Enabled=false;
btnReturn.Enabled=true;
txtGoodsClassID.Text="";
txtClassName.Text="";
txtClassUnit.Text="";
txtKCSX.Text="";
txtKCXX.Text="";
txtGoodsClassID.Focus();
}
else//单击保存
{
strings="InsertIntotbGoodsClass(ClassID,ClassName,ClassUnit,KCSX,KCXX)Values";
s+="('"+txtGoodsClassID.Text.Trim()+"','"+txtClassName.Text.Trim()+"','"+txtClassUnit.Text.Trim()+"','"+txtKCSX.Text.Trim()+"','"+txtKCXX.Text.Trim()+"')";
OperateRecord(s);
grpbClass.Enabled=false;
btnAdd.Text="添加";
btnXG.Enabled=true;
btnDelete.Enabled=true;
btnReturn.Enabled=true;
}
LoadGC();
}
privatevoidbtnDelete_Click(objectsender,EventArgse)//实现删功能
{
if(txtGoodsClassID.Text!
="")
{
if(MessageBox.Show("您确实要删除"+txtClassName.Text+"的类别吗?
","删除类别",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
{
strings="DeletefromtbGoo