Esempio n. 1
0
 public IList <Book.Model.InvoiceJRDetail> Select(Book.Model.InvoiceJR invoice)
 {
     return(sqlmapper.QueryForList <Model.InvoiceJRDetail>("InvoiceJRDetail.select_by_invoiceid", invoice.InvoiceId));
 }
Esempio n. 2
0
 public void Delete(Book.Model.InvoiceJR invoice)
 {
     sqlmapper.Delete("InvoiceJRDetail.delete_by_invoiceid", invoice.InvoiceId);
 }
Esempio n. 3
0
        private void _Insert(Book.Model.InvoiceJR invoice)
        {
            //往来单位
            //if (invoice.Customer != null)
            //    invoice.CustomerId = invoice.Customer.CustomerId;
            // 库房
            //invoice.DepotId = invoice.Depot.DepotId;
            //经手人
            invoice.Employee0Id = invoice.Employee0.EmployeeId;
            //录单人

            if (invoice.Employee1 != null)
            {
                invoice.Employee1Id = invoice.Employee1.EmployeeId;
            }

            if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal)
            {
                //过账人
                if (invoice.Employee2 != null)
                {
                    invoice.Employee2Id = invoice.Employee2.EmployeeId;
                }
                //过账时间
                invoice.InvoiceGZTime = DateTime.Now;
            }
            //插入表单
            accessor.Insert(invoice);

            //插入明细
            foreach (Model.InvoiceJRDetail detail in invoice.Details)
            {
                if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId))
                {
                    continue;
                }
                detail.InvoiceId = invoice.InvoiceId;
                detail.InvoiceWeiHuaiChuQuantity = detail.InvoiceJRDetailQuantity;
                detail.InvoiceYiHuaiChuQuantity  = 0;
                invoiceJRDetailAccessor.Insert(detail);

                Model.Product p = detail.Product;
                //if (detail.InvoiceProductUnit == p.ProductOuterPackagingUnit)
                //{
                //    quantity = detail.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship;
                //}
                //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit)
                //{
                //    quantity = detail.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship;
                //}
                //else
                //{
                //    quantity = detail.InvoiceJRDetailQuantity;
                //}
                //byte[] pic = new byte[] { };
                //if (p.ProductImage == null)
                //    p.ProductImage = pic;
                //if (p.ProductImage1 == null)
                //    p.ProductImage1 = pic;
                //if (p.ProductImage2 == null)
                //    p.ProductImage2 = pic;
                //if (p.ProductImage3 == null)
                //    p.ProductImage3 = pic;
                p.StocksQuantity += detail.InvoiceJRDetailQuantity;
                productAccessor.Update(p);

                Model.Stock stock = stockAccessor.GetStockByProductIdAndDepotPositionId(p.ProductId, detail.DepotPositionId);
                if (stock == null)
                {
                    stock                 = new Book.Model.Stock();
                    stock.StockId         = Guid.NewGuid().ToString();
                    stock.ProductId       = p.ProductId;
                    stock.DepotPositionId = detail.DepotPositionId;
                    stock.StockQuantity1  = detail.InvoiceJRDetailQuantity;
                    stock.StockCurrentJR  = stock.StockCurrentJR == null ? detail.InvoiceJRDetailQuantity : stock.StockCurrentJR + detail.InvoiceJRDetailQuantity;
                    stock.DepotId         = invoice.DepotId;
                    stock.ProduceUnit     = p.ProduceUnit.CnName;
                    stockAccessor.Insert(stock);
                }
                else
                {
                    stockAccessor.IncrementJR(depotPositionAcccessor.Get(detail.DepotPositionId), p, detail.InvoiceJRDetailQuantity.Value);
                }
            }
        }