Esempio n. 1
0
        private void btExcluir_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btExcluir.ImageIndex = 7;

            //o try é para tratamento de erros ao inserir objeto
            try
            {
                DialogResult d = MessageBox.Show("Tem certeza que deseja excluir o registro?", "Excluir?", MessageBoxButtons.YesNo);
                if (d.ToString() == "Yes")
                {
                    //MessageBox.Show("Excluindo o registro!");
                    DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                    DLLContato dll = new DLLContato(cx);
                    dll.Excluir(Convert.ToInt32(txtContatoCod.Text));
                    this.LimpaTela();
                    this.alteraBotoes(1);
                    closeCadContato = 1;
                }
                else
                {
                    MessageBox.Show("Erro no valor passado!" + d.ToString());
                }
            }
            catch
            {
                MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local.");
                this.alteraBotoes(3);
                closeCadContato = 3;
                //FormPrincipal.toolStripBarStatus.Text = "ERRO! Impossível excluir o registro.";
            }
            btExcluir.ImageIndex   = 6;
            btLocalizar.ImageIndex = 2;
            this.operacao          = "";
        }
Esempio n. 2
0
        private void btBusca_Click(object sender, EventArgs e)
        {
            btBusca.ImageIndex = 1;
            DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
            DLLContato dll = new DLLContato(cx);

            dgvDados.DataSource = dll.Localizar(txtNome.Text);
            label2.Visible      = true;
            btBusca.ImageIndex  = 0;
        }
Esempio n. 3
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões

            btSalvar.ImageIndex = 9;

            //o try é para tratamento de erros ao inserir objeto
            try
            {
                ModeloContato modelo = new ModeloContato();
                //modelo.ContatoCod = modelo.ContatoCod.ToString() +;

                /* if(chbFornecedor.Checked == true) modelo.ContatoForCod = Convert.ToInt32(cbForCod.SelectedValue);
                 * else modelo.ContatoForCod = 1;
                 *
                 * if (chbCliente.Checked == true) modelo.ContatoCliCod = Convert.ToInt32(cbCliCod.SelectedValue);
                 * else modelo.ContatoCliCod = 1;*/

                modelo.ContatoPaisCod   = Convert.ToInt32(cbContatoPais.SelectedValue);
                modelo.ContatoEstadoCod = Convert.ToInt32(cbContatoEstado.SelectedValue);
                modelo.ContatoCityCod   = Convert.ToInt32(cbContatoCity.SelectedValue);
                modelo.ContatoNome      = txtContatoNome.Text;
                modelo.ContatoCep       = txtContatoCep.Text;
                modelo.ContatoEndereco  = txtContatoEnd.Text;
                modelo.ContatoEmail     = txtContatoEmail.Text;
                modelo.ContatoCel1      = txtContatoCel1.Text;
                modelo.ContatoCel2      = txtContatoCel2.Text;
                //modelo.
                modelo.ContatoData   = DateTime.Now.ToShortDateString();
                modelo.ContatoTime   = DateTime.Now.ToShortTimeString();
                modelo.ContatoStatus = "local";

                //Obj para gravar os dados da conexão
                DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                DLLContato dll = new DLLContato(cx);

                if (this.operacao == "inserir")
                {
                    //Cadastrar nova categoria
                    dll.Incluir(modelo);
                    MessageBox.Show("Cadastro realizado: Código " + modelo.ContatoCod.ToString());
                    //toolStripBarStatus.Text = "Procedimento OK! Item " + modelo.CatCod.ToString() + " cadastrado!";
                }
                else
                {
                    //Alterar Categoria
                    modelo.ContatoCod = Convert.ToInt32(txtContatoCod.Text);
                    dll.Alterar(modelo);
                    MessageBox.Show("Cadastro Alterado!");
                    //toolStripBarStatus.Text = "Procedimento OK! Item " + txtcodigo.Text + " alterado!";
                    label1.Visible = false;
                }
                this.LimpaTela();
                this.alteraBotoes(1);
                closeCadContato = 1;
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
                //toolStripBarStatus.Text = "Erro! Cadastro não realizado!";
            }

            //Retorna parâmetros originais
            btSalvar.ImageIndex    = 8;
            btInserir.ImageIndex   = 0;
            btLocalizar.ImageIndex = 2;
            this.operacao          = "";
        }
Esempio n. 4
0
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btLocalizar.ImageIndex = 3;

            frmConsultaContato frmContato = new frmConsultaContato();

            frmContato.ShowDialog();
            if (frmContato.codigo != 0)
            {
                DALConexao    cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                DLLContato    dll    = new DLLContato(cx);
                ModeloContato modelo = dll.CarregaModeloContato(frmContato.codigo);
                txtContatoCod.Text           = modelo.ContatoCod.ToString();
                txtContatoNome.Text          = modelo.ContatoNome.ToString();
                txtContatoData.Text          = modelo.ContatoData.ToString();
                txtContatoEmail.Text         = modelo.ContatoEmail.ToString();
                txtContatoEnd.Text           = modelo.ContatoEndereco.ToString();
                txtContatoTel.Text           = modelo.ContatoTelefone.ToString();
                txtContatoCel1.Text          = modelo.ContatoCel1.ToString();
                txtContatoCel2.Text          = modelo.ContatoCel2.ToString();
                cbContatoOper1.SelectedValue = Convert.ToInt32(modelo.ContatoCel1Oper.ToString());
                cbContatoOper2.SelectedValue = Convert.ToInt32(modelo.ContatoCel2Oper.ToString());

                if (Convert.ToInt32(modelo.ContatoForCod.ToString()) == 0)
                {
                    chbFornecedor.Checked = true;
                    cbForCod.Enabled      = false;
                }
                else
                {
                    chbCliente.Checked = false;
                    cbForCod.Enabled   = true;

                    /*  DLLFornecedor dllf = new DLLFornecedor(cx);
                     * this.cbForCod.DataSource = dllf.Localizar("");
                     * this.cbForCod.DisplayMember = "for_nome";
                     * this.cbForCod.ValueMember = "for_cod";
                     * this.cbForCod.SelectedValue = Convert.ToInt32(modelo.ContatoForCod.ToString());*/
                }

                if (Convert.ToInt32(modelo.ContatoForCod.ToString()) == 0)
                {
                    chbFornecedor.Checked = true;
                    cbForCod.Enabled      = false;
                }
                else
                {
                    chbCliente.Checked = false;
                    cbForCod.Enabled   = true;

                    /*  DLLFornecedor dllf = new DLLFornecedor(cx);
                     * this.cbForCod.DataSource = dllf.Localizar("");
                     * this.cbForCod.DisplayMember = "for_nome";
                     * this.cbForCod.ValueMember = "for_cod";
                     * this.cbForCod.SelectedValue = Convert.ToInt32(modelo.ContatoForCod.ToString());*/
                }

                label1.Visible = true;
                this.alteraBotoes(3);
                closeCadContato = 3;
            }
            else
            {
                this.LimpaTela();
                this.alteraBotoes(1);
                btLocalizar.ImageIndex = 2;
            }
            frmContato.Dispose();
        }