diff --git a/result.Designer.cs b/result.Designer.cs index 55e8b50..40148a8 100644 --- a/result.Designer.cs +++ b/result.Designer.cs @@ -1,4 +1,4 @@ -namespace тест +namespace тест { partial class result { @@ -30,6 +30,9 @@ { this.textBox1 = new System.Windows.Forms.TextBox(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.SuspendLayout(); // // textBox1 @@ -42,11 +45,42 @@ this.textBox1.TabIndex = 0; this.textBox1.FontChanged += new System.EventHandler(this.textBox1_FontChanged); // + // saveFileDialog1 + // + this.saveFileDialog1.Filter = "Текстовые файлы (*.txt)|*.txt"; + this.saveFileDialog1.Title = "Сохранить результат"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(13, 281); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(355, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Сохранить результат"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(13, 310); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(355, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Загрузить результат"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // // result // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(380, 450); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "result"; this.Text = "result"; @@ -61,5 +95,8 @@ private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.OpenFileDialog openFileDialog1; } } \ No newline at end of file diff --git a/result.cs b/result.cs index 810d99a..7825795 100644 --- a/result.cs +++ b/result.cs @@ -1,8 +1,10 @@ -using System; +using Microsoft.Win32; +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; @@ -25,8 +27,25 @@ namespace тест } int sum; + int vopros1, vopros2, vopros3, vopros4, vopros5; - public result(string f, string l, string g, string c, int s) + private void button2_Click(object sender, EventArgs e) + { + if (openFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } + textBox1.Text = File.ReadAllText(openFileDialog1.FileName); + } + + private void button1_Click(object sender, EventArgs e) + { + saveFileDialog1.FileName = "Результат " + lname + " " + fname + ".txt"; // имя по умолчанию + + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + File.WriteAllText(saveFileDialog1.FileName, textBox1.Text); + } + } + + public result(string f, string l, string g, string c, int s, int v1, int v2, int v3, int v4, int v5) { InitializeComponent(); @@ -35,16 +54,37 @@ namespace тест group = g; course = c; sum = s; + vopros1 = v1; + vopros2 = v2; + vopros3 = v3; + vopros4 = v4; + vopros5 = v5; + + } private void result_Shown(object sender, EventArgs e) { textBox1.Text = "Тест пройден" + Environment.NewLine + "Фамилия: " + lname + Environment.NewLine + - "Имя: " + fname + Environment.NewLine + - "Группа: " + group + Environment.NewLine + + "Имя: " + fname + Environment.NewLine + + "Группа: " + group + Environment.NewLine + "Курс: " + course + Environment.NewLine + - "Количество баллов: " + Convert.ToString(sum) + Environment.NewLine; + "Количество баллов: " + Convert.ToString(sum) + Environment.NewLine + + "******************" + Environment.NewLine + + "Вопрос 1: " + correct(vopros1) + Environment.NewLine + + "Вопрос 2: " + correct(vopros2) + Environment.NewLine + + "Вопрос 3: " + correct(vopros3) + Environment.NewLine + + "Вопрос 4: " + correct(vopros4) + Environment.NewLine + + "Вопрос 5: " + correct(vopros5); + } + + + private string correct(int a) + { + if (a == 0) { return "Неверно"; } + else if (a == 1) { return "Верно"; } + return "Неопределенно"; } } } diff --git a/result.resx b/result.resx index 053da59..3b284f4 100644 --- a/result.resx +++ b/result.resx @@ -1,4 +1,4 @@ - +