public Edit(Output output) { InitializeComponent(); foreach (string fileNameReplacement in AttributeHelper.GetAttributeReplacements()) { MenuItem item = new MenuItem(); item.Header = new TextBlock() { Text = fileNameReplacement }; item.Tag = fileNameReplacement; item.Click += FileNameReplacementItem_Click; FileNameReplacementList.Items.Add(item); } NameTextBox.Text = output.Name; ApplicationTextBox.Text = output.Application; ArgumentsTextBox.Text = output.Arguments; FileNameTextBox.Text = output.FileName; FileFormatComboBox.ItemsSource = FileHelper.GetFileFormats(); FileFormatComboBox.SelectedValue = output.FileFormatID; NameTextBox.TextChanged += ValidateData; ApplicationTextBox.TextChanged += ValidateData; FileFormatComboBox.SelectionChanged += ValidateData; ValidateData(null, null); ApplicationTextBox.Focus(); }
private void LoadApplications(object sender, EventArgs e) { foreach (Button i in applicationButtons) { i.Show(); } sort[0].Show(); sort[1].Show(); ApplicationTextBox.Clear(); ApplicationTextBox.Hide(); ButtonApproved.Hide(); ButtonMeeting.Hide(); ButtonNotApproved.Hide(); ButtonReturn.Hide(); ButtonDelete.Hide(); }
private void loadApplication(object sender, EventArgs e) { Button a = (Button)sender; BD bd = new BD(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand(getEverythingFromBD, bd.getConnection()); command.Parameters.Add("@nm", MySqlDbType.VarChar).Value = a.Tag; bd.openBD(); MySqlDataReader reader = command.ExecuteReader(); id = Convert.ToInt32(a.Tag); while (reader.Read()) { dataFromBD[0] = Convert.ToString(reader.GetInt32(0)); dataFromBD[1] = Convert.ToString(reader.GetString(1)); dataFromBD[2] = Convert.ToString(reader.GetString(2)); dataFromBD[3] = Convert.ToString(reader.GetString(3)); dataFromBD[4] = Convert.ToString(reader.GetString(4)); dataFromBD[5] = Convert.ToString(reader.GetString(5)); dataFromBD[6] = Convert.ToString(reader.GetString(6)); dataFromBD[7] = Convert.ToString(reader.GetString(7)); dataFromBD[8] = Convert.ToString(reader.GetString(8)); dataFromBD[9] = Convert.ToString(reader.GetString(9)); dataFromBD[10] = Convert.ToString(reader.GetDateTime(10)); dataFromBD[11] = Convert.ToString(reader.GetString(11)); } reader.Close(); bd.closeBD(); foreach (Button i in applicationButtons) { i.Hide(); } sort[0].Hide(); sort[1].Hide(); ButtonApproved.Show(); ButtonMeeting.Show(); ButtonNotApproved.Show(); ButtonReturn.Show(); ButtonDelete.Show(); //Тут тоже костыль, можно вместо потехи с 6 строками, сделать цикл, пробегающийся по двумерному массиву - // - 1 строка это имена столбцов, а 2 - сами данные. Пока что только так ApplicationTextBox.Visible = true; ApplicationTextBox.Text += $"Номер анкеты: {dataFromBD[0]}\n\n"; ApplicationTextBox.Text += $"Имя: {dataFromBD[1]}\n\n"; ApplicationTextBox.Text += $"Ник в игре: {dataFromBD[2]}\n\n"; ApplicationTextBox.Text += $"Ник в дискорде: {dataFromBD[3]}\n\n"; ApplicationTextBox.Text += $"Возраст: {dataFromBD[4]}\n\n"; ApplicationTextBox.Text += $"О себе: {dataFromBD[5]}\n\n"; ApplicationTextBox.Text += $"Любимая книга: {dataFromBD[6]}\n\n"; ApplicationTextBox.Text += $"Кем себя видит: {dataFromBD[7]}\n\n"; ApplicationTextBox.Text += $"Причина: {dataFromBD[8]}\n\n"; ApplicationTextBox.Text += $"Правила: {dataFromBD[9]}\n\n"; ApplicationTextBox.Text += $"Дата поступления анкеты: {dataFromBD[10]}\n\n"; ApplicationTextBox.Text += $"IP: {dataFromBD[11]}\n\n"; try { if (int.Parse(dataFromBD[4]) < 16) { int positionInText = ApplicationTextBox.Find("Возраст"); string lengthInText = $"Возраст: {dataFromBD[4]}\n\n"; ApplicationTextBox.SelectionStart = positionInText; ApplicationTextBox.SelectionLength = lengthInText.Length; ApplicationTextBox.SelectionColor = Color.Red; } } catch (Exception exce) { } finally { } }