public RespondWebViewData <RequestEditClientViewModel> EditClient(RequestWebViewData <RequestEditClientViewModel> request)
        {
            var rData = request.data;

            if (this.mClientDataAccess.CheckClientIsExist(new QueryClientListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber, ClientId = rData.ClientId
            }))
            {
                return(new RespondWebViewData <RequestEditClientViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的往来单位已经存在", rData.Name, rData.SerialNumber)));
            }

            var respond = new RespondWebViewData <RequestEditClientViewModel>(WebViewErrorCode.Success);

            this.mDbConnection.ExecuteTransaction(tran =>
            {
                var client = this.mClientDataAccess.GetclientDataModelById(rData.ClientId);
                if (client == null)
                {
                    respond = new RespondWebViewData <RequestEditClientViewModel>(WebViewErrorCode.NotExistsDataInfo);
                    return;
                }
                if (client.deleted == (short)CommonDeleted.Deleted)
                {
                    respond = new RespondWebViewData <RequestEditClientViewModel>(WebViewErrorCode.NotExistsDataInfo);
                    return;
                }

                var data = new clientDataModel
                {
                    address      = rData.Address,
                    alias        = rData.Alias,
                    clientid     = rData.ClientId,
                    comment      = rData.Comment,
                    credits      = rData.Credits,
                    linkaddress  = rData.LinkAddress,
                    linktel      = rData.LinkTel,
                    linkman      = rData.LinkMan,
                    name         = rData.Name,
                    pinyin       = rData.Spelling,
                    pricemode    = rData.PriceMode,
                    serialnumber = rData.SerialNumber,
                    sort         = rData.Sort,
                    zipcode      = rData.ZipCode,
                    status       = client.status,
                    deleted      = client.deleted,
                    parentid     = client.parentid,
                    childnumber  = client.childnumber,
                    childcount   = client.childcount,
                    classid      = client.classid
                };
                this.mClientDataAccess.Update(data, tran);
                MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicClient);

                //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作
                //this.SaveMongoDbData("编辑往来客户资料", request, respond, this.GetType());
            });
            return(respond);
        }
        public RespondWebViewData <RespondAddClientViewModel> AddClient(RequestWebViewData <RequestAddClientViewModel> request)
        {
            var rData = request.data;

            if (this.mClientDataAccess.CheckClientIsExist(new QueryClientListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber
            }))
            {
                return(new RespondWebViewData <RespondAddClientViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的往来单位已经存在", rData.Name, rData.SerialNumber)));
            }

            var respond = new RespondWebViewData <RespondAddClientViewModel>(WebViewErrorCode.Success);

            try
            {
                var client = this.mClientDataAccess.GetClientByClassID(new QueryClientListParameter {
                    ParentId = rData.ParentId
                });
                if (client == null)
                {
                    return(new RespondWebViewData <RespondAddClientViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                if (client.deleted == (short)CommonDeleted.Deleted)
                {
                    return(new RespondWebViewData <RespondAddClientViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }

                this.mDbConnection.ExecuteTransaction(tran =>
                {
                    var parameter = new QueryClientListParameter
                    {
                        ParentId = rData.ParentId
                    };
                    var classId    = string.Concat(rData.ParentId, "000001");
                    var clientList = this.mClientDataAccess.GetClientListByParentID(parameter);
                    if (clientList.Count > 0)
                    {
                        classId = BuildNewClassIdByLastClassId.GeneratedNewClassIdByLastClassId(clientList[0].classid);
                    }

                    var data = new clientDataModel
                    {
                        address      = rData.Address,
                        alias        = rData.Alias,
                        childnumber  = 0,
                        childcount   = 0,
                        classid      = classId,
                        comment      = rData.Comment,
                        credits      = rData.Credits,
                        deleted      = (short)CommonDeleted.NotDeleted,
                        linktel      = rData.LinkTel,
                        linkman      = rData.LinkMan,
                        linkaddress  = rData.LinkAddress,
                        name         = rData.Name,
                        pinyin       = rData.Spelling,
                        parentid     = rData.ParentId,
                        pricemode    = rData.PriceMode,
                        status       = (short)CommonStatus.Used,
                        serialnumber = rData.SerialNumber,
                        sort         = rData.Sort,
                        zipcode      = rData.ZipCode
                    };
                    var addResult = this.mClientDataAccess.Add(data, tran);
                    if (addResult > 0)
                    {
                        this.mClientDataAccess.UpdateChildNumberByClassId(tran, parameter);
                    }
                    MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicClient);

                    //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作
                    //this.SaveMongoDbData("新增往来客户资料", request, respond, this.GetType());
                });
            }
            catch (Exception exception)
            {
                respond = new RespondWebViewData <RespondAddClientViewModel>(new ErrorCodeItem(WebViewErrorCode.Exception.ErrorCode, exception.Message));
            }
            return(respond);
        }