public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceBYManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } }
public ViewForm(Model.InvoiceBY initInvoiceBY) : this() { if (initInvoiceBY == null) { throw new ArithmeticException("InvoiceBY"); } this.invoice = initInvoiceBY; }
private void _Insert(Model.InvoiceBY invoice) { _ValidateForInsert(invoice); invoice.InsertTime = DateTime.Now; invoice.UpdateTime = DateTime.Now; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; if (invoice.Employee1 != null) { invoice.Employee1Id = invoice.Employee1.EmployeeId; } if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { if (invoice.Employee2 != null) { invoice.Employee2Id = invoice.Employee2.EmployeeId; } invoice.InvoiceGZTime = DateTime.Now; } accessor.Insert(invoice); foreach (Model.InvoiceBYDetail detail in invoice.Details) { detail.InvoiceId = invoice.InvoiceId; invoiceBYDetailAccessor.Insert(detail); } // 影响 if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { // 库存 foreach (Model.InvoiceBYDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } //double? quantity = 0; //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceBYDetailQuantity * detail.Product.ProductInnerUnitRelationship * detail.Product.ProductBaseUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceBYDetailQuantity * detail.Product.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceBYDetailQuantity; //} // productAccessor.UpdateCost1(detail.Product, 0, quantity); stockAccessor.Increment(detail.DepotPosition, detail.Product, detail.InvoiceBYDetailQuantity); productAccessor.UpdateProduct_Stock(detail.Product); } } }
public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
public EditForm(Model.InvoiceBY initInvoiceBY) : this() { if (initInvoiceBY == null) { throw new ArithmeticException("invoiceid"); } this.invoice = initInvoiceBY; this.action = "update"; }
protected override Form GetViewForm() { Model.InvoiceBY invoice = this.SelectedItem as Model.InvoiceBY; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
protected override void MovePrev() { Model.InvoiceBY invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
public R01(string invoiceId) { InitializeComponent(); this.invoice = this.invoiceManager.Get(invoiceId); if (this.invoice == null) { return; } this.invoice.Details = this.invoiceDetailManager.Select(this.invoice); this.DataSource = this.invoice.Details; //CompanyInfo this.xrLabelCompanyInfoAddress.Text = BL.Settings.CompanyAddress1; this.xrLabelCompanyInfoFAX.Text = BL.Settings.CompanyFax; this.xrLabelCompanyInfoName.Text = BL.Settings.CompanyChineseName + Properties.Resources.InvoiceBY; this.xrLabelCompanyInfoTelphone.Text = BL.Settings.CompanyPhone; //每页合计统计 this.xrLabelPateTotal.Summary.Running = SummaryRunning.Page; this.xrLabelPateTotal.Summary.Func = SummaryFunc.Sum; this.xrLabelPateTotal.Summary.FormatString = "{0:0}"; this.xrLabelPateTotal.Summary.IgnoreNullValues = true; this.xrLabelPateTotal.DataBindings.Add("Text", this.DataSource, Model.InvoiceBYDetail.PROPERTY_INVOICEBYDETAILQUANTITY, "{0:0}"); //单据信息 this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd"); this.xrLabelInvoiceId.Text = this.invoice.InvoiceId; this.xrLabelNote.Text = this.invoice.InvoiceNote; //this.xrLabelDepot.Text = this.invoice.Depot.DepotName; this.xrLabelTotal1.Summary.Running = SummaryRunning.Report; this.xrLabelTotal1.Summary.Func = SummaryFunc.Sum; this.xrLabelTotal1.Summary.IgnoreNullValues = true; this.xrLabelTotal1.DataBindings.Add("Text", this.DataSource, Model.InvoiceBYDetail.PROPERTY_INVOICEBYDETAILQUANTITY, "{0:0}"); //明细信息 this.xrTableCellProductId.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_Id); this.xrTableCellProductName.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductName); this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceBYDetail.PROPERTY_INVOICEPRODUCTUNIT); this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceBYDetail.PROPERTY_INVOICEBYDETAILQUANTITY, "{0:0}"); this.xrTableCellProductNote.DataBindings.Add("Text", this.DataSource, Model.InvoiceBYDetail.PROPERTY_INVOICEBYDETAILNOTE); }
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.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); } }
protected override void _ValidateForInsert(Book.Model.Invoice invoice) { base._ValidateForInsert(invoice); Model.InvoiceBY invoiceBS = invoice as Model.InvoiceBY; if (invoiceBS.Depot == null) { throw new Helper.RequireValueException("Depot"); } if (invoiceBS.Details.Count == 0) { throw new Helper.RequireValueException("Details"); } foreach (Model.InvoiceBYDetail detail in invoiceBS.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } if (detail.InvoiceBYDetailQuantity == 0) { throw new Helper.RequireValueException("Details"); } if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { throw new Exception("商品不為空"); } if (detail.DepotPosition == null || detail.DepotPositionId == null) { throw new Exception("貨位不為空"); } } }
public Model.InvoiceBY GetPrev(Model.InvoiceBY e) { return(accessor.GetPrev(e)); }
public Model.InvoiceBY GetNext(Model.InvoiceBY e) { return(accessor.GetNext(e)); }
public Model.InvoiceBY GetPrev(Model.InvoiceBY e) { return(sqlmapper.QueryForObject <Model.InvoiceBY>("InvoiceBY.get_prev", e)); }
public Model.InvoiceBY GetNext(Model.InvoiceBY e) { return(sqlmapper.QueryForObject <Model.InvoiceBY>("InvoiceBY.get_next", e)); }
public bool HasRowsAfter(Model.InvoiceBY e) { return(sqlmapper.QueryForObject <bool>("InvoiceBY.has_rows_after", e)); }
public bool HasRowsBefore(Model.InvoiceBY e) { return(sqlmapper.QueryForObject <bool>("InvoiceBY.has_rows_before", e)); }
public void Insert(Model.InvoiceBY e) { this.Insert <Model.InvoiceBY>(e); }
private void _TurnNull(Model.InvoiceBY invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public bool HasRowsBefore(Model.InvoiceBY e) { return(accessor.HasRowsBefore(e)); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
private void _Update(Model.InvoiceBY invoice) { _ValidateForUpdate(invoice); Model.InvoiceBY 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; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; accessor.Update(invoice); invoiceBYDetailAccessor.Delete(invoiceOriginal); foreach (Model.InvoiceBYDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceBYDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceBYDetailAccessor.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); invoiceBYDetailAccessor.Delete(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: // 库存 foreach (Model.InvoiceBYDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } // double? quantity = 0; //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceBYDetailQuantity * detail.Product.ProductInnerUnitRelationship * detail.Product.ProductBaseUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceBYDetailQuantity * detail.Product.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceBYDetailQuantity; //} //productAccessor.UpdateCost1(detail.Product, 0, -quantity); stockAccessor.Decrement(detail.DepotPosition, detail.Product, detail.InvoiceBYDetailQuantity); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public bool HasRowsAfter(Model.InvoiceBY e) { return(accessor.HasRowsAfter(e)); }
public void Update(Model.InvoiceBY e) { this.Update <Model.InvoiceBY>(e); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceBY(); 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.buttonEditEmployee.EditValue = this.invoice.Employee0; this.buttonEditDepot.EditValue = this.invoice.Depot; 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.textEditNote.Properties.ReadOnly = false; this.buttonEditDepot.ShowButton = true; this.buttonEditDepot.ButtonReadOnly = false; this.buttonEditEmployee.ShowButton = true; this.buttonEditEmployee.ButtonReadOnly = 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.textEditNote.Properties.ReadOnly = false; this.buttonEditDepot.ShowButton = true; this.buttonEditDepot.ButtonReadOnly = false; this.buttonEditEmployee.ShowButton = true; this.buttonEditEmployee.ButtonReadOnly = 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.textEditNote.Properties.ReadOnly = true; this.buttonEditDepot.ShowButton = false; this.buttonEditDepot.ButtonReadOnly = true; this.buttonEditEmployee.ShowButton = false; this.buttonEditEmployee.ButtonReadOnly = true; this.gridView1.OptionsBehavior.Editable = false; this.simpleButtonAppend.Enabled = false; this.simpleButtonRemove.Enabled = false; break; default: break; } base.Refresh(); }
public Model.InvoiceBY Get(string invoiceId) { Model.InvoiceBY invoice = accessor.Get(invoiceId); invoice.Details = invoiceBYDetailAccessor.Select(invoice); return(invoice); }