示例#1
0
        private void DgvResultados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                ObjetoTransferencia.TipoItem tipoItem = new ObjetoTransferencia.TipoItem();

                tipoItem.TipoItemID        = Convert.ToInt32(dgvResultados.SelectedRows[0].Cells[0].Value.ToString());
                tipoItem.TipoItemDescricao = dgvResultados.SelectedRows[0].Cells[1].Value.ToString();

                frmAlterarTipoItem frmAlterarTipoItem = new frmAlterarTipoItem(tipoItem);
                frmAlterarTipoItem.ShowDialog();

                TipoItemNegocios tipoItemNegocios = new TipoItemNegocios();
                if (rbID.Checked && txtID.Text.Trim() != string.Empty)
                {
                    dgvResultados.DataSource = tipoItemNegocios.ConsultaPorID(Convert.ToInt32(txtID.Text));
                }
                else if (rbDescricao.Checked)
                {
                    dgvResultados.DataSource = tipoItemNegocios.ConsultaPorDescricao(txtDescricao.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Houve algum erro, por favor, tente novamente.", "Houve algum erro.");
            }
        }
示例#2
0
 private void BtnConsultar_Click(object sender, EventArgs e)
 {
     try
     {
         TipoItemNegocios tipoItemNegocios = new TipoItemNegocios();
         if (rbID.Checked && txtID.Text.Trim() != string.Empty)
         {
             dgvResultados.DataSource = tipoItemNegocios.ConsultaPorID(Convert.ToInt32(txtID.Text));
         }
         else if (rbDescricao.Checked)
         {
             dgvResultados.DataSource = tipoItemNegocios.ConsultaPorDescricao(txtDescricao.Text);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Houve algum erro, por favor, tente novamente.", "Houve algum erro.");
     }
 }