Beispiel #1
0
        public ResultModel ContractInUpdate(NFMT.Common.UserModel user, Contract.Model.Contract contract, Model.ContractDetail contractDetail, Model.ContractPrice contractPrice, List<Model.ContractCorporationDetail> outCorps, List<Model.ContractCorporationDetail> inCorps, List<Model.ContractDept> depts, List<NFMT.Contract.Model.ContractClause> contractClauses, Model.ContractSub sub, List<Model.ContractTypeDetail> contractTypes)
        {
            ResultModel result = new ResultModel();

            try
            {
                if (contract == null)
                {
                    result.ResultStatus = -1;
                    result.Message = "合约不存在";
                    return result;
                }

                BLL.ContractSubBLL subBLL = new ContractSubBLL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Update(user, contract, contractDetail, contractPrice, outCorps, inCorps, depts, contractClauses, contractTypes);

                    //子合约
                    sub.ContractId = contract.ContractId;
                    sub.AssetId = contract.AssetId;
                    sub.ContractDate = contract.ContractDate;
                    sub.ContractId = contract.ContractId;
                    sub.ContractLimit = contract.ContractLimit;
                    sub.ContractSide = contract.ContractSide;
                    sub.DeliveryDate = contract.DeliveryDate;
                    sub.DeliveryStyle = contract.DeliveryStyle;
                    sub.InitQP = contract.InitQP;
                    sub.Memo = contract.Memo;
                    sub.OutContractNo = contract.OutContractNo;
                    sub.Premium = contract.Premium;
                    sub.PriceMode = contract.PriceMode;
                    sub.SettleCurrency = contract.SettleCurrency;
                    sub.TradeBorder = contract.TradeBorder;
                    sub.TradeDirection = contract.TradeDirection;
                    sub.UnitId = contract.UnitId;

                    //子合约明细
                    Model.SubDetail detail = new SubDetail();
                    detail.DelayRate = contractDetail.DelayRate;
                    detail.DelayType = contractDetail.DelayType;
                    detail.DiscountBase = contractDetail.DiscountBase;
                    detail.DiscountRate = contractDetail.DiscountRate;
                    detail.DiscountType = contractDetail.DiscountType;
                    detail.MoreOrLess = contractDetail.MoreOrLess;
                    detail.Status = StatusEnum.已生效;

                    //子合约价格明细
                    Model.SubPrice price = new SubPrice();
                    price.DoPriceBeginDate = contractPrice.DoPriceBeginDate;
                    price.DoPriceEndDate = contractPrice.DoPriceEndDate;
                    price.FixedPrice = contractPrice.FixedPrice;
                    price.FixedPriceMemo = contractPrice.FixedPriceMemo;
                    price.IsQP = contractPrice.IsQP;
                    price.MarginAmount = contractPrice.MarginAmount;
                    price.MarginMemo = contractPrice.MarginMemo;
                    price.MarginMode = contractPrice.MarginMode;
                    price.PriceFrom = contractPrice.PriceFrom;
                    price.PriceStyle1 = contractPrice.PriceStyle1;
                    price.PriceStyle2 = contractPrice.PriceStyle2;
                    price.Status = StatusEnum.已生效;
                    price.WhoDoPrice = contractPrice.WhoDoPrice;
                    price.AlmostPrice = contractPrice.AlmostPrice;

                    //子合约抬头
                    List<Model.SubCorporationDetail> outSubCorps = new List<SubCorporationDetail>();
                    List<Model.SubCorporationDetail> inSubCorps = new List<SubCorporationDetail>();

                    foreach (Model.ContractCorporationDetail corp in outCorps)
                    {
                        Model.SubCorporationDetail subCorp = new SubCorporationDetail();
                        subCorp.ContractId = contract.ContractId;
                        subCorp.CorpId = corp.CorpId;
                        subCorp.CorpName = corp.CorpName;
                        subCorp.DetailStatus = StatusEnum.已生效;
                        subCorp.IsDefaultCorp = corp.IsDefaultCorp;
                        subCorp.IsInnerCorp = corp.IsInnerCorp;

                        outSubCorps.Add(subCorp);
                    }

                    foreach (Model.ContractCorporationDetail corp in inCorps)
                    {
                        Model.SubCorporationDetail subCorp = new SubCorporationDetail();
                        subCorp.ContractId = contract.ContractId;
                        subCorp.CorpId = corp.CorpId;
                        subCorp.CorpName = corp.CorpName;
                        subCorp.DetailStatus = StatusEnum.已生效;
                        subCorp.IsDefaultCorp = corp.IsDefaultCorp;
                        subCorp.IsInnerCorp = corp.IsInnerCorp;

                        inSubCorps.Add(subCorp);
                    }

                    //子合约类型明细
                    List<Model.SubTypeDetail> subTypes = new List<SubTypeDetail>();
                    foreach (Model.ContractTypeDetail contractType in contractTypes)
                    {
                        Model.SubTypeDetail subType = new SubTypeDetail();
                        subType.ContractId = contract.ContractId;
                        subType.ContractType = contractType.ContractType;
                        subType.DetailStatus = StatusEnum.已生效;

                        subTypes.Add(subType);
                    }

                    result = subBLL.Update(user, sub, detail, price, outSubCorps, inSubCorps, subTypes);

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Beispiel #2
0
        public ResultModel ContractOutCreate(NFMT.Common.UserModel user, Contract.Model.Contract contract, Model.ContractDetail contractDetail, Model.ContractPrice contractPrice, List<Model.ContractCorporationDetail> outCorps, List<Model.ContractCorporationDetail> inCorps, List<Model.ContractDept> depts, List<NFMT.Contract.Model.ContractClause> contractClauses, Model.ContractSub sub, List<Model.ContractTypeDetail> contractTypes)
        {
            ResultModel result = new ResultModel();

            try
            {
                BLL.ContractSubBLL subBLL = new ContractSubBLL();

                //新增主合约
                contract.CreateFrom = (int)NFMT.Common.CreateFromEnum.销售合约库存创建;
                result = this.Create(user, contract, contractDetail, contractPrice, outCorps, inCorps, depts, contractClauses, contractTypes);

                if (result.ResultStatus != 0)
                    return result;

                Model.Contract resultContract = result.ReturnValue as Model.Contract;
                if (resultContract == null || resultContract.ContractId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "新增主合约失败";
                    return result;
                }

                //新增子合约
                sub.AssetId = resultContract.AssetId;
                sub.ContractDate = resultContract.ContractDate;
                sub.ContractId = resultContract.ContractId;
                sub.ContractLimit = resultContract.ContractLimit;
                sub.ContractSide = resultContract.ContractSide;
                sub.CreateFrom = resultContract.CreateFrom;
                sub.DeliveryDate = resultContract.DeliveryDate;
                sub.DeliveryStyle = resultContract.DeliveryStyle;
                sub.InitQP = resultContract.InitQP;
                sub.Memo = resultContract.Memo;
                sub.OutContractNo = resultContract.OutContractNo;
                sub.Premium = resultContract.Premium;
                sub.PriceMode = resultContract.PriceMode;
                sub.SettleCurrency = resultContract.SettleCurrency;
                sub.SubStatus = StatusEnum.已录入;
                sub.TradeBorder = resultContract.TradeBorder;
                sub.TradeDirection = resultContract.TradeDirection;
                sub.UnitId = resultContract.UnitId;

                //子合约明细
                Model.SubDetail detail = new SubDetail();
                detail.DelayRate = contractDetail.DelayRate;
                detail.DelayType = contractDetail.DelayType;
                detail.DiscountBase = contractDetail.DiscountBase;
                detail.DiscountRate = contractDetail.DiscountRate;
                detail.DiscountType = contractDetail.DiscountType;
                detail.MoreOrLess = contractDetail.MoreOrLess;
                detail.Status = StatusEnum.已生效;

                //子合约价格明细
                Model.SubPrice price = new SubPrice();
                price.DoPriceBeginDate = contractPrice.DoPriceBeginDate;
                price.DoPriceEndDate = contractPrice.DoPriceEndDate;
                price.FixedPrice = contractPrice.FixedPrice;
                price.FixedPriceMemo = contractPrice.FixedPriceMemo;
                price.IsQP = contractPrice.IsQP;
                price.MarginAmount = contractPrice.MarginAmount;
                price.MarginMemo = contractPrice.MarginMemo;
                price.MarginMode = contractPrice.MarginMode;
                price.PriceFrom = contractPrice.PriceFrom;
                price.PriceStyle1 = contractPrice.PriceStyle1;
                price.PriceStyle2 = contractPrice.PriceStyle2;
                price.Status = StatusEnum.已生效;
                price.WhoDoPrice = contractPrice.WhoDoPrice;
                price.AlmostPrice = contractPrice.AlmostPrice;

                //子合约抬头
                List<Model.SubCorporationDetail> outSubCorps = new List<SubCorporationDetail>();
                List<Model.SubCorporationDetail> inSubCorps = new List<SubCorporationDetail>();

                foreach (Model.ContractCorporationDetail corp in outCorps)
                {
                    Model.SubCorporationDetail subCorp = new SubCorporationDetail();
                    subCorp.ContractId = resultContract.ContractId;
                    subCorp.CorpId = corp.CorpId;
                    subCorp.CorpName = corp.CorpName;
                    subCorp.DetailStatus = StatusEnum.已生效;
                    subCorp.IsDefaultCorp = corp.IsDefaultCorp;
                    subCorp.IsInnerCorp = corp.IsInnerCorp;

                    outSubCorps.Add(subCorp);
                }

                foreach (Model.ContractCorporationDetail corp in inCorps)
                {
                    Model.SubCorporationDetail subCorp = new SubCorporationDetail();
                    subCorp.ContractId = resultContract.ContractId;
                    subCorp.CorpId = corp.CorpId;
                    subCorp.CorpName = corp.CorpName;
                    subCorp.DetailStatus = StatusEnum.已生效;
                    subCorp.IsDefaultCorp = corp.IsDefaultCorp;
                    subCorp.IsInnerCorp = corp.IsInnerCorp;

                    inSubCorps.Add(subCorp);
                }

                //子合约类型明细
                List<Model.SubTypeDetail> subTypes = new List<SubTypeDetail>();
                foreach (Model.ContractTypeDetail contractType in contractTypes)
                {
                    Model.SubTypeDetail subType = new SubTypeDetail();
                    subType.ContractId = resultContract.ContractId;
                    subType.ContractType = contractType.ContractType;
                    subType.DetailStatus = StatusEnum.已生效;

                    subTypes.Add(subType);
                }

                result = subBLL.Create(user, sub, detail, price, outSubCorps, inSubCorps, subTypes);
                if (result.ResultStatus != 0)
                    return result;

                Model.ContractSub resultSub = result.ReturnValue as Model.ContractSub;
                if (resultSub == null || resultSub.SubId <= 0)
                {
                    result.ResultStatus = -1;
                    result.Message = "新增子合约失败";
                    return result;
                }

                result.ReturnValue = resultContract;
                result.AffectCount = resultSub.SubId;
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Beispiel #3
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            SubTypeDetail subtypedetail = new SubTypeDetail();

            int indexDetailId = dr.GetOrdinal("DetailId");
            subtypedetail.DetailId = Convert.ToInt32(dr[indexDetailId]);

            int indexContractId = dr.GetOrdinal("ContractId");
            if (dr["ContractId"] != DBNull.Value)
            {
                subtypedetail.ContractId = Convert.ToInt32(dr[indexContractId]);
            }

            int indexSubId = dr.GetOrdinal("SubId");
            if (dr["SubId"] != DBNull.Value)
            {
                subtypedetail.SubId = Convert.ToInt32(dr[indexSubId]);
            }

            int indexContractType = dr.GetOrdinal("ContractType");
            if (dr["ContractType"] != DBNull.Value)
            {
                subtypedetail.ContractType = Convert.ToInt32(dr[indexContractType]);
            }

            int indexDetailStatus = dr.GetOrdinal("DetailStatus");
            if (dr["DetailStatus"] != DBNull.Value)
            {
                subtypedetail.DetailStatus = (StatusEnum)Convert.ToInt32(dr[indexDetailStatus]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            if (dr["CreatorId"] != DBNull.Value)
            {
                subtypedetail.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
            }

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            if (dr["CreateTime"] != DBNull.Value)
            {
                subtypedetail.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
            }

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                subtypedetail.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                subtypedetail.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return subtypedetail;
        }