private void btnAddBattalion_Click(object sender, RoutedEventArgs e)
        {
            if (lbMilitaryUnit.SelectedItem != null)
            {
                int     idMilitaryUnit = (lbMilitaryUnit.SelectedItem as MilitaryUnit).Id;
                SubUnit s = addSubUnit.getNewSubUnit(idMilitaryUnit, -1);
                if (s != null)
                {
                    if (bList == null)
                    {
                        bList = new SubUnitList();
                    }

                    int id = sqlWorker.getNewId("SubUnit");
                    s.Id = id;
                    if (sqlWorker.addSubUnit(id, s))
                    {
                        bList.values.Add(s);
                    }
                    else
                    {
                        MessageBox.Show("Ошибка при добавлении элемента");
                    }
                }
            }
        }
示例#2
0
 private void cbBattalion_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbBattalion.SelectedItem != null)
     {
         subUnitList = new SubUnitList(
             DataWorker.getSubUnitList(
                 sqlWorker.selectData("SELECT * FROM SubUnit WHERE idFKSubUnit = " +
                                      (cbBattalion.SelectedItem as SubUnit).Id +
                                      " ORDER BY name")));
         cbSubUnit.ItemsSource = subUnitList.values;
         if (subUnitList != null && subUnitList.values.Count != 0)
         {
             cbSubUnit.IsEnabled = true;
             if (rowSubUnit.Height.Value == 0)
             {
                 rowSubUnit.Height = new GridLength(30);
                 this.Height      += 30;
             }
         }
         else
         {
             cbSubUnit.IsEnabled = false;
             if (rowSubUnit.Height.Value > 0)
             {
                 rowSubUnit.Height = new GridLength(0);
                 this.Height      -= 30;
             }
         }
     }
 }
 private void lbBattalion_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lbBattalion.SelectedItem != null)
     {
         int idSubUnit = (lbBattalion.SelectedItem as SubUnit).Id;
         sList = new SubUnitList(DataWorker.getSubUnitList(sqlWorker.selectData("SELECT * FROM SubUnit WHERE idFKSubUnit = " + idSubUnit + " ORDER BY name")));
         lbSubUnit.ItemsSource = sList.values;
     }
 }
 private void lbMilitaryUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sList != null)
     {
         sList.values.Clear();
     }
     if (lbMilitaryUnit.SelectedItem != null)
     {
         int idMilitaryUnit = (lbMilitaryUnit.SelectedItem as MilitaryUnit).Id;
         bList = new SubUnitList(DataWorker.getSubUnitList(sqlWorker.selectData("SELECT * FROM SubUnit WHERE idMilitaryUnit = " + idMilitaryUnit + " ORDER BY name")));
         lbBattalion.ItemsSource = bList.values;
     }
 }
示例#5
0
        private void btnEditStructure_Click(object sender, RoutedEventArgs e)
        {
            MilitaryUnitList mList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));
            EditStructure    wE    = new EditStructure(sqlWorker, mList);

            wE.ShowDialog();

            militaryList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));
            cbMilitaryUnit.Items.Refresh();
            cbSubUnit.Items.Refresh();

            battalionList           = new SubUnitList(DataWorker.getSubUnitList(sqlWorker.selectData("SELECT * FROM SubUnit WHERE idMilitaryUnit = " + (cbMilitaryUnit.SelectedItem as MilitaryUnit).Id)));
            cbBattalion.ItemsSource = battalionList.values;
        }
示例#6
0
        private void cbMilitaryUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            cbSubUnit.IsEnabled = false;
            if (rowSubUnit.Height.Value > 0)
            {
                rowSubUnit.Height = new GridLength(0);
                this.Height      -= 30;
            }
            if (subUnitList != null)
            {
                subUnitList.values.Clear();
            }

            battalionList = new SubUnitList(
                DataWorker.getSubUnitList(
                    sqlWorker.selectData("SELECT * FROM SubUnit WHERE idMilitaryUnit = " +
                                         (cbMilitaryUnit.SelectedItem as MilitaryUnit).Id +
                                         " ORDER BY name")));
            cbBattalion.ItemsSource    = battalionList.values;
            cbBattalion.IsEnabled      = true;
            btnEditStructure.IsEnabled = true;
        }