Now, I wrote businessLogic layer.
In this project, Table's column name are:
Product,
UM,
ProductGroup,
ProductCode,
ProductName,
BuyingPrice,
SellingPrice,
IsActive,
IsDeleted
and then
I wrote stored procedures, they are:
1. Product_SelectList
2. Product_SelectByProduct
3. Product_SelectByUM
4. Product_SelectByProductType
5. Product_SelectByProductGroup
6. Product_Insert
7. Prodct_Update
8. Product_DeleteByProduct
9. Product_DeleteUM
10. Product_DeleteByProductType
11. Product_DeleteByProductGroup
I wrote Product_SelectByProduct in stored procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[Product_SeleteByProduct]
@Product char(36)
AS
Begin
Select
Product,
UM,
ProductType,
ProductGroup,
ProductCode,
ProductName,
BuyingPrice,
SellingPrice,
IsActive,
IsDeleted
from Product
Where Product=@Product
End
I wrote Product_SelectByProduct in the businesslogic layer
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections .ObjectModel ;
using System.Data ;
namespace Inventory.BusinessLogic
{
public class ProductInfo
{
private string _product;
public string Product
{
get { return _product; }
set { _product = value; }
}
private string _uM;
public string UM
{
get { return _uM; }
set { _uM = value; }
}
private string _productType;
public string ProductType
{
get { return _productType; }
set { _productType = value; }
}
private string _productGroup;
public string ProductGroup
{
get { return _productGroup; }
set { _productGroup = value; }
}
private string _productCode;
public string ProductCode
{
get { return _productCode; }
set { _productCode = value; }
}
private string _productName;
public string ProductName
{
get { return _productName; }
set { _productName = value; }
}
private string _buyingPrice;
public string BuyingPrice
{
get { return _buyingPrice; }
set { _buyingPrice = value; }
}
private string _sellingPrice;
public string SellingPrice
{
get { return _sellingPrice; }
set { _sellingPrice = value; }
}
private Boolean _isActive;
public Boolean IsActive
{
get { return _isActive; }
set { _isActive = value; }
}
private Boolean _isDeleted;
public Boolean IsDeleted
{
get { return _isDeleted; }
set { _isDeleted = value; }
}
}
public class ProductCollections : Collection<ProductInfo>
{ }
public class ProductController
{
Inventory.DataAccess.ProductDataController dataAccess;
public ProductController()
{
dataAccess = new Inventory.DataAccess.ProductDataController();
}
public void Insert(ProductInfo productInfo)
{
dataAccess.Insert(productInfo.Product, productInfo.UM, productInfo.ProductType,
productInfo.ProductGroup, productInfo.ProductCode, productInfo.BuyingPrice, productInfo.ProductName,
productInfo.SellingPrice, productInfo.IsActive, productInfo.IsDeleted);
}
public void Update(ProductInfo productInfo)
{
dataAccess.Update(productInfo.Product, productInfo.UM, productInfo.ProductType,
productInfo.ProductGroup, productInfo.ProductCode, productInfo.BuyingPrice, productInfo.ProductName,
productInfo.SellingPrice, productInfo.IsActive, productInfo.IsDeleted);
}
public void DeleteByProduct(string Product)
{
dataAccess.DelectByProduct(Product);
}
public void DeleteByProductType(string ProductType)
{
dataAccess.DeleteByProductType(ProductType);
}
public void DeleteByUM(string UM)
{
dataAccess.DeleteByUM(UM);
}
public void DeleteByProductGroup(string ProductGoup)
{
dataAccess.DeleteByProductGroup(ProductGoup);
}
public ProductInfo SeletcByProduct(string Product)
{
IDataReader Reader = dataAccess.SelectByProduct(Product);
ProductInfo productInfo = new ProductInfo();
if (Reader.Read())
{
productInfo.Product = Convert.ToString(Reader["Product"]);
productInfo.UM = Convert.ToString(Reader["UM"]);
productInfo.ProductType = Convert.ToString(Reader["ProductType"]);
productInfo.ProductGroup = Convert.ToString(Reader["ProductGroup"]);
productInfo.ProductCode = Convert.ToString(Reader["ProductCode"]);
productInfo.ProductName = Convert.ToString(Reader["ProductName"]);
productInfo.BuyingPrice = Convert.ToString(Reader["BuyingPrice"]);
productInfo.SellingPrice = Convert.ToString(Reader["SellingPrice"]);
productInfo.IsActive = Convert.ToBoolean(Reader["IsActive"]);
productInfo.IsDeleted = Convert.ToBoolean(Reader["IsDeleted"]);
}
Reader.Close();
return productInfo;
}
Now, I would like to Product_SelectByProductType
this is Product_SelectByProductType's stored procedure
开发者_开发百科set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[Product_SelectByProductType]
@ProductType char(36)
As
Begin
Select
ProductType,
ProductTypeDescription,
IsActive,
IsDefault,
IsDeleted
from ProductType
Where ProductType=@ProductType
End
how to write product_SelectByProductType in businesslogic layer in C#
please, help me
here an example of how to execute a store procedure in C# http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx
精彩评论