public void Init() { college.Items.Clear(); college.Items.Add("Please Select College Code"); college.SelectedIndex = 0; var rdx = SqlUtils.ExecuteQueryReader("select college_code from college", false); while (rdx.Read()) { college.Items.Add(rdx.GetString(0)); } AttendeeNames.Clear(); AttendeeNames.AddItem("Select Name of Attendee"); AttendeeNames.selectedIndex = 0; var rdy = SqlUtils.ExecuteQueryReader("select attendee_id,attendee_fullname from attendee where eventid=" + UserInfo.EventId, false); while (rdy.Read()) { //AttendeeNames.AddItem((string)rdy["attendee_fullname"]); NameLists.Add((string)rdy["attendee_fullname"]); IdLists.Add((int)rdy["attendee_id"]); } int idCounter = 0; foreach (var name in NameLists) { var data = IdLists[idCounter].ToString() + ':' + name; AttendeeNames.AddItem(data); Mixed.Add(data); idCounter += 1; } }
private void RemoveLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (AttendeeNames.selectedIndex != 0) { var result = MessageBox.Show("This cannot be undone, remove it permanently to the attendees ?", "Alert", MessageBoxButtons.OKCancel); if (result.Equals(DialogResult.OK)) { SqlUtils.ExecuteQuery("delete from attendee where attendee_id=" + UniversalAttendeeId, false); AttendeeNames.RemoveAt(AttendeeNames.selectedIndex); AttendeeNames.selectedIndex = 0; } } }
//int UpdateId = 0; // Fix tommorrow Implement to all Universe // Fix Update info via on key up searchbar private void SearchBar_KeyUp(object sender, KeyEventArgs e) { var pattern = new Regex(SearchBar.Text.ToLower()); AttendeeNames.Clear(); AttendeeNames.AddItem("Select Name of Attendee"); if (SearchBar.Text.Trim().Length > 0) { int result = 0; foreach (string mix in Mixed) { if (pattern.IsMatch(mix.ToLower())) { AttendeeNames.AddItem(mix); //NameLists.IndexOf(name); //AttendeeNames.AddItem(name); result += 1; } } if (result <= 0) { AttendeeNames.Clear(); AttendeeNames.AddItem("No Result Found"); } AttendeeNames.selectedIndex = 0; } else { AttendeeNames.selectedIndex = 0; int z = 0; foreach (var mix in Mixed) { AttendeeNames.AddItem(mix); z += 1; } } }