Example #1
0
        private void BtnCadFunc_Click(object sender, EventArgs e)
        {
            //ve se os campos estao vazios, validar todas as informaçoes
            try
            {
                //metodos com sob

                PessoaDTO obj = new PessoaDTO();
                //armazenando os valores das caixas na propriedades

                //vai criar uma classe, e validar as informaçoes atráves delas, provalvelmente vai ser em BLL

                obj.Nome           = txtNomeFunc.Text;
                obj.DataNascimento = mtbNascFunc.Text;
                obj.CPF            = mtbCPFFunc.Text;
                obj.TelCelular     = mtbCelFunc.Text;
                obj.RG             = txtRGFunc.Text;
                obj.Cargo          = txtCargoFunc.Text;
                obj.TelFixo        = mtbFixoFunc.Text;
                obj.Estado         = cbUFFunc.Text;
                obj.Endereco       = txtEndFunc.Text;
                obj.Numero         = txtNumFunc.Text;
                obj.Bairro         = txtBairFunc.Text;
                obj.Cidade         = txtCidFunc.Text;
                obj.CEP            = mtbCEPFunc.Text;

                if (rbFFunc.Checked == true)
                {
                    obj.Sexo = rbFFunc.Text;
                }
                if (rbMFunc.Checked == true)
                {
                    obj.Sexo = rbMFunc.Text;
                }
                if (rbOFunc.Checked == true)
                {
                    obj.Sexo = rbOFunc.Text;
                }
                if (rbAtFunc.Checked == true)
                {
                    obj.StatusPes = rbAtFunc.Text;
                }
                if (rbInaFunc.Checked == true)
                {
                    obj.StatusPes = rbInaFunc.Text;
                }

                string mensagem = FuncionarioBLL.CadFuncionario(obj);
                MessageBox.Show(mensagem, "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);


                txtNomeFunc.Clear();
                mtbNascFunc.Clear();
                mtbCPFFunc.Clear();
                mtbCelFunc.Clear();
                txtRGFunc.Clear();
                txtCargoFunc.Clear();
                mtbFixoFunc.Clear();
                cbUFFunc.SelectedIndex = -1;
                txtEndFunc.Clear();
                txtNumFunc.Clear();
                txtBairFunc.Clear();
                txtCidFunc.Clear();
                mtbCEPFunc.Clear();
                rbFFunc.Checked   = false;
                rbMFunc.Checked   = false;
                rbOFunc.Checked   = false;
                rbAtFunc.Checked  = false;
                rbInaFunc.Checked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                PessoaDTO obj = new PessoaDTO();
                obj.Nome           = textBox1.Text;
                obj.CPF            = maskedTextBox1.Text;
                obj.RG             = textBox3.Text;
                obj.DataNascimento = maskedTextBox2.Text;
                obj.TelFixo        = maskedTextBox4.Text;
                obj.TelCelular     = maskedTextBox5.Text;
                obj.Cargo          = comboBox1.Text;
                obj.Endereco       = textBox2.Text;
                obj.Numero         = textBox5.Text;
                obj.Bairro         = textBox4.Text;
                obj.Cidade         = textBox6.Text;
                obj.Estado         = comboBox2.Text;
                obj.CEP            = maskedTextBox3.Text;
                if (radioButton1.Checked == true)
                {
                    obj.Sexo = radioButton1.Text;
                }
                if (radioButton2.Checked == true)
                {
                    obj.Sexo = radioButton2.Text;
                }
                if (radioButton3.Checked == true)
                {
                    obj.Sexo = radioButton3.Text;
                }
                if (radioButton4.Checked == true)
                {
                    obj.Ativo = radioButton4.Text;
                }
                if (radioButton5.Checked == true)
                {
                    obj.Ativo = radioButton5.Text;
                }
                string mensagem = FuncionarioBLL.CadFuncionario(obj);
                MessageBox.Show(mensagem, "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                textBox1.Clear();
                maskedTextBox1.Clear();
                textBox3.Clear();
                maskedTextBox2.Clear();
                maskedTextBox4.Clear();
                maskedTextBox5.Clear();
                comboBox1.SelectedIndex = -1;
                textBox2.Clear();
                textBox4.Clear();
                textBox5.Clear();
                textBox6.Clear();
                comboBox2.SelectedIndex = -1;
                maskedTextBox3.Clear();
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                radioButton5.Checked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }