Esempio n. 1
0
        /// <summary>
        /// 新增
        /// znt 2015-03-20
        /// 2015-03-14 lxt 修改
        /// </summary>
        public override BaseResult Save(dynamic entity)
        {
            BaseResult   br    = new BaseResult();
            Td_Sale_Cart model = (Td_Sale_Cart)entity;
            Hashtable    param = new Hashtable();

            param.Add("id_cgs", model.id_cgs);
            param.Add("id_sp", model.id_sp);
            param.Add("id_sku", model.id_sku);
            param.Add("id_gys", model.id_gys);
            if (DAL.GetCount(typeof(Td_Sale_Cart), param) > 0)
            {
                param.Add("new_sl", model.sl);
                DAL.UpdatePart(typeof(Td_Sale_Cart), param);
                br.Success = true;
                return(br);
            }
            else
            {
                DAL.Add(model);
            }

            br.Success = true;
            return(br);
        }
Esempio n. 2
0
        public ActionResult Save(string obj)
        {
            BaseResult br = new BaseResult();

            try
            {
                Td_Sale_Cart model = JSON.Deserialize <Td_Sale_Cart>(obj);
                if (model.id_gys < 1)
                {
                    br.Success = false;
                    br.Message.Add("操作失败!提交的数据不完整。");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (model.id_sp < 1)
                {
                    br.Success = false;
                    br.Message.Add("操作失败!提交的数据不完整。");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (model.id_sku < 1)
                {
                    br.Success = false;
                    br.Message.Add("操作失败!提交的数据不完整。");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                if (model.sl < 1)
                {
                    br.Success = false;
                    br.Message.Add("操作失败!数量必须大于0。");
                    br.Level = ErrorLevel.Warning;
                    return(Json(br));
                }
                model.id_cgs  = GetLoginInfo <long>("id_buyer");
                model.id_user = GetLoginInfo <long>("id_user");
                br            = BusinessFactory.GoodsCart.Save(model);
                if (br.Success)
                {
                    Hashtable param = new Hashtable();
                    param.Add("id_cgs", model.id_cgs);
                    param.Add("id_user", model.id_user);
                    BaseResult br1 = BusinessFactory.GoodsCart.GetCount(param);
                    br.Data = br1.Data;
                }
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(br));
        }
Esempio n. 3
0
        public ActionResult SaveCart()
        {
            Hashtable  param = GetParameters();
            BaseResult br    = new BaseResult();

            ParamVessel p = new ParamVessel();

            p.Add("id_gys", (long)0, HandleType.ReturnMsg);
            p.Add("id_sp", (long)0, HandleType.ReturnMsg);
            p.Add("id_sku", (long)0, HandleType.ReturnMsg);
            p.Add("sl", (long)0, HandleType.ReturnMsg);
            param = param.Trim(p);
            try
            {
                Td_Sale_Cart model = new Td_Sale_Cart()
                {
                    id_cgs  = GetLoginInfo <long>("id_buyer"),
                    id_user = GetLoginInfo <long>("id_user"),

                    id_gys = Convert.ToInt32(param["id_gys"]),
                    id_sku = Convert.ToInt32(param["id_sku"]),
                    id_sp  = Convert.ToInt32(param["id_sp"]),
                    sl     = Convert.ToDecimal(param["sl"]),
                };

                br = BusinessFactory.GoodsCart.Save(model);
                if (br.Success)
                {
                    param.Clear();
                    param.Add("id_cgs", GetLoginInfo <long>("id_buyer"));
                    param.Add("id_user", GetLoginInfo <long>("id_user"));
                    BaseResult br1 = BusinessFactory.GoodsCart.GetCount(param);
                    br.Data = br1.Data;
                }
            }
            catch (CySoftException ex)
            {
                throw ex;
            }
            catch
            (Exception ex)
            {
                throw ex;
            }
            return(Json(br));
        }