Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!validatorTabPrincipal.Validate())
            {
                tab.SelectedTabPageIndex = 0;
                return;
            }
            if (!validatorSystem.Validate())
            {
                tab.SelectedTabPageIndex = 2;
                return;
            }

            if (IsNew)
            {
                if (!Unique.CnpjBusinessIsUnique(((business)bdgBusiness.Current)))
                {
                    tab.SelectedTabPageIndex = 0;
                    tfCnpj.SelectAll();
                    tfCnpj.Focus();
                    XtraMessageBox.Show("CNPJ ja encontra-se cadastrado, verifique!");
                    return;
                }
            }

            if (error)
            {
                return;
            }

            try
            {
                business b = ((business)bdgBusiness.Current);
                address  a = ((address)bdgAddress.Current);
                a.Save();
                b.address_id = a.id;
                b.Save();
                XtraMessageBox.Show(String.Format("Emitente {0} com sucesso!{1}",
                                                  IsNew ? "cadastrado" : "atualizado",
                                                  IsNew ? "\n\nFavor encaminhar o certificado digital para o email '*****@*****.**'\nContendo o nome do cliente/escritório e CNPJ do emitente!" : ""));
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(String.Format("{0}\n\n{1}", ex.Message, ex.InnerException));
            }
        }