private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text.ToString() != "") { var dadata = new SuggestClientDadata(); array = dadata.SuggestAddress(textBox1.Text.ToString()).ToArray(); listBox1.Items.Clear(); listBox1.Visible = true; for (int i = 0; i < array.Count(); i++) { listBox1.Items.Add(array[i].value); } } }
public static DataSet findKladr(string data) { string query = ""; string response = ""; DataSet dsobjects = new DataSet(); string sConnectionString = "Data Source=ТИНА-ПК\\SQLEXPRESS;Initial Catalog=realton;Integrated Security=True"; SqlConnection objConn = new SqlConnection(sConnectionString); objConn.Open(); var suggests = new SuggestClientDadata(); var address = suggests.SuggestAddress(data).ToArray(); if (address[0].data.street != null) { response = address[0].data.street_kladr_id; query = "select distinct addressId from Objects left join Adresses on Adresses.id = addressId left join Streets on Streets.id = streetId where street_kladr_id ='" + response + "'"; } else if (address[0].data.settlement != null) { response = address[0].data.settlement_kladr_id; query = "select distinct Adresses.id from Adresses left join Settlements on Settlements.id = settlementId where settlement_kladr_id ='" + response + "'"; } else if (address[0].data.city != null) { response = address[0].data.city_kladr_id; query = "select distinct Adresses.id from Adresses left join Cities on Cities.id = cityId where city_kladr_id = '" + response + "'"; } if (response != "" && query != "") { SqlDataAdapter array = new SqlDataAdapter(query, objConn); array.Fill(dsobjects, "Obj"); } objConn.Close(); return(dsobjects); }
private void constructQuery() { List<string> params_f = new List<string>(); if (Renovation.CheckedIndices.Count > 0) params_f.Add("renovation in(" + string.Join(",", Renovation.CheckedIndices.Cast<int>().ToArray().Select((x => x + 1))) + ")"); if (Status.CheckedIndices.Count > 0) params_f.Add("Objects.status in(" + string.Join(",", Status.CheckedIndices.Cast<int>().ToArray().Select((x => x + 1))) + ")"); if (Otype.CheckedIndices.Count > 0) params_f.Add("Objects.type in(" + string.Join(",", Otype.CheckedIndices.Cast<int>().ToArray().Select((x => x + 1))) + ")"); if (Wall.CheckedIndices.Count > 0) params_f.Add("Objects.wall in(" + string.Join(",", Wall.CheckedIndices.Cast<int>().ToArray().Select((x => x + 1))) + ")"); if (Rooms.CheckedIndices.Count > 0) params_f.Add("Objects.rooms in(" + string.Join(",", Rooms.CheckedIndices.Cast<int>().ToArray().Select((x => x + 1))) + ")"); if(textBox2.Text !="") params_f.Add("Objects.area < "+ textBox2.Text); if (textBox3.Text != "") params_f.Add("Objects.area > " + textBox3.Text); if(numericUpDown1.Value !=0) params_f.Add("Objects.floor = " + numericUpDown1.Value); if (numericUpDown2.Value != 0) params_f.Add("Objects.floors =" + numericUpDown1.Value); if (textBox1.Text != "") { DataTable addresses= SuggestClientDadata.findKladr(textBox1.Text).Tables[0]; params_f.Add("Objects.addressId in( " +string.Join(",", addresses.Rows.Cast<DataRow>().ToArray().Select( x=>x[0].ToString())) +")"); } filtr = "where " + string.Join(" and ", params_f.ToArray()) +" and tickets.type =1"; // richTextBox1.Text = filtr; }