/// <summary> /// Insert a InvoiceZZDetail. /// </summary> public void Insert(Model.InvoiceZZDetail invoiceZZDetail) { // // todo:add other logic here // accessor.Insert(invoiceZZDetail); }
/// <summary> /// Update a InvoiceZZDetail. /// </summary> public void Update(Model.InvoiceZZDetail invoiceZZDetail) { // // todo: add other logic here. // accessor.Update(invoiceZZDetail); }
private void Zongji() { if (this.action == "insert" || this.action == "update") { Model.InvoiceZZDetail detailIn = null; decimal zongji = 0; if (this.invoice.DetailsOut.Count > 0) { foreach (Model.InvoiceZZDetail detail in this.invoice.DetailsOut) { zongji += detail.InvoiceZZDetailZongji.Value; } } if (this.invoice.DetailsIn.Count > 0) { detailIn = this.invoice.DetailsIn[0]; } if (detailIn != null) { detailIn.InvoiceZZDetailPrice = zongji; detailIn.InvoiceZZDetailZongji = Convert.ToDecimal(detailIn.InvoiceZZDetailQuantity) * zongji; } this.gridControlIn.RefreshDataSource(); } }
private void gridViewOut_KeyDown(object sender, KeyEventArgs e) { if (this.action == "insert" || this.action == "update") { if (this.CanAdd(this.invoice.DetailsOut)) { if (e.KeyData == Keys.Enter) { Model.InvoiceZZDetail detailOut = new Model.InvoiceZZDetail(); detailOut.InvoiceZZDetailId = Guid.NewGuid().ToString(); detailOut.InvoiceZZDetailKind = "O"; detailOut.InvoiceZZDetailNote = ""; detailOut.InvoiceZZDetailPrice = 0; detailOut.InvoiceZZDetailQuantity = 0; detailOut.InvoiceZZDetailZongji = 0; detailOut.InvoiceProductUnit = ""; detailOut.Product = new Book.Model.Product(); this.invoice.DetailsOut.Add(detailOut); this.bindingSourceOut.Position = this.bindingSourceOut.IndexOf(detailOut); } } if (e.KeyData == Keys.Delete) { this.simpleButtonRemoveOut.PerformClick(); } this.gridControlOut.RefreshDataSource(); } }
private void gridViewOut_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == this.colProductId1) { Model.InvoiceZZDetail detailOut = this.gridViewOut.GetRow(e.RowHandle) as Model.InvoiceZZDetail; if (detailOut != null) { Model.Product p = productManager.Get(e.Value.ToString()); detailOut.InvoiceZZDetailId = Guid.NewGuid().ToString(); detailOut.InvoiceZZDetailKind = "O"; detailOut.InvoiceZZDetailNote = ""; detailOut.InvoiceZZDetailPrice = 0; detailOut.InvoiceZZDetailQuantity = 0; detailOut.InvoiceZZDetailZongji = 0; detailOut.Product = p; detailOut.ProductId = p.ProductId; //detailOut.InvoiceProductUnit = detailOut.Product.ProductBaseUnit; this.bindingSourceOut.Position = this.bindingSourceOut.IndexOf(detailOut); } this.gridControlOut.RefreshDataSource(); } }
private void simpleButtonRemoveOut_Click(object sender, EventArgs e) { if (this.bindingSourceOut.Current != null) { this.invoice.DetailsOut.Remove(this.bindingSourceOut.Current as Model.InvoiceZZDetail); if (this.invoice.DetailsOut.Count == 0) { Model.InvoiceZZDetail detail = new Model.InvoiceZZDetail(); detail.InvoiceZZDetailId = Guid.NewGuid().ToString(); detail.InvoiceZZDetailKind = "O"; detail.InvoiceZZDetailNote = ""; detail.InvoiceZZDetailPrice = 0; detail.InvoiceZZDetailQuantity = 0; detail.InvoiceZZDetailZongji = 0; detail.InvoiceProductUnit = ""; detail.Product = new Book.Model.Product(); this.invoice.DetailsOut.Add(detail); this.bindingSourceOut.Position = this.bindingSourceOut.IndexOf(detail); } this.gridControlOut.RefreshDataSource(); } }
protected override void AddNew() { this.invoice = new Model.InvoiceZZ(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.DetailsIn = new List <Model.InvoiceZZDetail>(); this.invoice.DetailsOut = new List <Model.InvoiceZZDetail>(); if (this.action == "insert") { Model.InvoiceZZDetail detailOut = new Model.InvoiceZZDetail(); detailOut.InvoiceZZDetailId = Guid.NewGuid().ToString(); detailOut.InvoiceZZDetailKind = "O"; detailOut.InvoiceZZDetailNote = ""; detailOut.InvoiceZZDetailPrice = 0; detailOut.InvoiceZZDetailQuantity = 0; detailOut.InvoiceZZDetailZongji = 0; detailOut.InvoiceProductUnit = ""; detailOut.Product = new Book.Model.Product(); this.invoice.DetailsOut.Add(detailOut); this.bindingSourceOut.Position = this.bindingSourceOut.IndexOf(detailOut); Model.InvoiceZZDetail detailIn = new Model.InvoiceZZDetail(); detailIn.InvoiceZZDetailId = Guid.NewGuid().ToString(); detailIn.InvoiceZZDetailKind = "I"; detailIn.InvoiceZZDetailNote = ""; detailIn.InvoiceZZDetailPrice = 0; detailIn.InvoiceZZDetailQuantity = 0; detailIn.InvoiceZZDetailZongji = 0; detailIn.InvoiceProductUnit = ""; detailIn.Product = new Book.Model.Product(); this.invoice.DetailsIn.Add(detailIn); this.bindingSourceIn.Position = this.bindingSourceIn.IndexOf(detailIn); } }
private void _Update(Model.InvoiceZZ invoice) { _ValidateForUpdate(invoice); Model.InvoiceZZ invoiceOriginal = this.Get(invoice.InvoiceId); switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus) { case Helper.InvoiceStatus.Draft: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: invoice.UpdateTime = DateTime.Now; accessor.Update(invoice); invoiceZZDetailAccessor.Delete(invoiceOriginal); foreach (Model.InvoiceZZDetail detail in invoice.DetailsIn) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceZZDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceZZDetailAccessor.Insert(detail); } foreach (Model.InvoiceZZDetail detail in invoice.DetailsOut) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceZZDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceZZDetailAccessor.Insert(detail); } break; case Helper.InvoiceStatus.Normal: accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } break; case Helper.InvoiceStatus.Normal: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: throw new InvalidOperationException(); case Helper.InvoiceStatus.Normal: invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _TurnNull(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: Model.InvoiceZZDetail itemIn = invoice.DetailsIn[0]; Model.Product product = itemIn.Product; //if (itemIn.InvoiceProductUnit == product.ProductOuterPackagingUnit) //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice / Convert.ToDecimal(product.ProductBaseUnitRelationship.Value) / Convert.ToDecimal(product.ProductInnerUnitRelationship.Value); // zzInQuantity = itemIn.InvoiceZZDetailQuantity * product.ProductBaseUnitRelationship * product.ProductInnerUnitRelationship; //} //else if (itemIn.InvoiceProductUnit == product.ProductInnerPackagingUnit) //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice / Convert.ToDecimal(product.ProductBaseUnitRelationship.Value); // zzInQuantity = itemIn.InvoiceZZDetailQuantity * product.ProductBaseUnitRelationship; //} //else //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice; // zzInQuantity = itemIn.InvoiceZZDetailQuantity; //} //productAccessor.UpdateCost1(product, product.ProductCurrentCGPrice, -zzInQuantity); //stockAccessor.Decrement(itemIn.Depot, product, zzInQuantity.Value); foreach (Model.InvoiceZZDetail itemOut in invoice.DetailsOut) { if (itemOut.Product == null || string.IsNullOrEmpty(itemOut.Product.ProductId)) { continue; } Model.Product p = itemOut.Product; //if (itemOut.InvoiceProductUnit == itemOut.Product.ProductOuterPackagingUnit) //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value) / Convert.ToDecimal(p.ProductInnerUnitRelationship.Value); // zzOutQuantity = itemOut.InvoiceZZDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (itemOut.InvoiceProductUnit == itemOut.Product.ProductInnerPackagingUnit) //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value); // zzOutQuantity = itemOut.InvoiceZZDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice; // zzOutQuantity = itemOut.InvoiceZZDetailQuantity; //} //stockAccessor.Increment(itemOut.Depot, p, zzOutQuantity.Value * itemIn.InvoiceZZDetailQuantity.Value); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
private void _Insert(Model.InvoiceZZ invoice) { _ValidateForInsert(invoice); invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.Employee1Id = invoice.Employee1.EmployeeId; if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { invoice.Employee2Id = invoice.Employee2.EmployeeId; invoice.InvoiceGZTime = DateTime.Now; } accessor.Insert(invoice); //插入收货商品明细 Model.InvoiceZZDetail itemIn = invoice.DetailsIn[0]; if (itemIn.Product == null || string.IsNullOrEmpty(itemIn.Product.ProductId)) { } else { //itemIn.DepotId = itemIn.Depot.DepotId; Model.Product product = itemIn.Product; //if (itemIn.InvoiceProductUnit == product.ProductOuterPackagingUnit) //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice / Convert.ToDecimal(product.ProductBaseUnitRelationship.Value) / Convert.ToDecimal(product.ProductInnerUnitRelationship.Value); // quantity = itemIn.InvoiceZZDetailQuantity * product.ProductBaseUnitRelationship * product.ProductInnerUnitRelationship; //} //else if (itemIn.InvoiceProductUnit == product.ProductInnerPackagingUnit) //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice / Convert.ToDecimal(product.ProductBaseUnitRelationship.Value); // quantity = itemIn.InvoiceZZDetailQuantity * product.ProductBaseUnitRelationship; //} //else //{ // product.ProductCurrentCGPrice = itemIn.InvoiceZZDetailPrice; // quantity = itemIn.InvoiceZZDetailQuantity; //} itemIn.InvoiceId = invoice.InvoiceId; //productAccessor.UpdateCost1(product, product.ProductCurrentCGPrice,quantity); //stockAccessor.Increment(itemIn.Depot, itemIn.Product, quantity.Value); invoiceZZDetailAccessor.Insert(itemIn); } //插入出库商品明细 foreach (Model.InvoiceZZDetail itemOut in invoice.DetailsOut) { if (itemOut.Product == null || string.IsNullOrEmpty(itemOut.Product.ProductId)) { continue; } //itemOut.DepotId = itemOut.Depot.DepotId; Model.Product p = itemOut.Product; //if (itemOut.InvoiceProductUnit == itemOut.Product.ProductOuterPackagingUnit) //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value) / Convert.ToDecimal(p.ProductInnerUnitRelationship.Value); // zsQuantity = itemOut.InvoiceZZDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (itemOut.InvoiceProductUnit == itemOut.Product.ProductInnerPackagingUnit) //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value); // zsQuantity = itemOut.InvoiceZZDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // p.ProductCurrentCGPrice = itemOut.InvoiceZZDetailPrice; // zsQuantity = itemOut.InvoiceZZDetailQuantity; //} //stockAccessor.Decrement(itemOut.Depot, p, zsQuantity.Value * itemIn.InvoiceZZDetailQuantity.Value); itemOut.InvoiceId = invoice.InvoiceId; invoiceZZDetailAccessor.Insert(itemOut); } }
public void Update(Model.InvoiceZZDetail e) { this.Update <Model.InvoiceZZDetail>(e); }
public void Insert(Model.InvoiceZZDetail e) { this.Insert <Model.InvoiceZZDetail>(e); }