123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- 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<System.Windows.Forms.CheckBox> checkBoxes = Interes.Controls.OfType<System.Windows.Forms.CheckBox>().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<System.Windows.Forms.RadioButton>().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<System.Windows.Forms.RadioButton>().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; // Настройка режима размеров изображения
- }
- }
- }
- }
- }
|