Exemple #1
0
        public void deletar(VerLocadores locadores)
        {
            DataGridViewRow selectedRow = locadores.dgvLocadores.Rows[locadores.linha];

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

            comando = new SqlCommand();

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

            comando.Connection = stringConexao.conn;

            comando.CommandText = "Delete from locador where id = '" + id_Locador + "'";

            try
            {
                comando.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível deletar este locador", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();
        }
Exemple #2
0
        public void checarExclusao(VerLocadores locadores)
        {
            DataGridViewRow selectedRow = locadores.dgvLocadores.Rows[locadores.linha];
            int             id_Locador  = Convert.ToInt16(selectedRow.Cells[0].Value);

            ds = new DataSet();

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível conectar. Contate o administrador do sistema",
                                "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                dataAdapter = new SqlDataAdapter("select id_Locador from imovel", stringConexao.conn);
                dataAdapter.Fill(ds);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível buscar os locadores do imóvel", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();

            bool verificar = false;

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    foreach (DataColumn column in table.Columns)
                    {
                        int item = Convert.ToInt16(row[column]);
                        if (id_Locador == item)
                        {
                            verificar = true;
                        }
                    }
                }
            }
            if (verificar == true)
            {
                MessageBox.Show("Esse locador registrou um ou mais imóveis. " +
                                "Delete seu(s) imóvel(eis) e tente novamente", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                deletar(locadores);
            }
        }
Exemple #3
0
        public void ordenar(VerLocadores locadores)
        {
            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 (locadores.rbCrescente.Checked)
            {
                dataAdapter = new SqlDataAdapter("select * from Locador order by nome",
                                                 stringConexao.conn);
            }
            else if (locadores.rbDecrescente.Checked)
            {
                dataAdapter = new SqlDataAdapter("select * from Locador order by nome desc",
                                                 stringConexao.conn);
            }

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

            stringConexao.conn.Close();
        }
Exemple #4
0
        public void mostrarEditar(VerLocadores locadores, CadLocImov1 locador)
        {
            DataGridViewRow selecteRow = locadores.dgvLocadores.Rows[locadores.linha];
            int             id_Locador = Convert.ToInt16(selecteRow.Cells[0].Value);

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

            string telRes = selecteRow.Cells[5].Value.ToString();

            locador.mtxtTelRes1.Text = telRes.Substring(0, 4);
            locador.mtxtTelRes2.Text = telRes.Substring(5);

            string TelCel = selecteRow.Cells[6].Value.ToString();

            locador.mtxtTelCel1.Text = TelCel.Substring(0, 4);
            locador.mtxtTelCel2.Text = telRes.Substring(5);
            locador.txtEmail.Text    = selecteRow.Cells[7].Value.ToString();
            locador.txtEnd.Text      = selecteRow.Cells[8].Value.ToString();

            locador.Visible = true;
        }