private void ContactListBox_SelectedIndexChanged(object sender, EventArgs e) { EntityCouplet selectedItem = (EntityCouplet)ContactListBox.SelectedItem; selectedContact = XLMain.Contact.FetchContact(selectedItem.crmID); this.Close(); }
private void Search(string query) { //clear existing entries if any ContactListBox.Items.Clear(); //start a new search string searchStr = SearchTB.Text; ContactListBox.Items.Clear(); ContactListBox.DisplayMember = "Name"; ContactListBox.ValueMember = "crmid"; SqlDataReader xlReader = null; xlReader = XLSQL.ReaderQuery(query); if (xlReader.HasRows) { while (xlReader.Read()) { EntityCouplet newEntity = new EntityCouplet(); newEntity.crmID = xlReader.NiceString("CRMId"); newEntity.name = xlReader.NiceString("display"); ContactListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } }
private void Search(string query = "") { //clear entries if any ClientListBox.Items.Clear(); //Then start a fresh search string searchStr = SearchTB.Text; Boolean IncLost = IncLostCheck.Checked; ClientListBox.DisplayMember = "Name"; ClientListBox.ValueMember = "crmid"; SqlDataReader xlReader = null; if (query == "") { query = "Select clientcode + ' - ' + name, crmID from Client where ((ClientCode like '%" + searchStr + "%') Or (Name Like '%" + searchStr + "%'))"; if (!IncLost) { query += " and status in ('New', 'Active')"; } query += " order by name"; } xlReader = XLSQL.ReaderQuery(query); if (xlReader == null) { MessageBox.Show("Unable to connect to database."); } else { if (xlReader.HasRows) { while (xlReader.Read()) { EntityCouplet newEntity = new EntityCouplet(); newEntity.crmID = xlReader.NiceString("CRMId"); newEntity.name = xlReader.NiceString("Name"); ClientListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } } }
public static List <EntityCouplet> AllStaff() { try { List <EntityCouplet> staff = new List <EntityCouplet>(); DataTable xlReader = XLSQL.ReturnTable("SELECT fullname, crmid from VCStaffView order by fullname"); if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { EntityCouplet tempStaff = new EntityCouplet(); tempStaff.crmID = row["crmid"].ToString(); tempStaff.name = row["fullname"].ToString(); staff.Add(tempStaff); } } return(staff); } catch (Exception ex) { XLtools.LogException("XLMain-Allstaff", ex.ToString()); return(null); } }