Exemple #1
0
        private void listViewCities_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonApply.Enabled  = true;
            buttonDelete.Enabled = true;

            textBoxCity.Enabled = true;

            bNew = false;

            if (listViewCities.FocusedItem == null)
            {
                return;
            }

            int k = queueCities.Count;

            for (int i = 0; i < k; i++)
            {
                m_cities = (_Cities)queueCities.Dequeue();
                if (m_cities.id == (string)listViewCities.Items[listViewCities.FocusedItem.Index].Tag)
                {
                    textBoxCity.Text = m_cities.name;

                    queueCities.Enqueue(m_cities);

                    break;
                }
                ;

                queueCities.Enqueue(m_cities);
            }
        }
Exemple #2
0
        public void refreshCities()
        {
            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string           sql       = "SELECT `city_id`, `name` FROM `city` ORDER BY `name`";
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewCities.Items.Clear();
                queueCities.Clear();
                _Cities t = new _Cities();

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["city_id"].ToString().Trim());
                    t.id = dataRow["city_id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["name"].ToString().Trim());
                    t.name = dataRow["name"].ToString().Trim();


                    listViewCities.Items.Add(item1);
                    listViewCities.Items[listViewCities.Items.Count - 1].Tag = dataRow["city_id"].ToString();
                    queueCities.Enqueue(t);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }
        }
Exemple #3
0
        private void listViewCities_SelectedIndexChanged(object sender, EventArgs e)
        {
            buttonApply.Enabled = true;
            buttonDelete.Enabled = true;

            textBoxCity.Enabled = true;

            bNew = false;

            if (listViewCities.FocusedItem == null)
                return;

            int k = queueCities.Count;
            for (int i = 0; i < k; i++)
            {
                m_cities = (_Cities)queueCities.Dequeue();
                if (m_cities.id == (string)listViewCities.Items[listViewCities.FocusedItem.Index].Tag)
                {
                    textBoxCity.Text = m_cities.name;

                    queueCities.Enqueue(m_cities);

                    break;
                };

                queueCities.Enqueue(m_cities);
            }
        }
Exemple #4
0
        public void refreshCities()
        {
            try
            {
                mainWin.m_dbConnector.Lock();
                MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection();

                string sql = "SELECT `city_id`, `name` FROM `city` ORDER BY `name`";
                MySqlDataAdapter myAdapter = new MySqlDataAdapter();
                myAdapter.SelectCommand = new MySqlCommand(sql, conn);
                DataSet dataSet = new DataSet();
                myAdapter.Fill(dataSet);
                DataTable dataTable = dataSet.Tables[0];

                listViewCities.Items.Clear();
                queueCities.Clear();
                _Cities t = new _Cities();

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    ListViewItem item1 = new ListViewItem(dataRow["city_id"].ToString().Trim());
                    t.id = dataRow["city_id"].ToString().Trim();
                    item1.SubItems.Add(dataRow["name"].ToString().Trim());
                    t.name = dataRow["name"].ToString().Trim();

                    listViewCities.Items.Add(item1);
                    listViewCities.Items[listViewCities.Items.Count - 1].Tag = dataRow["city_id"].ToString();
                    queueCities.Enqueue(t);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                mainWin.m_dbConnector.Unlock();
            }
        }