Пример #1
0
        private void DeleteState_Click(object sender, EventArgs e)
        {
            var state = new StateOrDistrict(ListState.SelectedItem.ToString(), TableState, ListCountry.SelectedItem.ToString());

            state.Delete(sqlConnection);

            ListState.DataSource = StateOrDistrict.LoadListState(TableState, ListCountry.SelectedItem.ToString(), sqlConnection);
        }
Пример #2
0
        private void DeleteDistrict_Click(object sender, EventArgs e)
        {
            var district = new StateOrDistrict(ListDistrict.SelectedItem.ToString(), TableDistrict, ListState.SelectedItem.ToString());

            district.Delete(sqlConnection);

            ListDistrict.DataSource = StateOrDistrict.LoadListState(TableDistrict, ListState.SelectedItem.ToString(), sqlConnection);
        }
Пример #3
0
        private void AddDistrict_Click(object sender, EventArgs e)
        {
            var district = new StateOrDistrict(InputDistrict.Text, TableDistrict, ListState.SelectedItem.ToString());

            district.Add(sqlConnection);

            ListDistrict.DataSource = StateOrDistrict.LoadListState(TableDistrict, ListState.SelectedItem.ToString(), sqlConnection);
            InputDistrict.Text      = "";
        }
Пример #4
0
        private void AddState_Click(object sender, EventArgs e)
        {
            var state = new StateOrDistrict(InputState.Text, TableState, ListCountry.SelectedItem.ToString());

            state.Add(sqlConnection);

            ListState.DataSource = StateOrDistrict.LoadListState(TableState, ListCountry.SelectedItem.ToString(), sqlConnection);
            InputState.Text      = "";
        }
Пример #5
0
 private void ListState_SelectedValueChanged(object sender, EventArgs e)
 {
     if (ListState.SelectedItem.ToString() == null)
     {
         ListDistrict.DataSource = null;
         ListTown.DataSource     = null;
     }
     else
     {
         ListDistrict.DataSource = StateOrDistrict.LoadListState(TableDistrict, ListState.SelectedItem.ToString(),
                                                                 sqlConnection);
         ListTown.DataSource = Town.LoadListState(ListDistrict.SelectedItem.ToString(), Choice_Type.Text, sqlConnection);
     }
 }
Пример #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Place"].ConnectionString);
            sqlConnection.Open();

            if (sqlConnection.State != ConnectionState.Open)
            {
                throw new InvalidOperationException("Data base isn`t  connected.");
            }

            ListCountry.DataSource  = Country.LoadList(sqlConnection);
            ListState.DataSource    = StateOrDistrict.LoadListState(TableState, ListCountry.Items[0].ToString(), sqlConnection);
            ListDistrict.DataSource = StateOrDistrict.LoadListState(TableDistrict, ListState.Items[0].ToString(), sqlConnection);
            ListTown.DataSource     = Town.LoadListState(ListDistrict.Items[0].ToString(), "все", sqlConnection);

            Choice_Type.Text = "все";
        }