protected override void _ValidateForInsert(Book.Model.Invoice invoice) { base._ValidateForInsert(invoice); Model.InvoiceBS invoiceBS = invoice as Model.InvoiceBS; if (invoiceBS.Depot == null) { throw new Helper.RequireValueException(Model.InvoiceBS.PROPERTY_DEPOTID); } if (invoiceBS.Details.Count == 0) { throw new Helper.RequireValueException("Details"); } foreach (Model.InvoiceBSDetail detail in invoiceBS.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } if (detail.InvoiceBSDetailQuantity == 0) { throw new Helper.RequireValueException("Details"); } } }
//一個參數invoiceId單據編號 public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); //if (invoice == null) // throw new ArithmeticException("invoiceid"); this.action = "update"; }
//一個參數initInvoiceBS單據model對象 public EditForm(Model.InvoiceBS initInvoiceBS) : this() { //if (initInvoiceBS == null) // throw new ArithmeticException("invoiceid"); this.invoice = initInvoiceBS; this.action = "update"; }
private void _Insert(Model.InvoiceBS invoice) { _ValidateForInsert(invoice); 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; } //invoice.DepotId = invoice.Depot.DepotId; accessor.Insert(invoice); foreach (Model.InvoiceBSDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { throw new Exception("商品不為空"); } if (detail.DepotPosition == null || detail.DepotPositionId == null) { throw new Exception("貨位不為空"); } detail.InvoiceId = invoice.InvoiceId; invoiceBSDetailAccessor.Insert(detail); } // 影响 if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { // 库存 foreach (Model.InvoiceBSDetail detail in invoice.Details) { //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductInnerUnitRelationship * detail.Product.ProductBaseUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceBSDetailQuantity; //} stockAccessor.Decrement(detail.DepotPosition, detail.Product, detail.InvoiceBSDetailQuantity); productAccessor.UpdateProduct_Stock(detail.Product); } } }
public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceBSManager.Get(invoiceId); if (invoice == null) { throw new ArithmeticException("invoiceid"); } }
public ViewForm(Model.InvoiceBS initInvoiceBS) : this() { if (initInvoiceBS == null) { throw new ArithmeticException("InvoiceBS"); } this.invoice = initInvoiceBS; }
protected override Form GetViewForm() { Model.InvoiceBS invoice = this.SelectedItem as Model.InvoiceBS; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
protected override void MovePrev() { Model.InvoiceBS 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.InvoiceBS; 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.InvoiceBSDetail.PROPERTY_INVOICEBSDETAILQUANTITY, "{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.InvoiceBSDetail.PROPERTY_INVOICEBSDETAILQUANTITY, "{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.InvoiceBSDetail.PROPERTY_INVOICEPRODUCTUNIT); this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceBSDetail.PROPERTY_INVOICEBSDETAILQUANTITY, "{0:0}"); this.xrTableCellProductNote.DataBindings.Add("Text", this.DataSource, Model.InvoiceBSDetail.PROPERTY_INVOICEBSDETAILNOTE); }
protected override void AddNew() { this.bindingSourceDepotPosition.DataSource = null; this.invoice = new Model.InvoiceBS(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceBSDetail>(); if (this.action == "insert") { Model.InvoiceBSDetail detail = new Model.InvoiceBSDetail(); detail.InvoiceBSDetailId = Guid.NewGuid().ToString(); detail.InvoiceBSDetailNote = ""; detail.InvoiceBSDetailQuantity = 1; detail.InvoiceProductUnit = ""; detail.Product = new Book.Model.Product(); this.invoice.Details.Add(detail); this.bindingSourceInvoiceBSDetail.Position = this.bindingSourceInvoiceBSDetail.IndexOf(detail); } }
public Model.InvoiceBS GetPrev(Model.InvoiceBS e) { return(accessor.GetPrev(e)); }
public bool HasRowsAfter(Model.InvoiceBS e) { return(accessor.HasRowsAfter(e)); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public bool HasRowsBefore(Model.InvoiceBS e) { return(sqlmapper.QueryForObject <bool>("InvoiceBS.has_rows_before", e)); }
public void Update(Model.InvoiceBS e) { this.Update <Model.InvoiceBS>(e); }
public void Insert(Model.InvoiceBS e) { this.Insert <Model.InvoiceBS>(e); }
private void _TurnNull(Model.InvoiceBS invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public Model.InvoiceBS Get(string invoiceId) { Model.InvoiceBS invoice = accessor.Get(invoiceId); invoice.Details = invoiceBSDetailAccessor.Select(invoice); return(invoice); }
private void _Update(Model.InvoiceBS invoice) { _ValidateForUpdate(invoice); Model.InvoiceBS 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); invoiceBSDetailAccessor.Delete(invoiceOriginal); foreach (Model.InvoiceBSDetail detail in invoice.Details) { detail.InvoiceBSDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceBSDetailAccessor.Insert(detail); } break; case Helper.InvoiceStatus.Normal: accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); //invoice.UpdateTime = DateTime.Now; //invoice.DepotId = invoice.Depot.DepotId; //invoice.Employee0Id = invoice.Employee0.EmployeeId; //invoice.Employee2Id = invoice.Employee2.EmployeeId; //invoice.InvoiceGZTime = DateTime.Now; //accessor.Update(invoice); //invoiceBSDetailAccessor.Delete(invoiceOriginal); //foreach (Model.InvoiceBSDetail detail in invoice.Details) //{ // detail.InvoiceBSDetailId = Guid.NewGuid().ToString(); // detail.InvoiceId = invoice.InvoiceId; // invoiceBSDetailAccessor.Insert(detail); //} //// 成本 //// 无 //// 库存 //foreach (Model.InvoiceBSDetail detail in invoice.Details) //{ // double? quantity = 0; // if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) // { // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductInnerUnitRelationship * detail.Product.ProductBaseUnitRelationship; // } // else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) // { // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductBaseUnitRelationship; // } // else // { // quantity = detail.InvoiceBSDetailQuantity; // } // stockAccessor.Increment(invoice.Depot, detail.Product, quantity); //} // 应收应付 // 无 break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } break; case Helper.InvoiceStatus.Normal: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: throw new ArgumentException(); case Helper.InvoiceStatus.Normal: invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _TurnNull(invoiceOriginal); invoiceBSDetailAccessor.Delete(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: //invoice.UpdateTime = DateTime.Now; //invoice.Employee3Id = invoice.Employee3.EmployeeId; //invoice.InvoiceZFTime = DateTime.Now; //accessor.Update(invoice); //foreach (Model.InvoiceBSDetail detail in invoice.Details) //{ // invoiceBSDetailAccessor.Update(detail); //} // 库存 foreach (Model.InvoiceBSDetail detail in invoice.Details) { // double? quantity = 0; //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductInnerUnitRelationship * detail.Product.ProductBaseUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // quantity = detail.InvoiceBSDetailQuantity * detail.Product.ProductBaseUnitRelationship; //} //else //{ // quantity = detail.InvoiceBSDetailQuantity; //} // productAccessor.UpdateCost1(detail.Product,0,detail.InvoiceBSDetailQuantity); stockAccessor.Increment(detail.DepotPosition, detail.Product, detail.InvoiceBSDetailQuantity); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public bool HasRowsBefore(Model.InvoiceBS e) { return(accessor.HasRowsBefore(e)); }
public Model.InvoiceBS GetNext(Model.InvoiceBS e) { return(sqlmapper.QueryForObject <Model.InvoiceBS>("InvoiceBS.get_next", e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceBS(); 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.bindingSourceInvoiceBSDetail.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.buttonEditEmployee.ShowButton = true; this.buttonEditEmployee.ButtonReadOnly = false; this.buttonEditDepot.ShowButton = true; this.buttonEditDepot.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.textEditAbstract.Properties.ReadOnly = 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.textEditAbstract.Properties.ReadOnly = true; 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.InvoiceBS GetPrev(Model.InvoiceBS e) { return(sqlmapper.QueryForObject <Model.InvoiceBS>("InvoiceBS.get_prev", e)); }
public bool HasRowsAfter(Model.InvoiceBS e) { return(sqlmapper.QueryForObject <bool>("InvoiceBS.has_rows_after", e)); }
public Model.InvoiceBS GetNext(Model.InvoiceBS e) { return(accessor.GetNext(e)); }