?? productcommon.cs
字號:
public IList<ProductInfo> GetProductCommonListByCharacter(ProductCharacter productCharacter)
{
IList<ProductInfo> list = new List<ProductInfo>();
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select P.* from PE_CommonProduct P inner join PE_CommonModel M on P.TableName=M.TableName and P.ProductID=M.ItemID and M.LinkType=0 and Status<>-3 Where (P.ProductCharacter&@ProductCharacter) > 0 and P.ProductType<>" + ProductType.Promotion.ToString("D"), new Parameters("@ProductCharacter", DbType.Int32, (int) productCharacter)))
{
while (reader.Read())
{
list.Add(ProductFromrdr(reader));
}
}
return list;
}
public ProductInfo GetProductInfoByType(int productId, string tableName, ProductType productType)
{
string strSql = string.Format("Select top 1 * from PE_CommonProduct where ProductId=@ProductId and TableName=@TableName and ProductType=@ProductType", new object[0]);
Parameters parameters = new Parameters();
parameters.AddInParameter("@ProductId", DbType.Int32, productId);
parameters.AddInParameter("@TableName", DbType.String, tableName);
parameters.AddInParameter("@ProductType", DbType.Int32, (int) productType);
using (NullableDataReader reader = DBHelper.ExecuteReaderSql(strSql))
{
if (reader.Read())
{
ProductInfo info = ProductFromrdr(reader);
info.TableName = tableName;
return info;
}
return new ProductInfo(true);
}
}
public string GetProductName(int id)
{
string str = "";
string strSql = "select ProductName from PE_CommonProduct where ProductID = @ID";
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@ID", DbType.String, id);
using (NullableDataReader reader = DBHelper.ExecuteReaderSql(strSql, cmdParams))
{
if (reader.Read())
{
str = reader.GetString("ProductName");
}
}
return str;
}
public IList<string> GetUnitList()
{
IList<string> list = new List<string>();
using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select DISTINCT Unit from PE_CommonProduct"))
{
while (reader.Read())
{
list.Add(reader.GetString("Unit"));
}
}
return list;
}
public bool IsExistSameProductNum(string productNum)
{
Parameters cmdParams = new Parameters();
cmdParams.AddInParameter("@ProductNum", DbType.String, productNum);
return DBHelper.ExecuteSql("select ProductID from PE_CommonProduct where ProductNum=@ProductNum", cmdParams);
}
private static ProductInfo ProductFromrdr(NullableDataReader rdr)
{
ProductInfo info = new ProductInfo();
info.ProductName = rdr.GetString("ProductName");
info.ProductId = rdr.GetInt32("ProductID");
info.ProductType = (ProductType) rdr.GetInt32("ProductType");
info.ProductPic = rdr.GetString("ProductPic");
info.ProductThumb = rdr.GetString("ProductThumb");
info.Unit = rdr.GetString("Unit");
info.ProductNum = rdr.GetString("ProductNum");
info.ServiceTermUnit = (ServiceTermUnit) rdr.GetInt32("ServiceTermUnit");
info.ServiceTerm = rdr.GetInt32("ServiceTerm");
info.PriceInfo.Price = rdr.GetDecimal("Price");
info.PriceMarket = rdr.GetDecimal("Price_Market");
info.PriceInfo.PriceMember = rdr.GetDecimal("Price_Member");
info.PriceInfo.PriceAgent = rdr.GetDecimal("Price_Agent");
info.EnableWholesale = rdr.GetBoolean("EnableWholesale");
info.PriceInfo.PriceWholesale1 = rdr.GetDecimal("Price_Wholesale1");
info.PriceInfo.PriceWholesale2 = rdr.GetDecimal("Price_Wholesale2");
info.PriceInfo.PriceWholesale3 = rdr.GetDecimal("Price_Wholesale3");
info.PriceInfo.NumberWholesale1 = rdr.GetInt32("Number_Wholesale1");
info.PriceInfo.NumberWholesale2 = rdr.GetInt32("Number_Wholesale2");
info.PriceInfo.NumberWholesale3 = rdr.GetInt32("Number_Wholesale3");
info.PresentId = rdr.GetInt32("PresentID");
info.PresentNumber = rdr.GetInt32("PresentNumber");
info.PresentPoint = rdr.GetInt32("PresentPoint");
info.PresentExp = rdr.GetInt32("PresentExp");
info.PresentMoney = rdr.GetDecimal("PresentMoney");
info.StocksProject = (StocksProject) rdr.GetInt32("StocksProject");
info.SalePromotionType = rdr.GetInt32("SalePromotionType");
info.MinNumber = rdr.GetInt32("MinNumber");
info.Discount = rdr.GetDouble("Discount");
info.IncludeTax = (TaxRateType) rdr.GetInt32("IncludeTax");
info.TaxRate = rdr.GetDouble("TaxRate");
info.Properties = rdr.GetString("Properties");
info.Weight = rdr.GetDouble("Weight");
info.LimitNum = rdr.GetInt32("LimitNum");
info.EnableSingleSell = rdr.GetBoolean("EnableSingleSell");
info.DependentProducts = rdr.GetString("DependentProducts");
info.ProductKind = (ProductKind) rdr.GetInt32("ProductKind");
info.ProductCharacter = (ProductCharacter) rdr.GetInt32("ProductCharacter");
info.EnableBuyWhenOutofstock = rdr.GetBoolean("EnableBuyWhenOutofstock");
info.ProductExplain = rdr.GetString("ProductExplain");
info.ProducerName = rdr.GetString("ProducerName");
info.BarCode = rdr.GetString("BarCode");
info.Stars = rdr.GetInt32("Stars");
info.TrademarkName = rdr.GetString("TrademarkName");
info.Keyword = rdr.GetString("Keyword");
info.ProductIntro = rdr.GetString("ProductIntro");
info.IsNew = rdr.GetBoolean("IsNew");
info.IsHot = rdr.GetBoolean("IsHot");
info.IsBest = rdr.GetBoolean("IsBest");
info.EnableSale = rdr.GetBoolean("EnableSale");
info.TableName = rdr.GetString("TableName");
info.Stocks = rdr.GetInt32("Stocks");
info.DownloadUrl = rdr.GetString("DownloadUrl");
info.Remark = rdr.GetString("Remark");
info.AlarmNum = rdr.GetInt32("AlarmNum");
info.OrderNum = rdr.GetInt32("OrderNum");
return info;
}
public bool Update(ProductInfo info, string tableName)
{
StringBuilder builder = new StringBuilder(0x80);
builder.Append("UPDATE ");
builder.Append("PE_CommonProduct");
builder.Append(" SET ");
string[] strArray = "ProductID,TableName,ProductName,ProductType,ProductPic,ProductThumb,Unit,ProductNum,ServiceTermUnit,ServiceTerm,Price,Price_Market,Price_Member,Price_Agent,EnableWholesale,Price_Wholesale1,Price_Wholesale2,Price_Wholesale3,Number_Wholesale1,Number_Wholesale2,Number_Wholesale3,PresentID,PresentNumber,PresentPoint,PresentExp,PresentMoney,StocksProject,SalePromotionType,MinNumber,Discount,IncludeTax,TaxRate,Properties,Weight,LimitNum,EnableSingleSell,DependentProducts,ProductKind,ProductCharacter,EnableBuyWhenOutofstock,Keyword,ProducerName,TrademarkName,BarCode,ProductIntro,ProductExplain,IsNew,IsHot,IsBest,Stars,EnableSale,Stocks,DownloadUrl,Remark,AlarmNum,OrderNum".Split(new char[] { ',' });
string[] strArray2 = "@ProductID,@TableName,@ProductName,@ProductType,@ProductPic,@ProductThumb,@Unit,@ProductNum,@ServiceTermUnit,@ServiceTerm,@Price,@Price_Market,@Price_Member,@Price_Agent,@EnableWholesale,@Price_Wholesale1,@Price_Wholesale2,@Price_Wholesale3,@Number_Wholesale1,@Number_Wholesale2,@Number_Wholesale3,@PresentID,@PresentNumber,@PresentPoint,@PresentExp,@PresentMoney,@StocksProject,@SalePromotionType,@MinNumber,@Discount,@IncludeTax,@TaxRate,@Properties,@Weight,@LimitNum,@EnableSingleSell,@DependentProducts,@ProductKind,@ProductCharacter,@EnableBuyWhenOutofstock,@Keyword,@ProducerName,@TrademarkName,@BarCode,@ProductIntro,@ProductExplain,@IsNew,@IsHot,@IsBest,@Stars,@EnableSale,@Stocks,@DownloadUrl,@Remark,@AlarmNum,@OrderNum".Split(new char[] { ',' });
for (int i = 0; i < strArray.Length; i++)
{
builder.Append(strArray[i]);
builder.Append("=");
builder.Append(strArray2[i]);
builder.Append(",");
}
builder.Remove(builder.Length - 1, 1);
builder.Append(" WHERE ProductId=@ProductId and TableName=@TableName");
return DBHelper.ExecuteSql(builder.ToString(), GetParameters(info, tableName));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -