private void btnSave_Click(object sender, EventArgs e) { if (!validator.Validate()) { return; } decimal value = Convert.ToDecimal(colvalue.SummaryItem.SummaryValue); if (value <= 0) { XtraMessageBox.Show("Informe as parcelas da Nota"); tabControl.SelectedTabPage = tabPayment; return; } if (value != Convert.ToDecimal(tfValueTotal.EditValue)) { XtraMessageBox.Show("Soma das parcelas nao conferem com o valor tota da Nota"); tabControl.SelectedTabPage = tabPayment; return; } try { SplashScreenManager.ShowForm(desk, typeof(PleaseWaitForm), false, false, false); using (var scope = accounts_to_pay.repo.GetTransaction()) { accounts_to_pay acp = (accounts_to_pay)bdgAccountToPay.Current; acp.registred_at = accounts_to_pay.Now(); acp.registred_by = Singleton.getUser().id; acp.emission_at = EmissionAt(); acp.guid_payment = Guid.NewGuid().ToString(); acp.Save(); List <payment> lPay = (List <payment>)bdgPayments.DataSource; foreach (payment p in lPay) { p.customer_id = acp.customer_id; p.truck_id = acp.truck_id; p.registred_at = acp.registred_at; p.registred_by = acp.registred_by; p.account_id = acp.id; p.guid = acp.guid_payment; p.category_id = acp.category_id; p.paid = false; p.Save(); } scope.Complete(); SplashScreenManager.CloseForm(false); if (MessageToSave("Conta a Pagar")) { desk.AddTabAndCloseCurrent(new AccountsToPayForm(null), "Nova Conta a Pagar", false); } } } catch (Exception ex) { accounts_to_pay.repo.AbortTransaction(); SplashScreenManager.CloseForm(false); XtraMessageBox.Show(String.Format("Ocorreu um erro:\n\n{0}\n{1}", ex.Message, ex.InnerException)); } }
public AccountsToPayForm(accounts_to_pay atp) { InitializeComponent(); ControlsUtil.SetBackColor(this.tabGeneral.Controls); ControlsUtil.SetBackColor(this.tabPayment.Controls); if (atp == null) { atp = new accounts_to_pay() { emission_at = null }; IsNew = true; } loadData(); bdgAccountToPay.DataSource = atp; EmissionAt(atp.emission_at); }
public AccountsToPayForm(accounts_to_pay atp) { InitializeComponent(); ControlsUtil.SetBackColor(this.tabGeneral.Controls); ControlsUtil.SetBackColor(this.tabPayment.Controls); if (atp == null) { atp = new accounts_to_pay() { emission_at = null }; IsNew = true; } loadData(); bdgAccountToPay.DataSource = atp; EmissionAt(atp.emission_at); }