Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

204 lignes
6.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// 网站配置
/// </summary>
namespace Basic.BLL
{
public class attribute
{
/// <summary>
/// 读取attribute分类的名字
/// </summary>
public static string GetTitle(int id)
{
Basic.DAL.attribute dala = new Basic.DAL.attribute();
Basic.Model.attribute modela = dala.GetModel(id);
string strTitle = "";
if (modela != null)
{
strTitle = modela.title;
}
return strTitle;
}
/// <summary>
/// 获取根据产品id和属性id获取属性的名字
/// </summary>
/// <param name="_attrid"></param>
/// <param name="_proid"></param>
/// <returns></returns>
public static string GetListTitle(int _attrid, int _proid)
{
Basic.DAL.product_attribute_list dal = new Basic.DAL.product_attribute_list();
Basic.Model.product_attribute_list model = dal.GetModel(_attrid, _proid);
if (model != null)
{
return model.title;
}
else
{
return "";
}
}
public static string GetAllAttrId(int _color, string _size, int _proid)
{
string strAttrId = "";
strAttrId += _color + ",";
if (_size != "")
{
string[] ArraySize = _size.Split(',');
for (int i = 0; i < ArraySize.Length; i++)
{
strAttrId += ArraySize[i] + ",";
}
}
if (strAttrId != "")
{
strAttrId = strAttrId.Substring(0, strAttrId.Length - 1);
}
return strAttrId;
}
public static string GetAllAttr(int _color, string _size, int _proid)
{
string strAttrId = "";
strAttrId += GetListTitle(_color, _proid) + ",";
if (_size != "")
{
string[] ArraySize = _size.Split(',');
for (int i = 0; i < ArraySize.Length; i++)
{
strAttrId += GetListTitle(Convert.ToInt32(ArraySize[i]), _proid) + ",";
}
}
if (strAttrId != "")
{
strAttrId = strAttrId.Substring(0, strAttrId.Length - 1);
}
return strAttrId;
}
public static string GetAttriString(int _color, string _size)
{
string strWhereSize = "";
if (_size != "")
{
strWhereSize += "-" + _size.Replace(",", "-") + "-";
}
string strWhereColor = "";
if (_color != 0)
{
strWhereColor += "-" + _color + "-";
}
string strWhere = strWhereColor + strWhereSize;
strWhere = strWhere.Replace("--", "-");
return strWhere;
}
//显示属性名称
public static string ShowSizeAttribute(string _size, int _proid)
{
string strResult = "";
if (!string.IsNullOrEmpty(_size))
{
string[] ArraySzie = _size.Split(',');
for (int m = 0; m < ArraySzie.Length; m++)
{
strResult += attribute.GetListTitle(Convert.ToInt32(ArraySzie[m]), _proid) + ",";
}
}
strResult = strResult.Trim();
return strResult;
}
//显示属性名称
public static string ShowAttribute(int _color, string _size, int _proid)
{
string strResult = "";
Basic.DAL.product_attribute_list dala = new Basic.DAL.product_attribute_list();
Basic.Model.product_attribute_list modela = dala.GetModel(_color, _proid);
if (modela != null)
{
strResult += modela.title + ",";
}
strResult += ShowSizeAttribute(_size, _proid);
strResult = strResult.Trim(',');
return strResult;
}
public static int GetKucun(string attrid, int _proid)
{
int Kucun = 0;
Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
Basic.Model.product_attribute_value modelpayv = dalpav.GetModel(_proid, ("-" + attrid.Replace(",", "-") + "-"));
if (modelpayv != null)
{
Kucun = modelpayv.count;
}
else
{
Basic.DAL.product dalp = new Basic.DAL.product();
Basic.Model.product modelp = dalp.GetModel(_proid);
if (modelp != null)
{
Kucun = modelp.kucun;
}
}
return Kucun;
}
public static string CountKucun(string attrid,int _proid,int _count,string strProInfo)
{
bool Flag = true;
int Kucun = 0;
int yiyouCount = 0;
Basic.DAL.product_attribute_value dalpav = new Basic.DAL.product_attribute_value();
Basic.Model.product_attribute_value modelpayv = dalpav.GetModel(_proid,("-"+attrid.Replace(",","-")+"-"));
if (modelpayv != null)
{
Kucun = modelpayv.count;
if (Kucun < _count)
{
Flag = false;
}
}
else
{
Basic.DAL.product dalp = new Basic.DAL.product();
Basic.Model.product modelp = dalp.GetModel(_proid);
if (modelp != null)
{
if (modelp.kucun < _count)
{
Flag = false;
}
}
else
{
Flag = false;
}
}
if (!Flag)
{
return "产品["+strProInfo.Trim()+"]库存少于购买数量。 ";
}
else
{
return "";
}
}
}
}