private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { con1.Open(); SqlCommand com2 = new SqlCommand(); com2.Connection = con1; com2.CommandText = "SELECT * FROM Customer WHERE CID='" + comboBox1.Text + "'"; SqlDataReader dr = com2.ExecuteReader(); if (dr.Read()) { com2.CommandText = "UPDATE Customer SET FristName='" + comboBox2.Text + "',LastName='" + textBox3.Text + "',NIC='" + textBox4.Text + "',Address='" + textBox5.Text + "',Tel='" + textBox6.Text + "',Mobile='" + textBox7.Text + "',Mail='" + textBox8.Text + "',Type= '" + textBox9.Text + "', balance='" + textBox1.Text + "' WHERE CID='" + comboBox1.Text + "' "; dr.Close(); com2.ExecuteNonQuery(); MessageBox.Show("Updated"); } con1.Close(); Customer_Update cu = new Customer_Update(); this.Hide(); cu.Show(); comboBox1.Focus(); } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Down) { if (isvalid()) { con1.Open(); SqlCommand com2 = new SqlCommand(); com2.Connection = con1; com2.CommandText = "SELECT * FROM Customer WHERE CID='" + comboBox1.Text.Trim() + "'"; SqlDataReader dr = com2.ExecuteReader(); if (dr.Read()) { com2.CommandText = "UPDATE Customer SET FristName='" + comboBox2.Text.Trim() + "',LastName='" + textBox3.Text.Trim() + "',NIC='" + textBox4.Text.Trim() + "',Address='" + textBox5.Text.Trim() + "',Tel='" + textBox6.Text.Trim() + "',Mobile='" + textBox7.Text.Trim() + "',Mail='" + textBox8.Text.Trim() + "',Date='" + dateTimePicker1.Value + "',Type= '" + textBox9.Text.Trim() + "', balance='" + textBox1.Text.Trim() + "' WHERE CID='" + comboBox1.Text.Trim() + "' "; dr.Close(); com2.ExecuteNonQuery(); MessageBox.Show("Updated"); } else { MessageBox.Show("Invaid CustomerID", "Error"); } con1.Close(); Customer_Update cu = new Customer_Update(); this.Hide(); cu.Show(); } } }
private void newToolStripButton_Click(object sender, EventArgs e) { Customer_Update cu = new Customer_Update(); cu.Show(); this.Hide(); }
private void button4_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { Customer_Update cu = new Customer_Update(); cu.Show(); } }
private void pictureBox4_Click(object sender, EventArgs e) { Customer_Update cu = new Customer_Update(); cu.Show(); }
private void customerToolStripMenuItem1_Click(object sender, EventArgs e) { Customer_Update cu = new Customer_Update(); cu.Show(); }