private void button_edit_Click(object sender, EventArgs e) { try { connection.Open(); OleDbCommand command = connection.CreateCommand(); command.Connection = connection; if (label5.Text == "kobi") { string quary = "update students set id='" + txtID.Text + "',fname='" + txtFirstName.Text + "',lname='" + txtLastName.Text + "',tel='" + txtTel.Text + "',email='" + txtEmail.Text + "',trands='" + trand_comboBox.Text + "',year1='" + year_comboBox.Text + "',how_pay='" + comboBox_cash.Text + "',gander='" + gender + "',picture='" + textBoximage_path.Text + "',gift='" + gift + "' where id=" + int.Parse(textBox_edit.Text) + "; "; command.CommandText = quary; } else { string quary = "update students set fname='" + txtFirstName.Text + "',lname='" + txtLastName.Text + "',tel='" + txtTel.Text + "',email='" + txtEmail.Text + "' where id=" + int.Parse(textBox_edit.Text) + "; "; command.CommandText = quary; } command.ExecuteNonQuery(); MessageBox.Show("Data Edit seccessful"); Refresh db = new Refresh(table); dataGridView1.DataSource = db.refreshdata1(); txtID.Clear(); txtFirstName.Clear(); txtLastName.Clear(); txtTel.Clear(); txtEmail.Clear(); male_radioButton.Checked = false; radioButton1.Checked = false; radioButton3.Checked = false; radioButton4.Checked = false; radioButton5.Checked = false; textBox_edit.Clear(); year_comboBox.SelectedIndex = -1; trand_comboBox.SelectedIndex = -1; pictureBox1.Visible = false; textBoximage_path.Clear(); connection.Close(); } catch (Exception err) { MessageBox.Show(err.Message); connection.Close(); } }
private void button_edituser_Click(object sender, EventArgs e) { try { connection.Open(); OleDbCommand command = connection.CreateCommand(); command.Connection = connection; command.CommandText = "update login set username1='" + textBox1.Text + "', password1='" + textBox2.Text + "' where username1='" + textBox3.Text + "'; "; command.ExecuteNonQuery(); MessageBox.Show("Data Edit seccessful"); Refresh db = new Refresh(table); dataGridView1.DataSource = db.refreshdata1(); connection.Close(); } catch (Exception err) { MessageBox.Show(err.Message); connection.Close(); } }
private void button_adduser_Click(object sender, EventArgs e) { try { connection.Open(); OleDbCommand command = connection.CreateCommand(); command.Connection = connection; command.CommandText = "insert into login (username1,password1) values('" + textBox1.Text + "','" + textBox2.Text + "')"; command.ExecuteNonQuery(); MessageBox.Show("Data Save"); Refresh db = new Refresh(table); dataGridView1.DataSource = db.refreshdata1(); connection.Close(); } catch (Exception err) { MessageBox.Show(err.Message); connection.Close(); } }