Example #1
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            try
            {
                Types.CargoType type = new Types.CargoType();
                type.Descricao = txtDescricao.Text;
                type.IdDepartamento = Int32.Parse(cmbDepartamento.SelectedValue.ToString());

                CargoBLL itemBLL = new CargoBLL();
                if (txtID.Text == "")
                {
                    txtID.Text = Convert.ToString(itemBLL.insert(type));
                }
                else
                {
                    type.IdCargo = Convert.ToInt32(txtID.Text);
                    itemBLL.alterar(type);
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show("Erro ao gravar. Mensagem: " +
                    erro.Message, "Erro", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            findAll();
        }
Example #2
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Tem certeza que deseja excluir?", "Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    Types.CargoType type = new Types.CargoType();
                    type.IdCargo = Convert.ToInt32(txtID.Text);

                    CargoBLL itemBLL = new CargoBLL();
                    itemBLL.excluir(type);
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro ao excluir. Mensagem: " +
                        erro.Message, "Erro", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                findAll();
                LimparCampos();
            }
        }
Example #3
0
 private void findAll()
 {
     CargoBLL bll = new CargoBLL();
     dataGridView1.DataSource = bll.select();
 }