Esempio n. 1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(BCW.Model.Goods model)
 {
     dal.Update(model);
 }
Esempio n. 2
0
    /// <summary>
    /// 添加/编辑商品
    /// </summary>
    private void UpdateShop(string act, string TypeName, int ptype, int nid, int id)
    {
        string aName = string.Empty;

        if (id == 0)
        {
            aName = "添加" + TypeName + "";
        }
        else
        {
            aName = "编辑" + TypeName + "";
        }
        Master.Title = aName;
        string  ac         = Utils.GetRequest("ac", "post", 1, "", "");
        string  Title      = Utils.GetRequest("Title", "post", 2, @"^[\s\S]{1,50}$", "商品名称限1-50字");
        string  Config     = Utils.GetRequest("Config", "post", 3, @"^[\s\S]{1,500}$", "商品配置最多500字");
        string  Content    = Utils.GetRequest("Content", "post", 2, @"^[\s\S]{1,}$", "商品内容不能为空");
        bool    IsAd       = bool.Parse(Utils.GetRequest("IsAd", "post", 2, @"^False|True$", "商品性质选择错误"));
        int     PostType   = int.Parse(Utils.GetRequest("PostType", "post", 2, @"^[0-2]$", "付款方式选择错误"));
        decimal CityMoney  = Convert.ToDecimal(Utils.GetRequest("CityMoney", "post", 2, @"^(\d)*(\.(\d){0,2})?$", "市场价格填写错误"));
        decimal VipMoney   = Convert.ToDecimal(Utils.GetRequest("VipMoney", "post", 2, @"^(\d)*(\.(\d){0,2})?$", "市场价格填写错误"));
        int     StockCount = int.Parse(Utils.GetRequest("StockCount", "post", 2, @"^[0-9]\d*$", "出售总量填写错误"));
        int     SellCount  = int.Parse(Utils.GetRequest("SellCount", "post", 1, @"^[0-9]\d*$", "0"));
        int     PayCount   = int.Parse(Utils.GetRequest("PayCount", "post", 1, @"^[0-9]\d*$", "0"));
        string  Mobile     = Utils.GetRequest("Mobile", "post", 2, @"^[\s\S]{1,200}$", "联系方式限200字");
        int     PayType    = int.Parse(Utils.GetRequest("PayType", "post", 2, @"^[0-9]\d*$", "送货方式选择错误"));
        string  PostMoney  = Utils.GetRequest("PostMoney", "post", 3, @"^[^\|]{1,50}(?:\|[^\|]{1,50}){1,500}$", "邮递邮费填写错误,可以留空");
        string  KeyWord    = Utils.GetRequest("KeyWord", "post", 1, "", "");
        string  sFiles     = string.Empty;
        int     newId      = 0;

        //关键字的生成
        if (string.IsNullOrEmpty(KeyWord))
        {
            KeyWord = Out.CreateKeyWord(Title, 2);
        }
        else
        {
            if (KeyWord.Length > 500)
            {
                Utils.Error("关键字不能超500字", "");
            }
            KeyWord = Utils.GetRequest("KeyWord", "post", 2, @"^[^\#]{1,50}(?:\#[^\#]{1,50}){0,500}$", "关键字填写格式错误");
        }

        //----------计算邮递邮费合法性开始
        if (PostMoney != "")
        {
            int GetNum = Utils.GetStringNum(PostMoney, "|");
            if (GetNum % 2 == 0)
            {
                Utils.Error("邮递邮费填写错误,可以留空", "");
            }
        }


        //添加验证
        if (id == 0)
        {
            if (new BCW.BLL.Goods().Exists(Title))
            {
                Utils.Error("数据库记录已存在“" + Title + "”", "");
            }
        }

        //写进数据库
        BCW.Model.Goods model = new BCW.Model.Goods();
        model.Title      = Title;
        model.KeyWord    = KeyWord;
        model.IsAd       = IsAd;
        model.Mobile     = Mobile;
        model.CityMoney  = CityMoney;
        model.VipMoney   = VipMoney;
        model.SellCount  = SellCount;
        model.StockCount = StockCount;
        model.Paycount   = PayCount;
        model.PayType    = PayType;
        model.PostType   = PostType;
        model.PostMoney  = PostMoney;
        model.UsId       = 0;
        model.NodeId     = nid;
        model.Content    = Content;
        model.AddTime    = DateTime.Now;
        model.Readcount  = 0;
        model.Evcount    = 0;
        model.Config     = Config;
        if (id == 0)
        {
            newId = new BCW.BLL.Goods().Add(model);
        }
        else
        {
            newId    = id;
            model.ID = id;
            new BCW.BLL.Goods().Update(model);
        }

        //商品附图上传开始
        if (Utils.ToSChinese(ac) == "上传")
        {
            if (SaveFiles(ptype, newId, out sFiles))
            {
                aName += "/上传商品附图";
            }
        }
        //商品附图上传结束
        //得到截图文件
        string sPics = "";
        string Pics  = "";

        if (sFiles != "")
        {
            sPics = Utils.Mid(sFiles, 1, sFiles.Length);
        }
        if (sPics == "#")
        {
            sPics = "";
        }

        if (sPics != "")
        {
            Pics = new BCW.BLL.Goods().GetFiles(newId);
            if (Pics != "")
            {
                sPics = Pics + "#" + sPics;
            }

            new BCW.BLL.Goods().UpdateFiles(newId, sPics);
        }

        builder.Append(Out.Tab("<div class=\"title\">", "<br />"));
        builder.Append("" + aName + "成功");
        builder.Append(Out.Tab("</div>", ""));
    }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BCW.Model.Goods model)
 {
     return(dal.Add(model));
 }