コード例 #1
0
        private void AdicionarDependente()
        {
            DependenteDAL dDal      = new DependenteDAL();
            bool          gravou    = false;
            DateTime?     dtNascDep = null;
            int?          intNumero = null;

            if (mskDtNascimentoDependente.Text != "  /  /")
            {
                dtNascDep = DateTime.Parse(mskDtNascimentoDependente.Text);
            }
            if (txtNumeroDependente.Text.Trim() != "")
            {
                intNumero = int.Parse(txtNumeroDependente.Text);
            }

            if (lblId.Text.Equals("idSocio"))
            {
                MessageBox.Show("Nenhum sócio selecionado.\n" +
                                "Se o cadastro estiver em andamento, primeiro finalizar o cadastro do sócio\n" +
                                "para fazer inclusão dos dependentes.", "Mensagem");
                // retorna para tab sócios
            }
            else
            {
                Dependente d = new Dependente
                {
                    Cpf            = mskCpfDependente.Text,
                    Nome           = txtNomeDependente.Text,
                    Obs            = txtObservacaoDependente.Text,
                    DataNascimento = dtNascDep,
                    Parentesco     = txtParentesco.Text,
                    Numero         = intNumero,
                    Fone           = mskFoneDependente.Text,
                    IdSocio        = int.Parse(lblId.Text)
                };

                gravou = dDal.InsertDependente(d);
                if (gravou)
                {
                    RetornaDependentes(long.Parse(lblId.Text));
                    frmTDM_Menssagem frmSucesso = new frmTDM_Menssagem("Adicionado com sucesso!", 1, "");
                    frmSucesso.Show();
                    LimparDependente();
                }
            }
        }
コード例 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            frmTDM_Login f = new frmTDM_Login();

            try
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new frmTDM_Princiapal());
                }
            }
            catch (SystemException ex)
            {
                string exception = ex.Message.ToString();
                exception += ex.ToString();
                frmTDM_Menssagem frm = new frmTDM_Menssagem("Verifique", 2, exception);
                frm.ShowDialog();
            }
        }
コード例 #3
0
        private void AtualizarDependente()
        {
            DependenteDAL dDal   = new DependenteDAL();
            bool          gravou = false;

            if (lblId.Text.Equals("idSocio"))
            {
                MessageBox.Show("Nenhum sócio selecionado.\n" +
                                "Cadastro em andamento, primeiro finalizar o cadastro do sócio\n" +
                                "para fazer inclusão dos dependentes.", "Mensagem");
                // retorna para tab sócios
            }
            else
            {
                Dependente d = new Dependente
                {
                    Id             = int.Parse(lblIdDependente.Text),
                    Cpf            = mskCpfDependente.Text,
                    Nome           = txtNomeDependente.Text,
                    Obs            = txtObservacaoDependente.Text,
                    DataNascimento = DateTime.Parse(mskDtNascimentoDependente.Text),
                    Parentesco     = txtParentesco.Text,
                    Numero         = int.Parse(txtNumeroDependente.Text),
                    Fone           = mskFoneDependente.Text,
                };

                gravou = dDal.UpdateDependente(d);
                if (gravou)
                {
                    RetornaDependentes(int.Parse(lblId.Text));

                    frmTDM_Menssagem frmSucesso = new frmTDM_Menssagem("Atualizado com sucesso!", 1, "");
                    frmSucesso.ShowDialog();
                    LimparDependente();
                }
            }
        }
コード例 #4
0
 private void cmdExcluir_Click(object sender, EventArgs e)
 {
     if (lblIdDependente.Text.Equals("idDependente"))
     {
         MessageBox.Show("Selecione o dependente.", "Mensagem");
     }
     else
     {
         DialogResult dr = new DialogResult();
         dr = MessageBox.Show($"Deseja excluir o dependente\n {txtNomeDependente.Text} ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             try
             {
                 int           id       = int.Parse(lblIdDependente.Text);
                 int           idSocio  = int.Parse(lblId.Text);
                 bool          deletado = false;
                 DependenteDAL dDal     = new DependenteDAL();
                 deletado = dDal.DeletaDependente(id);
                 if (deletado)
                 {
                     lstDependentes.Items.Clear();
                     RetornaDependentes(idSocio);
                     LimparDependente();
                     frmTDM_Menssagem frm = new frmTDM_Menssagem("Dependente excluído.", 1, "");
                     frm.Show();
                 }
                 LimparDependente();
             }
             catch (SystemException ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
コード例 #5
0
        private void InserirSocio()
        {
            DateTime?dtExpedicao  = null;
            DateTime?dtNascimento = null;

            if (mskDtExpedicao.Text != "  /  /")
            {
                dtExpedicao = DateTime.Parse(mskDtExpedicao.Text);
            }
            if (mskDtNascimentoSocio.Text != "  /  /")
            {
                dtNascimento = DateTime.Parse(mskDtNascimentoSocio.Text);
            }

            DialogResult dr;
            bool         gravou = false;

            dr = MessageBox.Show("Sócio sem endereço ou com endereço incompleto.\n" +
                                 "Deseja continuar o cadastro?", "Aviso", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    SocioDAL sDal = new SocioDAL();
                    Socio    S    = new Socio
                    {
                        Titulo           = int.Parse(txtTitulo.Text),
                        DataAdesao       = DateTime.Parse(mskDtAdesao.Text),
                        Cpf              = mskCpf.Text,
                        Nome             = txtNome.Text,
                        Rg               = txtRg.Text,
                        OrgaoExpedidor   = txtOrgaoExpedidor.Text,
                        UfOrgaoExpedidor = cmbUfOrgaoExpedidor.Text,
                        DataExpedicao    = dtExpedicao,
                        Situacao         = txtSituacao.Text,
                        DataNascimento   = dtNascimento,
                        FoneResidencial  = mskResidencial.Text,
                        FoneCelular      = mskCelular.Text,
                        FoneComercial    = mskComercial.Text,
                        Email            = txtEmail.Text,
                        DataCadastro     = DateTime.Parse(mskDtCadastroSocio.Text),
                        DataAtualizacao  = DateTime.Parse(mskDtAtualizacaoSocio.Text),
                        Ativo            = bool.Parse(ckbSocioAtivo.Checked.ToString()),
                        Obs              = txtAdicionaisObs.Text,
                        PathImagem       = foto
                    };
                    if (lblId.Text.Equals("idSocio"))
                    {
                        gravou = sDal.InsertSocio(S);
                        if (gravou)
                        {
                            if (ValidaEndereco())
                            {
                                Endereco E = new Endereco()
                                {
                                    Cep         = mskCep.Text,
                                    Rua         = txtRua.Text,
                                    Numero      = int.Parse(txtNumero.Text),
                                    Bairro      = txtBairro.Text,
                                    Cidade      = txtCidade.Text,
                                    Uf          = cmbUfEndereco.Text,
                                    Complemento = txtComplemento.Text,
                                    IdSocio     = ReturnIdGeradoSocio()
                                };
                                EnderecoDAL eDal = new EnderecoDAL();
                                gravou = eDal.InsertEndereco(E);
                            }
                        }
                    }
                }
                catch (SystemException ex)
                {
                    string           exception = ex.Message.ToString();
                    frmTDM_Menssagem frmErro   = new frmTDM_Menssagem("Revise os dados.", 2, exception);
                    frmErro.Show();
                }
            }
            if (gravou)
            {
                tabControl1.SelectedTab = tabPage1;
                frmTDM_Menssagem frm = new frmTDM_Menssagem("Cadastrado com sucesso!", 1, "");
                frm.Show();
                Limpar();
                LimparDependente();
            }
        }
コード例 #6
0
        private void AtualizarSocio()
        {
            DateTime?dtExpedicao  = null;
            DateTime?dtNascimento = null;

            if (mskDtExpedicao.Text != "  /  /")
            {
                dtExpedicao = DateTime.Parse(mskDtExpedicao.Text);
            }
            if (mskDtNascimentoSocio.Text != "  /  /")
            {
                dtNascimento = DateTime.Parse(mskDtNascimentoSocio.Text);
            }

            bool gravou = false;

            try
            {
                SocioDAL sDal = new SocioDAL();
                Socio    S    = new Socio
                {
                    Id               = int.Parse(lblId.Text),
                    Titulo           = int.Parse(txtTitulo.Text),
                    DataAdesao       = DateTime.Parse(mskDtAdesao.Text),
                    Cpf              = mskCpf.Text,
                    Nome             = txtNome.Text,
                    Rg               = txtRg.Text,
                    OrgaoExpedidor   = txtOrgaoExpedidor.Text,
                    UfOrgaoExpedidor = cmbUfOrgaoExpedidor.Text,
                    DataExpedicao    = dtExpedicao,
                    Situacao         = txtSituacao.Text,
                    DataNascimento   = dtNascimento,
                    FoneResidencial  = mskResidencial.Text,
                    FoneCelular      = mskCelular.Text,
                    FoneComercial    = mskComercial.Text,
                    Email            = txtEmail.Text,
                    DataAtualizacao  = DateTime.Now,
                    Ativo            = bool.Parse(ckbSocioAtivo.Checked.ToString()),
                    Obs              = txtAdicionaisObs.Text,
                    PathImagem       = foto
                };
                if (!lblId.Text.Equals("idSocio"))
                {
                    gravou = sDal.UpdatedSocio(S);
                    if (gravou)
                    {
                        try
                        {
                            int?numero = null;
                            if (txtNumero.Text.Trim() != "")
                            {
                                numero = int.Parse(txtNumero.Text);
                            }
                            Endereco E = new Endereco()
                            {
                                Cep         = mskCep.Text,
                                Rua         = txtRua.Text,
                                Numero      = numero,
                                Bairro      = txtBairro.Text,
                                Cidade      = txtCidade.Text,
                                Uf          = cmbUfEndereco.Text,
                                Complemento = txtComplemento.Text,
                                IdSocio     = int.Parse(lblId.Text)
                            };
                            EnderecoDAL eDal = new EnderecoDAL();
                            //idEnd = eDal.IdEnderecoBySocio(long.Parse(lblId.Text));
                            if (!lblIdEndereco.Text.Equals("idEndereco"))
                            {
                                gravou = eDal.UpdateEndereco(E);
                            }
                            else
                            {
                                gravou = eDal.InsertEndereco(E);
                            }
                        }
                        catch (SystemException ex)
                        {
                            string           exception = ex.Message.ToString();
                            frmTDM_Menssagem frmErro   = new frmTDM_Menssagem("Revise os dados.", 2, exception);
                            frmErro.Show();
                        }
                    }
                }
            }
            catch (SystemException ex)
            {
                string           exception = ex.Message.ToString();
                frmTDM_Menssagem frmErro   = new frmTDM_Menssagem("Revise os dados.", 2, exception);
                frmErro.Show();
            }
            if (gravou)
            {
                tabControl1.SelectedTab = tabPage1;
                frmTDM_Menssagem frm = new frmTDM_Menssagem("Cadastrado com sucesso!", 1, "");
                frm.Show();
                Limpar();
                LimparDependente();
            }
        }