урааа
This commit is contained in:
parent
a38c5d258b
commit
8bd5ec7e01
@ -41,6 +41,8 @@
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
|
@ -33,6 +33,16 @@ namespace ExamTimetable_Forms
|
||||
dataGridView.Columns.Add("Teachers", "Преподавательский состав");
|
||||
dataGridView.Columns.Add("Fuc", "Факультет");
|
||||
}
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxFuc.DataSource = bd.GetFaculties()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetFacultyById(x.faculty_id).faculty_name,
|
||||
Id = x.faculty_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxFuc.DisplayMember = "Text";
|
||||
comboBoxFuc.ValueMember = "Id";
|
||||
|
||||
// Заполняем dataGridView данными из списка моделей автомобилей
|
||||
foreach (Comission сomission in comissions)
|
||||
@ -107,16 +117,7 @@ namespace ExamTimetable_Forms
|
||||
// Получаем значение из выбранной строки
|
||||
string selectedFuc = row.Cells["Fuc"].Value.ToString();
|
||||
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxFuc.DataSource = bd.GetFaculties()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetFacultyById(x.faculty_id).faculty_name,
|
||||
Id = x.faculty_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxFuc.DisplayMember = "Text";
|
||||
comboBoxFuc.ValueMember = "Id";
|
||||
|
||||
|
||||
// Выбираем универ, который соответствует выбранному значению в строке
|
||||
comboBoxFuc.SelectedItem = selectedFuc;
|
||||
|
64
ExamTimetable/ExamTimetable/FormExam.Designer.cs
generated
64
ExamTimetable/ExamTimetable/FormExam.Designer.cs
generated
@ -29,7 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.textBoxDateTime = new System.Windows.Forms.TextBox();
|
||||
this.textBoxDate = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPlace = new System.Windows.Forms.TextBox();
|
||||
this.textBoxSubject = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxCom = new System.Windows.Forms.ComboBox();
|
||||
@ -40,11 +40,15 @@
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.textBoxTime = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
@ -53,23 +57,23 @@
|
||||
this.dataGridView.TabIndex = 0;
|
||||
this.dataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellClick);
|
||||
//
|
||||
// textBoxDateTime
|
||||
// textBoxDate
|
||||
//
|
||||
this.textBoxDateTime.Location = new System.Drawing.Point(647, 12);
|
||||
this.textBoxDateTime.Name = "textBoxDateTime";
|
||||
this.textBoxDateTime.Size = new System.Drawing.Size(141, 23);
|
||||
this.textBoxDateTime.TabIndex = 1;
|
||||
this.textBoxDate.Location = new System.Drawing.Point(647, 12);
|
||||
this.textBoxDate.Name = "textBoxDate";
|
||||
this.textBoxDate.Size = new System.Drawing.Size(141, 23);
|
||||
this.textBoxDate.TabIndex = 1;
|
||||
//
|
||||
// textBoxPlace
|
||||
//
|
||||
this.textBoxPlace.Location = new System.Drawing.Point(647, 56);
|
||||
this.textBoxPlace.Location = new System.Drawing.Point(647, 113);
|
||||
this.textBoxPlace.Name = "textBoxPlace";
|
||||
this.textBoxPlace.Size = new System.Drawing.Size(141, 23);
|
||||
this.textBoxPlace.TabIndex = 3;
|
||||
//
|
||||
// textBoxSubject
|
||||
//
|
||||
this.textBoxSubject.Location = new System.Drawing.Point(647, 103);
|
||||
this.textBoxSubject.Location = new System.Drawing.Point(647, 158);
|
||||
this.textBoxSubject.Name = "textBoxSubject";
|
||||
this.textBoxSubject.Size = new System.Drawing.Size(141, 23);
|
||||
this.textBoxSubject.TabIndex = 4;
|
||||
@ -77,7 +81,7 @@
|
||||
// comboBoxCom
|
||||
//
|
||||
this.comboBoxCom.FormattingEnabled = true;
|
||||
this.comboBoxCom.Location = new System.Drawing.Point(647, 149);
|
||||
this.comboBoxCom.Location = new System.Drawing.Point(647, 211);
|
||||
this.comboBoxCom.Name = "comboBoxCom";
|
||||
this.comboBoxCom.Size = new System.Drawing.Size(141, 23);
|
||||
this.comboBoxCom.TabIndex = 5;
|
||||
@ -85,16 +89,16 @@
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(559, 20);
|
||||
this.label1.Location = new System.Drawing.Point(589, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(82, 15);
|
||||
this.label1.Size = new System.Drawing.Size(35, 15);
|
||||
this.label1.TabIndex = 6;
|
||||
this.label1.Text = "Дата и время:";
|
||||
this.label1.Text = "Дата:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(579, 59);
|
||||
this.label2.Location = new System.Drawing.Point(589, 121);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(45, 15);
|
||||
this.label2.TabIndex = 7;
|
||||
@ -103,7 +107,7 @@
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(579, 106);
|
||||
this.label3.Location = new System.Drawing.Point(579, 166);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(58, 15);
|
||||
this.label3.TabIndex = 8;
|
||||
@ -112,7 +116,7 @@
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(572, 157);
|
||||
this.label4.Location = new System.Drawing.Point(572, 211);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(65, 15);
|
||||
this.label4.TabIndex = 9;
|
||||
@ -120,7 +124,7 @@
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Location = new System.Drawing.Point(713, 194);
|
||||
this.buttonCreate.Location = new System.Drawing.Point(713, 256);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreate.TabIndex = 10;
|
||||
@ -130,7 +134,7 @@
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(713, 236);
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(713, 301);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonUpdate.TabIndex = 11;
|
||||
@ -140,7 +144,7 @@
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(713, 284);
|
||||
this.buttonDelete.Location = new System.Drawing.Point(713, 339);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonDelete.TabIndex = 12;
|
||||
@ -148,11 +152,29 @@
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
|
||||
//
|
||||
// textBoxTime
|
||||
//
|
||||
this.textBoxTime.Location = new System.Drawing.Point(647, 60);
|
||||
this.textBoxTime.Name = "textBoxTime";
|
||||
this.textBoxTime.Size = new System.Drawing.Size(141, 23);
|
||||
this.textBoxTime.TabIndex = 13;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(589, 68);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(45, 15);
|
||||
this.label5.TabIndex = 14;
|
||||
this.label5.Text = "Время:";
|
||||
//
|
||||
// FormExam
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.textBoxTime);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
@ -163,7 +185,7 @@
|
||||
this.Controls.Add(this.comboBoxCom);
|
||||
this.Controls.Add(this.textBoxSubject);
|
||||
this.Controls.Add(this.textBoxPlace);
|
||||
this.Controls.Add(this.textBoxDateTime);
|
||||
this.Controls.Add(this.textBoxDate);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormExam";
|
||||
this.Text = "FormExam";
|
||||
@ -177,7 +199,7 @@
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private TextBox textBoxDateTime;
|
||||
private TextBox textBoxDate;
|
||||
private TextBox textBoxPlace;
|
||||
private TextBox textBoxSubject;
|
||||
private ComboBox comboBoxCom;
|
||||
@ -188,5 +210,7 @@
|
||||
private Button buttonCreate;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private TextBox textBoxTime;
|
||||
private Label label5;
|
||||
}
|
||||
}
|
@ -30,16 +30,27 @@ namespace ExamTimetable_Forms
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("DateTime", "Дата и время");
|
||||
dataGridView.Columns.Add("Date", "Дата");
|
||||
dataGridView.Columns.Add("Time", "Время");
|
||||
dataGridView.Columns.Add("Place", "Место");
|
||||
dataGridView.Columns.Add("Subject", "Предмет");
|
||||
dataGridView.Columns.Add("Comm", "Комиссия");
|
||||
}
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxCom.DataSource = bd.GetComissions()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetComissionById(x.comm_id).teaching_stuff,
|
||||
Id = x.comm_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxCom.DisplayMember = "Text";
|
||||
comboBoxCom.ValueMember = "Id";
|
||||
|
||||
// Заполняем dataGridView данными из списка моделей автомобилей
|
||||
foreach (Exam exam in exams)
|
||||
{
|
||||
dataGridView.Rows.Add(exam.exam_id, exam.exam_date + " " + exam.exam_time, exam.exam_place, exam.exam_subject, bd.GetComissionById(exam.com_id).teaching_stuff);
|
||||
dataGridView.Rows.Add(exam.exam_id, exam.exam_date.ToString().Split(" ")[0], exam.exam_time, exam.exam_place, exam.exam_subject, bd.GetComissionById(exam.com_id).teaching_stuff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,11 +59,11 @@ namespace ExamTimetable_Forms
|
||||
// Создаем новый объект с данными из текстовых полей и комбо-бокса
|
||||
Exam newExam = new Exam
|
||||
{
|
||||
exam_date = DateTime.Parse(textBoxDateTime.Text),
|
||||
exam_date = DateTime.Parse(textBoxDate.Text + " 00:00:00"),
|
||||
exam_place = textBoxPlace.Text,
|
||||
exam_subject = textBoxSubject.Text,
|
||||
com_id = ((helpCombobox)comboBoxCom.SelectedItem).Id,
|
||||
exam_time = DateTime.Parse(textBoxDateTime.Text)
|
||||
exam_time = TimeSpan.Parse(textBoxTime.Text)
|
||||
};
|
||||
|
||||
// Добавляем новый факультет в базу данных
|
||||
@ -70,11 +81,11 @@ namespace ExamTimetable_Forms
|
||||
Exam updatedExam = new Exam
|
||||
{
|
||||
exam_id = selectedRowId,
|
||||
exam_date = DateTime.Parse(textBoxDateTime.Text),
|
||||
exam_date = DateTime.Parse(textBoxDate.Text + " 00:00:00"),
|
||||
exam_place = textBoxPlace.Text,
|
||||
exam_subject = textBoxSubject.Text,
|
||||
com_id = ((helpCombobox)comboBoxCom.SelectedItem).Id,
|
||||
exam_time = DateTime.Parse(textBoxDateTime.Text)
|
||||
exam_time = TimeSpan.Parse(textBoxTime.Text)
|
||||
};
|
||||
|
||||
// Обновляем модель автомобиля в базе данных
|
||||
@ -108,23 +119,15 @@ namespace ExamTimetable_Forms
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
|
||||
// Заполняем текстовые поля данными из выбранной строки
|
||||
textBoxDateTime.Text = row.Cells["Date"].Value.ToString();
|
||||
textBoxDate.Text = row.Cells["Date"].Value.ToString().Split(" ")[0];
|
||||
textBoxTime.Text= row.Cells["Time"].Value.ToString();
|
||||
textBoxPlace.Text = row.Cells["Place"].Value.ToString();
|
||||
textBoxSubject.Text = row.Cells["Subject"].Value.ToString();
|
||||
|
||||
// Получаем значение из выбранной строки
|
||||
string selectedCom = row.Cells["Comm"].Value.ToString();
|
||||
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxCom.DataSource = bd.GetComissions()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetComissionById(x.comm_id).teaching_stuff,
|
||||
Id = x.comm_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxCom.DisplayMember = "Text";
|
||||
comboBoxCom.ValueMember = "Id";
|
||||
|
||||
|
||||
// Выбираем универ, который соответствует выбранному значению в строке
|
||||
comboBoxCom.SelectedItem = selectedCom;
|
||||
|
@ -41,6 +41,8 @@
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
|
@ -34,6 +34,17 @@ namespace ExamTimetable_Forms
|
||||
dataGridView.Columns.Add("Fuc", "Факультет");
|
||||
}
|
||||
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxFuc.DataSource = bd.GetFaculties()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetFacultyById(x.faculty_id).faculty_name,
|
||||
Id = x.faculty_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxFuc.DisplayMember = "Text";
|
||||
comboBoxFuc.ValueMember = "Id";
|
||||
|
||||
// Заполняем dataGridView данными из списка моделей автомобилей
|
||||
foreach (Specialization specialization in specializations)
|
||||
{
|
||||
@ -107,16 +118,6 @@ namespace ExamTimetable_Forms
|
||||
// Получаем значение из выбранной строки
|
||||
string selectedFuc = row.Cells["Fuc"].Value.ToString();
|
||||
|
||||
// Загружаем список в комбо-бокс
|
||||
comboBoxFuc.DataSource = bd.GetFaculties()
|
||||
.Select(x => new helpCombobox()
|
||||
{
|
||||
Text = bd.GetFacultyById(x.faculty_id).faculty_name,
|
||||
Id = x.faculty_id
|
||||
})
|
||||
.ToList();
|
||||
comboBoxFuc.DisplayMember = "Text";
|
||||
comboBoxFuc.ValueMember = "Id";
|
||||
|
||||
// Выбираем универ, который соответствует выбранному значению в строке
|
||||
comboBoxFuc.SelectedItem = selectedFuc;
|
||||
|
@ -34,7 +34,7 @@ namespace ExamTimetable_Database
|
||||
public string exam_place { get; set; }
|
||||
public string exam_subject { get; set; }
|
||||
public int com_id { get; set; }
|
||||
public DateTime exam_time { get; set; }
|
||||
public TimeSpan exam_time { get; set; }
|
||||
}
|
||||
public class helpCombobox
|
||||
{
|
||||
|
@ -276,6 +276,7 @@ namespace ExamTimetable_Database
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM exam", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
var aboba = reader.GetDataTypeName(1);
|
||||
while (reader.Read())
|
||||
{
|
||||
exams.Add(new Exam
|
||||
@ -285,7 +286,7 @@ namespace ExamTimetable_Database
|
||||
exam_place = reader.GetString(2),
|
||||
exam_subject = reader.GetString(3),
|
||||
com_id = reader.GetInt32(4),
|
||||
exam_time = reader.GetDateTime(5)
|
||||
exam_time = reader.GetTimeSpan(5)
|
||||
});
|
||||
}
|
||||
return exams;
|
||||
@ -305,7 +306,7 @@ namespace ExamTimetable_Database
|
||||
exam_place = reader.GetString(2),
|
||||
exam_subject = reader.GetString(3),
|
||||
com_id = reader.GetInt32(4),
|
||||
exam_time = reader.GetDateTime(5)
|
||||
exam_time = reader.GetTimeSpan(5)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user