public RespondWebViewData <RespondAddSubCompanyViewModel> AddSubCompany(RequestWebViewData <RequestAddSubCompanyViewModel> request)
        {
            var rData = request.data;

            if (this.mSubCompanyDataAccess.CheckSubCompanyIsExist(new QuerySubCompanyListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber
            }))
            {
                return(new RespondWebViewData <RespondAddSubCompanyViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的分公司已经存在", rData.Name, rData.SerialNumber)));
            }

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

            try
            {
                var subCompany = this.mSubCompanyDataAccess.GetSubCompanyByClassID(new QuerySubCompanyListParameter {
                    ParentId = rData.ParentId
                });
                if (subCompany == null)
                {
                    return(new RespondWebViewData <RespondAddSubCompanyViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                if (subCompany.deleted == (short)CommonDeleted.Deleted)
                {
                    return(new RespondWebViewData <RespondAddSubCompanyViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                this.mDbConnection.ExecuteTransaction(tran =>
                {
                    var parameter = new QuerySubCompanyListParameter
                    {
                        ParentId = rData.ParentId
                    };
                    var classId     = string.Concat(rData.ParentId, "000001");
                    var companyList = this.mSubCompanyDataAccess.GetSubCompanyListByParentID(parameter);
                    if (companyList.Count > 0)
                    {
                        classId = BuildNewClassIdByLastClassId.GeneratedNewClassIdByLastClassId(companyList[0].classid);
                    }

                    var data = new subcompanyDataModel
                    {
                        childnumber  = 0,
                        classid      = classId,
                        comment      = rData.Comment,
                        email        = rData.Email,
                        linktel      = rData.LinkTel,
                        linkman      = rData.LinkMan,
                        name         = rData.Name,
                        parentid     = rData.ParentId,
                        pinyin       = rData.Spelling,
                        pricemode    = rData.PriceMode,
                        serialnumber = rData.SerialNumber,
                        sort         = rData.Sort,
                        status       = (short)CommonStatus.Used,
                        deleted      = (short)CommonDeleted.NotDeleted
                    };
                    var addResult = this.mSubCompanyDataAccess.Add(data, tran);
                    if (addResult > 0)
                    {
                        this.mSubCompanyDataAccess.UpdateChildNumberByClassId(tran, parameter);
                    }
                    MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicSubCompany);

                    //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作
                    //this.SaveMongoDbData("新增分公司资料", request, respond, this.GetType());
                });
            }
            catch (Exception ex)
            {
                respond = new RespondWebViewData <RespondAddSubCompanyViewModel>(new ErrorCodeItem(WebViewErrorCode.Exception.ErrorCode, ex.Message));
            }
            return(respond);
        }
        public RespondWebViewData <RespondAddProductViewModel> AddProduct(RequestWebViewData <RequestAddProductViewModel> request)
        {
            var rData = request.data;

            if (this.mProductDataAccess.CheckProductIsExist(new QueryProductListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber
            }))
            {
                return(new RespondWebViewData <RespondAddProductViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的商品已经存在", rData.Name, rData.SerialNumber)));
            }

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

            try
            {
                var product = this.mProductDataAccess.GetProductByClassID(new QueryProductListParameter {
                    ParentId = rData.ParentId
                });
                if (product == null)
                {
                    return(new RespondWebViewData <RespondAddProductViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                if (product.deleted == (short)CommonDeleted.Deleted)
                {
                    return(new RespondWebViewData <RespondAddProductViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                this.mDbConnection.ExecuteTransaction(tran =>
                {
                    var parameter = new QueryProductListParameter()
                    {
                        ParentId = rData.ParentId
                    };
                    var classId = string.Concat(rData.ParentId, "000001");
                    var depList = this.mProductDataAccess.GetProductListByParentID(parameter);
                    if (depList.Count > 0)
                    {
                        classId = BuildNewClassIdByLastClassId.GeneratedNewClassIdByLastClassId(depList[0].classid);
                    }

                    var data = new productDataModel
                    {
                        classid      = classId,
                        deleted      = (short)CommonDeleted.NotDeleted,
                        name         = rData.Name,
                        parentid     = rData.ParentId,
                        pinyin       = rData.Spelling,
                        serialnumber = rData.SerialNumber,
                        sort         = rData.Sort,
                        status       = (short)CommonStatus.Used
                    };
                    var addResult = this.mProductDataAccess.Add(data, tran);
                    if (addResult > 0)
                    {
                        this.mProductDataAccess.UpdateChildNumberByClassId(tran, parameter);
                    }
                    MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicProduct);

                    //由于电脑配置不上mongodb固暂时先屏蔽掉此段mongodb的数据操作
                    //this.SaveMongoDbData("新增商品资料", request, respond, this.GetType());
                });
            }
            catch (Exception ex)
            {
                respond = new RespondWebViewData <RespondAddProductViewModel>(new ErrorCodeItem(WebViewErrorCode.Exception.ErrorCode, ex.Message));
            }
            return(respond);
        }
        public RespondWebViewData <RespondAddStorageViewModel> AddStorage(RequestWebViewData <RequestAddStorageViewModel> request)
        {
            var rData = request.data;

            if (this.mStorageDataAccess.CheckStorageIsExist(new QueryStorageListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber
            }))
            {
                return(new RespondWebViewData <RespondAddStorageViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的仓库已经存在", rData.Name, rData.SerialNumber)));
            }

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

            try
            {
                var storage = this.mStorageDataAccess.GetStorageByClassID(new QueryStorageListParameter {
                    ParentId = rData.ParentId
                });
                if (storage == null)
                {
                    return(new RespondWebViewData <RespondAddStorageViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                if (storage.deleted == (short)CommonDeleted.Deleted)
                {
                    return(new RespondWebViewData <RespondAddStorageViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }

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

                    var data = new storageDataModel
                    {
                        classid      = classId,
                        alias        = rData.Alias,
                        childnumber  = 0,
                        childcount   = 0,
                        comment      = rData.Comment,
                        deleted      = (short)CommonDeleted.NotDeleted,
                        name         = rData.Name,
                        parentid     = rData.ParentId,
                        PinYin       = rData.Spelling,
                        serialnumber = rData.SerialNumber,
                        status       = (short)CommonStatus.Used,
                        sort         = rData.Sort
                    };
                    var addResult = this.mStorageDataAccess.Add(data, tran);
                    if (addResult > 0)
                    {
                        this.mStorageDataAccess.UpdateChildNumberByClassId(tran, parameter);
                    }
                    MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicStorage);

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

            if (this.mEmployeeDataAccess.CheckEmployeeIsExist(new QueryEmployeeListParameter {
                Name = rData.Name, SerialNumber = rData.SerialNumber, DepId = rData.DepId
            }))
            {
                return(new RespondWebViewData <RespondAddEmployeeViewModel>(WebViewErrorCode.ExistsDataInfo.ErrorCode, string.Format("名称为[{0}]或编号为[{1}]的职员已经存在", rData.Name, rData.SerialNumber)));
            }

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

            try
            {
                var employee = this.mEmployeeDataAccess.GetEmployeeByClassID(new QueryEmployeeListParameter {
                    ParentId = rData.ParentId
                });
                if (employee == null)
                {
                    return(new RespondWebViewData <RespondAddEmployeeViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                if (employee.deleted == (short)CommonDeleted.Deleted)
                {
                    return(new RespondWebViewData <RespondAddEmployeeViewModel>(WebViewErrorCode.NotExistsDataInfo));
                }
                this.mDbConnection.ExecuteTransaction(tran =>
                {
                    var parameter = new QueryEmployeeListParameter()
                    {
                        ParentId = rData.ParentId
                    };
                    var classId = string.Concat(rData.ParentId, "000001");
                    var depList = this.mEmployeeDataAccess.GetEmployeeListByParentID(parameter);
                    if (depList.Count > 0)
                    {
                        classId = BuildNewClassIdByLastClassId.GeneratedNewClassIdByLastClassId(depList[0].classid);
                    }

                    var data = new employeeDataModel
                    {
                        address           = rData.Address,
                        childnumber       = 0,
                        classid           = classId,
                        comment           = rData.Comment,
                        deleted           = (short)CommonDeleted.NotDeleted,
                        depid             = rData.DepId,
                        depname           = rData.DepName,
                        lowestdiscount    = rData.LowestDiscount,
                        mobile            = rData.Mobile,
                        name              = rData.Name,
                        parentid          = rData.ParentId,
                        pinyin            = rData.Spelling,
                        serialnumber      = rData.SerialNumber,
                        sort              = rData.Sort,
                        status            = (short)CommonStatus.Used,
                        preinadvancetotal = rData.PreInAdvanceTotal,
                        prepayfeetotal    = rData.PrepayFeeTotal
                    };
                    var addResult = this.mEmployeeDataAccess.Add(data, tran);
                    if (addResult > 0)
                    {
                        this.mEmployeeDataAccess.UpdateChildNumberByClassId(tran, parameter);
                    }
                    MemcacheHelper.RemoveBy(ServiceMemcachedKeyManageConst.BasicEmployee);

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