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.InvoiceZS; this.xrLabelCompanyInfoTelphone.Text = BL.Settings.CompanyPhone; //每页合计统计 this.xrLabelPageTotal.Summary.Running = SummaryRunning.Page; this.xrLabelPageTotal.Summary.Func = SummaryFunc.Sum; this.xrLabelPageTotal.Summary.FormatString = "{0:0}"; this.xrLabelPageTotal.Summary.IgnoreNullValues = true; this.xrLabelPageTotal.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}"); //客户信息 this.xrLabelCustomName.Text = this.invoice.Customer.CustomerShortName; this.xrLabelCustomFax.Text = this.invoice.Customer.CustomerFax; this.xrLabelCustomTel.Text = string.IsNullOrEmpty(this.invoice.Customer.CustomerPhone) ? this.invoice.Customer.CustomerPhone1 : this.invoice.Customer.CustomerPhone; this.xrLabelTongYiNo.Text = this.invoice.Customer.CustomerNumber; this.xrLabelSongHuoAddress.Text = this.invoice.Customer.CustomerJinChuAddress; //单据信息 this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString("yyyy-MM-dd"); this.xrLabelInvoiceId.Text = this.invoice.InvoiceId; this.xrLabelYeWuName.Text = this.invoice.Employee0.EmployeeName; this.xrLabelNote.Text = this.invoice.InvoiceNote; this.xrLabelReportTotal.Summary.Func = SummaryFunc.Sum; this.xrLabelReportTotal.Summary.IgnoreNullValues = true; this.xrLabelReportTotal.Summary.Running = SummaryRunning.Report; this.xrLabelReportTotal.Summary.FormatString = "{0:0}"; this.xrLabelReportTotal.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}"); this.xrLabelNote.Text = this.invoice.InvoiceNote; //明细信息 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.xrTableCellProductGuige.DataBindings.Add("Text", this.DataSource, "Product." + Model.Product.PRO_ProductSpecification); this.xrTableCellProductUnit.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEPRODUCTUNIT); this.xrTableCellQuantity.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILQUANTITY); this.xrTableCellUintPrice.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILPRICE, "{0:0}"); this.xrTableCellMoney.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILMONEY, "{0:0}"); this.xrTableDetailNote.DataBindings.Add("Text", this.DataSource, Model.InvoiceZSDetail.PROPERTY_INVOICEZSDETAILNOTE); }
public ViewForm(string invoiceId) : this() { this.invoice = invoiceZSManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceZSManager"); } }
protected override void MovePrev() { Model.InvoiceZS invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
public EditForm(Model.InvoiceZS invoicezs) : this() { if (invoicezs == null) { throw new ArithmeticException("invoiceid"); } this.invoice = invoicezs; this.action = "update"; }
protected override Form GetViewForm() { Model.InvoiceZS invoice = this.SelectedItem as Model.InvoiceZS; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
public EditForm(string invoiceId) : this() { this.invoice = invoiceManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
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(); } }
private void Validate(Model.InvoiceZS invoice) { if (string.IsNullOrEmpty(invoice.InvoiceId)) { throw new Helper.RequireValueException("Id"); } if (invoice.Employee0 == null) { throw new Helper.RequireValueException("Employee0"); } //if (invoice.Employee1 == null) // throw new Helper.RequireValueException("Employee1"); if (invoice.Customer == null) { throw new Helper.RequireValueException("Company"); } //if (invoice.Depot == null) // throw new Helper.RequireValueException("Depot"); if (invoice.Details.Count == 0) { throw new Helper.RequireValueException("Details"); } foreach (Model.InvoiceZSDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } if (detail.InvoiceZSDetailQuantity == 0) { throw new Helper.RequireValueException("Details"); } } }
protected override void AddNew() { this.bindingSource3.DataSource = null; this.invoice = new Model.InvoiceZS(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); this.invoice.InvoiceDate = DateTime.Now; this.invoice.Details = new List <Model.InvoiceZSDetail>(); if (this.action == "insert") { Model.InvoiceZSDetail detail = new Model.InvoiceZSDetail(); detail.InvoiceZSDetailId = Guid.NewGuid().ToString(); detail.InvoiceZSDetailMoney = 0; detail.InvoiceZSDetailNote = ""; detail.InvoiceZSDetailPrice = 0; detail.InvoiceZSDetailQuantity = 0; detail.InvoiceProductUnit = ""; detail.PrimaryKey = new Book.Model.CustomerProducts(); this.invoice.Details.Add(detail); this.bindingSource1.Position = this.bindingSource1.IndexOf(detail); } }
public Model.InvoiceZS GetPrev(Model.InvoiceZS e) { return(accessor.GetPrev(e)); }
public bool HasRowsAfter(Model.InvoiceZS e) { return(accessor.HasRowsAfter(e)); }
public bool HasRowsBefore(Model.InvoiceZS e) { return(accessor.HasRowsBefore(e)); }
private void _Insert(Model.InvoiceZS invoice) { _ValidateForInsert(invoice); //客户 if (invoice.Customer != null) { invoice.CustomerId = invoice.Customer.CustomerId; } // 库房 //invoice.DepotId = invoice.Depot.DepotId; //经手人 if (invoice.Employee0 != null) { 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.InvoiceZSDetail detail in invoice.Details) { if (detail.PrimaryKey == null || string.IsNullOrEmpty(detail.PrimaryKey.PrimaryKeyId)) { throw new Exception("商品不為空"); } if (detail.DepotPosition == null || detail.DepotPositionId == null) { throw new Exception("貨位不為空"); } detail.InvoiceId = invoice.InvoiceId; invoiceZSDetailAccessor.Insert(detail); Model.CustomerProducts p = detail.PrimaryKey; p.PrimaryKeyId = detail.PrimaryKey.PrimaryKeyId; if (p.DepotQuantity == null) { p.DepotQuantity = 0; } if (p.OrderQuantity == null) { p.OrderQuantity = 0; } p.DepotQuantity -= detail.InvoiceZSDetailQuantity; //更新产品表库存 customerProductsAccessor.Update(p); } }
public Model.InvoiceZS Get(string invoiceId) { Model.InvoiceZS invoice = accessor.Get(invoiceId); invoice.Details = invoiceZSDetailAccessor.Select(invoice); return(invoice); }
public bool HasRowsBefore(Model.InvoiceZS e) { return(sqlmapper.QueryForObject <bool>("InvoiceZS.has_rows_before", e)); }
public void Insert(Model.InvoiceZS e) { this.Insert <Model.InvoiceZS>(e); }
private void _Update(Model.InvoiceZS invoice) { _ValidateForUpdate(invoice); invoice.UpdateTime = DateTime.Now; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.CustomerId = invoice.Customer.CustomerId; Model.InvoiceZS invoiceOriginal = this.Get(invoice.InvoiceId); Helper.InvoiceStatus invoiceStatus = (Helper.InvoiceStatus)invoice.InvoiceStatus.Value; switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus) { case Helper.InvoiceStatus.Draft: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: invoiceZSDetailAccessor.Delete(invoice); foreach (Model.InvoiceZSDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceZSDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceZSDetailAccessor.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); invoiceZSDetailAccessor.Delete(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); ////消除影响 //foreach (Model.InvoiceZSDetail detail in invoiceOriginal.Details) //{ // stockAccessor.Increment(invoiceOriginal.Depot, detail.Product, detail.InvoiceZSDetailQuantity.Value); //} //accessor.Delete(invoiceOriginal.InvoiceId); //invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal; //invoice.InsertTime = invoiceOriginal.InsertTime; //invoice.UpdateTime = DateTime.Now; //_Insert(invoice); break; case Helper.InvoiceStatus.Null: //invoice.Employee3Id = V.ActiveEmployee.EmployeeId; //invoice.InvoiceZFTime = DateTime.Now; //invoice.InvoiceZFCause = ""; //accessor.Update(invoice); //invoice.Details = invoiceZSDetailAccessor.Select(invoice); //消除影响 foreach (Model.InvoiceZSDetail detail in invoice.Details) { //if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue; Model.CustomerProducts p = detail.PrimaryKey; p.PrimaryKeyId = detail.PrimaryKey.PrimaryKeyId; if (p.DepotQuantity == null) { p.DepotQuantity = 0; } if (p.OrderQuantity == null) { p.OrderQuantity = 0; } p.DepotQuantity += detail.InvoiceZSDetailQuantity; customerProductsAccessor.Update(p); } break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
private void _TurnNormal(Model.InvoiceZS invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal; _Update(invoice); }
public Model.InvoiceZS GetNext(Model.InvoiceZS e) { return(accessor.GetNext(e)); }
public IList <Book.Model.InvoiceZSDetail> Select(Model.InvoiceZS invoice) { return(accessor.Select(invoice)); }
public Model.InvoiceZS GetNext(Model.InvoiceZS e) { return(sqlmapper.QueryForObject <Model.InvoiceZS>("InvoiceZS.get_next", e)); }
public void Update(Model.InvoiceZS e) { this.Update <Model.InvoiceZS>(e); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public bool HasRowsAfter(Model.InvoiceZS e) { return(sqlmapper.QueryForObject <bool>("InvoiceZS.has_rows_after", e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceZS(); this.action = "insert"; } if (this.action == "view") { this.invoice = this.invoiceManager.Get(invoice.InvoiceId); } if (invoice.Depot != null) { this.bindingSource3.DataSource = this.depotPositionManager.Select(invoice.Depot); } this.textEditInvoiceId.EditValue = this.invoice.InvoiceId; this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value; this.textEditNote.EditValue = this.invoice.InvoiceNote; this.buttonEditDepot.EditValue = this.invoice.Depot; this.buttonEditCompany.EditValue = this.invoice.Customer; this.buttonEditEmployee.EditValue = this.invoice.Employee0; this.buttonEditDepot.EditValue = this.invoice.Depot; this.calcEditTotal.EditValue = this.invoice.InvoiceTotal; this.bindingSource1.DataSource = this.invoice.Details; this.EmpAudit.EditValue = this.invoice.AuditEmp; this.textEditAuditState.Text = this.invoice.AuditStateName; this.bindingSource2.DataSource = this.customerProductManager.Select(this.buttonEditCompany.EditValue as Model.Customer); 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.buttonEditCompany.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.buttonEditDepot.ButtonReadOnly = false; this.buttonEditCompany.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.ShowButton = true; 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.buttonEditCompany.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.buttonEditDepot.ButtonReadOnly = false; this.buttonEditCompany.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditDepot.ShowButton = true; 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.calcEditTotal.Properties.ReadOnly = true; this.textEditNote.Properties.ReadOnly = true; this.buttonEditCompany.ButtonReadOnly = true; this.buttonEditEmployee.ButtonReadOnly = true; this.buttonEditDepot.ButtonReadOnly = true; this.buttonEditCompany.ShowButton = false; this.buttonEditEmployee.ShowButton = false; this.buttonEditDepot.ShowButton = false; this.simpleButtonAppend.Enabled = false; this.simpleButtonRemove.Enabled = false; this.gridView1.OptionsBehavior.Editable = false; break; default: break; } base.Refresh(); }
public Model.InvoiceZS GetPrev(Model.InvoiceZS e) { return(sqlmapper.QueryForObject <Model.InvoiceZS>("InvoiceZS.get_prev", e)); }
public ViewForm(Model.InvoiceZS invoicezs) : this() { this.invoice = invoicezs; }