Exemplo n.º 1
0
        public ResultModel GetDetailBySubId(UserModel user, int subId)
        {
            ResultModel result = new ResultModel();

            if (subId < 1)
            {
                result.Message = "合约序号不能小于1";
                return result;
            }

            List<SqlParameter> paras = new List<SqlParameter>();
            SqlParameter para = new SqlParameter("@subId", SqlDbType.Int, 4);
            para.Value = subId;
            paras.Add(para);

            SqlDataReader dr = null;

            try
            {
                string cmdText = "select * from dbo.Con_SubDetail where SubId =@subId";

                dr = SqlHelper.ExecuteReader(this.ConnectString, CommandType.Text, cmdText, paras.ToArray());

                SubDetail subdetail = new SubDetail();

                if (dr.Read())
                {
                    int indexSubDetailId = dr.GetOrdinal("SubDetailId");
                    subdetail.SubDetailId = Convert.ToInt32(dr[indexSubDetailId]);

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

                    int indexDiscountBase = dr.GetOrdinal("DiscountBase");
                    if (dr["DiscountBase"] != DBNull.Value)
                    {
                        subdetail.DiscountBase = Convert.ToInt32(dr[indexDiscountBase]);
                    }

                    int indexDiscountType = dr.GetOrdinal("DiscountType");
                    if (dr["DiscountType"] != DBNull.Value)
                    {
                        subdetail.DiscountType = Convert.ToInt32(dr[indexDiscountType]);
                    }

                    int indexDiscountRate = dr.GetOrdinal("DiscountRate");
                    if (dr["DiscountRate"] != DBNull.Value)
                    {
                        subdetail.DiscountRate = Convert.ToDecimal(dr[indexDiscountRate]);
                    }

                    int indexDelayType = dr.GetOrdinal("DelayType");
                    if (dr["DelayType"] != DBNull.Value)
                    {
                        subdetail.DelayType = Convert.ToInt32(dr[indexDelayType]);
                    }

                    int indexDelayRate = dr.GetOrdinal("DelayRate");
                    if (dr["DelayRate"] != DBNull.Value)
                    {
                        subdetail.DelayRate = Convert.ToDecimal(dr[indexDelayRate]);
                    }

                    int indexMoreOrLess = dr.GetOrdinal("MoreOrLess");
                    if (dr["MoreOrLess"] != DBNull.Value)
                    {
                        subdetail.MoreOrLess = Convert.ToDecimal(dr[indexMoreOrLess]);
                    }

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

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

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

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

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = subdetail;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            SubDetail subdetail = new SubDetail();

            int indexSubDetailId = dr.GetOrdinal("SubDetailId");
            subdetail.SubDetailId = Convert.ToInt32(dr[indexSubDetailId]);

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

            int indexDiscountBase = dr.GetOrdinal("DiscountBase");
            if (dr["DiscountBase"] != DBNull.Value)
            {
                subdetail.DiscountBase = Convert.ToInt32(dr[indexDiscountBase]);
            }

            int indexDiscountType = dr.GetOrdinal("DiscountType");
            if (dr["DiscountType"] != DBNull.Value)
            {
                subdetail.DiscountType = Convert.ToInt32(dr[indexDiscountType]);
            }

            int indexDiscountRate = dr.GetOrdinal("DiscountRate");
            if (dr["DiscountRate"] != DBNull.Value)
            {
                subdetail.DiscountRate = Convert.ToDecimal(dr[indexDiscountRate]);
            }

            int indexDelayType = dr.GetOrdinal("DelayType");
            if (dr["DelayType"] != DBNull.Value)
            {
                subdetail.DelayType = Convert.ToInt32(dr[indexDelayType]);
            }

            int indexDelayRate = dr.GetOrdinal("DelayRate");
            if (dr["DelayRate"] != DBNull.Value)
            {
                subdetail.DelayRate = Convert.ToDecimal(dr[indexDelayRate]);
            }

            int indexMoreOrLess = dr.GetOrdinal("MoreOrLess");
            if (dr["MoreOrLess"] != DBNull.Value)
            {
                subdetail.MoreOrLess = Convert.ToDecimal(dr[indexMoreOrLess]);
            }

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

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

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

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

            return subdetail;
        }
Exemplo n.º 4
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;
        }