Ejemplo n.º 1
0
        private void editStructureUnit_Click(object sender, RoutedEventArgs e)
        {
            MilitaryUnitList mList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));
            EditStructure    wE    = new EditStructure(sqlWorker, mList);

            wE.ShowDialog();
        }
Ejemplo n.º 2
0
        public AddAccomplice(SqliteWorker _sqlWorker)
        {
            InitializeComponent();
            this.ResizeMode = ResizeMode.CanMinimize;

            sqlWorker = _sqlWorker;

            postList         = new DBList("Post", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Post ORDER BY description")));
            draftList        = new DBList("Draft", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Draft ORDER BY description")));
            educationList    = new DBList("Education", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Education ORDER BY description")));
            familyStatusList = new DBList("FamilyStatus", DataWorker.getList(sqlWorker.selectData("SELECT * FROM FamilyStatus ORDER BY description")));

            rankList     = new RankList(DataWorker.getRankList(sqlWorker.selectData("SELECT * FROM Rank ORDER BY priority")));
            militaryList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));

            cbPost.ItemsSource         = postList.values;
            cbDraft.ItemsSource        = draftList.values;
            cbEducation.ItemsSource    = educationList.values;
            cbFamilyStatus.ItemsSource = familyStatusList.values;

            cbRank.ItemsSource         = rankList.values;
            cbMilitaryUnit.ItemsSource = militaryList.values;

            rowSubUnit.Height  = new GridLength(0);
            rowContrakt.Height = new GridLength(0);
            this.Height       -= 150;
        }
        public EditStructure(SqliteWorker _sqlWorker, MilitaryUnitList _mList)
        {
            InitializeComponent();

            sqlWorker = _sqlWorker;
            mList     = _mList;

            lbMilitaryUnit.ItemsSource = mList.values;
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            PleaseWait wndP = new PleaseWait();

            wndP.Show();

            InitializeComponent();

            dpLeft.Text  = "01.01." + DateTime.Now.ToString("yyyy");
            dpRight.Text = DateTime.Now.ToString("dd.MM.yyyy");

            crimes = new ObservableCollection <Crime>();
            try
            {
                sqlWorker = new SqliteWorker("CrimesAndIncidents");


                //изменение формата дат, оставлю, вдруг понадобится
                //for (int i = 0; i < crimes.Count; i++)
                //{
                //    sqlWorker.executeQuery("UPDATE Crime SET " +
                //        "dateRegistration = " + (crimes[i].DateRegistration == "" ? "NULL, " : "'" +crimes[i].DateRegistration + "', ") +
                //        "dateInstitution = " + (crimes[i].DateInstitution == "" ? "NULL, " : "'" + crimes[i].DateInstitution + "', ") +
                //        "dateCommit = " + (crimes[i].DateCommit == "" ? "NULL, " : "'" + crimes[i].DateCommit + "' ") +
                //        "WHERE idCrime = " + crimes[i].Id);
                //}
                coll = new CollectionViewSource();


                btnOk_Click_1(null, null);

                crimesDataGrid.CanUserAddRows = false;

                rowFilter.Height = new GridLength(0);

                cbRegistred.SelectedIndex = 1;

                mList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));
                mList.values.Add(new MilitaryUnit(-1, "", "все", "все", "", 0, 1));

                cbFilterMilitaryUnit.ItemsSource   = mList.values;
                cbFilterMilitaryUnit.SelectedIndex = mList.values.Count - 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Во время загрузки приложения возникли неполадки:\n" + ex.Message);
            }

            wndP.Close();
        }
Ejemplo n.º 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;
        }
        private void btnAddMilitaryUnit_Click(object sender, RoutedEventArgs e)
        {
            MilitaryUnit m = addMilitaryUnit.getNewMilitaryUnit();

            if (m != null)
            {
                if (mList == null)
                {
                    mList = new MilitaryUnitList();
                }

                int id = sqlWorker.getNewId("MilitaryUnit");
                m.Id = id;
                if (sqlWorker.addMilitaryUnit(id, m))
                {
                    mList.values.Add(m);
                }
                else
                {
                    MessageBox.Show("Ошибка при добавлении элемента");
                }
            }
        }
Ejemplo n.º 7
0
        public AddCrime(SqliteWorker _sqlWorker, Crime _c = null)
        {
            InitializeComponent();

            sqlWorker = _sqlWorker;

            organList    = new DBList("Organ", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Organ ORDER BY description")));
            categoryList = new DBList("Category", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Category ORDER BY description")));
            militaryList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));
            clauseList   = new ClauseList(DataWorker.getClauseList(sqlWorker.selectData("SELECT * FROM Clause ORDER BY number, part, point")));

            cbOrgan.ItemsSource        = organList.values;
            cbMilitaryUnit.ItemsSource = militaryList.values;
            cbClause.ItemsSource       = clauseList.values;
            lbCategoty.ItemsSource     = categoryList.values;

            if (_c != null)
            {
                isEditing = true;

                c                       = _c;
                txDamage.Text           = c.Damage;
                txDateCommit.Text       = c.DateCommit;
                txDateInstitution.Text  = c.DateInstitution;
                txDateRegistration.Text = c.DateRegistration;
                txDateVerdict.Text      = c.DateVerdict;
                txnumberCase.Text       = c.NumberCase;
                txStory.Text            = c.Story;
                txVerdict.Text          = c.Verdict;

                //если происшествие
                if (c.Clause == "")
                {
                    rbIncident.IsChecked = true;
                }

                chkIsRegistred.IsChecked = c.IsRegistred;

                for (int i = 0; i < cbOrgan.Items.Count; i++)
                {
                    if ((cbOrgan.Items[i] as KeyValue).Key == c.IdOrgan)
                    {
                        cbOrgan.SelectedIndex = i;
                    }
                }

                for (int i = 0; i < cbClause.Items.Count; i++)
                {
                    if ((cbClause.Items[i] as Clause).Id == c.IdClause)
                    {
                        cbClause.SelectedIndex = i;
                    }
                }

                for (int i = 0; i < cbMilitaryUnit.Items.Count; i++)
                {
                    if ((cbMilitaryUnit.Items[i] as MilitaryUnit).Id == c.IdMilitaryUnit)
                    {
                        cbMilitaryUnit.SelectedIndex = i;
                    }
                }

                accompliceList = new AccompliceList(
                    DataWorker.getAccompliceList(
                        sqlWorker.selectData("SELECT R.shortName as rank, S.shortName as subUnit, SF.shortName as battalion, M.shortName as militaryUnit, A.*, R.priority " +
                                             "FROM Accomplice A " +
                                             "INNER JOIN SubUnit S ON S.idSubUnit = A.idSubUnit " +
                                             "INNER JOIN Portaking P ON P.idAccomplice = A.idAccomplice " +
                                             "LEFT JOIN Rank R ON R.idRank = A.idRank " +
                                             "LEFT JOIN SubUnit SF ON S.idFKSubUnit = SF.idSubUnit " +
                                             "LEFT JOIN MilitaryUnit M ON M.idMilitaryUnit = S.idMilitaryUnit OR M.idMilitaryUnit = SF.idMilitaryUnit " +
                                             "WHERE P.idCrime = " + c.Id)));

                lbAccomplice.ItemsSource = accompliceList.values;

                //categoryList
                DBList categoryUsed = new DBList("", DataWorker.getList(sqlWorker.selectData("SELECT * FROM InCategory WHERE idCrime = " + c.Id + ";")));
                for (int i = 0; i < categoryUsed.values.Count; i++)
                {
                    for (int j = 0; j < categoryList.values.Count; j++)
                    {
                        if (categoryUsed.values[i].Key == categoryList.values[j].Key)
                        {
                            categoryList.values[j].IsCheked = true;
                        }
                    }
                }
            }
            else
            {
                chkIsRegistred.IsChecked = true;
            }
        }
Ejemplo n.º 8
0
        public AddAccomplice(Accomplice accomplice, SqliteWorker _sqlWorker)
        {
            InitializeComponent();
            this.ResizeMode = ResizeMode.CanMinimize;

            sqlWorker = _sqlWorker;

            postList         = new DBList("Post", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Post")));
            draftList        = new DBList("Draft", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Draft")));
            educationList    = new DBList("Education", DataWorker.getList(sqlWorker.selectData("SELECT * FROM Education")));
            familyStatusList = new DBList("FamilyStatus", DataWorker.getList(sqlWorker.selectData("SELECT * FROM FamilyStatus")));

            rankList     = new RankList(DataWorker.getRankList(sqlWorker.selectData("SELECT * FROM Rank")));
            militaryList = new MilitaryUnitList(DataWorker.getMilitaryUnitList(sqlWorker.selectData("SELECT * FROM MilitaryUnit")));

            cbPost.ItemsSource         = postList.values;
            cbDraft.ItemsSource        = draftList.values;
            cbEducation.ItemsSource    = educationList.values;
            cbFamilyStatus.ItemsSource = familyStatusList.values;

            cbRank.ItemsSource         = rankList.values;
            cbMilitaryUnit.ItemsSource = militaryList.values;

            rowSubUnit.Height  = new GridLength(0);
            rowContrakt.Height = new GridLength(0);
            this.Height       -= 150;

            txFullName.Text          = accomplice.FullName;
            txName.Text              = accomplice.ShortName;
            txNumberContrakt.Text    = (accomplice.NumberContrakt == 0 ? "" : accomplice.NumberContrakt.ToString());
            txDateOfBirthday.Text    = accomplice.DateOfBirth;
            txDateFirstContrakt.Text = accomplice.DateOfFirstContrakt;
            txDateLastContrakt.Text  = accomplice.DateOfLastContrakt;

            chkbContrakt.IsChecked = accomplice.IsContrakt;
            chkbMedic.IsChecked    = accomplice.IsMedic;

            rSex.IsChecked = accomplice.Sex;
            fSex.IsChecked = !accomplice.Sex;

            for (int i = 0; i < cbPost.Items.Count; i++)
            {
                if ((cbPost.Items[i] as KeyValue).Key == accomplice.IdPost)
                {
                    cbPost.SelectedIndex = i;
                }
            }

            for (int i = 0; i < cbDraft.Items.Count; i++)
            {
                if ((cbDraft.Items[i] as KeyValue).Key == accomplice.IdDraft)
                {
                    cbDraft.SelectedIndex = i;
                }
            }

            for (int i = 0; i < cbEducation.Items.Count; i++)
            {
                if ((cbEducation.Items[i] as KeyValue).Key == accomplice.IdEducation)
                {
                    cbEducation.SelectedIndex = i;
                }
            }

            for (int i = 0; i < cbFamilyStatus.Items.Count; i++)
            {
                if ((cbFamilyStatus.Items[i] as KeyValue).Key == accomplice.IdFamilyStatus)
                {
                    cbFamilyStatus.SelectedIndex = i;
                }
            }

            for (int i = 0; i < cbRank.Items.Count; i++)
            {
                if ((cbRank.Items[i] as Rank).Id == accomplice.IdRank)
                {
                    cbRank.SelectedIndex = i;
                }
            }

            //получение id воинской части и выбор этой части в комбобоксе
            DataTable dt = sqlWorker.selectData("SELECT M.idMilitaryUnit FROM SubUnit S " +
                                                "LEFT JOIN SubUnit SF ON S.idFKSubUnit = SF.idSubUnit " +
                                                "LEFT JOIN MilitaryUnit M ON S.idMilitaryUnit = M.idMilitaryUnit OR SF.idMilitaryUnit = M.idMilitaryUnit " +
                                                "WHERE S.idSubUnit = " + accomplice.IdSubUnit);
            int idT = Int32.Parse(dt.Rows[0][0].ToString());

            for (int i = 0; i < cbMilitaryUnit.Items.Count; i++)
            {
                if ((cbMilitaryUnit.Items[i] as MilitaryUnit).Id == idT)
                {
                    cbMilitaryUnit.SelectedIndex = i;
                }
            }

            dt = sqlWorker.selectData("SELECT SF.idSubUnit FROM SubUnit S " +
                                      "LEFT JOIN SubUnit SF ON S.idFKSubUnit = SF.idSubUnit " +
                                      "WHERE S.idSubUnit = " + accomplice.IdSubUnit);
            if (dt.Rows[0][0].ToString() != "")
            {
                //есть промежуточное подразделение (батальон)
                idT = Int32.Parse(dt.Rows[0][0].ToString());
                for (int i = 0; i < cbBattalion.Items.Count; i++)
                {
                    if ((cbBattalion.Items[i] as SubUnit).Id == idT)
                    {
                        cbBattalion.SelectedIndex = i;
                    }
                }
            }
            else
            {
                //подразделение непосредственного подчинения воинской части
                for (int i = 0; i < cbBattalion.Items.Count; i++)
                {
                    if ((cbBattalion.Items[i] as SubUnit).Id == accomplice.IdSubUnit)
                    {
                        cbBattalion.SelectedIndex = i;
                    }
                }
            }

            idA = accomplice.Id;
        }