public Criminal[] getGaveUpCriminals() { int criminalCode = getFirstCriminalCode(); Criminal[] criminals = new Criminal[1000000]; int criminal = 0; do { if (loadGaveUp(criminalCode) == true) { criminals[criminal] = new Criminal { name = loadName(criminalCode), surname = loadSurname(criminalCode), nickname = loadNickname(criminalCode), specialization = loadSpec(criminalCode), residence = loadResidence(criminalCode), date = loadDate(criminalCode), image = loadPhoto(criminalCode), code = criminalCode }; } criminal++; criminalCode++; } while (criminal < getNumberOfRows()); return(criminals); }
public Criminal[] searchResult(string whereCondition) { Criminal[] criminals = new Criminal[10000]; int criminal = 0; string commText = "SELECT * FROM Criminals WHERE " + whereCondition + " ;"; OleDbConnection conn = new OleDbConnection(connString); OleDbCommand command = new OleDbCommand(commText, conn); conn.Open(); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { try { MemoryStream ms = new MemoryStream(); ms.Write((byte[])reader[16], 0, ((byte[])reader[16]).Length); criminals[criminal] = new Criminal { name = reader[1].ToString(), surname = reader[2].ToString(), nickname = reader[3].ToString(), specialization = reader[15].ToString(), residence = reader[10].ToString(), date = reader[4].ToString().Substring(0, reader[4].ToString().Length - 8), image = new Bitmap(ms), code = Convert.ToInt32(reader[0]) }; } catch (Exception ex) { Console.WriteLine("Ошибка при выполнении поиска."); } } return(criminals); }
public Criminal[] getAliveCriminals() { int criminalCode = getFirstCriminalCode(); Criminal[] criminals = new Criminal[1000000]; int criminal = 0; if (criminalCode == 0) { MessageBox.Show("Отсутсвуют данные"); } else { do { if (loadIsDead(criminalCode) == false) { criminals[criminal] = new Criminal(); criminals[criminal].name = loadName(criminalCode); criminals[criminal].surname = loadSurname(criminalCode); criminals[criminal].nickname = loadNickname(criminalCode); criminals[criminal].specialization = loadSpec(criminalCode); criminals[criminal].residence = loadResidence(criminalCode); criminals[criminal].date = loadDate(criminalCode); criminals[criminal].image = loadPhoto(criminalCode); criminals[criminal].code = criminalCode; } criminalCode++; criminal++; } while (criminal < getNumberOfRows()); } return(criminals); }
public Criminal(Criminal copyCriminal) : this( copyCriminal.name, copyCriminal.surname, copyCriminal.nickname, copyCriminal.portrait, copyCriminal.citizenship, copyCriminal.lastHome, copyCriminal.languages, copyCriminal.criminalWork, copyCriminal.lastDeal, copyCriminal.id) { }
private void AddCriminal_Click(object sender, EventArgs e) { if (!RegexCheck(CriminalNameLabel.Text, CriminalName.Text, NameRusRegex, NameEngRegex) || !RegexCheck(SurnameLabel.Text, Surname.Text, NameRusRegex, NameEngRegex) || !RegexCheck(NicknameLabel.Text, Nickname.Text, NameRusRegex, NameEngRegex)) { return; } if (HairColorChoosed.IsEmpty) { MessageBox.Show("Не указано значение цвета волос!"); return; } if (EyeColorChoosed.IsEmpty) { MessageBox.Show("Не указано значение цвета глаз!"); return; } if (!RegexCheck(MotherlandLabel.Text, Motherland.Text, NameRusRegex, NameEngRegex)) { return; } if ((DateTime.Now - BirthDate.Value).TotalDays < ADULT) { MessageBox.Show("Неверная дата рождения!"); return; } if (!RegexCheck(CitizenshipLabel.Text, Citizenship.Text, NameRusRegex, NameEngRegex) || !RegexCheck(LastHomeLabel.Text, LastHome.Text, AddressEnumaration) || !RegexCheck(LanguagesLabel.Text, Langueges.Text, NamesEnumaration) || !RegexCheck(CriminalWorkLabel.Text, CriminalWork.Text, NameRusRegex, NameEngRegex) || !RegexCheck(LastDealLabel.Text, LastDeal.Text, NamesEnumaration)) { return; } if (editingId == NotEditID) { crimeBase.AddCriminal(CriminalName.Text, Surname.Text, Nickname.Text, Convert.ToInt32(CriminalHeight.Value), HairColorChoosed, EyeColorChoosed, Description.Text, Motherland.Text, BirthDate.Value, Citizenship.Text, LastHome.Text, Langueges.Text.Split(',').ToList(), CriminalWork.Text, LastDeal.Text); MessageBox.Show("Запись успешно создана!"); } else { if (editingId < 0 || editingId >= crimeBase.CountOfCriminals) { MessageBox.Show("Не существует записи с таким ID"); return; } crimeBase[editingId] = new Criminal( CriminalName.Text, Surname.Text, Nickname.Text, new PhotoModel(Convert.ToInt32(CriminalHeight.Value), HairColorChoosed, EyeColorChoosed, Description.Text, Motherland.Text, BirthDate.Value), Citizenship.Text, LastHome.Text, Langueges.Text.Split(',').ToList(), CriminalWork.Text, LastDeal.Text, editingId); MessageBox.Show("Запись успешно изменена!"); } this.Close(); }