private void GetDataAndFillBanksListView() { UsersInput ui = GetUsersInput(); //List<PublicOrganization> po = dbc.GetOrganizationsFilteredByValues(ui); currOrganizations = dbc.GetOrganizationsFilteredByValues(ui); if (currOrganizations.Count() == 1) { try { int tmp = currOrganizations[0].Title.Length; // MessageBox.Show("in find button try " + tmp); } catch { clearBanksListView(); MessageBox.Show("There no banks with this filters"); return; } } // MessageBox.Show("in find button " + po.Count()); fillBanksListView(GenerateListViewData(currOrganizations)); }
private void SetValuesForComboBoxes(UsersInput ui) { UpdateSortByComboBox(); CurrencyComboBox.Text = ui.FullCurrTitle; CityComboBox.Text = ui.City; OrgTypeComboBox.Text = ui.OrgType; SortByComboBox.Text = ui.SortBy; // MessageBox.Show(ui.SortBy); }
public List <PublicOrganization> GetOrganizationsFilteredByValues(UsersInput ui) { String command = "select * from organization " + "inner join org_type on org_type.org_type_id = organization.org_type_id " + "inner join region on region.region_id = organization.region_id " + "inner join city on city.city_id = organization.city_id " + "inner join currency on currency.org_id = organization.id " + "inner join curr_info on curr_info.eng_title = currency.curr_id "; command += GenerateCommandCondition(ui); // Console.WriteLine("\n\n" + command + "\n\n"); return(GetOrganizations(true, true, command)); }
UsersInput GetUsersInput() { UsersInput res = new UsersInput(); res.Currency = CurrencyComboBox.Text.Split(' ')[0]; res.FullCurrTitle = CurrencyComboBox.Text; res.City = CityComboBox.Text; res.OrgType = OrgTypeComboBox.Text; res.SortBy = SortByComboBox.Text; // MessageBox.Show(res.Currency + " " + res.City + " " + res.SortBy + " " + res.OrgType); return(res); }
private void UpdateButton_Click(object sender, EventArgs e) { UsersInput ui = GetUsersInput(); if (dbc.Update()) { UpdateAllFromDb(); SetValuesForComboBoxes(ui); // MessageBox.Show("setted ui back"); FindOrganizations(); } else { MessageBox.Show("Error! Can not connect to XML source server!\n" + "Check your internet connection or try later"); SetValuesForComboBoxes(ui); } }
public SortHeaders GetNewSortHeaders(UsersInput currUi) { String command = "select * " + "from organization " + "inner join org_type on org_type.org_type_id = organization.org_type_id " + "inner join city on city.city_id = organization.city_id " + "inner join currency on currency.org_id = organization.id " + "inner join curr_info on curr_info.eng_title = currency.curr_id "; command += GenerateCommandCondition(currUi); Console.WriteLine("\n\n" + command + "\n\n"); cmd.CommandText = command; rdr = cmd.ExecuteReader(); SortHeaders sh = new SortHeaders(); SortedSet <String> currencies = new SortedSet <String>(); SortedSet <String> cities = new SortedSet <String>(); SortedSet <String> orgTypes = new SortedSet <String>(); String tmp = ""; while (rdr.Read()) { tmp = rdr["eng_title"] + " " + rdr["rus_title"]; currencies.Add(tmp); // Console.WriteLine(tmp); tmp = rdr["city_title"].ToString(); cities.Add(tmp); // Console.WriteLine(tmp); tmp = rdr["org_type_title"].ToString(); orgTypes.Add(tmp); // Console.WriteLine(tmp); } sh.Currencies = currencies; sh.Cities = cities; sh.OrgTypes = orgTypes; rdr.Close(); return(sh); }
public String GenerateCommandCondition(UsersInput ui) { String command = ""; if (ui.Currency != "All" || ui.City != "All" || ui.OrgType != "All") { command += "WHERE "; } bool first = true; if (ui.Currency != "All") { if (first) { first = false; } else { command += " AND "; } command += "currency.curr_id = '" + ui.Currency + "' "; } if (ui.City != "All") { if (first) { first = false; } else { command += " AND "; } command += "city.city_title = '" + ui.City + "' "; } if (ui.OrgType != "All") { if (first) { first = false; } else { command += "AND "; } command += "org_type.org_type_title = '" + ui.OrgType + "' "; } command += "ORDER BY "; if (ui.SortBy == "Min Purchase") { command += "currency.purchase "; } else if (ui.SortBy == "Max Sale") { command += "currency.sale desc"; } else { command += "organization.id "; } command += ";"; return(command); }
public List <PublicOrganization> GetOrganizationsFilteredByValues(UsersInput ui) { return(db.GetOrganizationsFilteredByValues(ui)); }
public SortHeaders GetNewSortHeaders(UsersInput currUi) { return(db.GetNewSortHeaders(currUi)); }