예제 #1
0
        private void btnSalvarUs_Click(object sender, EventArgs e)
        {
            try
            {
                string sexo      = cbxSex.Text;
                string estadoId  = cbxEstado.SelectedValue.ToString();
                string cidadeId  = cbxCidade.SelectedValue.ToString();
                string empresaId = cbxEmpresa.SelectedValue.ToString();

                DaoMotorista DaoMotorista = new DaoMotorista();
                DaoMotorista.cnh       = new Cnh(txtCnh.Text, txtValidade.Text, cbxCategoria.Text);
                DaoMotorista.telefone  = new Telefone(txtDdd.Text, txtOpe.Text, txtCel.Text, txtTel.Text);
                DaoMotorista.endereco  = new Endereco(int.Parse(estadoId), int.Parse(cidadeId), txtRua.Text, txtNum.Text, txtCep.Text, txtComp.Text, txtBairro.Text);
                DaoMotorista.motorista = new Motorista(txtName.Text, txtNasc.Text, txtCpf.Text, txtRg.Text, sexo, txtEmail.Text);
                DaoMotorista.empresa   = new Empresa(empresaId);
                salvarImg();
                DaoMotorista.CadastraMotorista();
                lblAviso.Text = "Cadastrado com Sucesso !";
                Limpar();
            }
            catch (DomainExceptions ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }


            //lblAviso.Text = "";
        }
        private void ExcluirMotoristaBtn_Click(object sender, EventArgs e)
        {
            FrmMensagemCadSucesso frmMsgSucesso    = (FrmMensagemCadSucesso)Application.OpenForms["FrmMensagemCadSucesso"];
            FrmMensagemCadSucesso frmMsgSucessomsg = new FrmMensagemCadSucesso();

            FrmMsgSimNao frmMsgExcluirv = (FrmMsgSimNao)Application.OpenForms["FrmSairSistema"];
            FrmMsgSimNao frmMsgExcluir  = new FrmMsgSimNao();

            frmMsgExcluir.ShowDialog();

            if (frmMsgExcluir.btnSairClick == true)
            {
                DaoMotorista daoMotorista = new DaoMotorista();
                daoMotorista.ExcluirMotorista(m);
                PosGravar();
            }
            daoMotorista.ExcluirMotorista(m);
            limparDados();
        }
        private void PesquisatTodosCkb_CheckedChanged(object sender, EventArgs e)
        {
            DaoMotorista daoMotorista = new DaoMotorista();

            dataGridViewMotorista.DataSource = daoMotorista.TodosMotoristas();
        }
        public void atualizarGrid()
        {
            DaoMotorista daoMotorista = new DaoMotorista();

            dataGridViewMotorista.DataSource = daoMotorista.TodosMotoristas();
        }