private void textbox_Members_Id_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (textbox_Members_Id.Text != "") { try { Id = textbox_Members_Id.Text; int id = int.Parse(textbox_Members_Id.Text); DB_Connection dB_Connection = new DB_Connection(); SqlConnection con = new SqlConnection(dB_Connection.connectionstring); con.Open(); string qry = "SELECT * FROM Members Where Id=@Id "; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@Id", id); SqlDataReader da = dB_Connection.getDatausing_a(cmd); if (da.HasRows) { while (da.Read()) { textBoxNIC.Text = da.GetValue(1).ToString(); textboxName.Text = da.GetValue(2).ToString(); textboxGender.Text = da.GetValue(4).ToString(); textboxBodyType.Text = da.GetValue(5).ToString(); richTextBoxAddress.Text = da.GetValue(6).ToString(); textboxMobileNumber.Text = da.GetValue(7).ToString(); richTextBoxHealthCondition.Text = da.GetValue(8).ToString(); textboxEmergencyContactName.Text = da.GetValue(9).ToString(); textboxEmergencyContactPhoneNumber.Text = da.GetValue(10).ToString(); pictureBox1.Image = new Bitmap(da.GetValue(11).ToString()); Member_dp_path = da.GetValue(11).ToString(); memEmail_tb.Text = da.GetValue(12).ToString(); } con.Close(); } else { MessageBox.Show("There is no member by member id:" + id + "\nTry again with another Id"); } } catch (SqlException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (memberid_tb.Text != "") { try { int id = int.Parse(memberid_tb.Text); DB_Connection dB_Connection = new DB_Connection(); SqlConnection con = new SqlConnection(dB_Connection.connectionstring); con.Open(); string qry = "SELECT * FROM Members Where Id=@Id "; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@Id", id); SqlDataReader da = dB_Connection.getDatausing_a(cmd); if (da.HasRows) { while (da.Read()) { lbl_mname.Text = da.GetValue(2).ToString(); lbl_package_name.Text = da.GetValue(15).ToString(); string qrypack = "Select * From Packages where Package_Name='" + lbl_package_name.Text + "'"; DB_Connection dB_Connection1 = new DB_Connection(); SqlDataReader da2 = dB_Connection1.getData(qrypack); da2.Read(); lbl_fee.Text = da2["Fee"].ToString(); } con.Close(); } else { MessageBox.Show("There is no Staff Member by member id:" + id + "\nTry again with another Id"); } } catch (SqlException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
private void textbox_Members_Id_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (textbox_Staff_Members_Id.Text != "") { try { Id = textbox_Staff_Members_Id.Text; int id = int.Parse(textbox_Staff_Members_Id.Text); DB_Connection dB_Connection = new DB_Connection(); SqlConnection con = new SqlConnection(dB_Connection.connectionstring); con.Open(); string qry = "SELECT * FROM Staff_Member Where Id=@Id "; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@Id", id); SqlDataReader da = dB_Connection.getDatausing_a(cmd); if (da.HasRows) { while (da.Read()) { textBoxNIC.Text = da.GetValue(3).ToString(); textboxName.Text = da.GetValue(4).ToString(); textboxJobType.Text = da.GetValue(5).ToString(); txt_boxProQuli.Text = da.GetValue(6).ToString(); txt_boxAddressLivg.Text = da.GetValue(9).ToString(); txt_boxPN_private.Text = da.GetValue(10).ToString(); txt_boxPubN.Text = da.GetValue(11).ToString(); home_Address_tb.Text = da.GetValue(12).ToString(); txt_boxEmergencyContactNme.Text = da.GetValue(13).ToString(); txt_boxEmergencyContactPNo.Text = da.GetValue(14).ToString(); txt_boxMail.Text = da.GetValue(15).ToString(); mail_db = da.GetValue(15).ToString(); txt_boxGender.Text = da.GetValue(16).ToString(); if (da.GetValue(1).ToString() != "") { pictureBox1.Image = new Bitmap(da.GetValue(1).ToString()); Staff_Member_dp_path = da.GetValue(1).ToString(); } } con.Close(); } else { MessageBox.Show("There is no Staff Member by member id:" + id + "\nTry again with another Id"); } } catch (SqlException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
private void txtmodeid_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtmodeid.Text != "") { try { equipId = txtmodeid.Text; int id = int.Parse(txtmodeid.Text); DB_Connection dB_Connection = new DB_Connection(); SqlConnection con = new SqlConnection(dB_Connection.connectionstring); con.Open(); string qry = "SELECT * FROM Equipment Where Equip_ID=@Id "; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@Id", id); SqlDataReader da = dB_Connection.getDatausing_a(cmd); if (da.HasRows) { while (da.Read()) { txtmodename.Text = da.GetValue(1).ToString(); txtmodetype.Text = da.GetValue(2).ToString(); txtmodeamount.Text = da.GetValue(3).ToString(); if (da.GetValue(5).ToString() != null) { picbmodequip1.Image = new Bitmap(da.GetValue(5).ToString()); equip_imgpath1 = da.GetValue(5).ToString(); } if (da.GetValue(6).ToString() != null) { picbmodequip2.Image = new Bitmap(da.GetValue(6).ToString()); equip_imgpath2 = da.GetValue(6).ToString(); } if (da.GetValue(7).ToString() != null) { picbmodequip3.Image = new Bitmap(da.GetValue(7).ToString()); equip_imgpath3 = da.GetValue(7).ToString(); } if (da.GetValue(8).ToString() != null) { picbmodequip4.Image = new Bitmap(da.GetValue(8).ToString()); equip_imgpath4 = da.GetValue(8).ToString(); } } con.Close(); } else { MessageBox.Show("There is no Equipment by id:" + id + "\nTry again with another Id"); } } catch (SqlException ex) { MessageBox.Show(ex.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }