Beispiel #1
0
        public void mostrarEditar(verFiadores fiadores, cadFiador fiador)
        {
            DataGridViewRow selectedRow = fiadores.dgvFiadores.Rows[fiadores.linha];

            int id_Fiador = Convert.ToInt16(selectedRow.Cells[0].Value);



            fiador.txtNome.Text      = selectedRow.Cells[1].Value.ToString();
            fiador.mtxtCpf.Text      = selectedRow.Cells[2].Value.ToString();
            fiador.mtxtRg.Text       = selectedRow.Cells[3].Value.ToString();
            fiador.mtxtDataNasc.Text = selectedRow.Cells[4].Value.ToString();

            String telRes = selectedRow.Cells[5].Value.ToString();

            fiador.mtxtTelRes1.Text = telRes.Substring(0, 4);
            fiador.mtxtTelRel2.Text = telRes.Substring(4);

            String telCel = selectedRow.Cells[6].Value.ToString();

            fiador.mtxtTelCel1.Text = telCel.Substring(0, 4);
            fiador.mtxtTelCel2.Text = telCel.Substring(4);

            fiador.txtEmail.Text = selectedRow.Cells[7].Value.ToString();

            fiador.txtEndereco.Text = selectedRow.Cells[8].Value.ToString();

            fiador.txtValorFianca.Text = selectedRow.Cells[9].Value.ToString();

            fiador.Visible = true;
        }
Beispiel #2
0
        public void deletar(verFiadores fiadores)
        {
            DataGridViewRow selectedRow = fiadores.dgvFiadores.Rows[fiadores.linha];
            int             id_fiador   = Convert.ToInt16(selectedRow.Cells[0].Value);

            comando = new SqlCommand();

            try{
                stringConexao.conn.Open();
            }catch (SqlException ex)
            {
                MessageBox.Show("Conexão falhou! Contate o administrador do sistema.", "Mensagem", MessageBoxButtons.OK
                                , MessageBoxIcon.Error);
            }

            comando.Connection = stringConexao.conn;

            comando.CommandText = "Delete from Fiador where id = '" + id_fiador + "'";

            try
            {
                comando.ExecuteNonQuery();
                MessageBox.Show("Comando executado com sucesso.", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Este fiador está vinculado à uma locação, delete a " +
                                "locação a qual ele pertence e tente novamente.", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }

            stringConexao.conn.Close();
        }
Beispiel #3
0
        public void chamarFiadores(VerLocacoes verLocacoes, verFiadores fiadores)
        {
            DataGridViewRow selectedRow = verLocacoes.dgvLocacoes.Rows[verLocacoes.linha];

            int id_Locacao = Convert.ToInt16(selectedRow.Cells[0].Value);

            fiadores.btnOk.Text       = "Selecionar";
            fiadores.lblFiadores.Text = "Selecione um fiador";

            fiadores.Visible = true;
        }
Beispiel #4
0
        public void setNomeFiadorById(verFiadores fiadores)
        {
            DataGridViewRow selectedRow = fiadores.dgvFiadores.Rows[fiadores.linha];

            string nome = selectedRow.Cells[1].Value.ToString();

            fiadores.locacao.txtFiador.Text = nome;

            fiadores.locacao.id_Fiador = Convert.ToInt16(selectedRow.Cells[0].Value);
            fiadores.Visible           = false;
        }
Beispiel #5
0
        public void popFiador(Locacao locacao)
        {
            verFiadores fiadores = new verFiadores("selecionar", locacao, inicio);

            fiadores.btnAtualizar.Visible = false;
            fiadores.btnCadastrar.Visible = false;
            fiadores.btnDeletar.Visible   = false;
            fiadores.btnEditar.Visible    = false;

            fiadores.Visible = true;
        }
Beispiel #6
0
        public void verFiadoresDeUmaLocacao(VerLocacoes verLocacoes, verFiadores fiadores)
        {
            fiadores.gbFiadores.Visible   = false;
            fiadores.btnAtualizar.Visible = false;
            fiadores.btnCadastrar.Visible = false;
            fiadores.btnDeletar.Visible   = false;
            fiadores.btnEditar.Visible    = false;

            DataSet ds1 = getFiadoresDeUmaLocacao(verLocacoes);

            ds = new DataSet();

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível conectar com a base de dados", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            foreach (DataTable table in ds1.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    foreach (DataColumn column in table.Columns)
                    {
                        int item = Convert.ToInt16(row[column]);
                        // read column and item

                        dataAdapter = new SqlDataAdapter("SELECT * from Fiador where id = '" + item + "'",
                                                         stringConexao.conn);

                        try
                        {
                            dataAdapter.Fill(ds);
                        }catch (SqlException ex)
                        {
                            MessageBox.Show("Não foi possível buscar os dados do Fiador", "Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }

            stringConexao.conn.Close();

            fiadores.dgvFiadores.DataSource = ds.Tables[0];

            fiadores.Visible = true;
        }
Beispiel #7
0
        public void ordenar(verFiadores fiadores)
        {
            ds = new DataSet();

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível conectar com a base de dados", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }



            if (fiadores.rbCrescente.Checked)
            {
                dataAdapter = new SqlDataAdapter("select * from Fiador order by nome",
                                                 stringConexao.conn);
            }
            else if (fiadores.rbDecrescente.Checked)
            {
                dataAdapter = new SqlDataAdapter("select * from Fiador order by nome desc",
                                                 stringConexao.conn);
            }

            try
            {
                dataAdapter.Fill(ds);
                fiadores.dgvFiadores.DataSource = ds.Tables[0];
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível ordenar", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();
        }
Beispiel #8
0
        public void exibir(verFiadores fiador)
        {
            ds = new DataSet();

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Falha na conexão!Contate o administrador do sistema", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            dataAdapter = new SqlDataAdapter("select * from Fiador", stringConexao.conn);

            dataAdapter.Fill(ds);

            stringConexao.conn.Close();

            fiador.dgvFiadores.DataSource = ds.Tables[0];
        }
Beispiel #9
0
        public void addOutroFiadorLocacao(verFiadores fiadores)
        {
            comando = new SqlCommand();

            DataGridViewRow selectedRow = fiadores.dgvFiadores.Rows[fiadores.linha];

            int id_Fiador  = Convert.ToInt16(selectedRow.Cells[0].Value);
            int id_Locacao = fiadores.id_Locacao;

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível estabelecer conexão com a base de dados", "Mensagem",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            comando.Connection = stringConexao.conn;

            comando.CommandText = "INSERT INTO Fiador_Locacao(id_Locacao, id_Fiador) VALUES ('" + id_Locacao + "', " +
                                  "'" + id_Fiador + "')";

            try
            {
                comando.ExecuteNonQuery();
                MessageBox.Show("Fiador_Locacao foi adicionado com sucesso", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível registrar o Fiador_Locacao", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();
        }