private void editClause_Click_2(object sender, RoutedEventArgs e) { ClauseList cl = new ClauseList(DataWorker.getClauseList(sqlWorker.selectData("SELECT * FROM Clause"))); EditClauseList wndC = new EditClauseList(cl, sqlWorker); wndC.ShowDialog(); }
public EditClauseList(ClauseList _list, SqliteWorker _sqlWorker) { InitializeComponent(); list = _list; sqlWorker = _sqlWorker; dataGrid.AutoGenerateColumns = false; dataGrid.ItemsSource = list.values; }
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; } }