Exemple #1
0
        public void editar(CadLocImov1 locador)
        {
            string telRes = locador.mtxtTelRes1.Text;

            telRes += locador.mtxtTelRes2.Text;

            string telCel = locador.mtxtTelCel1.Text;

            telCel += locador.mtxtTelCel2.Text;

            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 = "Update Locador set nome = '" + locador.txtNome.Text + "', " +
                                  "cpf = '" + locador.mtxtCpf.Text + "', rg = '" + locador.mtxtRg.Text + "', dataNasc = '" + locador.mtxtDataNasc.Text + "', " +
                                  "telRes = '" + telRes + "', telCel = '" + telCel + "', email = '" + locador.txtEmail.Text + "', " +
                                  "endereco =  '" + locador.txtEnd.Text + "' " +
                                  " where id = '" + locador.id_locador + "'";

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

            stringConexao.conn.Close();
        }
Exemple #2
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;
        }