using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; namespace oprosnik { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public string filePath; public string selectedGender; public string selectedEducation; public string SelectedCheckBox; public string prefix; public string imagePath; private void button1_Click(object sender, EventArgs e) { switch (comboBox2.SelectedItem) { case "Лесозаготовки": prefix = "ЛЗ"; break; case "Администратирование базз данных": prefix = "АД"; break; case "Разработчик Веб и мультимидийных - приложений": prefix = "РП"; break; case "Гостиничное Дело": prefix = "ГД"; break; case "Сальто Назад": prefix = "СН"; break; default: prefix = "Неизвестно"; break; } filePath = Convert.ToString(prefix + "_" + textBox1.Text + ".txt"); if (!File.Exists(filePath)) { using (File.Create(filePath)) { Console.WriteLine("Файл создан: " + filePath); } } using (StreamWriter fileStream = File.AppendText(filePath)) { try { if (imagePath == null || textBox1.Text == "" || selectedGender == null || textBox2.Text == "" || textBox3.Text == "" || selectedEducation == null || richTextBox1.Text == "" || textBox4.Text == "" || textBox6.Text == "" || textBox7.Text == "" || comboBox1.SelectedItem == null || comboBox2.SelectedItem == null) { MessageBox.Show("Заполните все поля!!!", "Ошибка"); } else { List checkBoxes = Interes.Controls.OfType().ToList(); Console.WriteLine("Файл открыт для чтения: " + filePath); fileStream.WriteLine(textBox1.Text); fileStream.WriteLine(textBox7.Text); fileStream.WriteLine(textBox6.Text); fileStream.WriteLine(selectedGender); fileStream.WriteLine(dateTimePicker1.Value); fileStream.WriteLine(textBox2.Text); fileStream.WriteLine(textBox3.Text); fileStream.WriteLine(comboBox1.SelectedItem); fileStream.WriteLine(comboBox2.SelectedItem); fileStream.WriteLine(selectedEducation); fileStream.WriteLine(richTextBox1.Text); fileStream.WriteLine(imagePath + " - Путь до картинки, а как еще её в текстовый файл записать? мм?"); fileStream.WriteLine(" "); fileStream.WriteLine("Интересы:"); foreach (System.Windows.Forms.CheckBox checkBox in checkBoxes) { if (checkBox.Checked) { fileStream.WriteLine(checkBox.Text); } } fileStream.WriteLine(" "); fileStream.WriteLine(textBox4.Text); fileStream.WriteLine(dateTimePicker2.Value); fileStream.WriteLine(" "); } } catch (Exception exept) { MessageBox.Show(string.Format("Произошла ошибка {0}", exept), "Ошибка"); } } } private void radioButton_CheckedChanged(object sender, EventArgs e) { System.Windows.Forms.RadioButton selectedRadioButton = Gender.Controls.OfType().FirstOrDefault(r => r.Checked); if (selectedRadioButton != null) { selectedGender = selectedRadioButton.Text; } } private void radioButton1_CheckedChanged(object sender, EventArgs e) { System.Windows.Forms.RadioButton selectedRadioButton = Education.Controls.OfType().FirstOrDefault(r => r.Checked); if (selectedRadioButton != null) { selectedEducation = selectedRadioButton.Text; } } private void button2_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.gif;*.bmp"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { imagePath = openFileDialog1.FileName; byte[] imageBytes = File.ReadAllBytes(imagePath); using (MemoryStream ms = new MemoryStream(imageBytes)) { Image image = Image.FromStream(ms); pictureBox1.Image = image; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; // Настройка режима размеров изображения } } } } }