private void SaveXRs(Model.InvoiceSK invoice) { xr1Accessor.Delete(invoice); xr2Accessor.Delete(invoice); foreach (Model.Invoice01 detail in invoice.Details) { switch (detail.Kind.ToLower()) { case "xs": //冲销应付款情况1 Model.XR1 xr1 = new Book.Model.XR1(); xr1.InvoiceXSId = detail.InvoiceId; xr1.InvoiceSKId = invoice.InvoiceId; xr1.XR1Id = Guid.NewGuid().ToString(); xr1.XR1Money = detail.PayReceived == null ? decimal.Zero : detail.PayReceived.Value; xr1Accessor.Insert(xr1); break; case "ct": //冲销应付款情况2 Model.XR2 xr2 = new Book.Model.XR2(); xr2.InvoiceCTId = detail.InvoiceId; xr2.InvoiceSKId = invoice.InvoiceId; xr2.XR2Id = Guid.NewGuid().ToString(); xr2.XR2Money = detail.PayReceived == null ? decimal.Zero : detail.PayReceived.Value; xr2Accessor.Insert(xr2); break; } } }
private void Validate(Model.InvoiceSK invoice) { if (string.IsNullOrEmpty(invoice.InvoiceId)) { throw new Helper.RequireValueException("Id"); } if (invoice.Employee0 == null) { throw new Helper.RequireValueException("Employee0"); } if (invoice.Customer == null) { throw new Helper.RequireValueException("Company"); } if (invoice.PayMethod == null) { throw new Helper.RequireValueException("PayMethod"); } if (invoice.Account == null) { throw new Helper.RequireValueException("Account"); } if (invoice.InvoiceTotal.Value <= 0) { throw new Helper.RequireValueException("Total"); } }
public ViewForm(Model.InvoiceSK invoice) : this() { if (invoice == null) { throw new ArithmeticException("invoice"); } this.invoice = invoice; }
protected override void AddNew() { this.invoice = new Model.InvoiceSK(); this.invoice.InvoiceId = this.invoiceManager.GetNewId(); this.invoice.InvoiceDate = DateTime.Now; //this.invoice.Company = new Book.Model.Company(); this.invoice.Details = new List <Model.Invoice01>(); }
public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceSKManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceid"); } }
protected override Form GetViewForm() { Model.InvoiceSK invoice = this.SelectedItem as Model.InvoiceSK; if (invoice != null) { return(new ViewForm(invoice.InvoiceId)); } return(null); }
public EditForm(Model.InvoiceSK invoice) : this() { if (invoice == null) { throw new ArithmeticException("invoiceid"); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); this.action = "update"; }
public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
protected override void MovePrev() { Model.InvoiceSK invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
private void _Insert(Model.InvoiceSK invoice) { _ValidateForInsert(invoice); invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.PayMethodId = invoice.PayMethod.PayMethodId; invoice.CustomerId = invoice.Customer.CustomerId; invoice.AccountId = invoice.Account.AccountId; invoice.Employee1Id = invoice.Employee1.EmployeeId; if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { invoice.Employee2Id = invoice.Employee2.EmployeeId; invoice.InvoiceGZTime = DateTime.Now; } accessor.Insert(invoice); // 冲销记录 this.SaveXRs(invoice); if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { // 单据欠款额 foreach (Model.Invoice01 detail in invoice.Details) { switch (detail.Kind.ToLower()) { case "ct": invoiceCTAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; case "xs": invoiceXSAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; } } //Model.Company company = invoice.Company; // 应收款额 //companyAccessor.DecrementR(invoice.Company, invoice.InvoiceTotal); // 账户余额 accountAccessor.Increment(invoice.Account, invoice.InvoiceTotal); } }
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(); } }
public R01(string invoiceId) { InitializeComponent(); this.invoice = this.invoiceManager.Get(invoiceId); if (this.invoice == null) { throw new ArgumentException(); } this.xrLabelAbstract.Text = this.invoice.InvoiceAbstract; this.xrLabelAccount.Text = this.invoice.Account.AccountName; this.xrLabelCompanyAddress.Text = ""; this.xrLabelCompanyName.Text = this.invoice.Customer.CustomerFullName; this.xrLabelEmployee.Text = this.invoice.Employee0.EmployeeName; this.xrLabelInvoiceDate.Text = this.invoice.InvoiceDate.Value.ToString(); this.xrLabelInvoiceNote.Text = this.invoice.InvoiceNote; this.xrLabelPayMethod.Text = this.invoice.PayMethod.PayMethodName; this.xrLabelTotal.Text = this.invoice.InvoiceTotal.Value.ToString("0.00"); }
public bool HasRowsBefore(Model.InvoiceSK e) { return(sqlmapper.QueryForObject <bool>("InvoiceSK.has_rows_before", e)); }
public Model.InvoiceSK GetNext(Model.InvoiceSK e) { return(accessor.GetNext(e)); }
public bool HasRowsBefore(Model.InvoiceSK e) { return(accessor.HasRowsBefore(e)); }
private void _TurnNull(Model.InvoiceSK invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public void Update(Model.InvoiceSK e) { this.Update <Model.InvoiceSK>(e); }
public bool HasRowsAfter(Model.InvoiceSK e) { return(sqlmapper.QueryForObject <bool>("InvoiceSK.has_rows_after", e)); }
public Model.InvoiceSK GetNext(Model.InvoiceSK e) { return(sqlmapper.QueryForObject <Model.InvoiceSK>("InvoiceSK.get_next", e)); }
private void _Update(Model.InvoiceSK invoice) { _ValidateForUpdate(invoice); Model.InvoiceSK invoiceOriginal = accessor.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.PayMethodId = invoice.PayMethod.PayMethodId; invoice.CustomerId = invoice.Customer.CustomerId; invoice.AccountId = invoice.Account.AccountId; invoice.Employee0Id = invoice.Employee0.EmployeeId; accessor.Update(invoice); this.SaveXRs(invoice); break; case Helper.InvoiceStatus.Normal: invoice.UpdateTime = DateTime.Now; invoice.PayMethodId = invoice.PayMethod.PayMethodId; invoice.CustomerId = invoice.Customer.CustomerId; invoice.AccountId = invoice.Account.AccountId; invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.Employee2Id = invoice.Employee2.EmployeeId; invoice.InvoiceGZTime = DateTime.Now; accessor.Update(invoice); // 单据应付款额 foreach (Model.Invoice01 detail in invoice.Details) { if (detail.PayReceived.HasValue && detail.PayReceived == 0) { continue; } switch (detail.Kind.ToLower()) { case "xs": invoiceXSAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; case "ct": invoiceCTAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; } } // 应收应付 //companyAccessor.DecrementR(invoice.Company, invoice.InvoiceTotal); // 账户余额 accountAccessor.Increment(invoice.Account, invoice.InvoiceTotal); 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: IList <Model.XR1> xr1s1 = xr1Accessor.Select(invoiceOriginal); foreach (Model.XR1 xr1 in xr1s1) { invoiceXSAccessor.OwedIncrement(xr1.InvoiceXS, xr1.XR1Money); } // 单据应收款额 // 采购退货单 IList <Model.XR2> xr2s1 = xr2Accessor.Select(invoiceOriginal); foreach (Model.XR2 xr2 in xr2s1) { invoiceCTAccessor.OwedIncrement(xr2.InvoiceCT, xr2.XR2Money); } // 应收应付 //companyAccessor.IncrementR(invoice.Company, invoice.InvoiceTotal); //修改账户余额 accountAccessor.Increment(invoice.Account, invoice.InvoiceTotal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Normal; _Insert(invoice); break; case Helper.InvoiceStatus.Null: invoice.UpdateTime = DateTime.Now; invoice.Employee3Id = invoice.Employee3.EmployeeId; invoice.InvoiceZFTime = DateTime.Now; invoice.InvoiceZFCause = ""; accessor.Update(invoice); // 单据应收款额 // 销售出货单 IList <Model.XR1> xr1s = xr1Accessor.Select(invoice); foreach (Model.XR1 xr1 in xr1s) { invoiceXSAccessor.OwedIncrement(invoiceXSAccessor.Get(xr1.InvoiceXSId), xr1.XR1Money); } // 单据应收款额 // 采购退货单 IList <Model.XR2> xr2s = xr2Accessor.Select(invoice); foreach (Model.XR2 xr2 in xr2s) { invoiceCTAccessor.OwedIncrement(invoiceCTAccessor.Get(xr2.InvoiceCTId), xr2.XR2Money); } // 应收应付 //companyAccessor.IncrementR(companyAccessor.Get(invoice.CompanyId), invoice.InvoiceTotal); //修改账户余额 accountAccessor.Increment(accountAccessor.Get(invoice.AccountId), invoice.InvoiceTotal); break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public bool HasRowsAfter(Model.InvoiceSK e) { return(accessor.HasRowsAfter(e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceSK(); this.action = "insert"; } this.textEditInvoiceId.EditValue = this.invoice.InvoiceId; this.dateEditInvoiceDate.DateTime = this.invoice.InvoiceDate.Value; this.buttonEditEmployee.EditValue = this.invoice.Employee0; this.buttonEditAccount.EditValue = this.invoice.Account; this.buttonEditCompany.EditValue = this.invoice.Customer; this.buttonEditPayMethod.EditValue = this.invoice.PayMethod; //this.textEditAbstract.EditValue = this.invoice.InvoiceAbstract; this.textEditNote.EditValue = this.invoice.InvoiceNote; this.calcEditTotal.EditValue = this.invoice.InvoiceTotal; this.textEditPay.EditValue = this.invoice.Customer == null ? decimal.Zero : this.invoice.Customer.CustomerReceivable; this.invoice.Details = this.invoice01Manager.Select("SK_UPDATE", invoice.Customer == null?null:invoice.Customer.CustomerId, this.invoice.InvoiceId); 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.calcEditTotal.Properties.ReadOnly = false; //this.textEditAbstract.Properties.ReadOnly = false; this.textEditNote.Properties.ReadOnly = false; this.buttonEditCompany.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditAccount.ShowButton = true; this.buttonEditPayMethod.ShowButton = true; this.buttonEditCompany.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.buttonEditAccount.ButtonReadOnly = false; this.buttonEditPayMethod.ButtonReadOnly = false; 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.textEditInvoiceId.Properties.ReadOnly = false; this.dateEditInvoiceDate.Properties.ReadOnly = false; this.calcEditTotal.Properties.ReadOnly = false; //this.textEditAbstract.Properties.ReadOnly = false; this.textEditNote.Properties.ReadOnly = false; this.buttonEditCompany.ShowButton = true; this.buttonEditEmployee.ShowButton = true; this.buttonEditAccount.ShowButton = true; this.buttonEditPayMethod.ShowButton = true; this.buttonEditCompany.ButtonReadOnly = false; this.buttonEditEmployee.ButtonReadOnly = false; this.buttonEditAccount.ButtonReadOnly = false; this.buttonEditPayMethod.ButtonReadOnly = false; 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.textEditAbstract.Properties.ReadOnly = true; this.textEditNote.Properties.ReadOnly = true; this.buttonEditCompany.ShowButton = false; this.buttonEditEmployee.ShowButton = false; this.buttonEditAccount.ShowButton = false; this.buttonEditPayMethod.ShowButton = false; this.buttonEditCompany.ButtonReadOnly = true; this.buttonEditEmployee.ButtonReadOnly = true; this.buttonEditAccount.ButtonReadOnly = true; this.buttonEditPayMethod.ButtonReadOnly = true; this.gridView1.OptionsBehavior.Editable = false; break; default: break; } base.Refresh(); }
public Model.InvoiceSK GetPrev(Model.InvoiceSK e) { return(accessor.GetPrev(e)); }
public void Insert(Model.InvoiceSK e) { this.Insert <Model.InvoiceSK>(e); }
public Model.InvoiceSK GetPrev(Model.InvoiceSK e) { return(sqlmapper.QueryForObject <Model.InvoiceSK>("InvoiceSK.get_prev", e)); }