public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceHR(); this.action = "insert"; } else { if (this.action != "insert") { this.invoice = this.invoiceManager.Get(this.invoice.InvoiceId); if (this.invoice == null) { this.invoice = new Book.Model.InvoiceHR(); this.invoice.Details = new List <Model.InvoiceHRDetail>(); this.action = "insert"; } } } this.textEditInvoiceId.EditValue = this.invoice.InvoiceId; this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value; this.textEditNote.EditValue = this.invoice.InvoiceNote; if (this.invoice.Customer != null) { this.lookUpEditCustomer.EditValue = this.invoice.Customer.CustomerId; } //this.buttonEditCompany.EditValue = this.invoice.Customer; this.buttonEditEmployee.EditValue = this.invoice.Employee0; this.lookUpEdit_Depot.EditValue = this.invoice.DepotId; if (this.invoice.DepotId != null) { this.bindingSourceDepotPosition.DataSource = this.positionManager.Select(_depotManager.Get(invoice.DepotId)); } this.EmpAudit.EditValue = this.invoice.AuditEmp; this.textEditAuditState.Text = this.invoice.AuditStateName; this.bindingSourceInvoiceJCDetail.DataSource = this.invoice.Details; this.gridControl1.RefreshDataSource(); switch (this.action) { case "insert": case "update": this.barButtonItem1.Enabled = true; break; case "view": this.barButtonItem1.Enabled = false; break; } base.Refresh(); this.buttonEditEmployee.Enabled = false; this.buttonEditEmployee.ButtonReadOnly = true; this.lookUpEdit_Depot.Properties.ReadOnly = true; this.lookUpEditCustomer.Properties.ReadOnly = true; this.textEditFromInvoice.Properties.ReadOnly = true; }
protected override void AddNew() { this.invoice = new Model.InvoiceHR(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceHRDetail>(); //this.invoice.Jcdetails = new List<Model.InvoiceJCDetail>(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); }
public ViewForm(Model.InvoiceHR initInvoiceHR) : this() { if (initInvoiceHR == null) { throw new ArithmeticException("initInvoiceHR"); } this.invoice = initInvoiceHR; }
public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceHRManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } }
protected override void MovePrev() { Model.InvoiceHR 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.InvoiceHR invoice) : this() { if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.invoice = invoice; this.action = "update"; }
protected override Form GetViewForm() { Model.InvoiceHR invoice = this.SelectedItem as Model.InvoiceHR; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
protected override void TurnNull() { if (this.invoice == null) { return; } if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != 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(); } }
public bool HasRowsBefore(Model.InvoiceHR e) { return(accessor.HasRowsBefore(e)); }
public bool HasRowsAfter(Model.InvoiceHR e) { return(accessor.HasRowsAfter(e)); }
public Model.InvoiceHR Get(string invoiceId) { Model.InvoiceHR invoice = accessor.Get(invoiceId); invoice.Details = invoiceHRDetailAccessor.Select(invoice); return(invoice); }
private void _TurnNull(Model.InvoiceHR invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public bool HasRowsBefore(Model.InvoiceHR e) { return(sqlmapper.QueryForObject <bool>("InvoiceHR.has_rows_before", e)); }
private void _Update(Model.InvoiceHR invoice) { invoice.UpdateTime = DateTime.Now;; invoice.CustomerId = invoice.Customer.CustomerId; if (invoice.Employee0 != null) { invoice.Employee0Id = invoice.Employee0.EmployeeId; } Model.InvoiceHR 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); invoiceHRDetailAccessor.Delete(invoice); foreach (Model.InvoiceHRDetail detail in invoice.Details) { detail.InvoiceId = invoice.InvoiceId; invoiceHRDetailAccessor.Insert(detail); } break; case Helper.InvoiceStatus.Normal: accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); //accessor.Update(invoice); //invoiceHZDetailAccessor.Delete(invoice); //foreach (Model.InvoiceHZDetail detail in invoice.Details) //{ // stockAccessor.Increment(invoice.Depot, detail.Product, detail.InvoiceHZDetailQuantity.Value); // detail.InvoiceHZDetailId = Guid.NewGuid().ToString(); // detail.InvoiceId = invoice.InvoiceId; // invoiceHZDetailAccessor.Insert(detail); //} //invoice.Employee2Id = invoice.Employee2.EmployeeId; //invoice.InvoiceGZTime = DateTime.Now; 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); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: foreach (Model.InvoiceHRDetail detail in invoice.Details) { Model.Product p = detail.Product; //if (detail.InvoiceProductUnit == p.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceHRDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceHRDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceHRDetailQuantity; //} //detail.Product.ProductCurrentJCQuantity += quantity; p.StocksQuantity -= detail.InvoiceHRDetailQuantity; productAccessor.Update(p); stockAccessor.DecrementJR(new DepotPositionManager().Get(detail.DepotPositionId), p, detail.InvoiceHRDetailQuantity.Value); Model.InvoiceJCDetail temp = invoiceJCDetailAccessor.Get(detail.InvoiceJCDetailId); if (temp != null) { temp.InvoiceWeiHuaiRuQuantity += detail.InvoiceHRDetailQuantity; temp.InvoiceYiHuaiRuQuantity -= detail.InvoiceHRDetailQuantity; invoiceJCDetailAccessor.Update(temp); } } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public bool HasRowsAfter(Model.InvoiceHR e) { return(sqlmapper.QueryForObject <bool>("InvoiceHR.has_rows_after", e)); }
public IList <Model.InvoiceJCDetail> Select(Model.InvoiceHR invoice) { return(accessor.Select(invoice)); }
public Model.InvoiceHR GetNext(Model.InvoiceHR e) { return(sqlmapper.QueryForObject <Model.InvoiceHR>("InvoiceHR.get_next", e)); }
public void Update(Model.InvoiceHR e) { this.Update <Model.InvoiceHR>(e); }
public Model.InvoiceHR GetPrev(Model.InvoiceHR e) { return(accessor.GetPrev(e)); }
public Model.InvoiceHR GetPrev(Model.InvoiceHR e) { return(sqlmapper.QueryForObject <Model.InvoiceHR>("InvoiceHR.get_prev", e)); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public Model.InvoiceHR GetNext(Model.InvoiceHR e) { return(accessor.GetNext(e)); }
public void Insert(Model.InvoiceHR e) { this.Insert <Model.InvoiceHR>(e); }