ERP商品管理业务逻辑封装(三十一)
Posted 石
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERP商品管理业务逻辑封装(三十一)相关的知识,希望对你有一定的参考价值。
产品购进管理业务逻辑:
public class ProductBLL { /// <summary> /// 产品对象添加 并且返回产品编号 /// </summary> /// <param name="viewpro">产品视图对象</param> public int BiotbProductAdd(ViewProInfo model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ProID", SqlDbType.Int,4), new SqlParameter("@ProName", SqlDbType.NVarChar,100), new SqlParameter("@TypeID", SqlDbType.Int,4), new SqlParameter("@CustomerID", SqlDbType.Int,4), new SqlParameter("@ProLogo", SqlDbType.NVarChar,200), new SqlParameter("@Spec", SqlDbType.NVarChar,100), new SqlParameter("@ProFullName", SqlDbType.NVarChar,100), new SqlParameter("@ConfirmNo", SqlDbType.NVarChar,100), new SqlParameter("@Unit", SqlDbType.NVarChar,50), new SqlParameter("@ProSize", SqlDbType.NVarChar,50), new SqlParameter("@Grossweight", SqlDbType.NVarChar,50), new SqlParameter("@MadeEnterprise", SqlDbType.NVarChar,100), new SqlParameter("@Retailprice", SqlDbType.Money,8), new SqlParameter("@BidPrice", SqlDbType.Money,8), new SqlParameter("@TradePrice", SqlDbType.Money,8), new SqlParameter("@AdvicePrice", SqlDbType.Money,8), new SqlParameter("@CountyPrice", SqlDbType.Money,8), new SqlParameter("@CityPrice", SqlDbType.Money,8), new SqlParameter("@ProvincePrice", SqlDbType.Money,8), new SqlParameter("@NetPrice", SqlDbType.Money,8), new SqlParameter("@NetVipPrice", SqlDbType.Money,8), new SqlParameter("@NetMemberprice", SqlDbType.Money,8), new SqlParameter("@OurCompany", SqlDbType.NVarChar,100), new SqlParameter("@ChannelID", SqlDbType.Int,4), new SqlParameter("@Usefullife", SqlDbType.NVarChar,50), new SqlParameter("@SubmitTime", SqlDbType.DateTime), new SqlParameter("@StockMost", SqlDbType.NVarChar,100), new SqlParameter("@StockLess", SqlDbType.NVarChar,100), new SqlParameter("@Remark", SqlDbType.NVarChar,1000)}; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.ProName; parameters[2].Value = model.TypeID; parameters[3].Value = model.CustomerID; parameters[4].Value = model.ProLogo; parameters[5].Value = model.Spec; parameters[6].Value = model.ProFullName; parameters[7].Value = model.ConfirmNo; parameters[8].Value = model.Unit; parameters[9].Value = model.ProSize; parameters[10].Value = model.Grossweight; parameters[11].Value = model.MadeEnterprise; parameters[12].Value = model.Retailprice; parameters[13].Value = model.BidPrice; parameters[14].Value = model.TradePrice; parameters[15].Value = model.AdvicePrice; parameters[16].Value = model.CountyPrice; parameters[17].Value = model.CityPrice; parameters[18].Value = model.ProvincePrice; parameters[19].Value = model.NetPrice; parameters[20].Value = model.NetVipPrice; parameters[21].Value = model.NetMemberprice; parameters[22].Value = model.OurCompany; parameters[23].Value = model.ChannelID; parameters[24].Value = model.Usefullife; parameters[25].Value = model.SubmitTime; parameters[26].Value = model.StockMost; parameters[27].Value = model.StockLess; parameters[28].Value = model.Remark; rowsAffected= DataBaseHelper.ExcuteSqlReturnInt("BiotbProduct_ADD", CommandType.StoredProcedure, parameters); if (rowsAffected != 0) { return int.Parse(parameters[0].ToString()); } else { return 0; } } /// <summary> /// 修改产品对象 /// </summary> /// <param name="model">产品对象</param> /// <returns>int</returns> public int BiotbProductUpdate(ViewProInfo model) { SqlParameter[] parameters = { new SqlParameter("@ProID", SqlDbType.Int,4), new SqlParameter("@ProName", SqlDbType.NVarChar,100), new SqlParameter("@TypeID", SqlDbType.Int,4), new SqlParameter("@CustomerID", SqlDbType.Int,4), new SqlParameter("@ProLogo", SqlDbType.NVarChar,200), new SqlParameter("@Spec", SqlDbType.NVarChar,100), new SqlParameter("@ProFullName", SqlDbType.NVarChar,100), new SqlParameter("@ConfirmNo", SqlDbType.NVarChar,100), new SqlParameter("@Unit", SqlDbType.NVarChar,50), new SqlParameter("@ProSize", SqlDbType.NVarChar,50), new SqlParameter("@Grossweight", SqlDbType.NVarChar,50), new SqlParameter("@MadeEnterprise", SqlDbType.NVarChar,100), new SqlParameter("@Retailprice", SqlDbType.Money,8), new SqlParameter("@BidPrice", SqlDbType.Money,8), new SqlParameter("@TradePrice", SqlDbType.Money,8), new SqlParameter("@AdvicePrice", SqlDbType.Money,8), new SqlParameter("@CountyPrice", SqlDbType.Money,8), new SqlParameter("@CityPrice", SqlDbType.Money,8), new SqlParameter("@ProvincePrice", SqlDbType.Money,8), new SqlParameter("@NetPrice", SqlDbType.Money,8), new SqlParameter("@NetVipPrice", SqlDbType.Money,8), new SqlParameter("@NetMemberprice", SqlDbType.Money,8), new SqlParameter("@OurCompany", SqlDbType.NVarChar,100), new SqlParameter("@ChannelID", SqlDbType.Int,4), new SqlParameter("@Usefullife", SqlDbType.NVarChar,50), new SqlParameter("@SubmitTime", SqlDbType.DateTime), new SqlParameter("@StockMost", SqlDbType.NVarChar,100), new SqlParameter("@StockLess", SqlDbType.NVarChar,100), new SqlParameter("@Remark", SqlDbType.NVarChar,1000)}; parameters[0].Value = model.ProID; parameters[1].Value = model.ProName; parameters[2].Value = model.TypeID; parameters[3].Value = model.CustomerID; parameters[4].Value = model.ProLogo; parameters[5].Value = model.Spec; parameters[6].Value = model.ProFullName; parameters[7].Value = model.ConfirmNo; parameters[8].Value = model.Unit; parameters[9].Value = model.ProSize; parameters[10].Value = model.Grossweight; parameters[11].Value = model.MadeEnterprise; parameters[12].Value = model.Retailprice; parameters[13].Value = model.BidPrice; parameters[14].Value = model.TradePrice; parameters[15].Value = model.AdvicePrice; parameters[16].Value = model.CountyPrice; parameters[17].Value = model.CityPrice; parameters[18].Value = model.ProvincePrice; parameters[19].Value = model.NetPrice; parameters[20].Value = model.NetVipPrice; parameters[21].Value = model.NetMemberprice; parameters[22].Value = model.OurCompany; parameters[23].Value = model.ChannelID; parameters[24].Value = model.Usefullife; parameters[25].Value = model.SubmitTime; parameters[26].Value = model.StockMost; parameters[27].Value = model.StockLess; parameters[28].Value = model.Remark; return DataBaseHelper.ExcuteSqlReturnInt("BioProType_Update", CommandType.StoredProcedure, parameters); } /// <summary> /// 根据产品编号返回产品视图实体对象 /// </summary> /// <param name="proid"></param> /// <returns></returns> public ViewProInfo getProViewByProId(string ProID) { SqlParameter[] parameters = { new SqlParameter("@ProID", SqlDbType.Int,4) }; parameters[0].Value = ProID; ViewProInfo model = new ViewProInfo(); DataSet ds = DataBaseHelper.SelectSQLReturnDataSet("View_ProInfo_GetModel",CommandType.StoredProcedure,parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ProID"].ToString() != "") { model.ProID = int.Parse(ds.Tables[0].Rows[0]["ProID"].ToString()); } model.ProName = ds.Tables[0].Rows[0]["ProName"].ToString(); if (ds.Tables[0].Rows[0]["TypeID"].ToString() != "") { model.TypeID = int.Parse(ds.Tables[0].Rows[0]["TypeID"].ToString()); } model.TypeName = ds.Tables[0].Rows[0]["TypeName"].ToString(); if (ds.Tables[0].Rows[0]["CustomerID"].ToString() != "") { model.CustomerID = int.Parse(ds.Tables[0].Rows[0]["CustomerID"].ToString()); } model.CustomerName = ds.Tables[0].Rows[0]["CustomerName"].ToString(); model.ProLogo = ds.Tables[0].Rows[0]["ProLogo"].ToString(); model.Spec = ds.Tables[0].Rows[0]["Spec"].ToString(); model.ProFullName = ds.Tables[0].Rows[0]["ProFullName"].ToString(); model.ConfirmNo = ds.Tables[0].Rows[0]["ConfirmNo"].ToString(); model.Unit = ds.Tables[0].Rows[0]["Unit"].ToString(); model.ProSize = ds.Tables[0].Rows[0]["ProSize"].ToString(); model.Grossweight = ds.Tables[0].Rows[0]["Grossweight"].ToString(); model.MadeEnterprise = ds.Tables[0].Rows[0]["MadeEnterprise"].ToString(); if (ds.Tables[0].Rows[0]["Retailprice"].ToString() != "") { model.Retailprice = decimal.Parse(ds.Tables[0].Rows[0]["Retailprice"].ToString()); } if (ds.Tables[0].Rows[0]["BidPrice"].ToString() != "") { model.BidPrice = decimal.Parse(ds.Tables[0].Rows[0]["BidPrice"].ToString()); } if (ds.Tables[0].Rows[0]["TradePrice"].ToString() != "") { model.TradePrice = decimal.Parse(ds.Tables[0].Rows[0]["TradePrice"].ToString()); } if (ds.Tables[0].Rows[0]["AdvicePrice"].ToString() != "") { model.AdvicePrice = decimal.Parse(ds.Tables[0].Rows[0]["AdvicePrice"].ToString()); } if (ds.Tables[0].Rows[0]["CountyPrice"].ToString() != "") { model.CountyPrice = decimal.Parse(ds.Tables[0].Rows[0]["CountyPrice"].ToString()); } if (ds.Tables[0].Rows[0]["CityPrice"].ToString() != "") { model.CityPrice = decimal.Parse(ds.Tables[0].Rows[0]["CityPrice"].ToString()); } if (ds.Tables[0].Rows[0]["ProvincePrice"].ToString() != "") { model.ProvincePrice = decimal.Parse(ds.Tables[0].Rows[0]["ProvincePrice"].ToString()); } if (ds.Tables[0].Rows[0]["NetPrice"].ToString() != "") { model.NetPrice = decimal.Parse(ds.Tables[0].Rows[0]["NetPrice"].ToString()); } if (ds.Tables[0].Rows[0]["NetVipPrice"].ToString() != "") { model.NetVipPrice = decimal.Parse(ds.Tables[0].Rows[0]["NetVipPrice"].ToString()); } if (ds.Tables[0].Rows[0]["NetMemberprice"].ToString() != "") { model.NetMemberprice = decimal.Parse(ds.Tables[0].Rows[0]["NetMemberprice"].ToString()); } model.OurCompany = ds.Tables[0].Rows[0]["OurCompany"].ToString(); if (ds.Tables[0].Rows[0]["ChannelID"].ToString() != "") { model.ChannelID = int.Parse(ds.Tables[0].Rows[0]["ChannelID"].ToString()); } model.ChannelName = ds.Tables[0].Rows[0]["ChannelName"].ToString(); model.Usefullife = ds.Tables[0].Rows[0]["Usefullife"].ToString(); if (ds.Tables[0].Rows[0]["SubmitTime"].ToString() != "") { model.SubmitTime = DateTime.Parse(ds.Tables[0].Rows[0]["SubmitTime"].ToString()); } model.StockMost = ds.Tables[0].Rows[0]["StockMost"].ToString(); model.StockLess = ds.Tables[0].Rows[0]["StockLess"].ToString(); model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return model; } else { return null; } } }
商品类型的业务:
public class BioProTypeBLL { /// <summary> /// 添加一个产品类型对象 /// </summary> /// <param name="model"></param> /// <returns></returns> public int ProTypeAdd(BioProType model) { SqlParameter[] parameters = { new SqlParameter("@ParentTypeID", SqlDbType.Int,4), new SqlParameter("@TypeName", SqlDbType.NVarChar,100)}; parameters[0].Value = model.ParentTypeID; parameters[1].Value = model.TypeName; return DataBaseHelper.ExcuteSqlReturnInt("BioProType_Add", CommandType.StoredProcedure, parameters); } /// <summary> /// 产品类型修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public int ProTypeUpdate(BioProType model) { SqlParameter[] parameters = { new SqlParameter("@TypeID", SqlDbType.Int,4), new SqlParameter("@ParentTypeID", SqlDbType.Int,4), new SqlParameter("@TypeName", SqlDbType.NVarChar,100)}; parameters[0].Value = model.TypeID; parameters[1].Value = model.ParentTypeID; parameters[2].Value = model.TypeName; return DataBaseHelper.ExcuteSqlReturnInt("BioProType_Update", CommandType.StoredProcedure, parameters); } /// <summary> /// 根据产品类型编号返回产品类型对象 /// </summary> /// <param name="id"></param> /// <returns></returns> public BioProType getProTypeByTypeID(string id) { SqlDataReader reader= SqlComm.GetDataReaderByCondition("dbo.BioProType", "*", " TypeID=" + id); BioProType type = new BioProType(); if (reader.Read()) { if (reader["TypeID"] != null) { type.TypeID = int.Parse(reader["TypeID"].ToString()); } if (reader["ParentTypeID"] != null) { type.ParentTypeID = int.Parse(reader["ParentTypeID"].ToString()); } if (reader["TypeName"] != null) { type.TypeName = reader["TypeName"].ToString(); } } return type; } }
商品图片的BLL:
/// <summary> /// 添加一条图片对象 /// </summary> /// <param name="images"></param> /// <returns></returns> public int BiotbProImgsAdd(BiotbProImgs images) { SqlParameter[] parameters = { new SqlParameter("@ProID", SqlDbType.Int,4), new SqlParameter("@ProImg", SqlDbType.NVarChar,200)}; parameters[0].Value = images.ProID; parameters[1].Value = images.ProImg; return DataBaseHelper.ExcuteSqlReturnInt("BiotbProImgs_ADD", CommandType.StoredProcedure, parameters); }
添加产品类型的页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProTypeList.aspx.cs" Inherits="BioErpWeb.PersonList.ProTypeList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> function ReturnValue(noteid) { if (noteid != NaN || noteid != 0) { window.returnValue = noteid; window.close(); } else { window.returnValue = 0; window.close(); } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TreeView ID="TreeView1" runat="server"> </asp:TreeView> </div> </form> </body> </html>
选择的js:
function showProType() { var re = showModalDialog("../../PersonList/ProTypeList.aspx", "", "dialogWidth=350px;dialogHeight=400px"); var obj = window.event.srcElement; var td = obj.parentNode; var txts = td.getElementsByTagName(‘input‘); if (re == null || re == "") { if (txts[0].value == "" || txts[0].value == null) { txts[0].value = "请选择"; } } else { txts[0].value = re; } }
后台代码:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CreateTreeVeiw(); } } DataSet ds; DataTable dt; private void CreateTreeVeiw() { ds = SqlComm.GetDataByCondition("dbo.BioProType", "TypeID,ParentTypeID,TypeName", "1=1"); dt = new DataTable(); dt = ds.Tables[0]; if (dt.Rows.Count == 0) { Response.Write("<span style=‘color:red;‘>数据库中没有产品类型数据,请直接输入0即可…</span>"); return; } DataView dv = new DataView(dt, "ParentTypeID=0 or ParentTypeID=null", "TypeID", DataViewRowState.CurrentRows); //遍历父节点 foreach (DataRowView d in dv) { TreeNode n = new TreeNode(d["TypeName"].ToString(), d["TypeID"].ToString()); n.ImageToolTip = dt.TableName; n.NavigateUrl = "javascript:ReturnValue(" + d["TypeID"].ToString() + ");"; TreeView1.Nodes.Add(n); n.Expanded = false; //根据父节点筛选出对应的子节点 dv = new DataView(dt, " ParentTypeID=‘" + d["TypeID"] + "‘", "TypeID", DataViewRowState.CurrentRows); if (dv.Count > 0) { CreateSubTreeView(n, dv); } } } /// <summary> /// 添加子项 /// </summary> /// <param name="n"></param> /// <param name="dv"></param> private void CreateSubTreeView(TreeNode n, DataView dv) { foreach (DataRowView d in dv) { TreeNode cn = new TreeNode(d["TypeName"].ToString(), d["TypeID"].ToString()); cn.NavigateUrl = "javascript:ReturnValue(" + d["TypeID"].ToString() + ");"; n.ChildNodes.Add(cn); DataView sdv = new DataView(dt, "ParentTypeID=‘" + d["TypeID"] + "‘", "TypeID", DataViewRowState.CurrentRows); if (sdv.Count > 0) { CreateSubTreeView(cn, sdv); } } }
类型的添加:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProTypeInsert.aspx.cs" Inherits="BioErpWeb.WholeSaleSystem.Product.ProTypeInsert" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script> <script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script> <script src="../../Scripts/validateExtender.js" type="text/javascript"></script> <script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script> <script src="../../JS/ProTypeChoose.js" type="text/javascript"></script> <style type="text/css"> .style1 { height: 22px; } </style> <script type="text/javascript"> $().ready(function () { $("#form1").validate(); }); </script> </head> <body> <form id="form1" runat="server"> <div> <table class="maintable"> <tr> <td colspan="2" class="titlebar"> 产品类型添加 </td> </tr> <tr> <td class="style1"> 类型名称 </td> <td class="style1"> <asp:TextBox ID="txtTypeName" CssClass="{required:true}" runat="server" ></asp:TextBox> </td> </tr> <tr> <td class="style1"> 所属大类</td> <td class="style1"> <asp:TextBox ID="txtSupertTypeID" CssClass="{required:true, number:true, min:0}" runat="server" ></asp:TextBox><input type="button" value="选择" onclick="showProType()"/> <asp:Label ID="Label1" runat="server" ForeColor="Red" Text="(注:如果为0代表顶级父类)"></asp:Label> </td> </tr> <tr> <td colspan="2" class="bottomtd"> <asp:Button ID="btnSubmit" runat="server" Text="产品类型保存" OnClick="btnSubmit_Click" /> <asp:Button ID="btnReturn" runat="server" CausesValidation="false" UseSubmitBehavior="false" Text="返回列表" OnClick="btnReturn_Click" /> </td> </tr> </table> <br /> </div> </form> </body> </html>
添加的代码:
BioProTypeBLL typebll=new BioProTypeBLL(); BioProType type = new BioProType(); type.ParentTypeID = int.Parse(this.txtSupertTypeID.Text.Trim()) ; type.TypeName = this.txtTypeName.Text; if (typebll.ProTypeAdd(type) != 0) { ClientScript.RegisterStartupScript(this.GetType(), "test", "alert(‘添加类型成功‘)", true); return; }
以上是关于ERP商品管理业务逻辑封装(三十一)的主要内容,如果未能解决你的问题,请参考以下文章