📄 present.cs
字号:
namespace PowerEasy.Shop
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Enumerations;
using PowerEasy.IDal.Shop;
using PowerEasy.Model.Shop;
using System;
using System.Collections.Generic;
public sealed class Present
{
private static readonly IPresent dal = DataAccess.CreatePresent();
private Present()
{
}
public static bool AddPresent(PresentInfo info)
{
if (dal.AddPresent(info))
{
AddStockInfo(DoHtmlDecode(info));
return true;
}
return false;
}
private static void AddStockInfo(PresentInfo presentInfo)
{
StockInfo stockInfo = new StockInfo();
stockInfo.StockId = StockManage.GetMaxId() + 1;
stockInfo.StockNum = StockItem.GetInStockNum();
stockInfo.InputTime = DateTime.Now;
stockInfo.StockType = StockType.InStock;
stockInfo.Inputer = PEContext.Current.Admin.AdminName;
stockInfo.Remark = "商品库存初始";
if (StockManage.Add(stockInfo))
{
StockItemInfo info = new StockItemInfo();
info.Amount = presentInfo.Stocks;
info.Price = presentInfo.Price;
info.ProductId = presentInfo.PresentId;
info.TableName = string.Empty;
info.Property = string.Empty;
info.ProductNum = presentInfo.PresentNum;
info.Unit = presentInfo.Unit;
info.ProductName = presentInfo.PresentName;
StockItem.Add(info, stockInfo.StockId);
}
}
public static bool AddStocks(int id, int quantity)
{
return dal.AddStocks(id, quantity);
}
public static bool DeletePresents(string idList)
{
return (DataValidator.IsValidId(idList) && dal.DeletePresents(idList));
}
private static PresentInfo DoHtmlDecode(PresentInfo presentInfo)
{
presentInfo.PresentNum = DataSecurity.HtmlDecode(presentInfo.PresentNum);
presentInfo.PresentName = DataSecurity.HtmlDecode(presentInfo.PresentName);
presentInfo.PresentPic = DataSecurity.HtmlDecode(presentInfo.PresentPic);
presentInfo.PresentThumb = DataSecurity.HtmlDecode(presentInfo.PresentThumb);
presentInfo.Unit = DataSecurity.HtmlDecode(presentInfo.Unit);
presentInfo.DownloadUrl = DataSecurity.HtmlDecode(presentInfo.DownloadUrl);
presentInfo.Remark = DataSecurity.HtmlDecode(presentInfo.Remark);
presentInfo.PresentIntro = DataSecurity.HtmlDecode(presentInfo.PresentIntro);
return presentInfo;
}
private static PresentInfo DoHtmlEncode(PresentInfo presentInfo)
{
presentInfo.PresentNum = DataSecurity.HtmlEncode(presentInfo.PresentNum);
presentInfo.PresentName = DataSecurity.HtmlEncode(presentInfo.PresentName);
presentInfo.PresentPic = DataSecurity.HtmlEncode(presentInfo.PresentPic);
presentInfo.PresentThumb = DataSecurity.HtmlEncode(presentInfo.PresentThumb);
presentInfo.Unit = DataSecurity.HtmlEncode(presentInfo.Unit);
presentInfo.DownloadUrl = DataSecurity.HtmlEncode(presentInfo.DownloadUrl);
presentInfo.Remark = DataSecurity.HtmlEncode(presentInfo.Remark);
presentInfo.PresentIntro = DataSecurity.HtmlEncode(presentInfo.PresentIntro);
return presentInfo;
}
public static IList<PresentInfo> GetPresentByCharacter(ProductCharacter productCharacter)
{
IList<PresentInfo> presentByCharacter = dal.GetPresentByCharacter(productCharacter);
foreach (PresentInfo info in presentByCharacter)
{
DoHtmlDecode(info);
}
return presentByCharacter;
}
public static PresentInfo GetPresentById(int id)
{
return DoHtmlDecode(dal.GetPresentById(id));
}
public static PresentInfo GetPresentByPresentNum(string presentNum)
{
return DoHtmlDecode(dal.GetPresentByPresentNum(presentNum));
}
public static Dictionary<int, string> GetPresentList(string idList)
{
Dictionary<int, string> dictionary = new Dictionary<int, string>();
if (DataValidator.IsValidId(idList))
{
foreach (string str in idList.Split(new char[] { ',' }))
{
int id = DataConverter.CLng(str);
string presentNameById = GetPresentNameById(id);
if (!string.IsNullOrEmpty(presentNameById))
{
dictionary.Add(id, presentNameById);
}
}
}
return dictionary;
}
public static IList<PresentInfo> GetPresentList(int startRowIndexId, int maxNumberRows)
{
IList<PresentInfo> presentList = dal.GetPresentList(startRowIndexId, maxNumberRows);
foreach (PresentInfo info in presentList)
{
DoHtmlDecode(info);
}
return presentList;
}
public static IList<PresentInfo> GetPresentList(int startRowIndexId, int maxNumberRows, int searchType, string keyword)
{
IList<PresentInfo> list = dal.GetPresentList(startRowIndexId, maxNumberRows, searchType, DataSecurity.FilterBadChar(keyword));
foreach (PresentInfo info in list)
{
DoHtmlDecode(info);
}
return list;
}
public static string GetPresentNameById(int id)
{
return dal.GetPresentNameById(id);
}
public static int GetPresentTotal()
{
return dal.GetPresentTotal();
}
public static int GetPresentTotal(int searchType, string keyword)
{
return GetPresentTotal();
}
public static IList<string> GetUnitList()
{
return dal.GetUnitList();
}
public static bool UpdatePressent(PresentInfo info)
{
return dal.UpdatePressent(DoHtmlEncode(info));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -