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"; DataTable xlReader = null; xlReader = XLSQL.ReturnTable(query); if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { XLMain.EntityCouplet newEntity = new XLMain.EntityCouplet(); newEntity.crmID = row["CRMId"].ToString(); newEntity.name = row["display"].ToString(); ContactListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } }
private void Search(string query = "", string param1 = null, string param2 = null) { //clear existing entries if any ClientListBox.Items.Clear(); //start a new search string searchStr = SearchTB.Text; Boolean IncLost = IncLostCheck.Checked; ClientListBox.DisplayMember = "Name"; ClientListBox.ValueMember = "crmid"; DataTable xlReader = null; if (query == "") { query = "Select clientcode + ' - ' + name as Name, crmID from Client where ((ClientCode like '%' + @param1 + '%') Or (Name Like '%' + @param1 + '%'))"; param1 = searchStr; if (!IncLost) { query += " and status in ('New', 'Active')"; } query += " order by name"; } xlReader = XLSQL.ReturnTable(query, param1, param2); if (xlReader != null) { if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { XLMain.EntityCouplet newEntity = new XLMain.EntityCouplet(); newEntity.crmID = row["Crmid"].ToString(); newEntity.name = row["name"].ToString(); ClientListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } } else { MessageBox.Show("Unable to connect to the database."); } }
private int CheckToDos(string name) { try { int noOfItems; //Run query against database //select * index01 from indextable where index05=name List <string> newToDos = new List <string>(); string str = "select fileid from VCFileIndexView where index" + toBeIndex + " ='" + user.name + "'"; DataTable xlReader = XLSQL.ReturnTable(str); if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { newToDos.Add(row["fileID"].ToString()); } } //compare list List <string> newItems = null; //handle there being nothing on the first run if (toDos == null) { newItems = newToDos; } else { newItems = newToDos.Except(toDos).ToList(); } noOfItems = newItems.Count(); //then set the todos to your new list for the next comparison toDos = newToDos; return(noOfItems); } catch (Exception e) { XLtools.LogException("XLant Monitor", e.ToString()); return(0); } }
private void Search(string query = "", string param1 = null, string param2 = null) { //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"; DataTable xlReader = null; if (query == "") { query = "select Fullname + ' - ' + Case when ISNULL(Organisations.Name,'') = '' then ISNULL(Occupation,'') else Organisations.Name end as display, contact.CRMid from Contact left outer join organisations on contact.organisationid=organisations.crmid where ((Fullname like '%' + @param1 + '%') or (Name like '%' + @param1 + '%')) order by last_name"; param1 = searchStr; } xlReader = XLSQL.ReturnTable(query, param1, param2); if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { XLMain.EntityCouplet newEntity = new XLMain.EntityCouplet(); newEntity.crmID = row["CRMId"].ToString(); newEntity.name = row["display"].ToString(); ContactListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } }
private void Search(string query = "", string param1 = null, string param2 = null) { //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"; DataTable xlReader = null; if (query == "") { query = "select Fullname + ' - ' + Department as display, CRMid from Staff where (Fullname like '%' + @param1 + '%') order by surname"; param1 = searchStr; } xlReader = XLSQL.ReturnTable(query, param1, param2); if (xlReader.Rows.Count != 0) { foreach (DataRow row in xlReader.Rows) { XLMain.EntityCouplet newEntity = new XLMain.EntityCouplet(); newEntity.crmID = row["CRMId"].ToString(); newEntity.name = row["display"].ToString(); ContactListBox.Items.Add(newEntity); } } else { MessageBox.Show("No Records found"); } }
private void OKBtn_Click(object sender, EventArgs e) { ReturnedTable = XLSQL.ReturnTable("Select * from Excel_" + Requested + "_" + ViewDDL.SelectedValue); this.Close(); }
private System.Data.DataTable GetViews(string requested) { System.Data.DataTable table = XLSQL.ReturnTable("SELECT Substring(name, 10, LEN(name)-6) AS name FROM sys.views where name like 'Excel_" + requested + "_%'"); return(table); }