private void LST_GUEST_LIST_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if (LST_GUEST_LIST.Items[0].Selected == true) { TXT_NIC_NO.Focus(); } } if (e.KeyCode == Keys.Enter) { GUEST_F_NAME = LST_GUEST_LIST.SelectedItems[0].SubItems[1].Text; GUEST_L_NAME = LST_GUEST_LIST.SelectedItems[0].SubItems[2].Text; MOBILE = LST_GUEST_LIST.SelectedItems[0].SubItems[3].Text; GENDER = LST_GUEST_LIST.SelectedItems[0].SubItems[4].Text; PASSPORT_NO = LST_GUEST_LIST.SelectedItems[0].SubItems[5].Text; ADDRESSS = LST_GUEST_LIST.SelectedItems[0].SubItems[6].Text; EMAIL = LST_GUEST_LIST.SelectedItems[0].SubItems[7].Text; COUNTRY = LST_GUEST_LIST.SelectedItems[0].SubItems[8].Text; GUEST_ID = LST_GUEST_LIST.SelectedItems[0].SubItems[9].Text; TXT_NIC_NO.Text = LST_GUEST_LIST.SelectedItems[0].SubItems[0].Text; TXT_F_NAME.Text = GUEST_F_NAME; TXT_L_NAME.Text = GUEST_L_NAME; TXT_EMAIL.Text = EMAIL; TXT_TEL.Text = MOBILE; TXT_F_NAME.Enabled = false; TXT_L_NAME.Enabled = false; TXT_TEL.Enabled = false; TXT_EMAIL.Enabled = false; LST_GUEST_LIST.Hide(); TXT_ADULT.Focus(); } }
private void TXT_NIC_NO_TextChanged(object sender, EventArgs e) { if (TXT_NIC_NO.Text.Length > 1) { LOAD_GUESTS_TO_LISTVIEW(); } else { LST_GUEST_LIST.Hide(); } }
private void LOAD_GUESTS_TO_LISTVIEW() { try { CONNECTION.open_connection(); using (MySqlDataAdapter DA = new MySqlDataAdapter("SELECT id_no,first_name,last_name,mobile_no,gender,passport_no,address,email,country.country_name,guest_id FROM guest INNER JOIN country ON (country.id=guest.country_id) WHERE id_no LIKE @id_no", CONNECTION.CON)) { DA.SelectCommand.Parameters.Clear(); DA.SelectCommand.Parameters.AddWithValue("@id_no", "%" + TXT_NIC_NO.Text + "%"); DataTable DT = new DataTable(); DA.Fill(DT); if (DT.Rows.Count > 0) { LST_GUEST_LIST.Items.Clear(); foreach (DataRow DR in DT.Rows) { ListViewItem LST = new ListViewItem(DR.Field <string>(0)); { LST.SubItems.Add(DR.Field <string>(1)); LST.SubItems.Add(DR.Field <string>(2)); LST.SubItems.Add(DR.Field <string>(3)); LST.SubItems.Add(DR.Field <string>(4)); LST.SubItems.Add(DR.Field <string>(5)); LST.SubItems.Add(DR.Field <string>(6)); LST.SubItems.Add(DR.Field <string>(7)); LST.SubItems.Add(DR.Field <string>(8)); LST.SubItems.Add(DR.Field <string>(9)); } LST_GUEST_LIST.Items.Add(LST); } LST_GUEST_LIST.Size = new Size(493, 221); LST_GUEST_LIST.Show(); } else { LST_GUEST_LIST.Hide(); } } } catch (Exception EX) { MSGBOX mdg = new MSGBOX(MessageAlertHeder.Error(), EX.Message, MessageAlertImage.Error()); mdg.ShowDialog(); } }