public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceJRManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } }
public ViewForm(Model.InvoiceJR initInvoiceJR) : this() { if (initInvoiceJR == null) { throw new ArithmeticException("initInvoiceJR"); } this.invoice = initInvoiceJR; }
public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
public EditForm(Model.InvoiceJR invoice) : this() { if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.invoice = invoice; this.action = "update"; }
protected override Form GetViewForm() { Model.InvoiceJR invoice = this.SelectedItem as Model.InvoiceJR; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
protected override void MovePrev() { Model.InvoiceJR invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
private void bindingSourceInvoiceJr_CurrentChanged(object sender, EventArgs e) { if (this.bindingSourceInvoiceJr.Current != null) { if ((this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details == null || (this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details.Count == 0) { Model.InvoiceJR jr = this.bindingSourceInvoiceJr.Current as Model.InvoiceJR; IList <Model.InvoiceJRDetail> jrdetail = this._invoicejrDetailManager.Select(jr); (this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details = jrdetail; } this.DefaultSelectALL((this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details); this.bindingSourceInvoiceJrDetail.DataSource = (this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details; } }
//绑定数据 public void mBind() { this.bindingSourceInvoiceJr.DataSource = this._invoicejrManager.Select(this.startDate.DateTime, this.endDate.DateTime, this.newChooseContorl_Supper.EditValue as Model.Supplier); if (this.bindingSourceInvoiceJr.Current != null) { Model.InvoiceJR jr = this.bindingSourceInvoiceJr.Current as Model.InvoiceJR; IList <Model.InvoiceJRDetail> jrDetail = this._invoicejrDetailManager.Select(jr); (this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details = jrDetail; this.DefaultSelectALL((this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details); this.bindingSourceInvoiceJrDetail.DataSource = (this.bindingSourceInvoiceJr.Current as Model.InvoiceJR).Details; } else { this.bindingSourceInvoiceJrDetail.DataSource = null; } }
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.InvoiceJR(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceJRDetail>(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); Model.InvoiceJRDetail detail = new Model.InvoiceJRDetail(); detail.InvoiceJRDetailId = Guid.NewGuid().ToString(); detail.InvoiceHCDetailNote = ""; detail.InvoiceHCDetailQuantity = 0; detail.InvoiceJRDetailNote = ""; detail.InvoiceJRDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.InvoiceWeiHuaiChuQuantity = 0; detail.InvoiceYiHuaiChuQuantity = 0; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); }
public bool HasRowsAfter(Model.InvoiceJR e) { return(accessor.HasRowsAfter(e)); }
public bool HasRowsBefore(Model.InvoiceJR e) { return(accessor.HasRowsBefore(e)); }
private void _Update(Model.InvoiceJR invoice) { invoice.UpdateTime = DateTime.Now;; //if (invoice.Customer != null) // invoice.CustomerId = invoice.Customer.CustomerId; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; Model.InvoiceJR 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); invoiceJRDetailAccessor.Delete(invoice); foreach (Model.InvoiceJRDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceId = invoice.InvoiceId; detail.InvoiceWeiHuaiChuQuantity = detail.InvoiceJRDetailQuantity; detail.InvoiceYiHuaiChuQuantity = 0; invoiceJRDetailAccessor.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); invoiceJRDetailAccessor.Delete(invoice); foreach (Model.InvoiceJRDetail 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.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceJRDetailQuantity; //} //p.ProductCurrentJRQuantity += quantity; if (detail.InvoiceJRDetailQuantity.Value == 0) { throw new Helper.InvalidValueException(Model.InvoiceJRDetail.PRO_InvoiceJRDetailQuantity); } byte[] pic = new byte[] { }; //if (p.ProductImage == null) // p.ProductImage = pic; //if (p.ProductImage1 == null) // p.ProductImage1 = pic; //if (p.ProductImage2 == null) // p.ProductImage2 = pic; //if (p.ProductImage3 == null) // p.ProductImage3 = pic; p.StocksQuantity += detail.InvoiceJRDetailQuantity.Value; productAccessor.Update(p); detail.InvoiceWeiHuaiChuQuantity = detail.InvoiceJRDetailQuantity - detail.InvoiceYiHuaiChuQuantity; Model.InvoiceJRDetail temp = invoiceJRDetailAccessor.Get(detail.InvoiceJRDetailId); if (temp != null) { temp.InvoiceId = invoice.InvoiceId; temp.InvoiceHCDetailQuantity = detail.InvoiceHCDetailQuantity; invoiceJRDetailAccessor.Update(temp); } else { detail.InvoiceId = invoice.InvoiceId; invoiceJRDetailAccessor.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.InvoiceJRDetailQuantity; stock.StockCurrentJR = stock.StockCurrentJR == null ? detail.InvoiceJRDetailQuantity : stock.StockCurrentJR + detail.InvoiceJRDetailQuantity; stock.DepotId = invoice.DepotId; stock.ProduceUnit = p.ProduceUnit.CnName; stockAccessor.Insert(stock); } else { stockAccessor.IncrementJR(depotPositionAcccessor.Get(detail.DepotPositionId), p, detail.InvoiceJRDetailQuantity.Value); } } accessor.Update(invoice); break; case Helper.InvoiceStatus.Null: foreach (Model.InvoiceJRDetail 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.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // jrQuantity = detail.InvoiceJRDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // jrQuantity = detail.InvoiceJRDetailQuantity; //} //p.ProductCurrentJRQuantity -= jrQuantity; p.StocksQuantity -= detail.InvoiceJRDetailQuantity.Value; //byte[] pic = new byte[] { }; //if (p.ProductImage == null) // p.ProductImage = pic; //if (p.ProductImage1 == null) // p.ProductImage1 = pic; //if (p.ProductImage2 == null) // p.ProductImage2 = pic; //if (p.ProductImage3 == null) // p.ProductImage3 = pic; productAccessor.Update(p); stockAccessor.DecrementJR(depotPositionAcccessor.Get(detail.DepotPositionId), p, detail.InvoiceJRDetailQuantity.Value); detail.InvoiceWeiHuaiChuQuantity -= detail.InvoiceJRDetailQuantity; detail.InvoiceJRDetailQuantity -= detail.InvoiceJRDetailQuantity; invoiceJRDetailAccessor.Update(detail); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public Model.InvoiceJR Get(string invoiceId) { Model.InvoiceJR invoice = accessor.Get(invoiceId); invoice.Details = invoiceJRDetailAccessor.Select(invoice); return(invoice); }
public void Insert(Model.InvoiceJR e) { this.Insert <Model.InvoiceJR>(e); }
public IList <Model.InvoiceJR> Select(Model.InvoiceJR invoicejr) { return(sqlmapper.QueryForList <Model.InvoiceJR>("InvoiceJR.select_by_supperId", invoicejr.InvoiceId)); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public Model.InvoiceJR GetNext(Model.InvoiceJR e) { return(sqlmapper.QueryForObject <Model.InvoiceJR>("InvoiceJR.get_next", e)); }
public bool HasRowsAfter(Model.InvoiceJR e) { return(sqlmapper.QueryForObject <bool>("InvoiceJR.has_rows_after", e)); }
public bool HasRowsBefore(Model.InvoiceJR e) { return(sqlmapper.QueryForObject <bool>("InvoiceJR.has_rows_before", e)); }
public void Update(Model.InvoiceJR e) { this.Update <Model.InvoiceJR>(e); }
public Model.InvoiceJR GetPrev(Model.InvoiceJR e) { return(accessor.GetPrev(e)); }
private void _TurnNull(Model.InvoiceJR invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public Model.InvoiceJR GetNext(Model.InvoiceJR e) { return(accessor.GetNext(e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceJR(); 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.textEditAbstract.EditValue = this.invoice.InvoiceAbstract; this.textEditNote.EditValue = this.invoice.InvoiceNote; this.NewChooserControlSupper.EditValue = this.invoice.Supplier; this.buttonEditEmployee.EditValue = this.invoice.Employee0; this.buttonEditDepot.EditValue = this.invoice.DepotId; this.NewChooserControlSupper.EditValue = this.invoice.Supplier; this.EmpAudit.EditValue = this.invoice.AuditEmp; this.textEditAuditState.Text = this.invoice.AuditStateName; this.bindingSource1.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.textEditAbstract.Properties.ReadOnly = false; this.textEditNote.Properties.ReadOnly = false; this.NewChooserControlSupper.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.Properties.ReadOnly = false; this.NewChooserControlSupper.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.simpleButtonAppend.Enabled = true; this.simpleButtonRemove.Enabled = true; this.gridView1.OptionsBehavior.Editable = true; break; case "update": this.textEditInvoiceId.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false; this.textEditNote.Properties.ReadOnly = false; this.NewChooserControlSupper.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.Properties.ReadOnly = false; this.NewChooserControlSupper.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.simpleButtonAppend.Enabled = true; this.simpleButtonRemove.Enabled = true; this.gridView1.OptionsBehavior.Editable = true; break; case "view": this.textEditInvoiceId.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.ReadOnly = true; this.dateEditInvoiceDate.Properties.Buttons[0].Visible = false; this.textEditNote.Properties.ReadOnly = true; this.NewChooserControlSupper.ShowButton = false; this.buttonEditEmployee.ShowButton = false; this.buttonEditDepot.Properties.ReadOnly = true; this.NewChooserControlSupper.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.InvoiceJR GetPrev(Model.InvoiceJR e) { return(sqlmapper.QueryForObject <Model.InvoiceJR>("InvoiceJR.get_prev", e)); }
public IList <Model.InvoiceJR> Select(Model.InvoiceJR invoicejr) { return(accessor.Select(invoicejr)); }