public ViewForm(Model.InvoiceJC initInvoiceJC) : this() { if (initInvoiceJC == null) { throw new ArithmeticException("initInvoiceJC"); } this.invoice = initInvoiceJC; }
public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceJCManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } }
protected override Form GetViewForm() { Model.InvoiceJC invoice = this.SelectedItem as Model.InvoiceJC; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
protected override void MovePrev() { Model.InvoiceJC invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
public EditForm(Model.InvoiceJC invoice) : this() { if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.invoice = invoice; this.action = "update"; }
protected override void TurnNull() { if (this.invoice == null) { return; } if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } this.invoiceManager.TurnNull(this.invoice.InvoiceId); this.invoice = this.invoiceManager.GetNext(this.invoice); if (this.invoice == null) { this.invoice = this.invoiceManager.GetLast(); } }
protected override void AddNew() { this.invoice = new Model.InvoiceJC(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceJCDetail>(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); if (this.action == "insert") { Model.InvoiceJCDetail detail = new Model.InvoiceJCDetail(); detail.InvoiceJCDetailId = Guid.NewGuid().ToString(); detail.InvoiceHRDetailNote = ""; detail.InvoiceHRDetailQuantity = 0; detail.InvoiceJCDetailNote = ""; detail.InvoiceJCDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.InvoiceWeiHuaiRuQuantity = 0; detail.InvoiceYiHuaiRuQuantity = 0; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSourceInvoiceJCDetail.Position = this.bindingSourceInvoiceJCDetail.IndexOf(detail); } }
public Model.InvoiceJC GetNext(Model.InvoiceJC e) { return(sqlmapper.QueryForObject <Model.InvoiceJC>("InvoiceJC.get_next", e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceJC(); this.action = "insert"; } else { if (this.action == "view") { this.invoice = this.invoiceManager.Get(invoice.InvoiceId); } } this.textEditInvoiceId.EditValue = this.invoice.InvoiceId; this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value; this.textEditNote.EditValue = this.invoice.InvoiceNote; this.NewChooseControlCustomer.EditValue = this.invoice.Customer; this.buttonEditEmployee.EditValue = this.invoice.Employee0; this.buttonEditDepot.EditValue = this.invoice.DepotId; this.textEditInvoiceSendAddress.EditValue = this.invoice.InvoiceSendAddress; this.EmpAudit.EditValue = this.invoice.AuditEmp; this.textEditAuditState.Text = this.invoice.AuditStateName; this.bindingSourceInvoiceJCDetail.DataSource = this.invoice.Details; switch (this.action) { case "insert": this.textEditInvoiceId.Properties.ReadOnly = false; this.dateEditInvoiceDate.Properties.ReadOnly = false; this.dateEditInvoiceDate.Properties.Buttons[0].Visible = true; this.textEditNote.Properties.ReadOnly = false; this.NewChooseControlCustomer.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.Properties.ReadOnly = false; this.NewChooseControlCustomer.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.textEditInvoiceSendAddress.Properties.ReadOnly = false; this.gridView1.OptionsBehavior.Editable = true; this.simpleButtonAppend.Enabled = true; this.simpleButtonRemove.Enabled = true; break; case "update": this.textEditInvoiceId.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false; this.textEditInvoiceSendAddress.Properties.ReadOnly = false; this.textEditNote.Properties.ReadOnly = false; this.NewChooseControlCustomer.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.Properties.ReadOnly = false; this.NewChooseControlCustomer.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.textEditInvoiceSendAddress.Properties.ReadOnly = false; this.gridView1.OptionsBehavior.Editable = true; this.simpleButtonAppend.Enabled = true; this.simpleButtonRemove.Enabled = true; break; case "view": this.textEditInvoiceId.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false; this.textEditInvoiceSendAddress.Properties.ReadOnly = true; this.textEditNote.Properties.ReadOnly = true; this.textEditInvoiceSendAddress.Properties.ReadOnly = true; this.NewChooseControlCustomer.ShowButton = false; this.buttonEditEmployee.ShowButton = false; this.buttonEditDepot.Properties.ReadOnly = true; this.NewChooseControlCustomer.ButtonReadOnly = true; this.buttonEditEmployee.ButtonReadOnly = true; this.simpleButtonAppend.Enabled = false; this.simpleButtonRemove.Enabled = false; this.gridView1.OptionsBehavior.Editable = false; break; default: break; } base.Refresh(); }
public Model.InvoiceJC GetPrev(Model.InvoiceJC e) { return(accessor.GetPrev(e)); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
private void _TurnNull(Model.InvoiceJC invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public Model.InvoiceJC GetNext(Model.InvoiceJC e) { return(accessor.GetNext(e)); }
private void _Update(Model.InvoiceJC invoice) { invoice.UpdateTime = DateTime.Now;; //invoice.CustomerId = invoice.Customer.CustomerId; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; Model.InvoiceJC invoiceOriginal = this.Get(invoice.InvoiceId); Helper.InvoiceStatus invoiceStatus = (Helper.InvoiceStatus)invoice.InvoiceStatus.Value; switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus) { case Helper.InvoiceStatus.Draft: switch (invoiceStatus) { case Helper.InvoiceStatus.Draft: accessor.Update(invoice); invoiceJCDetailAccessor.Delete(invoice); foreach (Model.InvoiceJCDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceId = invoice.InvoiceId; detail.InvoiceWeiHuaiRuQuantity = detail.InvoiceJCDetailQuantity; detail.InvoiceYiHuaiRuQuantity = 0; invoiceJCDetailAccessor.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 (invoiceStatus) { case Helper.InvoiceStatus.Draft: throw new InvalidOperationException(); case Helper.InvoiceStatus.Normal: invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _TurnNull(invoiceOriginal); invoiceJCDetailAccessor.Delete(invoice); foreach (Model.InvoiceJCDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = detail.Product; //if (detail.InvoiceProductUnit == p.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceJCDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceJCDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceJCDetailQuantity; //} p.StocksQuantity -= detail.InvoiceJCDetailQuantity.Value; productAccessor.Update(p); detail.InvoiceId = invoice.InvoiceId; invoiceJCDetailAccessor.Insert(detail); 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.InvoiceJCDetailQuantity; stock.StockCurrentJC = stock.StockCurrentJC == null ? detail.InvoiceJCDetailQuantity : stock.StockCurrentJC + detail.InvoiceJCDetailQuantity; stock.DepotId = invoice.DepotId; stock.ProduceUnit = p.ProduceUnit.CnName; stockAccessor.Insert(stock); } else { stockAccessor.IncrementJC(depotpositionAccessor.Get(detail.DepotPositionId), p, detail.InvoiceJCDetailQuantity.Value); } } break; case Helper.InvoiceStatus.Null: foreach (Model.InvoiceJCDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = detail.Product; //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // jrQuantity = detail.InvoiceJCDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // jrQuantity = detail.InvoiceJCDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // jrQuantity = detail.InvoiceJCDetailQuantity; //} //p.ProductCurrentJCQuantity -= jrQuantity; productAccessor.Update(p); stockAccessor.DecrementJC(depotpositionAccessor.Get(detail.DepotPositionId), p, detail.InvoiceJCDetailQuantity.Value); //stockAccessor.DecrementJC(invoice.Depot, p, jrQuantity.Value); detail.InvoiceWeiHuaiRuQuantity += detail.InvoiceJCDetailQuantity; detail.InvoiceJCDetailQuantity -= detail.InvoiceJCDetailQuantity; invoiceJCDetailAccessor.Update(detail); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public Model.InvoiceJC Get(string invoiceId) { Model.InvoiceJC invoice = accessor.Get(invoiceId); invoice.Details = invoiceJCDetailAccessor.Select(invoice); return(invoice); }
public bool HasRowsAfter(Model.InvoiceJC e) { return(accessor.HasRowsAfter(e)); }
public void Insert(Model.InvoiceJC e) { this.Insert <Model.InvoiceJC>(e); }
public bool HasRowsAfter(Model.InvoiceJC e) { return(sqlmapper.QueryForObject <bool>("InvoiceJC.has_rows_after", e)); }
public bool HasRowsBefore(Model.InvoiceJC e) { return(sqlmapper.QueryForObject <bool>("InvoiceJC.has_rows_before", e)); }
public void Update(Model.InvoiceJC e) { this.Update <Model.InvoiceJC>(e); }
public Model.InvoiceJC GetPrev(Model.InvoiceJC e) { return(sqlmapper.QueryForObject <Model.InvoiceJC>("InvoiceJC.get_prev", e)); }
public bool HasRowsBefore(Model.InvoiceJC e) { return(accessor.HasRowsBefore(e)); }