/// <summary> /// 验证单据编号,经手人,出货和收货库房等 /// </summary> private void Validate(Model.InvoicePT invoicePT) { if (string.IsNullOrEmpty(invoicePT.InvoiceId)) { throw new Helper.RequireValueException("Id"); } if (invoicePT.Employee0 == null) { throw new Helper.RequireValueException("Employee0"); } //if (invoicePT.Depot0 == null) // throw new Helper.RequireValueException("Depot0"); //if (invoicePT.Depot1 == null) // throw new Helper.RequireValueException("Depot1"); if (invoicePT.Details.Count == 0) { throw new Helper.RequireValueException("Details"); } foreach (Model.InvoicePTDetail detail in invoicePT.Details) { if (detail.InvoicePTDetailQuantity == 0) { throw new Helper.RequireValueException("Details"); } } }
public ViewForm(Model.InvoicePT initInvoicePt) : this() { if (initInvoicePt == null) { throw new ArithmeticException("InvoicePT"); } this.invoice = initInvoicePt; }
protected override Form GetViewForm() { Model.InvoicePT invoice = this.SelectedItem as Model.InvoicePT; if (invoice != null) { return(new EditForm(invoice.InvoiceId)); } return(null); }
protected override void MovePrev() { Model.InvoicePT 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; this.xrLabelCompanyInfoTelphone.Text = BL.Settings.CompanyPhone; this.xrLabel28.Text = Properties.Resources.InvoicePT; //每页合计统计 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.InvoicePTDetail.PROPERTY_INVOICEPTDETAILQUANTITY, "{0:0}"); //单据信息 //this.xrLabelDepotIn.Text = this.invoice.Depot1.DepotName; //this.xrLabelDepotOut.Text = this.invoice.Depot0.DepotName; this.xrLabelDepotIn.Text = this.invoice.DepotIn == null ? "" : this.invoice.DepotIn.DepotName; this.xrLabelDepotOut.Text = this.invoice.Depot == null ? "" : this.invoice.Depot.DepotName; this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd"); this.xrLabelInvoiceId.Text = this.invoice.InvoiceId; this.xrLabelNote.Text = this.invoice.InvoiceNote; this.xrLabelTotal.Summary.Running = SummaryRunning.Report; this.xrLabelTotal.Summary.Func = SummaryFunc.Sum; this.xrLabelTotal.Summary.FormatString = "{0:0}"; this.xrLabelTotal.Summary.IgnoreNullValues = true; this.xrLabelTotal.DataBindings.Add("Text", this.DataSource, Model.InvoicePTDetail.PROPERTY_INVOICEPTDETAILQUANTITY, "{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.InvoicePTDetail.PROPERTY_INVOICEPRODUCTUNIT); this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoicePTDetail.PROPERTY_INVOICEPTDETAILQUANTITY); this.xrTableCellNote.DataBindings.Add("Text", this.DataSource, Model.InvoicePTDetail.PROPERTY_INVOICEPTDETAILNOTE, "{0:0}"); this.xrRichTextDesc.DataBindings.Add("Rtf", this.DataSource, "Product." + Model.Product.PRO_ProductDescription); }
public EditForm(Model.InvoicePT initInvoicePt) : this() { if (initInvoicePt == null) { throw new ArithmeticException("InvoicePT"); } this.invoice = initInvoicePt; this.action = "view"; if (this.action == "view") { LastFlag = 1; } }
/// <summary> /// 验证单据编号,经手人,出货和收货库房等 /// </summary> private void Validate(Model.InvoicePT invoicePT) { if (string.IsNullOrEmpty(invoicePT.InvoiceId)) { throw new Helper.RequireValueException("Id"); } if (invoicePT.Employee0 == null) { throw new Helper.RequireValueException("Employee0"); } //if (invoicePT.Depot0 == null) // throw new Helper.RequireValueException("Depot0"); //if (invoicePT.Depot1 == null) // throw new Helper.RequireValueException("Depot1"); if (invoicePT.Details.Count == 0) { throw new Helper.RequireValueException("Details"); } foreach (Model.InvoicePTDetail detail in invoicePT.Details) { if (detail.InvoicePTDetailQuantity == 0) { throw new Helper.RequireValueException("Details"); } if (detail.DepotPositionId == null) { throw new Helper.MessageValueException("Please input deliver goods allocation!"); } if (detail.DepotPositionInId == null) { throw new Helper.MessageValueException("Please input receive goods allocation!"); } } }
public bool HasRowsBefore(Model.InvoicePT e) { return(accessor.HasRowsBefore(e)); }
private void _Insert(Model.InvoicePT invoice) { //_ValidateForInsert(invoice); //经手人 if (invoice.Employee0 != null) { invoice.Employee0Id = invoice.Employee0.EmployeeId; } //录单人 if (invoice.Employee1 != null) { invoice.Employee1Id = invoice.Employee1.EmployeeId; } //invoice.Depot0Id = invoice.Depot0.DepotId; //invoice.Depot1Id = invoice.Depot1.DepotId; 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.InvoicePTDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceId = invoice.InvoiceId; invoicePTDetailAccessor.Insert(detail); //影响库存 //Model.Stock tem = stockAccessor.GetStockByProductIdAndDepotPositionId(detail.ProductId, detail.DepotPositionId); //if(tem==null) // throw new Helper.InvalidValueException(Model.InvoicePTDetail.PROPERTY_DEPOTPOSITIONID); //if (tem.StockQuantity1 < detail.InvoicePTDetailQuantity.Value) // throw new Helper.InvalidValueException(Model.InvoicePTDetail.PROPERTY_DEPOTPOSITIONID); stockAccessor.Increment(new DepotPositionManager().Get(detail.DepotPositionInId), detail.Product, detail.InvoicePTDetailQuantity.Value); stockAccessor.Decrement(new DepotPositionManager().Get(detail.DepotPositionId), detail.Product, detail.InvoicePTDetailQuantity.Value); } //if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) //{ // //Model.Depot depotOut = invoice.Depot0; // //Model.Depot depotIn = invoice.Depot1; // foreach (Model.InvoicePTDetail 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) //{ // ptQuantity = detail.InvoicePTDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // ptQuantity = detail.InvoicePTDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // ptQuantity = detail.InvoicePTDetailQuantity; //} //stockAccessor.Increment(depotIn, p, ptQuantity.Value); //stockAccessor.Decrement(depotOut, p, ptQuantity.Value); // } //} }
private void _TurnNormal(Model.InvoicePT invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal; _Update(invoice); }
public Model.InvoicePT GetNext(Model.InvoicePT e) { return(accessor.GetNext(e)); }
public Model.InvoicePT GetPrev(Model.InvoicePT e) { return(accessor.GetPrev(e)); }
public bool HasRowsAfter(Model.InvoicePT e) { return(accessor.HasRowsAfter(e)); }
public void Update(Model.InvoicePT e) { this.Update <Model.InvoicePT>(e); }
private void _Update(Model.InvoicePT invoice) { invoice.UpdateTime = DateTime.Now; Model.InvoicePT 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: invoicePTDetailAccessor.Delete(invoice); foreach (Model.InvoicePTDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoicePTDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoicePTDetailAccessor.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); this.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: //Model.Depot Out = invoice.Depot0; //Model.Depot In = invoice.Depot1; invoice.Details = invoicePTDetailAccessor.Select(invoice); foreach (Model.InvoicePTDetail 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) //{ // ptQuantity = detail.InvoicePTDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // ptQuantity = detail.InvoicePTDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // ptQuantity = detail.InvoicePTDetailQuantity; //} stockAccessor.Decrement(detail.DepotPositionIn, p, detail.InvoicePTDetailQuantity); stockAccessor.Increment(detail.DepotPosition, p, detail.InvoicePTDetailQuantity); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public bool HasRowsBefore(Model.InvoicePT e) { return(sqlmapper.QueryForObject <bool>("InvoicePT.has_rows_before", e)); }
public Model.InvoicePT GetPrev(Model.InvoicePT e) { return(sqlmapper.QueryForObject <Model.InvoicePT>("InvoicePT.get_prev", e)); }
public Model.InvoicePT GetNext(Model.InvoicePT e) { return(sqlmapper.QueryForObject <Model.InvoicePT>("InvoicePT.get_next", e)); }
public bool HasRowsAfter(Model.InvoicePT e) { return(sqlmapper.QueryForObject <bool>("InvoicePT.has_rows_after", e)); }
public Model.InvoicePT Get(string invoiceId) { Model.InvoicePT invoice = accessor.Get(invoiceId); invoice.Details = invoicePTDetailAccessor.Select(invoice); return(invoice); }
public void Insert(Model.InvoicePT e) { this.Insert <Model.InvoicePT>(e); }