private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { Model.InvoiceBYDetail detail = this.gridView1.GetRow(e.RowHandle) as Model.InvoiceBYDetail; if (e.Column == this.colProductId) { if (detail != null) { Model.Product p = productManager.Get(e.Value.ToString()); detail.InvoiceBYDetailId = Guid.NewGuid().ToString(); detail.Invoice = this.invoice; detail.InvoiceBYDetailNote = ""; detail.InvoiceBYDetailQuantity = 1; detail.Product = p; detail.ProductId = p.ProductId; //detail.InvoiceProductUnit = detail.Product.ProductBaseUnit; this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); } this.gridControl1.RefreshDataSource(); } if (e.Column == this.gridColumnPositionId) { if (detail != null) { Model.DepotPosition position = new BL.DepotPositionManager().Get(e.Value.ToString()); detail.DepotPosition = position; if (position != null) { detail.DepotPositionId = position.DepotPositionId; } } this.gridControl1.RefreshDataSource(); } }
/// <summary> /// Update a InvoiceBYDetail. /// </summary> public void Update(Model.InvoiceBYDetail invoiceBYDetail) { // // todo: add other logic here. // accessor.Update(invoiceBYDetail); }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { if (this.action == "insert" || this.action == "update") { if (this.CanAdd(this.invoice.Details)) { if (e.KeyData == Keys.Enter) { Model.InvoiceBYDetail detail = new Model.InvoiceBYDetail(); detail.InvoiceBYDetailId = Guid.NewGuid().ToString(); detail.InvoiceBYDetailNote = ""; detail.InvoiceBYDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); } } if (e.KeyData == Keys.Delete) { this.simpleButtonRemove.PerformClick(); } this.gridControl1.RefreshDataSource(); } }
/// <summary> /// Insert a InvoiceBYDetail. /// </summary> public void Insert(Model.InvoiceBYDetail invoiceBYDetail) { // // todo:add other logic here // accessor.Insert(invoiceBYDetail); }
private void simpleButtonRemove_Click(object sender, EventArgs e) { if (this.bindingSource1.Current != null) { this.invoice.Details.Remove(this.bindingSource1.Current as Book.Model.InvoiceBYDetail); if (this.invoice.Details.Count == 0) { Model.InvoiceBYDetail detail = new Model.InvoiceBYDetail(); detail.InvoiceBYDetailId = Guid.NewGuid().ToString(); detail.InvoiceBYDetailNote = ""; detail.InvoiceBYDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); } this.gridControl1.RefreshDataSource(); } }
protected override void AddNew() { this.bindingSource3.DataSource = null; this.invoice = new Model.InvoiceBY(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceBYDetail>(); if (this.action == "insert") { Model.InvoiceBYDetail detail = new Model.InvoiceBYDetail(); detail.InvoiceBYDetailId = Guid.NewGuid().ToString(); detail.InvoiceBYDetailNote = ""; detail.InvoiceBYDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); } }
public void Update(Model.InvoiceBYDetail e) { this.Update <Model.InvoiceBYDetail>(e); }
public void Insert(Model.InvoiceBYDetail e) { this.Insert <Model.InvoiceBYDetail>(e); }