public IList <Book.Model.InvoiceJRDetail> Select(Book.Model.InvoiceHC invoice) { Hashtable table = new Hashtable(); table.Add("invoiceid", invoice.JrInvoiceId); table.Add("SupplierId", invoice.SupplierId); return(sqlmapper.QueryForList <Model.InvoiceJRDetail>("InvoiceJRDetail.select_by_supperId_update", table)); }
public void Delete(Book.Model.InvoiceHC invoice) { sqlmapper.Delete("InvoiceHCDetail.delete_by_invoiceid", invoice.InvoiceId); }
private void _Insert(Book.Model.InvoiceHC invoice) { //经手人 if (invoice.Employee0 != null) { 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.InvoiceHCDetail detail in invoice.Details) { Model.InvoiceJRDetail odetail = invoiceJRDetailAccessor.Get(detail.InvoiceJRDetailId); Model.InvoiceHCDetail hcdetail = new Book.Model.InvoiceHCDetail(); if (detail.InvoiceHCDetailQuantity > 0) { if (detail.InvoiceHCDetailQuantity <= odetail.InvoiceWeiHuaiChuQuantity) { hcdetail.InvoiceId = invoice.InvoiceId; hcdetail.InvoiceHCDetailId = Guid.NewGuid().ToString(); hcdetail.InvoiceHCDetailNote = detail.InvoiceHCDetailNote; hcdetail.InvoiceHCDetailQuantity = detail.InvoiceHCDetailQuantity; hcdetail.InvoiceJRDetailId = detail.InvoiceJRDetailId; hcdetail.InvoiceProductUnit = detail.InvoiceProductUnit; hcdetail.DepotPositionId = detail.DepotPositionId; hcdetail.ProductId = detail.ProductId; invoiceHCDetailAccessor.Insert(hcdetail); Model.Product p = productAccessor.Get(detail.ProductId); //if (p.ProductImage == null || p.ProductImage.Length == 0) // p.ProductImage = new byte[] { }; //if (p.ProductImage1 == null || p.ProductImage1.Length == 0) // p.ProductImage1 = new byte[] { }; //if (p.ProductImage2 == null || p.ProductImage2.Length == 0) // p.ProductImage2 = new byte[] { }; //if (p.ProductImage3 == null || p.ProductImage3.Length == 0) // p.ProductImage3 = new byte[] { }; p.StocksQuantity -= detail.InvoiceHCDetailQuantity; productAccessor.Update(p); odetail.InvoiceWeiHuaiChuQuantity -= detail.InvoiceHCDetailQuantity; odetail.InvoiceYiHuaiChuQuantity += detail.InvoiceHCDetailQuantity; invoiceJRDetailAccessor.Update(odetail); 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.InvoiceHCDetailQuantity; stock.StockCurrentJC = stock.StockCurrentJC == null ? detail.InvoiceHCDetailQuantity : stock.StockCurrentJC + detail.InvoiceHCDetailQuantity; stock.DepotId = invoice.DepotId; stock.ProduceUnit = p.ProduceUnit.CnName; stockAccessor.Insert(stock); } else { stockAccessor.IncrementJC(new BL.DepotPositionManager().Get(detail.DepotPositionId), p, detail.InvoiceHCDetailQuantity.Value); } } else { throw new Helper.InvalidValueException("HaiRuTaiDuo"); } } else { throw new Helper.InvalidValueException("Details"); } } }
public IList <Book.Model.InvoiceHCDetail> Select(Book.Model.InvoiceHC invoice) { return(sqlmapper.QueryForList <Model.InvoiceHCDetail>("InvoiceHCDetail.select_by_invoiceid", invoice.InvoiceId)); }
public IList <Book.Model.InvoiceHCDetail> Select(Book.Model.InvoiceHC invoice) { return(accessor.Select(invoice)); }