Пример #1
0
        public ActionResult Create(SuppliersModel model)
        {
            ViewBag.thArea   = _thAreaService.GetTHAreaByParentID(ACultureHelper.GetLanguageID, 0).Data;
            ViewBag.xianArea = SelectCommon.GetTHArea_lang(null);

            if (ModelState.IsValid)
            {
                ResultModel resultModel = new ResultModel();

                if (model.SupplierId > 0)
                {
                    model.UpdateBy = UserInfo.CurrentUserName;
                    model.UpdateDT = DateTime.Now;
                    var result = _suppliersService.UpdateSuppliers(model).IsValid;

                    resultModel.Messages = new List <string> {
                        result == true ? " success!" : " failed!"
                    };
                    var opera = string.Empty;
                    opera = string.Format("修改供应商管理:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "修改供应商管理");
                }
                else
                {
                    SalesSuppliersModel smodel = new SalesSuppliersModel();
                    smodel.Mobile     = model.Mobile;
                    smodel.PagedIndex = 0;
                    smodel.PagedSize  = 2;
                    var bl = Mobile(smodel);
                    if (bl)
                    {
                        model.PassWord   = FormsAuthentication.HashPasswordForStoringInConfigFile(model.PassWord.Trim(), "MD5");
                        model.SupplierId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                        model.CreateBy   = UserInfo.CurrentUserName;
                        model.CreateDT   = DateTime.Now;
                        model.UpdateBy   = UserInfo.CurrentUserName;
                        model.UpdateDT   = DateTime.Now;
                        var result = _suppliersService.AddSuppliers(model).IsValid;
                        resultModel.Messages = new List <string> {
                            result == true ? " success!" : " failed!"
                        };
                        var opera = string.Empty;
                        opera = string.Format("添加供应商管理:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                        LogPackage.InserAC_OperateLog(opera, "添加供应商管理");
                    }
                    else
                    {
                        resultModel.IsValid  = false;
                        resultModel.Messages = new List <string> {
                            " Mobile phone number already exists!"
                        };
                    }
                }


                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }

            return(PartialView(model));
        }