Exemplo n.º 1
0
        public ResultModel CreateReplaceOrder(UserModel user, Model.DocumentOrder order, List<NFMT.Document.Model.OrderReplaceStock> stockInvoices, NFMT.Document.Model.DocumentOrderDetail detail, bool isSubmitAudit)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.DocumentOrderDetailDAL orderDetailDAL = new DocumentOrderDetailDAL();
                DAL.DocumentOrderStockDAL orderStockDAL = new DocumentOrderStockDAL();
                DAL.DocumentOrderInvoiceDAL orderInvoiceDAL = new DocumentOrderInvoiceDAL();
                NFMT.WareHouse.DAL.StockDAL stockDAL = new WareHouse.DAL.StockDAL();
                NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new WareHouse.DAL.StockNameDAL();
                NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
                NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();
                NFMT.Contract.DAL.ContractCorporationDetailDAL corpDetailDAL = new Contract.DAL.ContractCorporationDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    if (order == null)
                    {
                        result.Message = "制单指令不包含任何数据";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //验证临票指令
                    result = this.documentorderDAL.Get(user, order.CommercialId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.DocumentOrder commercialOrder = result.ReturnValue as Model.DocumentOrder;
                    if (commercialOrder == null || commercialOrder.OrderId <= 0)
                    {
                        result.Message = "临票制单指令不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    if (commercialOrder.OrderStatus != StatusEnum.已生效)
                    {
                        result.Message = "临票制单指令状态不正确,不能替临";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //验证合约
                    result = contractDAL.Get(user, order.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.Message = "合约不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //验证子合约
                    result = subDAL.Get(user, order.SubId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.Message = "子合约不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    if (sub.SubStatus != StatusEnum.已生效)
                    {
                        result.Message = "子合约非已生效状态,不能进行制单指令新增";
                        result.ResultStatus = -1;
                        return result;
                    }

                    if (sub.ContractId != order.ContractId)
                    {
                        result.Message = "子合约归属主合约与制单指令主合约不一致";
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = corpDetailDAL.LoadCorpListByContractId(user, sub.ContractId, true);
                    if (result.ResultStatus != 0)
                        return result;

                    List<NFMT.Contract.Model.ContractCorporationDetail> corps = result.ReturnValue as List<NFMT.Contract.Model.ContractCorporationDetail>;
                    if (corps == null || corps.Count == 0)
                    {
                        result.Message = "合约我方抬头获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    int orderId = 0;

                    //制单指令主表数据初始化
                    //付款方式默认为LC
                    order.PaymentStyle = 19;
                    //卖方默认为合约我方抬头默认公司
                    order.SellerCorp = corps[0].CorpId;
                    ////临票制单或直接终票制单,临终发票差额为0
                    //order.InvGap = 0;
                    //LC未加入时LC序号为0
                    order.LCId = 0;
                    order.ApplyEmpId = user.EmpId;

                    //新增主表
                    order.OrderStatus = StatusEnum.已录入;
                    result = this.documentorderDAL.Insert(user, order);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out orderId) || orderId <= 0)
                    {
                        result.Message = "制单指令新增失败";
                        result.ResultStatus = -1;
                        return result;
                    }
                    order.OrderId = orderId;

                    //新增明细表
                    detail.OrderId = orderId;
                    detail.DetailStatus = StatusEnum.已生效;
                    result = orderDetailDAL.Insert(user, detail);
                    if (result.ResultStatus != 0)
                        return result;

                    //临票指令类型,区分是否分配库存
                    OrderTypeEnum orderType = (OrderTypeEnum)commercialOrder.OrderType;

                    //新增库存明细与发票明细
                    foreach (Model.OrderReplaceStock stockInvoice in stockInvoices)
                    {
                        //添加库存明细
                        Model.DocumentOrderStock orderStock = new DocumentOrderStock();
                        orderStock.DetailStatus = StatusEnum.已生效;
                        orderStock.OrderId = orderId;
                        orderStock.ApplyAmount = stockInvoice.ApplyWeight;
                        orderStock.ComDetailId = stockInvoice.DetailId;

                        //验证临票库存明细是否存在
                        result = orderStockDAL.Get(user,stockInvoice.DetailId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.DocumentOrderStock commercialOrderStock = result.ReturnValue as Model.DocumentOrderStock;
                        if (commercialOrderStock == null || commercialOrderStock.DetailId <= 0)
                        {
                            result.Message = "替换的库存明细不存在";
                            result.ResultStatus = -1;
                            return result;
                        }

                        if (commercialOrderStock.DetailStatus != StatusEnum.已生效)
                        {
                            result.Message = "替换的库存状态不正确";
                            result.ResultStatus = -1;
                            return result;
                        }

                        int orderStockId = 0;

                        orderStock.StockId = commercialOrderStock.StockId;
                        orderStock.StockNameId = commercialOrderStock.StockNameId;
                        orderStock.RefNo = commercialOrderStock.RefNo;

                        result = orderStockDAL.Insert(user, orderStock);
                        if (result.ResultStatus != 0)
                            return result;

                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out orderStockId) || orderStockId <= 0)
                        {
                            result.Message = "制单指令库存明细新增失败";
                            result.ResultStatus = -1;
                            return result;
                        }

                        //添加发票明细
                        Model.DocumentOrderInvoice orderInvoice = new DocumentOrderInvoice();
                        orderInvoice.DetailStatus = StatusEnum.已生效;
                        orderInvoice.InvoiceBala = stockInvoice.InvoiceBala;
                        orderInvoice.InvoiceNo = stockInvoice.InvoiceNo;
                        orderInvoice.OrderId = orderId;
                        orderInvoice.StockDetailId = orderStockId;

                        result = orderInvoiceDAL.Insert(user, orderInvoice);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (isSubmitAudit)
                    {
                        NFMT.WorkFlow.AutoSubmit submit = new WorkFlow.AutoSubmit();
                        NFMT.WorkFlow.ITaskProvider taskProvider = new TaskProvider.OrderTaskProvider();
                        result = submit.Submit(user, order, taskProvider, WorkFlow.MasterEnum.制单指令审核);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = order;

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

            return result;
        }
Exemplo n.º 2
0
        public ResultModel Update(UserModel user, Model.DocumentOrder order, List<NFMT.Document.Model.OrderStockInvoice> stockInvoices, NFMT.Document.Model.DocumentOrderDetail detail)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.DocumentOrderDetailDAL orderDetailDAL = new DocumentOrderDetailDAL();
                DAL.DocumentOrderStockDAL orderStockDAL = new DocumentOrderStockDAL();
                DAL.DocumentOrderInvoiceDAL orderInvoiceDAL = new DocumentOrderInvoiceDAL();
                NFMT.WareHouse.DAL.StockDAL stockDAL = new WareHouse.DAL.StockDAL();
                NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new WareHouse.DAL.StockNameDAL();
                NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
                NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();
                NFMT.Contract.DAL.ContractCorporationDetailDAL corpDetailDAL = new Contract.DAL.ContractCorporationDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    if (order == null)
                    {
                        result.Message = "制单指令不包含任何数据";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //验证制单指令
                    result = this.documentorderDAL.Get(user, order.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.DocumentOrder resultOrder = result.ReturnValue as Model.DocumentOrder;
                    if (resultOrder == null || resultOrder.OrderId <= 0)
                    {
                        result.Message = "制单指令不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    resultOrder.ContractNo = order.ContractNo;
                    resultOrder.LCNo = order.LCNo;
                    resultOrder.LCDay = order.LCDay;
                    resultOrder.OrderType = order.OrderType;
                    resultOrder.OrderDate = order.OrderDate;
                    resultOrder.ApplyCorp = order.ApplyCorp;
                    resultOrder.ApplyDept = order.ApplyDept;
                    resultOrder.BuyerCorp = order.BuyerCorp;
                    resultOrder.BuyerCorpName = order.BuyerCorpName;
                    resultOrder.BuyerAddress = order.BuyerAddress;
                    resultOrder.RecBankId = order.RecBankId;
                    resultOrder.DiscountBase = order.DiscountBase;
                    resultOrder.AssetId = order.AssetId;
                    resultOrder.BrandId = order.BrandId;
                    resultOrder.AreaName = order.AreaName;
                    resultOrder.BankCode = order.BankCode;
                    resultOrder.GrossAmount = order.GrossAmount;
                    resultOrder.NetAmount = order.NetAmount;
                    resultOrder.UnitId = order.UnitId;
                    resultOrder.Bundles = order.Bundles;
                    resultOrder.Currency = order.Currency;
                    resultOrder.UnitPrice = order.UnitPrice;
                    resultOrder.InvBala = order.InvBala;
                    resultOrder.Meno = order.Meno;

                    //更新主表
                    result = this.documentorderDAL.Update(user, resultOrder);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取明细表
                    result = orderDetailDAL.GetByOrderId(user, order.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.DocumentOrderDetail resultDetail = result.ReturnValue as Model.DocumentOrderDetail;
                    if (resultDetail == null || resultDetail.DetailId <= 0)
                    {
                        result.Message = "制单指令明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    resultDetail.InvoiceCopies = detail.InvoiceCopies;
                    resultDetail.InvoiceSpecific = detail.InvoiceSpecific;
                    resultDetail.QualityCopies = detail.QualityCopies;
                    resultDetail.QualitySpecific = detail.QualitySpecific;
                    resultDetail.WeightCopies = detail.WeightCopies;
                    resultDetail.WeightSpecific = detail.WeightSpecific;
                    resultDetail.TexCopies = detail.TexCopies;
                    resultDetail.TexSpecific = detail.TexSpecific;
                    resultDetail.DeliverCopies = detail.DeliverCopies;
                    resultDetail.DeliverSpecific = detail.DeliverSpecific;
                    resultDetail.TotalInvCopies = detail.TotalInvCopies;
                    resultDetail.TotalInvSpecific = detail.TotalInvSpecific;

                    result = orderDetailDAL.Update(user, resultDetail);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废库存明细与发票明细
                    result = orderInvoiceDAL.Load(user, order.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.DocumentOrderInvoice> orderInvoices = result.ReturnValue as List<Model.DocumentOrderInvoice>;
                    if (orderInvoices == null)
                    {
                        result.Message = "制单指令发票明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }
                    foreach (Model.DocumentOrderInvoice orderInvoice in orderInvoices)
                    {
                        result = orderInvoiceDAL.Invalid(user, orderInvoice);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    result = orderStockDAL.Load(user,order.OrderId);
                    if(result.ResultStatus!=0)
                        return result;
                    List<Model.DocumentOrderStock> orderStocks = result.ReturnValue as List<Model.DocumentOrderStock>;
                    if (orderStocks == null)
                    {
                        result.Message = "制单指令库存明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    foreach (Model.DocumentOrderStock orderStock in orderStocks)
                    {
                        result = orderStockDAL.Invalid(user, orderStock);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    OrderTypeEnum orderType = (OrderTypeEnum)order.OrderType;

                    //新增库存明细与发票明细
                    foreach (Model.OrderStockInvoice stockInvoice in stockInvoices)
                    {
                        Model.DocumentOrderStock orderStock = new DocumentOrderStock();
                        orderStock.DetailStatus = StatusEnum.已生效;
                        orderStock.OrderId = order.OrderId;
                        orderStock.ApplyAmount = stockInvoice.ApplyWeight;

                        //库存分配制单指令校验库存信息
                        if (orderType == OrderTypeEnum.临票制单指令 || orderType == OrderTypeEnum.替临制单指令)
                        {
                            //验证库存
                            result = stockDAL.Get(user, stockInvoice.StockId);
                            if (result.ResultStatus != 0)
                                return result;
                            NFMT.WareHouse.Model.Stock stock = result.ReturnValue as NFMT.WareHouse.Model.Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.Message = "制单指令分配库存不存在";
                                result.ResultStatus = -1;
                                return result;
                            }

                            if (stock.AssetId != order.AssetId)
                            {
                                result.Message = "库存品种不匹配";
                                result.ResultStatus = -1;
                                return result;
                            }

                            if (stock.CurNetAmount < stockInvoice.ApplyWeight)
                            {
                                result.Message = "申请重量不能大于库存剩余净重";
                                result.ResultStatus = -1;
                                return result;
                            }

                            //获取业务单号
                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;

                            NFMT.WareHouse.Model.StockName stockName = result.ReturnValue as NFMT.WareHouse.Model.StockName;
                            if (stockName == null || stockName.StockNameId <= 0)
                            {
                                result.Message = "业务单号不存在";
                                result.ResultStatus = -1;
                                return result;
                            }

                            orderStock.StockId = stock.StockId;
                            orderStock.StockNameId = stock.StockNameId;
                            orderStock.RefNo = stockName.RefNo;
                        }
                        else
                        {
                            //无库存配货权录入业务单号
                            orderStock.RefNo = stockInvoice.RefNo;
                        }

                        //添加库存明细
                        int orderStockId = 0;

                        result = orderStockDAL.Insert(user, orderStock);
                        if (result.ResultStatus != 0)
                            return result;

                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out orderStockId) || orderStockId <= 0)
                        {
                            result.Message = "制单指令库存明细新增失败";
                            result.ResultStatus = -1;
                            return result;
                        }

                        //添加发票明细
                        Model.DocumentOrderInvoice orderInvoice = new DocumentOrderInvoice();
                        orderInvoice.DetailStatus = StatusEnum.已生效;
                        orderInvoice.InvoiceBala = stockInvoice.InvoiceBala;
                        orderInvoice.InvoiceNo = stockInvoice.InvoiceNo;
                        orderInvoice.OrderId = order.OrderId;
                        orderInvoice.StockDetailId = orderStockId;

                        result = orderInvoiceDAL.Insert(user, orderInvoice);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = order;

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

            return result;
        }
Exemplo n.º 3
0
        public ResultModel UpdateReplaceOrder(UserModel user, Model.DocumentOrder order, List<NFMT.Document.Model.OrderReplaceStock> stockInvoices, NFMT.Document.Model.DocumentOrderDetail detail)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.DocumentOrderDetailDAL orderDetailDAL = new DocumentOrderDetailDAL();
                DAL.DocumentOrderStockDAL orderStockDAL = new DocumentOrderStockDAL();
                DAL.DocumentOrderInvoiceDAL orderInvoiceDAL = new DocumentOrderInvoiceDAL();
                NFMT.WareHouse.DAL.StockDAL stockDAL = new WareHouse.DAL.StockDAL();
                NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new WareHouse.DAL.StockNameDAL();
                NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
                NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();
                NFMT.Contract.DAL.ContractCorporationDetailDAL corpDetailDAL = new Contract.DAL.ContractCorporationDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    if (order == null)
                    {
                        result.Message = "制单指令不包含任何数据";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //验证制单指令
                    result = this.documentorderDAL.Get(user, order.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.DocumentOrder resultOrder = result.ReturnValue as Model.DocumentOrder;
                    if (resultOrder == null || resultOrder.OrderId <= 0)
                    {
                        result.Message = "制单指令不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    resultOrder.OrderDate = order.OrderDate;
                    resultOrder.BankCode = order.BankCode;
                    resultOrder.GrossAmount = order.GrossAmount;
                    resultOrder.NetAmount = order.NetAmount;
                    resultOrder.Bundles = order.Bundles;
                    resultOrder.UnitPrice = order.UnitPrice;
                    resultOrder.InvBala = order.InvBala;
                    resultOrder.InvGap = order.InvGap;
                    resultOrder.Meno = order.Meno;

                    //更新主表
                    result = this.documentorderDAL.Update(user, resultOrder);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取明细表
                    result = orderDetailDAL.GetByOrderId(user, resultOrder.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.DocumentOrderDetail resultDetail = result.ReturnValue as Model.DocumentOrderDetail;
                    if (resultDetail == null || resultDetail.DetailId <= 0)
                    {
                        result.Message = "制单指令明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    resultDetail.InvoiceCopies = detail.InvoiceCopies;
                    resultDetail.InvoiceSpecific = detail.InvoiceSpecific;
                    resultDetail.QualityCopies = detail.QualityCopies;
                    resultDetail.QualitySpecific = detail.QualitySpecific;
                    resultDetail.WeightCopies = detail.WeightCopies;
                    resultDetail.WeightSpecific = detail.WeightSpecific;
                    resultDetail.TexCopies = detail.TexCopies;
                    resultDetail.TexSpecific = detail.TexSpecific;
                    resultDetail.DeliverCopies = detail.DeliverCopies;
                    resultDetail.DeliverSpecific = detail.DeliverSpecific;
                    resultDetail.TotalInvCopies = detail.TotalInvCopies;
                    resultDetail.TotalInvSpecific = detail.TotalInvSpecific;

                    result = orderDetailDAL.Update(user, resultDetail);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废库存明细与发票明细
                    result = orderInvoiceDAL.Load(user, resultOrder.OrderId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.DocumentOrderInvoice> orderInvoices = result.ReturnValue as List<Model.DocumentOrderInvoice>;
                    if (orderInvoices == null)
                    {
                        result.Message = "制单指令发票明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }
                    foreach (Model.DocumentOrderInvoice orderInvoice in orderInvoices)
                    {
                        result = orderInvoiceDAL.Invalid(user, orderInvoice);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    result = orderStockDAL.Load(user, resultOrder.OrderId);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.DocumentOrderStock> orderStocks = result.ReturnValue as List<Model.DocumentOrderStock>;
                    if (orderStocks == null)
                    {
                        result.Message = "制单指令库存明细获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    foreach (Model.DocumentOrderStock orderStock in orderStocks)
                    {
                        result = orderStockDAL.Invalid(user, orderStock);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    OrderTypeEnum orderType = (OrderTypeEnum)resultOrder.OrderType;

                    //新增库存明细与发票明细
                    foreach (Model.OrderReplaceStock stockInvoice in stockInvoices)
                    {
                        //验证临票库存明细
                        result = orderStockDAL.Get(user, stockInvoice.DetailId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.DocumentOrderStock commercialOrderStock = result.ReturnValue as Model.DocumentOrderStock;
                        if (commercialOrderStock == null || commercialOrderStock.OrderId <= 0)
                        {
                            result.Message = "制单指令替临库存不存在";
                            result.ResultStatus = -1;
                            return result;
                        }

                        if (commercialOrderStock.DetailStatus != StatusEnum.已生效)
                        {
                            result.Message = "制单指令替临库存状态不正确";
                            result.ResultStatus = -1;
                            return result;
                        }

                        if (commercialOrderStock.OrderId != resultOrder.CommercialId)
                        {
                            result.Message = "制单指令替临库存不存在";
                            result.ResultStatus = -1;
                            return result;
                        }

                        Model.DocumentOrderStock orderStock = new DocumentOrderStock();
                        orderStock.DetailStatus = StatusEnum.已生效;
                        orderStock.OrderId = resultOrder.OrderId;
                        orderStock.ApplyAmount = stockInvoice.ApplyWeight;
                        orderStock.StockId = commercialOrderStock.StockId;
                        orderStock.StockNameId = commercialOrderStock.StockNameId;
                        orderStock.RefNo = commercialOrderStock.RefNo;
                        orderStock.ComDetailId = commercialOrderStock.DetailId;

                        //添加库存明细
                        int orderStockId = 0;

                        result = orderStockDAL.Insert(user, orderStock);
                        if (result.ResultStatus != 0)
                            return result;

                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out orderStockId) || orderStockId <= 0)
                        {
                            result.Message = "制单指令库存明细新增失败";
                            result.ResultStatus = -1;
                            return result;
                        }

                        //添加发票明细
                        Model.DocumentOrderInvoice orderInvoice = new DocumentOrderInvoice();
                        orderInvoice.DetailStatus = StatusEnum.已生效;
                        orderInvoice.InvoiceBala = stockInvoice.InvoiceBala;
                        orderInvoice.InvoiceNo = stockInvoice.InvoiceNo;
                        orderInvoice.OrderId = resultOrder.OrderId;
                        orderInvoice.StockDetailId = orderStockId;

                        result = orderInvoiceDAL.Insert(user, orderInvoice);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = resultOrder;

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

            return result;
        }
Exemplo n.º 4
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            DocumentOrderInvoice documentorderinvoice = new DocumentOrderInvoice();

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

            int indexOrderId = dr.GetOrdinal("OrderId");
            if (dr["OrderId"] != DBNull.Value)
            {
                documentorderinvoice.OrderId = Convert.ToInt32(dr[indexOrderId]);
            }

            int indexStockDetailId = dr.GetOrdinal("StockDetailId");
            if (dr["StockDetailId"] != DBNull.Value)
            {
                documentorderinvoice.StockDetailId = Convert.ToInt32(dr[indexStockDetailId]);
            }

            int indexInvoiceNo = dr.GetOrdinal("InvoiceNo");
            if (dr["InvoiceNo"] != DBNull.Value)
            {
                documentorderinvoice.InvoiceNo = Convert.ToString(dr[indexInvoiceNo]);
            }

            int indexInvoiceBala = dr.GetOrdinal("InvoiceBala");
            if (dr["InvoiceBala"] != DBNull.Value)
            {
                documentorderinvoice.InvoiceBala = Convert.ToDecimal(dr[indexInvoiceBala]);
            }

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

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

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

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

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

            return documentorderinvoice;
        }