private void SaveXPs(Model.InvoiceFK invoice) { xp1Accessor.Delete(invoice); xp2Accessor.Delete(invoice); foreach (Model.Invoice01 detail in invoice.Details) { switch (detail.Kind.ToLower()) { case "cg": //冲销应付款情况1 Model.XP1 xp1 = new Book.Model.XP1(); xp1.InvoiceCGId = detail.InvoiceId; xp1.InvoiceFKId = invoice.InvoiceId; xp1.XP1Id = Guid.NewGuid().ToString(); xp1.XP1Money = detail.PayReceived == null ? decimal.Zero : detail.PayReceived.Value; xp1Accessor.Insert(xp1); break; case "xt": //冲销应付款情况2 Model.XP2 xp2 = new Book.Model.XP2(); xp2.InvoiceXTId = detail.InvoiceId; xp2.InvoiceFKId = invoice.InvoiceId; xp2.XP2Id = Guid.NewGuid().ToString(); xp2.XP2Money = detail.PayReceived == null ? decimal.Zero : detail.PayReceived.Value; xp2Accessor.Insert(xp2); break; } } }
protected override void AddNew() { this.invoice = new Model.InvoiceFK(); 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(Model.InvoiceFK invoiceFk) : this() { if (invoiceFk == null) { throw new ArithmeticException("invoiceFk"); } this.invoice = invoiceFk; }
public ViewForm(string invoiceId) : this() { this.invoice = this.invoiceFKManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceid"); } }
protected override void MovePrev() { Model.InvoiceFK invoice = this.invoiceManager.GetPrev(this.invoice); if (invoice == null) { throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows); } this.invoice = this.invoiceManager.Get(invoice.InvoiceId); }
public EditForm(string invoiceId) : this() { this.invoice = this.invoiceManager.Get(invoiceId); if (this.invoice == null) { throw new ArithmeticException("invoiceid"); } this.action = "update"; }
public EditForm(Model.InvoiceFK invoiceFk) : this() { if (invoiceFk == null) { throw new ArithmeticException("invoiceid"); } this.invoice = invoiceFk; this.action = "update"; }
private void Validate(Model.InvoiceFK invoice) { if (invoice.Customer == null) { throw new Helper.RequireValueException("Compamy"); } if (invoice.Account == null) { throw new Helper.RequireValueException("Account"); } if (invoice.PayMethod == null) { throw new Helper.RequireValueException("PayMethod"); } }
private void _Insert(Model.InvoiceFK 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); // 冲销记录 SaveXPs(invoice); if ((Helper.InvoiceStatus)invoice.InvoiceStatus.Value == Helper.InvoiceStatus.Normal) { // 单据欠款额 foreach (Model.Invoice01 detail in invoice.Details) { switch (detail.Kind.ToLower()) { case "cg": invoiceCGAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived == null ? 0 : detail.PayReceived); break; case "xt": invoiceXTAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived == null ? 0 : detail.PayReceived); break; } } // 应付款额 //companyAccessor.DecrementP(invoice.Company, invoice.InvoiceTotal); // 账户余额 accountAccessor.Decrement(invoice.Account, invoice.InvoiceTotal); } }
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(); } }
public R01(string invoiceId) { InitializeComponent(); this.invoice = this.invoiceManager.Get(invoiceId); if (this.invoice == null) { return; } this.xrLabelCompanyInfoName.Text = BL.Settings.CompanyChineseName + Properties.Resources.InvoiceFK; this.xrLabelAbstract.Text = this.invoice.InvoiceAbstract; this.xrLabelAccount.Text = this.invoice.Account.AccountName; this.xrLabelCompanyAddress.Text = this.invoice.Customer == null ? "" : this.invoice.Customer.CustomerAddress; this.xrLabelCompanyName.Text = this.invoice.Customer.CustomerShortName; 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 HasRowsAfter(Model.InvoiceFK e) { return(accessor.HasRowsAfter(e)); }
public override void Refresh() { if (this.invoice == null) { this.invoice = new Book.Model.InvoiceFK(); 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; if (invoice.Customer != null) { this.invoice.Details = this.invoice01Manager.Select("FK_UPDATE", 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.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(); }
protected override void MoveLast() { this.invoice = this.invoiceManager.Get(this.invoiceManager.GetLast() == null ? "" : this.invoiceManager.GetLast().InvoiceId); }
public Model.InvoiceFK GetPrev(Model.InvoiceFK e) { return(accessor.GetPrev(e)); }
public Model.InvoiceFK GetNext(Model.InvoiceFK e) { return(accessor.GetNext(e)); }
public bool HasRowsAfter(Model.InvoiceFK e) { return(sqlmapper.QueryForObject <bool>("InvoiceFK.has_rows_after", e)); }
public void Insert(Model.InvoiceFK e) { this.Insert <Model.InvoiceFK>(e); }
private void _Update(Model.InvoiceFK invoice) { _ValidateForUpdate(invoice); Model.InvoiceFK 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.SaveXPs(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); this.SaveXPs(invoice); // 单据应付款额 foreach (Model.Invoice01 detail in invoice.Details) { if (detail.PayReceived.HasValue && detail.PayReceived == 0) { continue; } switch (detail.Kind.ToLower()) { case "cg": invoiceCGAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; case "xt": invoiceXTAccessor.OwedDecrement(detail.InvoiceId, detail.PayReceived); break; } } // 应收应付 //companyAccessor.DecrementP(invoice.Company, invoice.InvoiceTotal); // 账户余额 accountAccessor.Decrement(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.XP1> xp1s = xp1Accessor.Select(invoiceOriginal); foreach (Model.XP1 xp1 in xp1s) { invoiceCGAccessor.OwedIncrement(xp1.InvoiceCG, xp1.XP1Money); } // 单据应付款额 // 销售退货单 IList <Model.XP2> xp2s = xp2Accessor.Select(invoiceOriginal); foreach (Model.XP2 xp2 in xp2s) { invoiceXTAccessor.OwedIncrement(xp2.InvoiceXT, xp2.XP2Money); } // 应收应付 //companyAccessor.IncrementP(invoiceOriginal.Company, invoiceOriginal.InvoiceTotal); //修改账户余额 accountAccessor.Increment(invoiceOriginal.Account, invoiceOriginal.InvoiceTotal); accessor.Delete(invoice.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.XP1> xp1s1 = xp1Accessor.Select(invoice); foreach (Model.XP1 xp1 in xp1s1) { invoiceCGAccessor.OwedIncrement(invoiceCGAccessor.Get(xp1.InvoiceCGId), xp1.XP1Money); } // 单据应付款额 // 销售退货单 IList <Model.XP2> xp2s1 = xp2Accessor.Select(invoice); foreach (Model.XP2 xp2 in xp2s1) { invoiceXTAccessor.OwedIncrement(invoiceXTAccessor.Get(xp2.InvoiceXTId), xp2.XP2Money); } // 应收应付 //companyAccessor.IncrementP(companyAccessor.Get(invoice.CompanyId), invoice.InvoiceTotal); //修改账户余额 accountAccessor.Increment(accountAccessor.Get(invoice.AccountId), invoice.InvoiceTotal); break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
public void Update(Model.InvoiceFK e) { this.Update <Model.InvoiceFK>(e); }
public Model.InvoiceFK GetPrev(Model.InvoiceFK e) { return(sqlmapper.QueryForObject <Model.InvoiceFK>("InvoiceFK.get_prev", e)); }
public Model.InvoiceFK GetNext(Model.InvoiceFK e) { return(sqlmapper.QueryForObject <Model.InvoiceFK>("InvoiceFK.get_next", e)); }
public bool HasRowsBefore(Model.InvoiceFK e) { return(accessor.HasRowsBefore(e)); }
private void _TurnNull(Model.InvoiceFK invoice) { invoice.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _Update(invoice); }
public bool HasRowsBefore(Model.InvoiceFK e) { return(sqlmapper.QueryForObject <bool>("InvoiceFK.has_rows_before", e)); }