ERP仓库管理系统(九)

网友投稿 836 2022-10-06

ERP仓库管理系统(九)

ERP仓库管理系统(九)

需求分析:

1.设计库房表,至少包括两个字段,库房名称,库房所属公司的ID(在客户资质审批表中找到对应公司的ID)

2.设计增、删、改、查一套程序,其中的删除要做限制,只要有库存数据存在则不允许删除对应库房的记录。

3.库房管理权限为高级权限,程序开发开始后,到配一个新的权限值。

新增的原理:

仓库管理员的新增和修改:

ALTER PROCEDURE [dbo].[BioErpStockUsers_ADD]@StockID int,@UserID int AS INSERT INTO [BioErpStockUsers]( [StockID],[UserID] )VALUES( @StockID,@UserID )

ALTER PROCEDURE [dbo].[BioErpStockUsers_Update]@ID int,@StockID int,@UserID int AS UPDATE [BioErpStockUsers] SET [StockID] = @StockID,[UserID] = @UserID WHERE ID=@ID

仓库信息的新增和修改存储过程:

--修改:删除了LeaderUserID字段,新增加@ID输出参数------------------------------------ALTER PROCEDURE [dbo].[BioErpStockTable_ADD]--输出的参数@ID int output,@StockName nvarchar(80),@FarhterCompany int,@StockAddress nvarchar(100),@IsDel bit AS INSERT INTO [BioErpStockTable]( [StockName],[FarhterCompany],[StockAddress],[IsDel] )VALUES( @StockName,@FarhterCompany,@StockAddress,@IsDel ) --赋值 @@为全局变量 获取当前表的最大表示列(与下面的是等效的) SET @ID=@@IDENTITY-- SELECT @ID=MAX(ID) FROM BioErpStockTable

修改的存储过程:

ALTER PROCEDURE [dbo].[BioErpStockTable_Update]@ID int,@StockName nvarchar(80),@FarhterCompany int,@StockAddress nvarchar(100),@IsDel bit AS UPDATE [BioErpStockTable] SET [StockName] = @StockName,[FarhterCompany] = @FarhterCompany,[StockAddress] = @StockAddress,[IsDel] = @IsDel WHERE ID=@ID

实现的效果图:

前台界面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StockAdd.aspx.cs" Inherits="BioErpWeb.StockSystem.StockAdd" %><%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

仓库信息管理系统
库房名称:
库房地址:
所属公司
仓库管理员

选择员工的界面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonList.aspx.cs" Inherits="BioErpWeb.PersonList.PersonList" %>

员工姓名

选择不同的员工显示不同的编号:

查询公司列表的BLL:

public class CompanyTableBll { ///

/// 查询公司列表 /// /// DataTable public DataTable GetCompanyList() { return SqlComm.GetDataByTableNameValue("dbo.BioErpCompanyTable", "*").Tables[0]; } }

添加和修改仓库管理员数据:

public class BioErpStockUsersBLL { ///

/// 添加管理员数据 /// /// /// public int StockUserAdd(BioErpStockUsers stockuser) { SqlParameter[] parameters = { new SqlParameter("@StockID", SqlDbType.Int,4), new SqlParameter("@UserID", SqlDbType.Int,4)}; parameters[0].Value = stockuser.StockID; parameters[1].Value = stockuser.UserID; return DataBaseHelper.ExcuteSqlReturnInt("BioErpStockUsers_ADD", CommandType.StoredProcedure, parameters); } /// /// 根据ID修改仓库管理员信息 /// /// /// public int StockUserUpdeat(BioErpStockUsers stockuser) { SqlParameter[] parameters = { new SqlParameter("@ID",SqlDbType.Int,4), new SqlParameter("@StockID", SqlDbType.Int,4), new SqlParameter("@UserID", SqlDbType.Int,4)}; parameters[0].Value = stockuser.ID; parameters[1].Value = stockuser.StockID; parameters[2].Value = stockuser.UserID; return DataBaseHelper.ExcuteSqlReturnInt("BioErpStockUsers_Update", CommandType.StoredProcedure, parameters); } }

添加UI层后台的代码:

public partial class StockAdd : System.Web.UI.Page { CompanyTableBll companybll = new CompanyTableBll(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CompanyListBind(); } } private void CompanyListBind() { this.ddlCompany.DataSource = companybll.GetCompanyList(); this.ddlCompany.DataTextField = "CompanyName"; this.ddlCompany.DataValueField = "ID"; this.ddlCompany.DataBind(); this.ddlCompany.Items.Add(new ListItem("--请选择--","0")); this.ddlCompany.SelectedValue = "0"; } protected void btnSubmit_Click(object sender, EventArgs e) { StockTable stock = new StockTable(); stock.StockName = this.txtStockName.Text; stock.StockAddress = this.txtAddress.Text; stock.FarhterCompany = int.Parse(this.ddlCompany.SelectedValue.ToString()); stock.IsDel = false; BioErpStockTableBLL stocktablebll = new BioErpStockTableBLL(); int stockid= stocktablebll.StockTableAdd(stock); BioErpStockUsers stockusers = new BioErpStockUsers(); BioErpStockUsersBLL stockusersbll = new BioErpStockUsersBLL(); stockusers.StockID = stockid; string userids= Request["UserId"].ToString(); string[] userarrayList = userids.Split(','); for (int i = 0; i < userarrayList.Length; i++) { stockusers.UserID = int.Parse(userarrayList[i].ToString()); stockusersbll.StockUserAdd(stockusers); }

.Transfer("StockTableList.aspx");

} }

游标的介绍:

Transact_SQL 游标是由DECLARE CURSOR 语法定义、主要用在Transact_SQL 脚本、​​存储过程​​​和​​触发器​​​中。Transact_SQL 游标主要用在服务器上,由从​​客户端​​​发送给服务器的Transact_SQL 语句或是​​批处理​​、存储过程、触发器中的Transact_SQL 进行管理。

查询实现的需求:

1.联合2个表查询,将返回结果绑定给GridView控件。

2.将员工编号对应的姓名组装成姓名字符串,显示在列表中。

游标的定义方式:

-- Description: <通过userid'2,331,332,333'等查询对应的用户名>-- =============================================--select dbo.[BioErpTbFN_GetUserNameListByID](',2,331,332,333,')ALTER FUNCTION [dbo].[BioErpTbFN_GetUserNameListByID](@userID NVARCHAR(200))RETURNS NVARCHAR(1000)ASBEGIN declare cur cursor for select UserID,UserName from UserManager where CHARINDEX(','+convert(NVARCHAR(10) ,id)+',',(','+@userID+','))>0 open cur declare @id int declare @name NVARCHAR(50) declare @nn NVARCHAR(3000) set @nn='' fetch next from cur into @id, @name while @@fetch_status = 0 begin set @nn=@nn+@name+';' if len(@nn)>50 begin set @nn=SUBSTRING(@nn,0,50) set @nn=@nn+'……' break end fetch next from cur into @id, @name end close cur DEALLOCATE cur RETURN @nnEND

游标的具体使用:

-- Description: 根据仓库编号返回员工姓名字符串-- =============================================ALTER FUNCTION [dbo].[GetUserListByStockID]( --传递的参数 @StockID int)--返回的类型RETURNS nvarchar(200)ASBEGIN --定义游标 declare cur cursor for --子查询 SELECT userName FROM UserManager WHERE UserManager.UserId IN ( SELECT UserID FROM BioErpStockUsers WHERE StockID=@StockID) --打开游标 open cur --定义姓名的参数 DECLARE @name nvarchar(20) --姓名组装后的字符串的参数 DECLARE @names nvarchar(1000) --给变量设置值 SET @names='' --从游标中取出数据下个数据放到变量中去 FETCH next FROM cur INTO @name --取到了一行数据 WHILE @@FETCH_STATUS =0 --取到数据之后组装字符串 BEGIN --赋值 SET @names=@names+@name+',' --在去下一条 FETCH next FROM cur INTO @name END --关闭游标 CLOSE cur --回收游标 DEALLOCATE cur --返回变量 RETURN @names END--调用select [dbo].[GetUserListByStockID](1)

结合实例的具体使用:

仓库信息列表的显示列:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StockTableList.aspx.cs" Inherits="BioErpWeb.StockSystem.StockTableList" %><%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

仓库信息管理系统

把查询的数据放入视图中:

create View [View_StockList] as select ID, [FarhterCompany]=[dbo].[getCompanyNameByCompanyID](FarhterCompany), [StockAddress], [IsDel], 'UserNames'=[dbo].[GetUserListByStockID](ID) from [dbo].[BioErpStockTable]

对应的公司名称(标量函数):

-- Description: 根据公司编号返回公司名称-- =============================================ALTER FUNCTION [dbo].[getCompanyNameByCompanyID] ( @ID int)--返回的值RETURNS nvarchar(100)ASBEGIN -- Declare the return variable here DECLARE @companyname nvarchar(100) -- Add the T-SQL statements to compute the return value here SELECT @companyname=CompanyName FROM BioErpCompanyTable WHERE ID=@ID -- 返回变量 RETURN @companynameEND

显示的代码:

public partial class StockTableList : System.Web.UI.Page { static string Condition = ""; static int pageindex=0; static int pagesize = 8; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { getStockList(); } } ///

/// 获取仓库信息列表 /// private void getStockList() { this.GridView1.DataSource= SqlComm.getDataByPageIndex("View_StockList", "ID,StockName,FarhterCompany,StockAddress,IsDel,UserNames", "ID",Condition, pageindex, pagesize); this.GridView1.DataBind(); } }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序中UI与容器组件的介绍(小程序内常见的组件)
下一篇:微信小程序商城中侧栏分类的效果实现(微信小程序侧边栏)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~