Сделал все формы
This commit is contained in:
parent
49bcd53718
commit
0e5ceb46f4
@ -21,7 +21,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Description = reader.GetString(1),
|
||||
Deadline = reader.GetDateTime(2),
|
||||
IsAccepted = reader.GetBoolean(3),
|
||||
MarkId = reader.GetInt32(4),
|
||||
MarkId = !reader.IsDBNull(4) ? reader.GetInt32(4) : 0,
|
||||
});
|
||||
}
|
||||
return homeworks;
|
||||
@ -41,7 +41,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Description = reader.GetString(1),
|
||||
Deadline = reader.GetDateTime(2),
|
||||
IsAccepted = reader.GetBoolean(3),
|
||||
MarkId = reader.GetInt32(4),
|
||||
MarkId = !reader.IsDBNull(4) ? reader.GetInt32(4) : 0,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@ -55,7 +55,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
cmd.Parameters.AddWithValue("@Description", homework.Description);
|
||||
cmd.Parameters.AddWithValue("@Deadline", homework.Deadline);
|
||||
cmd.Parameters.AddWithValue("@IsAccepted", homework.IsAccepted);
|
||||
cmd.Parameters.AddWithValue("@MarkId", homework.MarkId);
|
||||
cmd.Parameters.AddWithValue("@MarkId", homework.MarkId == 0 ? DBNull.Value : homework.MarkId);
|
||||
cmd.ExecuteNonQuery();
|
||||
return homework;
|
||||
}
|
||||
@ -64,7 +64,8 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
{
|
||||
using var con = SqlConnection.GetConnection();
|
||||
con.Open();
|
||||
using var cmd = new NpgsqlCommand($"UPDATE homework SET description = '{homework.Description}', deadline = {homework.Deadline}, is_accepted = {homework.IsAccepted}, fk_mark_id = {homework.MarkId} WHERE grade_id = {homework.Id}", con);
|
||||
using var cmd = new NpgsqlCommand($"UPDATE homework SET description = '{homework.Description}', deadline = '{homework.Deadline}', is_accepted = {homework.IsAccepted}, fk_mark_id =@MarkId WHERE homework_id = {homework.Id}", con);
|
||||
cmd.Parameters.AddWithValue("@MarkId", homework.MarkId == 0 ? DBNull.Value : homework.MarkId);
|
||||
cmd.ExecuteNonQuery();
|
||||
var element = Get(homework.Id);
|
||||
return element;
|
||||
|
@ -20,9 +20,9 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LessonDate = reader.GetDateTime(1),
|
||||
IsMissed = reader.GetBoolean(2),
|
||||
TeacherComment = reader.GetString(3),
|
||||
MarkId = reader.GetInt32(4),
|
||||
HomeworkId = reader.GetInt32(5),
|
||||
TeacherComment = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
MarkId = !reader.IsDBNull(4) ? reader.GetInt32(4) : 0,
|
||||
HomeworkId = !reader.IsDBNull(5) ? reader.GetInt32(5) : 0,
|
||||
StudentId = reader.GetInt32(6),
|
||||
SubjectId = reader.GetInt32(7),
|
||||
TeacherId = reader.GetInt32(8),
|
||||
@ -45,9 +45,9 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LessonDate = reader.GetDateTime(1),
|
||||
IsMissed = reader.GetBoolean(2),
|
||||
TeacherComment = reader.GetString(3),
|
||||
MarkId = reader.GetInt32(4),
|
||||
HomeworkId = reader.GetInt32(5),
|
||||
TeacherComment = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
MarkId = !reader.IsDBNull(4) ? reader.GetInt32(4) : 0,
|
||||
HomeworkId = !reader.IsDBNull(5) ? reader.GetInt32(5) : 0,
|
||||
StudentId = reader.GetInt32(6),
|
||||
SubjectId = reader.GetInt32(7),
|
||||
TeacherId = reader.GetInt32(8),
|
||||
@ -65,8 +65,8 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
cmd.Parameters.AddWithValue("@LessonDate", lesson.LessonDate);
|
||||
cmd.Parameters.AddWithValue("@IsMissed", lesson.IsMissed);
|
||||
cmd.Parameters.AddWithValue("@TeacherComment", lesson.TeacherComment);
|
||||
cmd.Parameters.AddWithValue("@MarkId", lesson.MarkId);
|
||||
cmd.Parameters.AddWithValue("@HomeworkId", lesson.HomeworkId);
|
||||
cmd.Parameters.AddWithValue("@MarkId", lesson.MarkId == 0 ? DBNull.Value : lesson.MarkId);
|
||||
cmd.Parameters.AddWithValue("@HomeworkId", lesson.HomeworkId == 0 ? DBNull.Value : lesson.HomeworkId);
|
||||
cmd.Parameters.AddWithValue("@StudentId", lesson.StudentId);
|
||||
cmd.Parameters.AddWithValue("@SubjectId", lesson.SubjectId);
|
||||
cmd.Parameters.AddWithValue("@TeacherId", lesson.TeacherId);
|
||||
@ -79,7 +79,9 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
{
|
||||
using var con = SqlConnection.GetConnection();
|
||||
con.Open();
|
||||
using var cmd = new NpgsqlCommand($"UPDATE lesson SET lesson_date = {lesson.LessonDate}, is_missed = {lesson.IsMissed}, teacher_comment = '{lesson.TeacherComment}', fk_mark_id = {lesson.MarkId}, fk_homework_id = {lesson.HomeworkId}, fk_student_id = {lesson.StudentId}, fk_subject_id = {lesson.SubjectId}, fk_teacher_id = {lesson.TeacherId}, fk_study_area_id = {lesson.StudyAreaId} WHERE lesson_id = {lesson.Id}", con);
|
||||
using var cmd = new NpgsqlCommand($"UPDATE lesson SET lesson_date = '{lesson.LessonDate}', is_missed = {lesson.IsMissed}, teacher_comment = '{lesson.TeacherComment}', fk_mark_id = @MarkId, fk_homework_id = @HomeworkId, fk_student_id = {lesson.StudentId}, fk_subject_id = {lesson.SubjectId}, fk_teacher_id = {lesson.TeacherId}, fk_study_area_id = {lesson.StudyAreaId} WHERE lesson_id = {lesson.Id}", con);
|
||||
cmd.Parameters.AddWithValue("@MarkId", lesson.MarkId == 0 ? DBNull.Value : lesson.MarkId);
|
||||
cmd.Parameters.AddWithValue("@HomeworkId", lesson.HomeworkId == 0 ? DBNull.Value : lesson.HomeworkId);
|
||||
cmd.ExecuteNonQuery();
|
||||
var element = Get(lesson.Id);
|
||||
return element;
|
||||
|
@ -27,7 +27,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LastName = reader.GetString(1),
|
||||
FirstName = reader.GetString(2),
|
||||
Patronymic = reader.GetString(3),
|
||||
Patronymic = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
GradeId = reader.GetInt32(4),
|
||||
UserId = reader.GetInt32(5),
|
||||
});
|
||||
@ -48,7 +48,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LastName = reader.GetString(1),
|
||||
FirstName = reader.GetString(2),
|
||||
Patronymic = reader.GetString(3),
|
||||
Patronymic = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
GradeId = reader.GetInt32(4),
|
||||
UserId = reader.GetInt32(5),
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LastName = reader.GetString(1),
|
||||
FirstName = reader.GetString(2),
|
||||
Patronymic = reader.GetString(3),
|
||||
Patronymic = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
UserId = reader.GetInt32(4),
|
||||
});
|
||||
}
|
||||
@ -47,7 +47,7 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
Id = reader.GetInt32(0),
|
||||
LastName = reader.GetString(1),
|
||||
FirstName = reader.GetString(2),
|
||||
Patronymic = reader.GetString(3),
|
||||
Patronymic = !reader.IsDBNull(3) ? reader.GetString(3) : "",
|
||||
UserId = reader.GetInt32(4),
|
||||
};
|
||||
}
|
||||
|
@ -18,12 +18,18 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FormStudent.cs">
|
||||
<Compile Update="FormLesson.cs" />
|
||||
<Compile Update="FormHomework.cs" />
|
||||
<Compile Update="FormMark.cs" />
|
||||
<Compile Update="FormUser.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="FormGrade.cs">
|
||||
<Compile Update="FormStudyArea.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="FormTeacher.cs" />
|
||||
<Compile Update="FormStudent.cs" />
|
||||
<Compile Update="FormGrade.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
205
ElectronicDiary/ElectronicDiaryView/FormHomework.Designer.cs
generated
Normal file
205
ElectronicDiary/ElectronicDiaryView/FormHomework.Designer.cs
generated
Normal file
@ -0,0 +1,205 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormHomework
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxDescription = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
label2 = new Label();
|
||||
comboBoxMark = new ComboBox();
|
||||
checkBoxIsAccepted = new CheckBox();
|
||||
dateTimePickerDeadline = new DateTimePicker();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(741, 409);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(741, 360);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(741, 311);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxDescription
|
||||
//
|
||||
textBoxDescription.Location = new Point(746, 13);
|
||||
textBoxDescription.Name = "textBoxDescription";
|
||||
textBoxDescription.Size = new Size(232, 23);
|
||||
textBoxDescription.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(596, 16);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(68, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Описание: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 426);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(596, 90);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(51, 15);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "Оценка:";
|
||||
//
|
||||
// comboBoxMark
|
||||
//
|
||||
comboBoxMark.FormattingEnabled = true;
|
||||
comboBoxMark.Location = new Point(746, 87);
|
||||
comboBoxMark.Name = "comboBoxMark";
|
||||
comboBoxMark.Size = new Size(232, 23);
|
||||
comboBoxMark.TabIndex = 30;
|
||||
//
|
||||
// checkBoxIsAccepted
|
||||
//
|
||||
checkBoxIsAccepted.AutoSize = true;
|
||||
checkBoxIsAccepted.Location = new Point(746, 127);
|
||||
checkBoxIsAccepted.Name = "checkBoxIsAccepted";
|
||||
checkBoxIsAccepted.Size = new Size(77, 19);
|
||||
checkBoxIsAccepted.TabIndex = 31;
|
||||
checkBoxIsAccepted.Text = "Принято.";
|
||||
checkBoxIsAccepted.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dateTimePickerDeadline
|
||||
//
|
||||
dateTimePickerDeadline.Location = new Point(746, 50);
|
||||
dateTimePickerDeadline.Name = "dateTimePickerDeadline";
|
||||
dateTimePickerDeadline.Size = new Size(232, 23);
|
||||
dateTimePickerDeadline.TabIndex = 32;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(596, 127);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(104, 15);
|
||||
label3.TabIndex = 33;
|
||||
label3.Text = "Состояние сдачи:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(596, 53);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(73, 15);
|
||||
label4.TabIndex = 34;
|
||||
label4.Text = "Срок сдачи:";
|
||||
//
|
||||
// FormHomework
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(990, 450);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(dateTimePickerDeadline);
|
||||
Controls.Add(checkBoxIsAccepted);
|
||||
Controls.Add(comboBoxMark);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxDescription);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormHomework";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Домашние задания";
|
||||
Load += FormHomework_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxDescription;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxMark;
|
||||
private CheckBox checkBoxIsAccepted;
|
||||
private DateTimePicker dateTimePickerDeadline;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
}
|
||||
}
|
126
ElectronicDiary/ElectronicDiaryView/FormHomework.cs
Normal file
126
ElectronicDiary/ElectronicDiaryView/FormHomework.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormHomework : Form
|
||||
{
|
||||
private readonly IHomeworkWork _homeworkLogic;
|
||||
|
||||
private readonly IMarkWork _markLogic;
|
||||
|
||||
public FormHomework(IHomeworkWork homeworkLogic, IMarkWork markLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_homeworkLogic = homeworkLogic;
|
||||
_markLogic = markLogic;
|
||||
}
|
||||
|
||||
private void FormHomework_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var homeworks = _homeworkLogic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Description", "Описание");
|
||||
dataGridView.Columns.Add("Deadline", "Срок сдачи");
|
||||
dataGridView.Columns.Add("IsAccepted", "Состояние сдачи");
|
||||
dataGridView.Columns.Add("MarkId", "MarkId");
|
||||
dataGridView.Columns["MarkId"].Visible = false;
|
||||
dataGridView.Columns.Add("Mark", "Оценка");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Description"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Deadline"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["IsAccepted"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Mark"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
comboBoxMark.DataSource = _markLogic.GetAll();
|
||||
comboBoxMark.DisplayMember = "Value";
|
||||
comboBoxMark.ValueMember = "Id";
|
||||
|
||||
foreach (var homework in homeworks)
|
||||
{
|
||||
dataGridView.Rows.Add(homework.Id, homework.Description, homework.Deadline, homework.IsAccepted ? "Принято" : "Не принято", homework.MarkId, _markLogic.Get(homework.MarkId)?.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Homework newHomework = new()
|
||||
{
|
||||
Description = textBoxDescription.Text,
|
||||
Deadline = dateTimePickerDeadline.Value,
|
||||
IsAccepted = checkBoxIsAccepted.Checked,
|
||||
MarkId = ((Mark?)comboBoxMark.SelectedItem)?.Id ?? 0,
|
||||
};
|
||||
|
||||
_homeworkLogic.Create(newHomework);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int homeworkId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Homework updatedHomework = new()
|
||||
{
|
||||
Id = homeworkId,
|
||||
Description = textBoxDescription.Text,
|
||||
Deadline = dateTimePickerDeadline.Value,
|
||||
IsAccepted = checkBoxIsAccepted.Checked,
|
||||
MarkId = ((Mark?)comboBoxMark.SelectedItem)?.Id ?? 0,
|
||||
};
|
||||
|
||||
_homeworkLogic.Update(updatedHomework);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите домашнее задание, которое необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int homeworkId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_homeworkLogic.Delete(homeworkId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите домашнее задание, которое необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
textBoxDescription.Text = row.Cells["Description"].Value.ToString();
|
||||
dateTimePickerDeadline.Value = Convert.ToDateTime(row.Cells["Deadline"].Value);
|
||||
checkBoxIsAccepted.Checked = row.Cells["IsAccepted"].Value.ToString() == "Принято";
|
||||
comboBoxMark.SelectedValue = Convert.ToInt32(row.Cells["MarkId"].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormHomework.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormHomework.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
319
ElectronicDiary/ElectronicDiaryView/FormLesson.Designer.cs
generated
Normal file
319
ElectronicDiary/ElectronicDiaryView/FormLesson.Designer.cs
generated
Normal file
@ -0,0 +1,319 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormLesson
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
label2 = new Label();
|
||||
comboBoxMark = new ComboBox();
|
||||
checkBoxIsMissed = new CheckBox();
|
||||
dateTimePickerDate = new DateTimePicker();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
textBoxTeacherComment = new TextBox();
|
||||
label1 = new Label();
|
||||
comboBoxHomework = new ComboBox();
|
||||
label5 = new Label();
|
||||
comboBoxStudent = new ComboBox();
|
||||
label6 = new Label();
|
||||
comboBoxSubject = new ComboBox();
|
||||
label7 = new Label();
|
||||
comboBoxTeacher = new ComboBox();
|
||||
label8 = new Label();
|
||||
comboBoxStudyArea = new ComboBox();
|
||||
label9 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(1255, 544);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(1255, 495);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(1255, 446);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1081, 564);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(1116, 128);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(51, 15);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "Оценка:";
|
||||
//
|
||||
// comboBoxMark
|
||||
//
|
||||
comboBoxMark.FormattingEnabled = true;
|
||||
comboBoxMark.Location = new Point(1266, 125);
|
||||
comboBoxMark.Name = "comboBoxMark";
|
||||
comboBoxMark.Size = new Size(232, 23);
|
||||
comboBoxMark.TabIndex = 30;
|
||||
//
|
||||
// checkBoxIsMissed
|
||||
//
|
||||
checkBoxIsMissed.AutoSize = true;
|
||||
checkBoxIsMissed.Location = new Point(1266, 54);
|
||||
checkBoxIsMissed.Name = "checkBoxIsMissed";
|
||||
checkBoxIsMissed.Size = new Size(96, 19);
|
||||
checkBoxIsMissed.TabIndex = 31;
|
||||
checkBoxIsMissed.Text = "Пропущено.";
|
||||
checkBoxIsMissed.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dateTimePickerDate
|
||||
//
|
||||
dateTimePickerDate.Location = new Point(1266, 14);
|
||||
dateTimePickerDate.Name = "dateTimePickerDate";
|
||||
dateTimePickerDate.Size = new Size(232, 23);
|
||||
dateTimePickerDate.TabIndex = 32;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(1116, 54);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(101, 15);
|
||||
label3.TabIndex = 33;
|
||||
label3.Text = "Статус пропуска:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(1116, 17);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(103, 15);
|
||||
label4.TabIndex = 34;
|
||||
label4.Text = "Дата проведения:";
|
||||
//
|
||||
// textBoxTeacherComment
|
||||
//
|
||||
textBoxTeacherComment.Location = new Point(1266, 88);
|
||||
textBoxTeacherComment.Name = "textBoxTeacherComment";
|
||||
textBoxTeacherComment.Size = new Size(232, 23);
|
||||
textBoxTeacherComment.TabIndex = 36;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(1116, 91);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(137, 15);
|
||||
label1.TabIndex = 35;
|
||||
label1.Text = "Комментарий учителя: ";
|
||||
//
|
||||
// comboBoxHomework
|
||||
//
|
||||
comboBoxHomework.FormattingEnabled = true;
|
||||
comboBoxHomework.Location = new Point(1266, 162);
|
||||
comboBoxHomework.Name = "comboBoxHomework";
|
||||
comboBoxHomework.Size = new Size(232, 23);
|
||||
comboBoxHomework.TabIndex = 38;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(1116, 165);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(116, 15);
|
||||
label5.TabIndex = 37;
|
||||
label5.Text = "Домашнее задание:";
|
||||
//
|
||||
// comboBoxStudent
|
||||
//
|
||||
comboBoxStudent.FormattingEnabled = true;
|
||||
comboBoxStudent.Location = new Point(1266, 199);
|
||||
comboBoxStudent.Name = "comboBoxStudent";
|
||||
comboBoxStudent.Size = new Size(232, 23);
|
||||
comboBoxStudent.TabIndex = 40;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(1116, 202);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(50, 15);
|
||||
label6.TabIndex = 39;
|
||||
label6.Text = "Ученик:";
|
||||
//
|
||||
// comboBoxSubject
|
||||
//
|
||||
comboBoxSubject.FormattingEnabled = true;
|
||||
comboBoxSubject.Location = new Point(1266, 236);
|
||||
comboBoxSubject.Name = "comboBoxSubject";
|
||||
comboBoxSubject.Size = new Size(232, 23);
|
||||
comboBoxSubject.TabIndex = 42;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.AutoSize = true;
|
||||
label7.Location = new Point(1116, 239);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(58, 15);
|
||||
label7.TabIndex = 41;
|
||||
label7.Text = "Предмет:";
|
||||
//
|
||||
// comboBoxTeacher
|
||||
//
|
||||
comboBoxTeacher.FormattingEnabled = true;
|
||||
comboBoxTeacher.Location = new Point(1266, 273);
|
||||
comboBoxTeacher.Name = "comboBoxTeacher";
|
||||
comboBoxTeacher.Size = new Size(232, 23);
|
||||
comboBoxTeacher.TabIndex = 44;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
label8.AutoSize = true;
|
||||
label8.Location = new Point(1116, 276);
|
||||
label8.Name = "label8";
|
||||
label8.Size = new Size(55, 15);
|
||||
label8.TabIndex = 43;
|
||||
label8.Text = "Учитель:";
|
||||
//
|
||||
// comboBoxStudyArea
|
||||
//
|
||||
comboBoxStudyArea.FormattingEnabled = true;
|
||||
comboBoxStudyArea.Location = new Point(1266, 310);
|
||||
comboBoxStudyArea.Name = "comboBoxStudyArea";
|
||||
comboBoxStudyArea.Size = new Size(232, 23);
|
||||
comboBoxStudyArea.TabIndex = 46;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
label9.AutoSize = true;
|
||||
label9.Location = new Point(1116, 313);
|
||||
label9.Name = "label9";
|
||||
label9.Size = new Size(113, 15);
|
||||
label9.TabIndex = 45;
|
||||
label9.Text = "Место проведения:";
|
||||
//
|
||||
// FormLesson
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1510, 582);
|
||||
Controls.Add(comboBoxStudyArea);
|
||||
Controls.Add(label9);
|
||||
Controls.Add(comboBoxTeacher);
|
||||
Controls.Add(label8);
|
||||
Controls.Add(comboBoxSubject);
|
||||
Controls.Add(label7);
|
||||
Controls.Add(comboBoxStudent);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(comboBoxHomework);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(textBoxTeacherComment);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(dateTimePickerDate);
|
||||
Controls.Add(checkBoxIsMissed);
|
||||
Controls.Add(comboBoxMark);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormLesson";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Уроки";
|
||||
Load += FormLesson_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private Label label5;
|
||||
private DataGridView dataGridView;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxMark;
|
||||
private CheckBox checkBoxIsMissed;
|
||||
private DateTimePicker dateTimePickerDate;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private TextBox textBoxTeacherComment;
|
||||
private Label label1;
|
||||
private ComboBox comboBoxHomework;
|
||||
private ComboBox comboBoxStudent;
|
||||
private Label label6;
|
||||
private ComboBox comboBoxSubject;
|
||||
private Label label7;
|
||||
private ComboBox comboBoxTeacher;
|
||||
private Label label8;
|
||||
private ComboBox comboBoxStudyArea;
|
||||
private Label label9;
|
||||
}
|
||||
}
|
202
ElectronicDiary/ElectronicDiaryView/FormLesson.cs
Normal file
202
ElectronicDiary/ElectronicDiaryView/FormLesson.cs
Normal file
@ -0,0 +1,202 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormLesson : Form
|
||||
{
|
||||
private readonly ILessonWork _lessonLogic;
|
||||
|
||||
private readonly IMarkWork _markLogic;
|
||||
|
||||
private readonly IHomeworkWork _homeworkLogic;
|
||||
|
||||
private readonly IStudentWork _studentLogic;
|
||||
|
||||
private readonly ISubjectWork _subjectLogic;
|
||||
|
||||
private readonly ITeacherWork _teacherLogic;
|
||||
|
||||
private readonly IStudyAreaWork _studyAreaLogic;
|
||||
|
||||
public FormLesson(ILessonWork lessonLogic, IMarkWork markLogic, IHomeworkWork homeworkLogic, IStudentWork studentLogic,
|
||||
ISubjectWork subjectLogic, ITeacherWork teacherLogic, IStudyAreaWork studyAreaLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_lessonLogic = lessonLogic;
|
||||
_markLogic = markLogic;
|
||||
_homeworkLogic = homeworkLogic;
|
||||
_studentLogic = studentLogic;
|
||||
_subjectLogic = subjectLogic;
|
||||
_teacherLogic = teacherLogic;
|
||||
_studyAreaLogic = studyAreaLogic;
|
||||
}
|
||||
|
||||
private void FormLesson_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var lessons = _lessonLogic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("LessonDate", "Дата проведения");
|
||||
dataGridView.Columns.Add("IsMissed", "Статус пропуска");
|
||||
dataGridView.Columns.Add("TeacherComment", "Комментарий учителя");
|
||||
dataGridView.Columns.Add("MarkId", "MarkId");
|
||||
dataGridView.Columns["MarkId"].Visible = false;
|
||||
dataGridView.Columns.Add("Mark", "Оценка");
|
||||
dataGridView.Columns.Add("HomeworkId", "HomeworkId");
|
||||
dataGridView.Columns["HomeworkId"].Visible = false;
|
||||
dataGridView.Columns.Add("HomeworkDeadline", "Дата сдачи домашнего задания");
|
||||
dataGridView.Columns.Add("StudentId", "StudentId");
|
||||
dataGridView.Columns["StudentId"].Visible = false;
|
||||
dataGridView.Columns.Add("StudentName", "Ученик");
|
||||
dataGridView.Columns.Add("SubjectId", "SubjectId");
|
||||
dataGridView.Columns["SubjectId"].Visible = false;
|
||||
dataGridView.Columns.Add("SubjectName", "Предмет");
|
||||
dataGridView.Columns.Add("TeacherId", "TeacherId");
|
||||
dataGridView.Columns["TeacherId"].Visible = false;
|
||||
dataGridView.Columns.Add("TeacherName", "Учитель");
|
||||
dataGridView.Columns.Add("StudyAreaId", "StudyAreaId");
|
||||
dataGridView.Columns["StudyAreaId"].Visible = false;
|
||||
dataGridView.Columns.Add("StudyAreaName", "Место проведения");
|
||||
}
|
||||
|
||||
dataGridView.Columns["LessonDate"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["IsMissed"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["TeacherComment"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Mark"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["HomeworkDeadline"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["StudentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["SubjectName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["TeacherName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["StudyAreaName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
comboBoxMark.DataSource = _markLogic.GetAll();
|
||||
comboBoxMark.DisplayMember = "Value";
|
||||
comboBoxMark.ValueMember = "Id";
|
||||
comboBoxHomework.DataSource = _homeworkLogic.GetAll();
|
||||
comboBoxHomework.DisplayMember = "Description";
|
||||
comboBoxHomework.ValueMember = "Id";
|
||||
comboBoxStudent.DataSource = _studentLogic.GetAll().Select(x =>
|
||||
new { x.Id, FullName = x.LastName + " " + x.FirstName + " " + x.Patronymic }
|
||||
).ToList();
|
||||
comboBoxStudent.DisplayMember = "FullName";
|
||||
comboBoxStudent.ValueMember = "Id";
|
||||
comboBoxSubject.DataSource = _subjectLogic.GetAll();
|
||||
comboBoxSubject.DisplayMember = "Name";
|
||||
comboBoxSubject.ValueMember = "Id";
|
||||
comboBoxTeacher.DataSource = _teacherLogic.GetAll().Select(x =>
|
||||
new { x.Id, FullName = x.LastName + " " + x.FirstName + " " + x.Patronymic }
|
||||
).ToList();
|
||||
comboBoxTeacher.DisplayMember = "FullName";
|
||||
comboBoxTeacher.ValueMember = "Id";
|
||||
comboBoxStudyArea.DataSource = _studyAreaLogic.GetAll();
|
||||
comboBoxStudyArea.DisplayMember = "Name";
|
||||
comboBoxStudyArea.ValueMember = "Id";
|
||||
|
||||
foreach (var lesson in lessons)
|
||||
{
|
||||
var student = _studentLogic.Get(lesson.StudentId);
|
||||
var teacher = _teacherLogic.Get(lesson.TeacherId);
|
||||
dataGridView.Rows.Add(lesson.Id, lesson.LessonDate, lesson.IsMissed ? "Пропущен" : "Не пропущен", lesson.TeacherComment, lesson.MarkId,
|
||||
_markLogic.Get(lesson.MarkId)?.Value, lesson.HomeworkId, _homeworkLogic.Get(lesson.HomeworkId)?.Deadline, lesson.StudentId,
|
||||
student?.LastName + " " + student?.FirstName + " " + student?.Patronymic, lesson.SubjectId, _subjectLogic.Get(lesson.SubjectId)?.Name,
|
||||
lesson.TeacherId, teacher?.LastName + " " + teacher?.FirstName + " " + teacher?.Patronymic, lesson.StudyAreaId, _studyAreaLogic.Get(lesson.StudyAreaId)?.Name);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Lesson newLesson = new()
|
||||
{
|
||||
LessonDate = dateTimePickerDate.Value,
|
||||
IsMissed = checkBoxIsMissed.Checked,
|
||||
TeacherComment = textBoxTeacherComment.Text,
|
||||
MarkId = ((Mark?)comboBoxMark.SelectedItem)?.Id ?? 0,
|
||||
HomeworkId = ((Homework?)comboBoxHomework.SelectedItem)?.Id ?? 0,
|
||||
StudentId = ((dynamic)comboBoxStudent.SelectedItem).Id,
|
||||
SubjectId = ((Subject)comboBoxSubject.SelectedItem).Id,
|
||||
TeacherId = ((dynamic)comboBoxTeacher.SelectedItem).Id,
|
||||
StudyAreaId = ((StudyArea)comboBoxStudyArea.SelectedItem).Id,
|
||||
};
|
||||
|
||||
_lessonLogic.Create(newLesson);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int lessonId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Lesson updatedLesson = new()
|
||||
{
|
||||
Id = lessonId,
|
||||
LessonDate = dateTimePickerDate.Value,
|
||||
IsMissed = checkBoxIsMissed.Checked,
|
||||
TeacherComment = textBoxTeacherComment.Text,
|
||||
MarkId = ((Mark?)comboBoxMark.SelectedItem)?.Id ?? 0,
|
||||
HomeworkId = ((Homework?)comboBoxHomework.SelectedItem)?.Id ?? 0,
|
||||
StudentId = ((dynamic)comboBoxStudent.SelectedItem).Id,
|
||||
SubjectId = ((Subject)comboBoxSubject.SelectedItem).Id,
|
||||
TeacherId = ((dynamic)comboBoxTeacher.SelectedItem).Id,
|
||||
StudyAreaId = ((StudyArea)comboBoxStudyArea.SelectedItem).Id,
|
||||
};
|
||||
|
||||
_lessonLogic.Update(updatedLesson);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите урок, который необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int lessonId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_lessonLogic.Delete(lessonId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите урок, который необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
dateTimePickerDate.Value = Convert.ToDateTime(row.Cells["LessonDate"].Value);
|
||||
checkBoxIsMissed.Checked = row.Cells["IsMissed"].Value.ToString() == "Пропущен";
|
||||
textBoxTeacherComment.Text = row.Cells["TeacherComment"].Value.ToString();
|
||||
comboBoxMark.SelectedValue = Convert.ToInt32(row.Cells["MarkId"].Value);
|
||||
comboBoxHomework.SelectedValue = Convert.ToInt32(row.Cells["HomeworkId"].Value);
|
||||
comboBoxStudent.SelectedValue = Convert.ToInt32(row.Cells["StudentId"].Value);
|
||||
comboBoxSubject.SelectedValue = Convert.ToInt32(row.Cells["SubjectId"].Value);
|
||||
comboBoxTeacher.SelectedValue = Convert.ToInt32(row.Cells["TeacherId"].Value);
|
||||
comboBoxStudyArea.SelectedValue = Convert.ToInt32(row.Cells["StudyAreaId"].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormLesson.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormLesson.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -32,9 +32,13 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
предметыToolStripMenuItem = new ToolStripMenuItem();
|
||||
классыToolStripMenuItem = new ToolStripMenuItem();
|
||||
замерВремениToolStripMenuItem = new ToolStripMenuItem();
|
||||
textBoxTest = new TextBox();
|
||||
ученикиToolStripMenuItem = new ToolStripMenuItem();
|
||||
учителяToolStripMenuItem = new ToolStripMenuItem();
|
||||
домашниеЗаданияToolStripMenuItem = new ToolStripMenuItem();
|
||||
урокиToolStripMenuItem = new ToolStripMenuItem();
|
||||
замерВремениToolStripMenuItem = new ToolStripMenuItem();
|
||||
labelTest = new Label();
|
||||
оценкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -43,13 +47,13 @@
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, замерВремениToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(316, 24);
|
||||
menuStrip1.Size = new Size(554, 24);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { предметыToolStripMenuItem, классыToolStripMenuItem, ученикиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { предметыToolStripMenuItem, классыToolStripMenuItem, ученикиToolStripMenuItem, учителяToolStripMenuItem, домашниеЗаданияToolStripMenuItem, урокиToolStripMenuItem, оценкиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -57,17 +61,45 @@
|
||||
// предметыToolStripMenuItem
|
||||
//
|
||||
предметыToolStripMenuItem.Name = "предметыToolStripMenuItem";
|
||||
предметыToolStripMenuItem.Size = new Size(180, 22);
|
||||
предметыToolStripMenuItem.Size = new Size(181, 22);
|
||||
предметыToolStripMenuItem.Text = "Предметы";
|
||||
предметыToolStripMenuItem.Click += ПредметыToolStripMenuItem_Click;
|
||||
//
|
||||
// классыToolStripMenuItem
|
||||
//
|
||||
классыToolStripMenuItem.Name = "классыToolStripMenuItem";
|
||||
классыToolStripMenuItem.Size = new Size(180, 22);
|
||||
классыToolStripMenuItem.Size = new Size(181, 22);
|
||||
классыToolStripMenuItem.Text = "Классы";
|
||||
классыToolStripMenuItem.Click += КлассыToolStripMenuItem_Click;
|
||||
//
|
||||
// ученикиToolStripMenuItem
|
||||
//
|
||||
ученикиToolStripMenuItem.Name = "ученикиToolStripMenuItem";
|
||||
ученикиToolStripMenuItem.Size = new Size(181, 22);
|
||||
ученикиToolStripMenuItem.Text = "Ученики";
|
||||
ученикиToolStripMenuItem.Click += УченикиToolStripMenuItem_Click;
|
||||
//
|
||||
// учителяToolStripMenuItem
|
||||
//
|
||||
учителяToolStripMenuItem.Name = "учителяToolStripMenuItem";
|
||||
учителяToolStripMenuItem.Size = new Size(181, 22);
|
||||
учителяToolStripMenuItem.Text = "Учителя";
|
||||
учителяToolStripMenuItem.Click += УчителяToolStripMenuItem_Click;
|
||||
//
|
||||
// домашниеЗаданияToolStripMenuItem
|
||||
//
|
||||
домашниеЗаданияToolStripMenuItem.Name = "домашниеЗаданияToolStripMenuItem";
|
||||
домашниеЗаданияToolStripMenuItem.Size = new Size(181, 22);
|
||||
домашниеЗаданияToolStripMenuItem.Text = "Домашние задания";
|
||||
домашниеЗаданияToolStripMenuItem.Click += ДомашниеЗаданияToolStripMenuItem_Click;
|
||||
//
|
||||
// урокиToolStripMenuItem
|
||||
//
|
||||
урокиToolStripMenuItem.Name = "урокиToolStripMenuItem";
|
||||
урокиToolStripMenuItem.Size = new Size(181, 22);
|
||||
урокиToolStripMenuItem.Text = "Уроки";
|
||||
урокиToolStripMenuItem.Click += УрокиToolStripMenuItem_Click;
|
||||
//
|
||||
// замерВремениToolStripMenuItem
|
||||
//
|
||||
замерВремениToolStripMenuItem.Name = "замерВремениToolStripMenuItem";
|
||||
@ -75,29 +107,28 @@
|
||||
замерВремениToolStripMenuItem.Text = "Замер времени";
|
||||
замерВремениToolStripMenuItem.Click += ЗамерВремениToolStripMenuItem_Click;
|
||||
//
|
||||
// textBoxTest
|
||||
// labelTest
|
||||
//
|
||||
textBoxTest.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
textBoxTest.Location = new Point(12, 27);
|
||||
textBoxTest.Multiline = true;
|
||||
textBoxTest.Name = "textBoxTest";
|
||||
textBoxTest.ReadOnly = true;
|
||||
textBoxTest.Size = new Size(296, 85);
|
||||
textBoxTest.TabIndex = 2;
|
||||
labelTest.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelTest.Location = new Point(156, 82);
|
||||
labelTest.Name = "labelTest";
|
||||
labelTest.Size = new Size(250, 100);
|
||||
labelTest.TabIndex = 3;
|
||||
labelTest.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// ученикиToolStripMenuItem
|
||||
// оценкиToolStripMenuItem
|
||||
//
|
||||
ученикиToolStripMenuItem.Name = "ученикиToolStripMenuItem";
|
||||
ученикиToolStripMenuItem.Size = new Size(180, 22);
|
||||
ученикиToolStripMenuItem.Text = "Ученики";
|
||||
ученикиToolStripMenuItem.Click += УченикиToolStripMenuItem_Click;
|
||||
оценкиToolStripMenuItem.Name = "оценкиToolStripMenuItem";
|
||||
оценкиToolStripMenuItem.Size = new Size(181, 22);
|
||||
оценкиToolStripMenuItem.Text = "Оценки";
|
||||
оценкиToolStripMenuItem.Click += ОценкиToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(316, 124);
|
||||
Controls.Add(textBoxTest);
|
||||
ClientSize = new Size(554, 261);
|
||||
Controls.Add(labelTest);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
@ -114,9 +145,13 @@
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem предметыToolStripMenuItem;
|
||||
private TextBox textBoxTest;
|
||||
private ToolStripMenuItem замерВремениToolStripMenuItem;
|
||||
private ToolStripMenuItem классыToolStripMenuItem;
|
||||
private ToolStripMenuItem ученикиToolStripMenuItem;
|
||||
private ToolStripMenuItem учителяToolStripMenuItem;
|
||||
private ToolStripMenuItem домашниеЗаданияToolStripMenuItem;
|
||||
private Label labelTest;
|
||||
private ToolStripMenuItem урокиToolStripMenuItem;
|
||||
private ToolStripMenuItem оценкиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -37,6 +37,42 @@ namespace ElectronicDiaryView
|
||||
}
|
||||
}
|
||||
|
||||
private void УчителяToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTeacher));
|
||||
if (service is FormTeacher form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ДомашниеЗаданияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormHomework));
|
||||
if (service is FormHomework form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void УрокиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormLesson));
|
||||
if (service is FormLesson form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ОценкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMark));
|
||||
if (service is FormMark form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ЗамерВремениToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ISubjectWork));
|
||||
@ -49,7 +85,7 @@ namespace ElectronicDiaryView
|
||||
subjectWork.Delete(id);
|
||||
DateTime endTime = DateTime.Now;
|
||||
|
||||
textBoxTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
labelTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
140
ElectronicDiary/ElectronicDiaryView/FormMark.Designer.cs
generated
Normal file
140
ElectronicDiary/ElectronicDiaryView/FormMark.Designer.cs
generated
Normal file
@ -0,0 +1,140 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormMark
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
numericUpDownValue = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownValue).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(639, 410);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(639, 361);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(639, 312);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(596, 16);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(54, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Оценка: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 426);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// numericUpDownValue
|
||||
//
|
||||
numericUpDownValue.Location = new Point(656, 13);
|
||||
numericUpDownValue.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownValue.Name = "numericUpDownValue";
|
||||
numericUpDownValue.Size = new Size(132, 23);
|
||||
numericUpDownValue.TabIndex = 30;
|
||||
numericUpDownValue.TextAlign = HorizontalAlignment.Center;
|
||||
numericUpDownValue.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// FormMark
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(numericUpDownValue);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormMark";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Оценки";
|
||||
Load += FormMark_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownValue).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private NumericUpDown numericUpDownValue;
|
||||
}
|
||||
}
|
103
ElectronicDiary/ElectronicDiaryView/FormMark.cs
Normal file
103
ElectronicDiary/ElectronicDiaryView/FormMark.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormMark : Form
|
||||
{
|
||||
private readonly IMarkWork _logic;
|
||||
|
||||
public FormMark(IMarkWork logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormMark_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var marks = _logic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Value", "Оценка");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Value"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
foreach (var mark in marks)
|
||||
{
|
||||
dataGridView.Rows.Add(mark.Id, mark.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Mark newMark = new()
|
||||
{
|
||||
Value = Convert.ToInt32(numericUpDownValue.Value),
|
||||
};
|
||||
|
||||
_logic.Create(newMark);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int markd = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Mark updatedMark = new()
|
||||
{
|
||||
Id = markd,
|
||||
Value = Convert.ToInt32(numericUpDownValue.Value),
|
||||
};
|
||||
|
||||
_logic.Update(updatedMark);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите оценку, которую необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int markId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_logic.Delete(markId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите оценку, которую необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
numericUpDownValue.Value = (decimal)row.Cells["Value"].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormMark.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormMark.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -242,7 +242,7 @@
|
||||
Name = "FormStudent";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Ученики";
|
||||
Load += FormGrade_Load;
|
||||
Load += FormStudent_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
@ -22,7 +22,7 @@ namespace ElectronicDiaryView
|
||||
_subjectLogic = subjectLogic;
|
||||
}
|
||||
|
||||
private void FormGrade_Load(object sender, EventArgs e)
|
||||
private void FormStudent_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace ElectronicDiaryView
|
||||
Email = "email" + someNumber,
|
||||
Password = "password" + someNumber,
|
||||
PhoneNumber = "phonenumber" + someNumber,
|
||||
AccessLevel = "student",
|
||||
AccessLevel = "Ученик",
|
||||
};
|
||||
_userLogic.Create(newUser);
|
||||
int newUserId = _userLogic.GetAll().Max(user => user.Id);
|
||||
|
157
ElectronicDiary/ElectronicDiaryView/FormStudyArea.Designer.cs
generated
Normal file
157
ElectronicDiary/ElectronicDiaryView/FormStudyArea.Designer.cs
generated
Normal file
@ -0,0 +1,157 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormStudyArea
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxName = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
textBoxType = new TextBox();
|
||||
label2 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(639, 410);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(639, 361);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(639, 312);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(667, 13);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(128, 23);
|
||||
textBoxName.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(596, 16);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(65, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Название: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 426);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// textBoxType
|
||||
//
|
||||
textBoxType.Location = new Point(667, 50);
|
||||
textBoxType.Name = "textBoxType";
|
||||
textBoxType.Size = new Size(128, 23);
|
||||
textBoxType.TabIndex = 30;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(596, 53);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(33, 15);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "Тип: ";
|
||||
//
|
||||
// FormStudyArea
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(textBoxType);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormStudyArea";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Учебные помещения";
|
||||
Load += FormStudyArea_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxName;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private TextBox textBoxType;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
107
ElectronicDiary/ElectronicDiaryView/FormStudyArea.cs
Normal file
107
ElectronicDiary/ElectronicDiaryView/FormStudyArea.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormStudyArea : Form
|
||||
{
|
||||
private readonly IStudyAreaWork _logic;
|
||||
|
||||
public FormStudyArea(IStudyAreaWork logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormStudyArea_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var studyAreas = _logic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Name", "Название помещения");
|
||||
dataGridView.Columns.Add("Type", "Тип помещения");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Type"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
foreach (var studyArea in studyAreas)
|
||||
{
|
||||
dataGridView.Rows.Add(studyArea.Id, studyArea.Name, studyArea.Type);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
StudyArea newStudyArea = new()
|
||||
{
|
||||
Name = textBoxName.Text,
|
||||
Type = textBoxType.Text,
|
||||
};
|
||||
|
||||
_logic.Create(newStudyArea);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studyAreaId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
StudyArea updatedStudyArea = new()
|
||||
{
|
||||
Id = studyAreaId,
|
||||
Name = textBoxName.Text,
|
||||
Type = textBoxType.Text,
|
||||
};
|
||||
|
||||
_logic.Update(updatedStudyArea);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите помещение, которое необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studyAreaId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_logic.Delete(studyAreaId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите помещение, которое необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
textBoxName.Text = row.Cells["Name"].Value.ToString();
|
||||
textBoxType.Text = row.Cells["Type"].Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormStudyArea.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormStudyArea.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
254
ElectronicDiary/ElectronicDiaryView/FormTeacher.Designer.cs
generated
Normal file
254
ElectronicDiary/ElectronicDiaryView/FormTeacher.Designer.cs
generated
Normal file
@ -0,0 +1,254 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormTeacher
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxLastName = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
textBoxFirstName = new TextBox();
|
||||
label3 = new Label();
|
||||
textBoxPatronymic = new TextBox();
|
||||
labelPatronymic = new Label();
|
||||
buttonGetSubjects = new Button();
|
||||
buttonDeleteSubjects = new Button();
|
||||
comboBoxSubject = new ComboBox();
|
||||
label4 = new Label();
|
||||
buttonAddSubject = new Button();
|
||||
buttonDeleteSubject = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(802, 278);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(802, 229);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(802, 180);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxLastName
|
||||
//
|
||||
textBoxLastName.Location = new Point(798, 10);
|
||||
textBoxLastName.Name = "textBoxLastName";
|
||||
textBoxLastName.Size = new Size(201, 23);
|
||||
textBoxLastName.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(725, 13);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(64, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Фамилия: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(687, 608);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// textBoxFirstName
|
||||
//
|
||||
textBoxFirstName.Location = new Point(800, 53);
|
||||
textBoxFirstName.Name = "textBoxFirstName";
|
||||
textBoxFirstName.Size = new Size(199, 23);
|
||||
textBoxFirstName.TabIndex = 32;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(725, 56);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(37, 15);
|
||||
label3.TabIndex = 31;
|
||||
label3.Text = "Имя: ";
|
||||
//
|
||||
// textBoxPatronymic
|
||||
//
|
||||
textBoxPatronymic.Location = new Point(802, 96);
|
||||
textBoxPatronymic.Name = "textBoxPatronymic";
|
||||
textBoxPatronymic.Size = new Size(197, 23);
|
||||
textBoxPatronymic.TabIndex = 34;
|
||||
//
|
||||
// labelPatronymic
|
||||
//
|
||||
labelPatronymic.AutoSize = true;
|
||||
labelPatronymic.Location = new Point(725, 99);
|
||||
labelPatronymic.Name = "labelPatronymic";
|
||||
labelPatronymic.Size = new Size(64, 15);
|
||||
labelPatronymic.TabIndex = 33;
|
||||
labelPatronymic.Text = "Отчество: ";
|
||||
//
|
||||
// buttonGetSubjects
|
||||
//
|
||||
buttonGetSubjects.Location = new Point(802, 421);
|
||||
buttonGetSubjects.Name = "buttonGetSubjects";
|
||||
buttonGetSubjects.Size = new Size(128, 30);
|
||||
buttonGetSubjects.TabIndex = 35;
|
||||
buttonGetSubjects.Text = "Предметы учителя";
|
||||
buttonGetSubjects.UseVisualStyleBackColor = true;
|
||||
buttonGetSubjects.Click += ButtonGetSubjects_Click;
|
||||
//
|
||||
// buttonDeleteSubjects
|
||||
//
|
||||
buttonDeleteSubjects.Location = new Point(802, 571);
|
||||
buttonDeleteSubjects.Name = "buttonDeleteSubjects";
|
||||
buttonDeleteSubjects.Size = new Size(128, 46);
|
||||
buttonDeleteSubjects.TabIndex = 36;
|
||||
buttonDeleteSubjects.Text = "Удалить все предметы";
|
||||
buttonDeleteSubjects.UseVisualStyleBackColor = true;
|
||||
buttonDeleteSubjects.Click += ButtonDeleteSubjects_Click;
|
||||
//
|
||||
// comboBoxSubject
|
||||
//
|
||||
comboBoxSubject.FormattingEnabled = true;
|
||||
comboBoxSubject.Location = new Point(808, 380);
|
||||
comboBoxSubject.Name = "comboBoxSubject";
|
||||
comboBoxSubject.Size = new Size(197, 23);
|
||||
comboBoxSubject.TabIndex = 38;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(731, 383);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(58, 15);
|
||||
label4.TabIndex = 37;
|
||||
label4.Text = "Предмет:";
|
||||
//
|
||||
// buttonAddSubject
|
||||
//
|
||||
buttonAddSubject.Location = new Point(802, 471);
|
||||
buttonAddSubject.Name = "buttonAddSubject";
|
||||
buttonAddSubject.Size = new Size(128, 30);
|
||||
buttonAddSubject.TabIndex = 39;
|
||||
buttonAddSubject.Text = "Добавить предмет";
|
||||
buttonAddSubject.UseVisualStyleBackColor = true;
|
||||
buttonAddSubject.Click += ButtonAddSubject_Click;
|
||||
//
|
||||
// buttonDeleteSubject
|
||||
//
|
||||
buttonDeleteSubject.Location = new Point(802, 521);
|
||||
buttonDeleteSubject.Name = "buttonDeleteSubject";
|
||||
buttonDeleteSubject.Size = new Size(128, 30);
|
||||
buttonDeleteSubject.TabIndex = 40;
|
||||
buttonDeleteSubject.Text = "Удалить предмет";
|
||||
buttonDeleteSubject.UseVisualStyleBackColor = true;
|
||||
buttonDeleteSubject.Click += ButtonDeleteSubject_Click;
|
||||
//
|
||||
// FormTeacher
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1014, 634);
|
||||
Controls.Add(buttonDeleteSubject);
|
||||
Controls.Add(buttonAddSubject);
|
||||
Controls.Add(comboBoxSubject);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(buttonDeleteSubjects);
|
||||
Controls.Add(buttonGetSubjects);
|
||||
Controls.Add(textBoxPatronymic);
|
||||
Controls.Add(labelPatronymic);
|
||||
Controls.Add(textBoxFirstName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxLastName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormTeacher";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Учителя";
|
||||
Load += FormTeacher_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxLastName;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private TextBox textBoxFirstName;
|
||||
private Label label3;
|
||||
private TextBox textBoxPatronymic;
|
||||
private Label labelPatronymic;
|
||||
private Button buttonGetSubjects;
|
||||
private Button buttonDeleteSubjects;
|
||||
private ComboBox comboBoxSubject;
|
||||
private Label label4;
|
||||
private Button buttonAddSubject;
|
||||
private Button buttonDeleteSubject;
|
||||
}
|
||||
}
|
201
ElectronicDiary/ElectronicDiaryView/FormTeacher.cs
Normal file
201
ElectronicDiary/ElectronicDiaryView/FormTeacher.cs
Normal file
@ -0,0 +1,201 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormTeacher : Form
|
||||
{
|
||||
private readonly ITeacherWork _teacherLogic;
|
||||
|
||||
private readonly IUserWork _userLogic;
|
||||
|
||||
private readonly ISubjectWork _subjectLogic;
|
||||
|
||||
public FormTeacher(ITeacherWork teacherLogic, IUserWork userLogic, ISubjectWork subjectLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_teacherLogic = teacherLogic;
|
||||
_userLogic = userLogic;
|
||||
_subjectLogic = subjectLogic;
|
||||
}
|
||||
|
||||
private void FormTeacher_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var teachers = _teacherLogic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Name", "Имя учителя");
|
||||
dataGridView.Columns.Add("UserId", "UserId");
|
||||
dataGridView.Columns["UserId"].Visible = false;
|
||||
dataGridView.Columns.Add("UserLogin", "Логин");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["UserLogin"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
comboBoxSubject.DataSource = _subjectLogic.GetAll();
|
||||
comboBoxSubject.DisplayMember = "Name";
|
||||
comboBoxSubject.ValueMember = "Id";
|
||||
|
||||
foreach (var teacher in teachers)
|
||||
{
|
||||
dataGridView.Rows.Add(teacher.Id, teacher.LastName + " " + teacher.FirstName + " " + teacher.Patronymic, teacher.UserId, _userLogic.Get(teacher.UserId)?.Login);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
int someNumber = _userLogic.GetAll().Max(user => user.Id) + 1;
|
||||
User newUser = new()
|
||||
{
|
||||
Login = "login" + someNumber,
|
||||
Email = "email" + someNumber,
|
||||
Password = "password" + someNumber,
|
||||
PhoneNumber = "phonenumber" + someNumber,
|
||||
AccessLevel = "Учитель",
|
||||
};
|
||||
_userLogic.Create(newUser);
|
||||
int newUserId = _userLogic.GetAll().Max(user => user.Id);
|
||||
|
||||
Teacher newTeacher = new()
|
||||
{
|
||||
LastName = textBoxLastName.Text,
|
||||
FirstName = textBoxFirstName.Text,
|
||||
Patronymic = textBoxPatronymic.Text,
|
||||
UserId = newUserId,
|
||||
};
|
||||
|
||||
_teacherLogic.Create(newTeacher);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int teacherId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Teacher updatedTeacher = new()
|
||||
{
|
||||
Id = teacherId,
|
||||
LastName = textBoxLastName.Text,
|
||||
FirstName = textBoxFirstName.Text,
|
||||
Patronymic = textBoxPatronymic.Text,
|
||||
};
|
||||
|
||||
_teacherLogic.Update(updatedTeacher);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, информацию о котором необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int teacherId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_teacherLogic.Delete(teacherId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, информацию о котором необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonGetSubjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSubjects));
|
||||
if (service is FormSubjects form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
form.IsStudent = false;
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, информацию о предметах которого необходимо посмотреть");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddSubject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int teacherId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_teacherLogic.AddTeacherSubject(teacherId, ((Subject)comboBoxSubject.SelectedItem).Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, с которым необходимо связать предмет");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteSubject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int teacherId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_teacherLogic.DeleteTeacherSubject(teacherId, ((Subject)comboBoxSubject.SelectedItem).Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, от которого необходимо отвязать предмет");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteSubjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int teacherId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_teacherLogic.DeleteAllTeacherSubjects(teacherId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите учителя, информацию о предметах которого необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
string[] nameParts = (row != null && row.Cells["Name"] != null) ? row.Cells["Name"].Value.ToString().Split(' ') : new string[] { "", "", "" };
|
||||
textBoxLastName.Text = nameParts[0];
|
||||
textBoxFirstName.Text = nameParts[1];
|
||||
textBoxPatronymic.Text = nameParts[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormTeacher.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormTeacher.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
224
ElectronicDiary/ElectronicDiaryView/FormUser.Designer.cs
generated
Normal file
224
ElectronicDiary/ElectronicDiaryView/FormUser.Designer.cs
generated
Normal file
@ -0,0 +1,224 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
partial class FormUser
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxLogin = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
textBoxEmail = new TextBox();
|
||||
label2 = new Label();
|
||||
textBoxPassword = new TextBox();
|
||||
label3 = new Label();
|
||||
textBoxPhone = new TextBox();
|
||||
label4 = new Label();
|
||||
comboBoxAccessLevel = new ComboBox();
|
||||
label5 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(676, 410);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(676, 361);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(676, 312);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxLogin
|
||||
//
|
||||
textBoxLogin.Location = new Point(708, 12);
|
||||
textBoxLogin.Name = "textBoxLogin";
|
||||
textBoxLogin.Size = new Size(181, 23);
|
||||
textBoxLogin.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(596, 16);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(47, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Логин: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 426);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// textBoxEmail
|
||||
//
|
||||
textBoxEmail.Location = new Point(708, 50);
|
||||
textBoxEmail.Name = "textBoxEmail";
|
||||
textBoxEmail.Size = new Size(181, 23);
|
||||
textBoxEmail.TabIndex = 30;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(596, 53);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(47, 15);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "E-mail: ";
|
||||
//
|
||||
// textBoxPassword
|
||||
//
|
||||
textBoxPassword.Location = new Point(708, 87);
|
||||
textBoxPassword.Name = "textBoxPassword";
|
||||
textBoxPassword.Size = new Size(181, 23);
|
||||
textBoxPassword.TabIndex = 32;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(596, 90);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(55, 15);
|
||||
label3.TabIndex = 31;
|
||||
label3.Text = "Пароль: ";
|
||||
//
|
||||
// textBoxPhone
|
||||
//
|
||||
textBoxPhone.Location = new Point(708, 124);
|
||||
textBoxPhone.Name = "textBoxPhone";
|
||||
textBoxPhone.Size = new Size(181, 23);
|
||||
textBoxPhone.TabIndex = 34;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(596, 127);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(61, 15);
|
||||
label4.TabIndex = 33;
|
||||
label4.Text = "Телефон: ";
|
||||
//
|
||||
// comboBoxAccessLevel
|
||||
//
|
||||
comboBoxAccessLevel.FormattingEnabled = true;
|
||||
comboBoxAccessLevel.Items.AddRange(new object[] { "Администратор", "Ученик", "Учитель" });
|
||||
comboBoxAccessLevel.Location = new Point(708, 161);
|
||||
comboBoxAccessLevel.Name = "comboBoxAccessLevel";
|
||||
comboBoxAccessLevel.Size = new Size(181, 23);
|
||||
comboBoxAccessLevel.TabIndex = 35;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(596, 164);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(105, 15);
|
||||
label5.TabIndex = 36;
|
||||
label5.Text = "Уровень доступа: ";
|
||||
//
|
||||
// FormUser
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(904, 450);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(comboBoxAccessLevel);
|
||||
Controls.Add(textBoxPhone);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxPassword);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(textBoxEmail);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxLogin);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormUser";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Учебные помещения";
|
||||
Load += FormUser_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxLogin;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private TextBox textBoxEmail;
|
||||
private Label label2;
|
||||
private TextBox textBoxPassword;
|
||||
private Label label3;
|
||||
private TextBox textBoxPhone;
|
||||
private Label label4;
|
||||
private ComboBox comboBoxAccessLevel;
|
||||
}
|
||||
}
|
121
ElectronicDiary/ElectronicDiaryView/FormUser.cs
Normal file
121
ElectronicDiary/ElectronicDiaryView/FormUser.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormUser : Form
|
||||
{
|
||||
private readonly IUserWork _logic;
|
||||
|
||||
public FormUser(IUserWork logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormUser_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var users = _logic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Login", "Логин");
|
||||
dataGridView.Columns.Add("Email", "E-mail");
|
||||
dataGridView.Columns.Add("Password", "Пароль");
|
||||
dataGridView.Columns.Add("PhoneNumber", "Номер телефона");
|
||||
dataGridView.Columns.Add("AccessLevel", "Уровень доступа");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Login"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Password"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["PhoneNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["AccessLevel"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
dataGridView.Rows.Add(user.Id, user.Login, user.Email, user.Password, user.PhoneNumber, user.AccessLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
User newUser = new()
|
||||
{
|
||||
Login = textBoxLogin.Text,
|
||||
Email = textBoxEmail.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
PhoneNumber = textBoxPhone.Text,
|
||||
AccessLevel = comboBoxAccessLevel.SelectedItem.ToString() ?? "Ученик",
|
||||
};
|
||||
|
||||
_logic.Create(newUser);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int userId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
User updatedUser = new()
|
||||
{
|
||||
Id = userId,
|
||||
Email = textBoxEmail.Text,
|
||||
Password = textBoxPassword.Text,
|
||||
PhoneNumber = textBoxPhone.Text,
|
||||
AccessLevel = comboBoxAccessLevel.SelectedItem.ToString() ?? "Ученик",
|
||||
};
|
||||
|
||||
_logic.Update(updatedUser);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите пользователя, информацию о котором необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int userId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_logic.Delete(userId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите пользователя, которого необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
textBoxLogin.Text = row.Cells["Name"].Value.ToString();
|
||||
textBoxEmail.Text = row.Cells["Type"].Value.ToString();
|
||||
textBoxPassword.Text = row.Cells["Password"].Value.ToString();
|
||||
textBoxPhone.Text = row.Cells["PhoneNumber"].Value.ToString();
|
||||
comboBoxAccessLevel.SelectedValue = row.Cells["AccessLevel"].Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectronicDiary/ElectronicDiaryView/FormUser.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormUser.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -35,9 +35,15 @@ namespace ElectronicDiaryView
|
||||
services.AddTransient<IUserWork, UserWork>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormGrade>();
|
||||
services.AddTransient<FormHomework>();
|
||||
services.AddTransient<FormLesson>();
|
||||
services.AddTransient<FormMark>();
|
||||
services.AddTransient<FormStudent>();
|
||||
services.AddTransient<FormStudyArea>();
|
||||
services.AddTransient<FormSubject>();
|
||||
services.AddTransient<FormSubjects>();
|
||||
services.AddTransient<FormTeacher>();
|
||||
services.AddTransient<FormUser>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user