コード例 #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 FrmCadastroItem_Load(object sender, EventArgs e)
        {
            TipoItemNegocios tipoItemNegocios = new TipoItemNegocios();

            cbbTipoItem.ValueMember   = "TipoItemID";
            cbbTipoItem.DisplayMember = "TipoItemDescricao";
            TipoItemCollection tipoItems = tipoItemNegocios.ConsultaTodos();

            if (tipoItems.Count > 0)
            {
                cbbTipoItem.DataSource = tipoItems;
            }
            else
            {
                MessageBox.Show("Por favor, realize o cadastro dos tipos de itens.", "Cadastre tipos de itens.");
                Close();
            }
        }
コード例 #3
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.");
     }
 }
コード例 #4
0
        private void BtnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtDescricao.Text.Trim() != string.Empty)
                {
                    TipoItemNegocios tipoItemNegocios = new TipoItemNegocios();
                    tipoItem.TipoItemDescricao = txtDescricao.Text.Trim();
                    tipoItemNegocios.Alterar(tipoItem);

                    MessageBox.Show("Tipo de Item de ID " + tipoItem.TipoItemID.ToString() + " alterado com sucesso!", "Alteração realizada!");
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Houve algum erro, por favor, tente novamente.", "Houve algum erro.");
            }
        }
コード例 #5
0
        private void BtnCadastrar_Click(object sender, EventArgs e)
        {
            if (txtDescricao.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Por favor, informe a descrição.", "Informa a descrição.");
            }
            else
            {
                try
                {
                    ObjetoTransferencia.TipoItem tipoItem         = new ObjetoTransferencia.TipoItem();
                    TipoItemNegocios             tipoItemNegocios = new TipoItemNegocios();

                    tipoItem.TipoItemDescricao = txtDescricao.Text.Trim();

                    MessageBox.Show("Tipo de Item de ID: " + tipoItemNegocios.Cadastrar(tipoItem) + " cadastrado com sucesso!");
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Houve um erro no cadastro de Tipo de Item, por favor, contate seu suporte.\nObservações: " + ex.Message);
                }
            }
        }