Ejemplo n.º 1
0
 private void TsbDocAdd_Click(object sender, EventArgs e)
 {
     try
     {
         frmCad_Documento frmCad_Documento = new frmCad_Documento(0, administracao_dto.ID_FINANCEIRO);
         DialogResult     result           = frmCad_Documento.ShowDialog();
         if (result == DialogResult.OK)
         {
             PopularGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Não foi possível incluir o registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 2
0
        private void TsbDocEdit_Click(object sender, EventArgs e)
        {
            try
            {
                //Setando o mousepointer para ocupado.
                Cursor.Current = Cursors.WaitCursor;

                //Verifica se existem registros no datagrid
                if (dtgDadosDocumento.RowCount == 0)
                {
                    return;
                }

                //Visualizando o registro selecionado
                int Id = Convert.ToInt32(dtgDadosDocumento.CurrentRow.Cells["ID"].Value.ToString());
                if (Id != 0)
                {
                    frmCad_Documento frmCad_Documento = new frmCad_Documento(Id, administracao_dto.ID_FINANCEIRO);
                    DialogResult     result           = frmCad_Documento.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        PopularGrid();
                    }
                }
                else
                {
                    throw new Exception("O Id do registro selecionado está incorreto!");
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Nenhum registro válido foi selecionado!", "Não foi possível a visualização do registro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Não foi possível a visualização do registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }