//buton actualizare
private void button1_Click(object sender, EventArgs e)
{
try
{
OracleConnection conn = new OracleConnection(CONNECTION_STRING);
//deschiderea conexiunii
conn.Open();
//comanda sql care poate fi interogare sql, procedura stocata etc...
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
String sqlCommand = "UPDATE CLIENTI_IT set nume = '";
sqlCommand += textNume.Text + "'";
sqlCommand += ", prenume = '" + textPrenume.Text + "'";
sqlCommand += ", mail = '" + textMail.Text + "'";
sqlCommand += ", nr_tel = '" + textTel.Text + "'";
sqlCommand += " where id_client=" + ((ComboItem)cmbClienti.SelectedItem).Value; ;
cmd.CommandText = sqlCommand;
int rezult = cmd.ExecuteNonQuery();
if (rezult > 0)
{
MessageBox.Show("Updated");
// Refresh1();
}
else
{
MessageBox.Show("Error");
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Exception" + ex.Message);
}
}
}
//inchiderea conexiunii
conn.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Dispose();
}
Functia IncarcaCLient ()
//incarca clienti
private void IncarcaClient()
{
OracleConnection conn = new OracleConnection(CONNECTION_STRING);
try
{
//deschiderea conexiunii
conn.Open();
//comanda sql care poate fi interogare sql, procedura stocata etc...
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select id_client,nume from CLIENTI_IT";
cmd.CommandType = CommandType.Text;
//executia comenzii
OracleDataReader dr = cmd.ExecuteReader();
//preluarea datelor i plasarea lor ntr-un combobox
while (dr.Read())
{
cmbClienti.Items.Add(new ComboItem(dr.GetString(1), (Int32)dr.GetDecimal(0)));
}
//inchiderea conexiunii
conn.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Dispose();
}
}
Clasa combo item