ExcelBuilder
This commit is contained in:
parent
7e70458d08
commit
733040c716
@ -5,18 +5,30 @@ namespace ProjectShedule.Entities;
|
|||||||
public class CurriculumSubject
|
public class CurriculumSubject
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
public int CurriculumId { get; private set; }
|
public int CurriculumId { get; private set; }
|
||||||
public IEnumerable<SubjectSubject> SubjectSubject { get; private set; } = [];
|
public IEnumerable<SubjectSubject> SubjectSubject { get; private set; } = [];
|
||||||
public Course Course { get; private set; }
|
public Course Course { get; private set; }
|
||||||
|
|
||||||
public static CurriculumSubject CreateCurriculumSubject(int id, int curriculumId, Course course, IEnumerable<SubjectSubject> subjectSubjects)
|
public static CurriculumSubject CreateCurriculumSubject(int id, DateTime date, int curriculumId, Course course, IEnumerable<SubjectSubject> subjectSubjects)
|
||||||
{
|
{
|
||||||
return new CurriculumSubject()
|
return new CurriculumSubject()
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
|
Date = date,
|
||||||
CurriculumId = curriculumId,
|
CurriculumId = curriculumId,
|
||||||
Course = course,
|
Course = course,
|
||||||
SubjectSubject = subjectSubjects
|
SubjectSubject = subjectSubjects
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public static CurriculumSubject CreateCurriculumSubject(TempCurriculumSubject tempCurriculumSubject, IEnumerable<SubjectSubject> subjectSubject)
|
||||||
|
{
|
||||||
|
return new CurriculumSubject
|
||||||
|
{
|
||||||
|
Id = tempCurriculumSubject.Id,
|
||||||
|
Date = tempCurriculumSubject.Date,
|
||||||
|
CurriculumId = tempCurriculumSubject.CurriculumId,
|
||||||
|
SubjectSubject = subjectSubject
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,14 @@ public class Shedule
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
public PairNumber PairNumber { get; private set; }
|
public PairNumber PairNumber { get; private set; }
|
||||||
|
public int PairCount { get; private set; }
|
||||||
public int StudentsGroupId { get; private set; }
|
public int StudentsGroupId { get; private set; }
|
||||||
public int TeacherId { get; private set; }
|
public int TeacherId { get; private set; }
|
||||||
public int SubjectId { get; private set; }
|
public int SubjectId { get; private set; }
|
||||||
public int ClassroomId { get; private set; }
|
public int ClassroomId { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public static Shedule CreateOperation(int id, DateTime date, PairNumber pairNumber
|
public static Shedule CreateOperation(int id, DateTime date, PairNumber pairNumber, int pairCount
|
||||||
, int studentsGroupId, int teacherId, int subjectId, int classroomId)
|
, int studentsGroupId, int teacherId, int subjectId, int classroomId)
|
||||||
{
|
{
|
||||||
return new Shedule
|
return new Shedule
|
||||||
@ -21,6 +22,7 @@ public class Shedule
|
|||||||
Id = id,
|
Id = id,
|
||||||
Date = date,
|
Date = date,
|
||||||
PairNumber = pairNumber,
|
PairNumber = pairNumber,
|
||||||
|
PairCount = pairCount,
|
||||||
StudentsGroupId = studentsGroupId,
|
StudentsGroupId = studentsGroupId,
|
||||||
TeacherId = teacherId,
|
TeacherId = teacherId,
|
||||||
SubjectId = subjectId,
|
SubjectId = subjectId,
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using ProjectShedule.Entities.Enums;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
|
public class TempCurriculumSubject
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
public int CurriculumId { get; private set; }
|
||||||
|
public int SubjectId { get; private set; }
|
||||||
|
public int LessonsCount { get; private set; }
|
||||||
|
public Course Course { get; private set; }
|
||||||
|
}
|
@ -40,6 +40,7 @@
|
|||||||
createCurriculumToolStripMenuItem = new ToolStripMenuItem();
|
createCurriculumToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
directoryReportToolStripMenuItem = new ToolStripMenuItem();
|
directoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
sheduleReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -118,7 +119,7 @@
|
|||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem });
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem, sheduleReportToolStripMenuItem });
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
@ -127,10 +128,18 @@
|
|||||||
//
|
//
|
||||||
directoryReportToolStripMenuItem.Name = "directoryReportToolStripMenuItem";
|
directoryReportToolStripMenuItem.Name = "directoryReportToolStripMenuItem";
|
||||||
directoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
directoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
directoryReportToolStripMenuItem.Size = new Size(354, 26);
|
directoryReportToolStripMenuItem.Size = new Size(382, 26);
|
||||||
directoryReportToolStripMenuItem.Text = "Документ со справочниками ";
|
directoryReportToolStripMenuItem.Text = "Документ со справочниками ";
|
||||||
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
|
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// sheduleReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
sheduleReportToolStripMenuItem.Name = "sheduleReportToolStripMenuItem";
|
||||||
|
sheduleReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
sheduleReportToolStripMenuItem.Size = new Size(432, 26);
|
||||||
|
sheduleReportToolStripMenuItem.Text = "Cводка по прохождению учебного плана";
|
||||||
|
sheduleReportToolStripMenuItem.Click += sheduleReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormSchedulingBureau
|
// FormSchedulingBureau
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -163,5 +172,6 @@
|
|||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem createCurriculumToolStripMenuItem;
|
private ToolStripMenuItem createCurriculumToolStripMenuItem;
|
||||||
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem sheduleReportToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using ProjectGasStation.Forms;
|
|
||||||
using ProjectShedule.Forms;
|
using ProjectShedule.Forms;
|
||||||
using System.ComponentModel;
|
|
||||||
using Unity;
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectShedule
|
namespace ProjectShedule
|
||||||
@ -118,5 +116,18 @@ namespace ProjectShedule
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sheduleReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormSheduleReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,11 @@
|
|||||||
textBoxClassroomNumber.Name = "textBoxClassroomNumber";
|
textBoxClassroomNumber.Name = "textBoxClassroomNumber";
|
||||||
textBoxClassroomNumber.Size = new Size(150, 27);
|
textBoxClassroomNumber.Size = new Size(150, 27);
|
||||||
textBoxClassroomNumber.TabIndex = 3;
|
textBoxClassroomNumber.TabIndex = 3;
|
||||||
|
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
label3.AutoSize = true;
|
label3.AutoSize = true;
|
||||||
label3.Location = new Point(47, 149);
|
label3.Location = new Point(47, 154);
|
||||||
label3.Name = "label3";
|
label3.Name = "label3";
|
||||||
label3.Size = new Size(116, 20);
|
label3.Size = new Size(116, 20);
|
||||||
label3.TabIndex = 4;
|
label3.TabIndex = 4;
|
||||||
@ -85,7 +84,7 @@
|
|||||||
//
|
//
|
||||||
comboBoxTypeClassroom.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxTypeClassroom.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxTypeClassroom.FormattingEnabled = true;
|
comboBoxTypeClassroom.FormattingEnabled = true;
|
||||||
comboBoxTypeClassroom.Location = new Point(219, 141);
|
comboBoxTypeClassroom.Location = new Point(218, 146);
|
||||||
comboBoxTypeClassroom.Name = "comboBoxTypeClassroom";
|
comboBoxTypeClassroom.Name = "comboBoxTypeClassroom";
|
||||||
comboBoxTypeClassroom.Size = new Size(151, 28);
|
comboBoxTypeClassroom.Size = new Size(151, 28);
|
||||||
comboBoxTypeClassroom.TabIndex = 5;
|
comboBoxTypeClassroom.TabIndex = 5;
|
||||||
|
@ -35,15 +35,17 @@
|
|||||||
comboBoxDirection = new ComboBox();
|
comboBoxDirection = new ComboBox();
|
||||||
comboBoxCourse = new ComboBox();
|
comboBoxCourse = new ComboBox();
|
||||||
groupBoxCurriculum = new GroupBox();
|
groupBoxCurriculum = new GroupBox();
|
||||||
dataGridViewCur = new DataGridView();
|
|
||||||
Column1 = new DataGridViewComboBoxColumn();
|
|
||||||
Column2 = new DataGridViewTextBoxColumn();
|
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
ColumnSubject = new DataGridViewComboBoxColumn();
|
ColumnSubject = new DataGridViewComboBoxColumn();
|
||||||
ColumnLessons = new DataGridViewTextBoxColumn();
|
ColumnLessons = new DataGridViewTextBoxColumn();
|
||||||
|
dataGridViewCur = new DataGridView();
|
||||||
|
Column1 = new DataGridViewComboBoxColumn();
|
||||||
|
Column2 = new DataGridViewTextBoxColumn();
|
||||||
|
dateTimePicker1 = new DateTimePicker();
|
||||||
|
label2 = new Label();
|
||||||
groupBoxCurriculum.SuspendLayout();
|
groupBoxCurriculum.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewCur).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewCur).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
@ -69,7 +71,7 @@
|
|||||||
// label4
|
// label4
|
||||||
//
|
//
|
||||||
label4.AutoSize = true;
|
label4.AutoSize = true;
|
||||||
label4.Location = new Point(115, 96);
|
label4.Location = new Point(115, 113);
|
||||||
label4.Name = "label4";
|
label4.Name = "label4";
|
||||||
label4.Size = new Size(44, 20);
|
label4.Size = new Size(44, 20);
|
||||||
label4.TabIndex = 16;
|
label4.TabIndex = 16;
|
||||||
@ -78,7 +80,7 @@
|
|||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
label1.AutoSize = true;
|
label1.AutoSize = true;
|
||||||
label1.Location = new Point(52, 44);
|
label1.Location = new Point(52, 73);
|
||||||
label1.Name = "label1";
|
label1.Name = "label1";
|
||||||
label1.Size = new Size(107, 20);
|
label1.Size = new Size(107, 20);
|
||||||
label1.TabIndex = 11;
|
label1.TabIndex = 11;
|
||||||
@ -88,7 +90,7 @@
|
|||||||
//
|
//
|
||||||
comboBoxDirection.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxDirection.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxDirection.FormattingEnabled = true;
|
comboBoxDirection.FormattingEnabled = true;
|
||||||
comboBoxDirection.Location = new Point(165, 36);
|
comboBoxDirection.Location = new Point(165, 65);
|
||||||
comboBoxDirection.Name = "comboBoxDirection";
|
comboBoxDirection.Name = "comboBoxDirection";
|
||||||
comboBoxDirection.Size = new Size(150, 28);
|
comboBoxDirection.Size = new Size(150, 28);
|
||||||
comboBoxDirection.TabIndex = 10;
|
comboBoxDirection.TabIndex = 10;
|
||||||
@ -97,7 +99,7 @@
|
|||||||
//
|
//
|
||||||
comboBoxCourse.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxCourse.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxCourse.FormattingEnabled = true;
|
comboBoxCourse.FormattingEnabled = true;
|
||||||
comboBoxCourse.Location = new Point(165, 93);
|
comboBoxCourse.Location = new Point(165, 110);
|
||||||
comboBoxCourse.Name = "comboBoxCourse";
|
comboBoxCourse.Name = "comboBoxCourse";
|
||||||
comboBoxCourse.Size = new Size(150, 28);
|
comboBoxCourse.Size = new Size(150, 28);
|
||||||
comboBoxCourse.TabIndex = 20;
|
comboBoxCourse.TabIndex = 20;
|
||||||
@ -114,33 +116,6 @@
|
|||||||
groupBoxCurriculum.TabStop = false;
|
groupBoxCurriculum.TabStop = false;
|
||||||
groupBoxCurriculum.Text = "Учбеный план";
|
groupBoxCurriculum.Text = "Учбеный план";
|
||||||
//
|
//
|
||||||
// dataGridViewCur
|
|
||||||
//
|
|
||||||
dataGridViewCur.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewCur.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewCur.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewCur.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2 });
|
|
||||||
dataGridViewCur.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewCur.Location = new Point(3, 23);
|
|
||||||
dataGridViewCur.Name = "dataGridViewCur";
|
|
||||||
dataGridViewCur.RowHeadersWidth = 51;
|
|
||||||
dataGridViewCur.Size = new Size(354, 289);
|
|
||||||
dataGridViewCur.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// Column1
|
|
||||||
//
|
|
||||||
Column1.HeaderText = "Column1";
|
|
||||||
Column1.MinimumWidth = 6;
|
|
||||||
Column1.Name = "Column1";
|
|
||||||
Column1.Width = 125;
|
|
||||||
//
|
|
||||||
// Column2
|
|
||||||
//
|
|
||||||
Column2.HeaderText = "Column2";
|
|
||||||
Column2.MinimumWidth = 6;
|
|
||||||
Column2.Name = "Column2";
|
|
||||||
Column2.Width = 125;
|
|
||||||
//
|
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
@ -171,11 +146,56 @@
|
|||||||
ColumnLessons.MinimumWidth = 6;
|
ColumnLessons.MinimumWidth = 6;
|
||||||
ColumnLessons.Name = "ColumnLessons";
|
ColumnLessons.Name = "ColumnLessons";
|
||||||
//
|
//
|
||||||
|
// dataGridViewCur
|
||||||
|
//
|
||||||
|
dataGridViewCur.AllowUserToResizeColumns = false;
|
||||||
|
dataGridViewCur.AllowUserToResizeRows = false;
|
||||||
|
dataGridViewCur.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewCur.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2 });
|
||||||
|
dataGridViewCur.Dock = DockStyle.Fill;
|
||||||
|
dataGridViewCur.Location = new Point(3, 23);
|
||||||
|
dataGridViewCur.Name = "dataGridViewCur";
|
||||||
|
dataGridViewCur.RowHeadersWidth = 51;
|
||||||
|
dataGridViewCur.Size = new Size(354, 289);
|
||||||
|
dataGridViewCur.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// Column1
|
||||||
|
//
|
||||||
|
Column1.HeaderText = "Column1";
|
||||||
|
Column1.MinimumWidth = 6;
|
||||||
|
Column1.Name = "Column1";
|
||||||
|
Column1.Width = 125;
|
||||||
|
//
|
||||||
|
// Column2
|
||||||
|
//
|
||||||
|
Column2.HeaderText = "Column2";
|
||||||
|
Column2.MinimumWidth = 6;
|
||||||
|
Column2.Name = "Column2";
|
||||||
|
Column2.Width = 125;
|
||||||
|
//
|
||||||
|
// dateTimePicker1
|
||||||
|
//
|
||||||
|
dateTimePicker1.Location = new Point(165, 23);
|
||||||
|
dateTimePicker1.Name = "dateTimePicker1";
|
||||||
|
dateTimePicker1.Size = new Size(150, 27);
|
||||||
|
dateTimePicker1.TabIndex = 22;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(24, 30);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(135, 20);
|
||||||
|
label2.TabIndex = 23;
|
||||||
|
label2.Text = "Дата составления:";
|
||||||
|
//
|
||||||
// FormCurriculumSubject
|
// FormCurriculumSubject
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(384, 522);
|
ClientSize = new Size(384, 522);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(dateTimePicker1);
|
||||||
Controls.Add(groupBoxCurriculum);
|
Controls.Add(groupBoxCurriculum);
|
||||||
Controls.Add(comboBoxCourse);
|
Controls.Add(comboBoxCourse);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
@ -186,8 +206,8 @@
|
|||||||
Name = "FormCurriculumSubject";
|
Name = "FormCurriculumSubject";
|
||||||
Text = "Составление учебного плана";
|
Text = "Составление учебного плана";
|
||||||
groupBoxCurriculum.ResumeLayout(false);
|
groupBoxCurriculum.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewCur).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewCur).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -207,5 +227,7 @@
|
|||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewComboBoxColumn ColumnSubject;
|
private DataGridViewComboBoxColumn ColumnSubject;
|
||||||
private DataGridViewTextBoxColumn ColumnLessons;
|
private DataGridViewTextBoxColumn ColumnLessons;
|
||||||
|
private DateTimePicker dateTimePicker1;
|
||||||
|
private Label label2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using ProjectShedule.Entities;
|
using ProjectShedule.Entities;
|
||||||
using ProjectShedule.Entities.Enums;
|
using ProjectShedule.Entities.Enums;
|
||||||
using ProjectShedule.Repositories;
|
using ProjectShedule.Repositories;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
namespace ProjectShedule.Forms
|
namespace ProjectShedule.Forms
|
||||||
@ -39,6 +40,7 @@ namespace ProjectShedule.Forms
|
|||||||
throw new Exception("Есть незаполненные поля");
|
throw new Exception("Есть незаполненные поля");
|
||||||
}
|
}
|
||||||
_curriculumSubjectRepository.CreateCurriculumSubject(CurriculumSubject.CreateCurriculumSubject(0,
|
_curriculumSubjectRepository.CreateCurriculumSubject(CurriculumSubject.CreateCurriculumSubject(0,
|
||||||
|
dateTimePicker1.Value,
|
||||||
(int)comboBoxDirection.SelectedValue!,
|
(int)comboBoxDirection.SelectedValue!,
|
||||||
(Course)comboBoxCourse.SelectedItem!,
|
(Course)comboBoxCourse.SelectedItem!,
|
||||||
CreateListSubjectSubjectFromDataGrid()));
|
CreateListSubjectSubjectFromDataGrid()));
|
||||||
@ -67,7 +69,8 @@ namespace ProjectShedule.Forms
|
|||||||
Convert.ToInt32(row.Cells["ColumnSubject"].Value),
|
Convert.ToInt32(row.Cells["ColumnSubject"].Value),
|
||||||
Convert.ToInt32(row.Cells["ColumnLessons"].Value)));
|
Convert.ToInt32(row.Cells["ColumnLessons"].Value)));
|
||||||
}
|
}
|
||||||
return list;
|
return list.GroupBy(x => x.SubjectId, x => x.LessonsCount, (id, counts) =>
|
||||||
|
SubjectSubject.CreateOperation(0, id, counts.Sum())).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,18 @@
|
|||||||
<metadata name="ColumnLessons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnLessons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="ColumnSubject.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnLessons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace ProjectGasStation.Forms
|
namespace ProjectShedule.Forms
|
||||||
{
|
{
|
||||||
partial class FormDirectoryReport
|
partial class FormDirectoryReport
|
||||||
{
|
{
|
||||||
@ -28,92 +28,91 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
checkBoxClassrooms = new CheckBox();
|
|
||||||
checkBoxTeachers = new CheckBox();
|
|
||||||
checkBoxSubjects = new CheckBox();
|
|
||||||
checkBoxCurriculums = new CheckBox();
|
|
||||||
buttonBuild = new Button();
|
|
||||||
checkBoxGroups = new CheckBox();
|
checkBoxGroups = new CheckBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
checkBoxCurriculums = new CheckBox();
|
||||||
|
checkBoxSubjects = new CheckBox();
|
||||||
|
checkBoxTeachers = new CheckBox();
|
||||||
|
checkBoxClassrooms = new CheckBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// checkBoxClassrooms
|
|
||||||
//
|
|
||||||
checkBoxClassrooms.AutoSize = true;
|
|
||||||
checkBoxClassrooms.Location = new Point(14, 16);
|
|
||||||
checkBoxClassrooms.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxClassrooms.Name = "checkBoxClassrooms";
|
|
||||||
checkBoxClassrooms.Size = new Size(107, 24);
|
|
||||||
checkBoxClassrooms.TabIndex = 0;
|
|
||||||
checkBoxClassrooms.Text = "Аудитории";
|
|
||||||
checkBoxClassrooms.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxTeachers
|
|
||||||
//
|
|
||||||
checkBoxTeachers.AutoSize = true;
|
|
||||||
checkBoxTeachers.Location = new Point(14, 61);
|
|
||||||
checkBoxTeachers.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxTeachers.Name = "checkBoxTeachers";
|
|
||||||
checkBoxTeachers.Size = new Size(140, 24);
|
|
||||||
checkBoxTeachers.TabIndex = 1;
|
|
||||||
checkBoxTeachers.Text = "Преподаватели";
|
|
||||||
checkBoxTeachers.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxSubjects
|
|
||||||
//
|
|
||||||
checkBoxSubjects.AutoSize = true;
|
|
||||||
checkBoxSubjects.Location = new Point(14, 109);
|
|
||||||
checkBoxSubjects.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxSubjects.Name = "checkBoxSubjects";
|
|
||||||
checkBoxSubjects.Size = new Size(121, 24);
|
|
||||||
checkBoxSubjects.TabIndex = 2;
|
|
||||||
checkBoxSubjects.Text = "Дисциплины";
|
|
||||||
checkBoxSubjects.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxCurriculums
|
|
||||||
//
|
|
||||||
checkBoxCurriculums.AutoSize = true;
|
|
||||||
checkBoxCurriculums.Location = new Point(14, 157);
|
|
||||||
checkBoxCurriculums.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxCurriculums.Name = "checkBoxCurriculums";
|
|
||||||
checkBoxCurriculums.Size = new Size(127, 24);
|
|
||||||
checkBoxCurriculums.TabIndex = 3;
|
|
||||||
checkBoxCurriculums.Text = "Направлении";
|
|
||||||
checkBoxCurriculums.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// buttonBuild
|
|
||||||
//
|
|
||||||
buttonBuild.Location = new Point(12, 257);
|
|
||||||
buttonBuild.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonBuild.Name = "buttonBuild";
|
|
||||||
buttonBuild.Size = new Size(159, 31);
|
|
||||||
buttonBuild.TabIndex = 4;
|
|
||||||
buttonBuild.Text = "Сформировать";
|
|
||||||
buttonBuild.UseVisualStyleBackColor = true;
|
|
||||||
buttonBuild.Click += buttonBuild_Click;
|
|
||||||
//
|
|
||||||
// checkBoxGroups
|
// checkBoxGroups
|
||||||
//
|
//
|
||||||
checkBoxGroups.AutoSize = true;
|
checkBoxGroups.AutoSize = true;
|
||||||
checkBoxGroups.Location = new Point(14, 206);
|
checkBoxGroups.Location = new Point(12, 203);
|
||||||
checkBoxGroups.Margin = new Padding(3, 4, 3, 4);
|
checkBoxGroups.Margin = new Padding(3, 4, 3, 4);
|
||||||
checkBoxGroups.Name = "checkBoxGroups";
|
checkBoxGroups.Name = "checkBoxGroups";
|
||||||
checkBoxGroups.Size = new Size(83, 24);
|
checkBoxGroups.Size = new Size(83, 24);
|
||||||
checkBoxGroups.TabIndex = 5;
|
checkBoxGroups.TabIndex = 11;
|
||||||
checkBoxGroups.Text = "Группы";
|
checkBoxGroups.Text = "Группы";
|
||||||
checkBoxGroups.UseVisualStyleBackColor = true;
|
checkBoxGroups.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(10, 254);
|
||||||
|
buttonBuild.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(159, 31);
|
||||||
|
buttonBuild.TabIndex = 10;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += buttonBuild_Click;
|
||||||
|
//
|
||||||
|
// checkBoxCurriculums
|
||||||
|
//
|
||||||
|
checkBoxCurriculums.AutoSize = true;
|
||||||
|
checkBoxCurriculums.Location = new Point(12, 154);
|
||||||
|
checkBoxCurriculums.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxCurriculums.Name = "checkBoxCurriculums";
|
||||||
|
checkBoxCurriculums.Size = new Size(127, 24);
|
||||||
|
checkBoxCurriculums.TabIndex = 9;
|
||||||
|
checkBoxCurriculums.Text = "Направлении";
|
||||||
|
checkBoxCurriculums.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxSubjects
|
||||||
|
//
|
||||||
|
checkBoxSubjects.AutoSize = true;
|
||||||
|
checkBoxSubjects.Location = new Point(12, 106);
|
||||||
|
checkBoxSubjects.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxSubjects.Name = "checkBoxSubjects";
|
||||||
|
checkBoxSubjects.Size = new Size(121, 24);
|
||||||
|
checkBoxSubjects.TabIndex = 8;
|
||||||
|
checkBoxSubjects.Text = "Дисциплины";
|
||||||
|
checkBoxSubjects.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxTeachers
|
||||||
|
//
|
||||||
|
checkBoxTeachers.AutoSize = true;
|
||||||
|
checkBoxTeachers.Location = new Point(12, 58);
|
||||||
|
checkBoxTeachers.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxTeachers.Name = "checkBoxTeachers";
|
||||||
|
checkBoxTeachers.Size = new Size(140, 24);
|
||||||
|
checkBoxTeachers.TabIndex = 7;
|
||||||
|
checkBoxTeachers.Text = "Преподаватели";
|
||||||
|
checkBoxTeachers.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxClassrooms
|
||||||
|
//
|
||||||
|
checkBoxClassrooms.AutoSize = true;
|
||||||
|
checkBoxClassrooms.Location = new Point(12, 13);
|
||||||
|
checkBoxClassrooms.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
checkBoxClassrooms.Name = "checkBoxClassrooms";
|
||||||
|
checkBoxClassrooms.Size = new Size(107, 24);
|
||||||
|
checkBoxClassrooms.TabIndex = 6;
|
||||||
|
checkBoxClassrooms.Text = "Аудитории";
|
||||||
|
checkBoxClassrooms.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// FormDirectoryReport
|
// FormDirectoryReport
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(191, 317);
|
ClientSize = new Size(187, 300);
|
||||||
Controls.Add(checkBoxGroups);
|
Controls.Add(checkBoxGroups);
|
||||||
Controls.Add(buttonBuild);
|
Controls.Add(buttonBuild);
|
||||||
Controls.Add(checkBoxCurriculums);
|
Controls.Add(checkBoxCurriculums);
|
||||||
Controls.Add(checkBoxSubjects);
|
Controls.Add(checkBoxSubjects);
|
||||||
Controls.Add(checkBoxTeachers);
|
Controls.Add(checkBoxTeachers);
|
||||||
Controls.Add(checkBoxClassrooms);
|
Controls.Add(checkBoxClassrooms);
|
||||||
Margin = new Padding(3, 4, 3, 4);
|
|
||||||
Name = "FormDirectoryReport";
|
Name = "FormDirectoryReport";
|
||||||
Text = "FormDirectoryReport";
|
Text = "FormDirectoryReport";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
@ -122,11 +121,11 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private CheckBox checkBoxClassrooms;
|
|
||||||
private CheckBox checkBoxTeachers;
|
|
||||||
private CheckBox checkBoxSubjects;
|
|
||||||
private CheckBox checkBoxCurriculums;
|
|
||||||
private Button buttonBuild;
|
|
||||||
private CheckBox checkBoxGroups;
|
private CheckBox checkBoxGroups;
|
||||||
|
private Button buttonBuild;
|
||||||
|
private CheckBox checkBoxCurriculums;
|
||||||
|
private CheckBox checkBoxSubjects;
|
||||||
|
private CheckBox checkBoxTeachers;
|
||||||
|
private CheckBox checkBoxClassrooms;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,52 +1,52 @@
|
|||||||
using ProjectShedule.Reports;
|
using ProjectShedule.Reports;
|
||||||
using Unity;
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectGasStation.Forms;
|
namespace ProjectShedule.Forms
|
||||||
|
|
||||||
public partial class FormDirectoryReport : Form
|
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
public partial class FormDirectoryReport : Form
|
||||||
public FormDirectoryReport(IUnityContainer container)
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
private readonly IUnityContainer _container;
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
public FormDirectoryReport(IUnityContainer container)
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonBuild_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (!checkBoxClassrooms.Checked && !checkBoxTeachers.Checked && !checkBoxSubjects.Checked && !checkBoxCurriculums.Checked && !checkBoxGroups.Checked)
|
InitializeComponent();
|
||||||
{
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
|
||||||
}
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Docx Files | *.docx"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() != DialogResult.OK)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран файла для отчета");
|
|
||||||
}
|
|
||||||
if
|
|
||||||
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxClassrooms.Checked, checkBoxTeachers.Checked, checkBoxSubjects.Checked, checkBoxCurriculums.Checked, checkBoxGroups.Checked))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!checkBoxClassrooms.Checked && !checkBoxTeachers.Checked && !checkBoxSubjects.Checked && !checkBoxCurriculums.Checked && !checkBoxGroups.Checked)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||||
|
}
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Docx Files | *.docx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран файла для отчета");
|
||||||
|
}
|
||||||
|
if
|
||||||
|
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxClassrooms.Checked, checkBoxTeachers.Checked, checkBoxSubjects.Checked, checkBoxCurriculums.Checked, checkBoxGroups.Checked))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace ProjectShedule.Forms
|
|||||||
comboBoxClassroom.DataSource = classroomRepository.ReadClassroom();
|
comboBoxClassroom.DataSource = classroomRepository.ReadClassroom();
|
||||||
comboBoxClassroom.DisplayMember = "Name";
|
comboBoxClassroom.DisplayMember = "Name";
|
||||||
comboBoxClassroom.ValueMember = "Id";
|
comboBoxClassroom.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -45,13 +45,16 @@ namespace ProjectShedule.Forms
|
|||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
PairNumber pairNumber = PairNumber.None;
|
PairNumber pairNumber = PairNumber.None;
|
||||||
|
int pairCount = 0;
|
||||||
foreach (var elem in checkedListBox.CheckedItems)
|
foreach (var elem in checkedListBox.CheckedItems)
|
||||||
{
|
{
|
||||||
pairNumber |= (PairNumber)elem;
|
pairNumber |= (PairNumber)elem;
|
||||||
|
pairCount++;
|
||||||
}
|
}
|
||||||
_sheduleRepository.CreateShedule(Shedule.CreateOperation(0,
|
_sheduleRepository.CreateShedule(Shedule.CreateOperation(0,
|
||||||
dateTimePicker.Value,
|
dateTimePicker.Value,
|
||||||
pairNumber,
|
pairNumber,
|
||||||
|
pairCount,
|
||||||
(int)comboBoxGroup.SelectedValue!,
|
(int)comboBoxGroup.SelectedValue!,
|
||||||
(int)comboBoxTeacher.SelectedValue!,
|
(int)comboBoxTeacher.SelectedValue!,
|
||||||
(int)comboBoxSubject.SelectedValue!,
|
(int)comboBoxSubject.SelectedValue!,
|
||||||
|
168
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.Designer.cs
generated
Normal file
168
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.Designer.cs
generated
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
namespace ProjectShedule.Forms
|
||||||
|
{
|
||||||
|
partial class FormSheduleReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
label4 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
buttonFile = new Button();
|
||||||
|
textBoxFilePath = new TextBox();
|
||||||
|
comboBoxSubject = new ComboBox();
|
||||||
|
dateTimePickerStart = new DateTimePicker();
|
||||||
|
dateTimePickerEnd = new DateTimePicker();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(27, 183);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(90, 20);
|
||||||
|
label4.TabIndex = 19;
|
||||||
|
label4.Text = "Дата конца:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(27, 132);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(97, 20);
|
||||||
|
label3.TabIndex = 18;
|
||||||
|
label3.Text = "Дата начала:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(27, 75);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(73, 20);
|
||||||
|
label2.TabIndex = 17;
|
||||||
|
label2.Text = "Предмет:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(27, 23);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(112, 20);
|
||||||
|
label1.TabIndex = 16;
|
||||||
|
label1.Text = "Путь до файла:";
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(27, 233);
|
||||||
|
buttonBuild.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(338, 31);
|
||||||
|
buttonBuild.TabIndex = 15;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += buttonBuild_Click;
|
||||||
|
//
|
||||||
|
// buttonFile
|
||||||
|
//
|
||||||
|
buttonFile.Location = new Point(333, 19);
|
||||||
|
buttonFile.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonFile.Name = "buttonFile";
|
||||||
|
buttonFile.Size = new Size(30, 31);
|
||||||
|
buttonFile.TabIndex = 14;
|
||||||
|
buttonFile.Text = "...";
|
||||||
|
buttonFile.UseVisualStyleBackColor = true;
|
||||||
|
buttonFile.Click += buttonFile_Click;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(137, 19);
|
||||||
|
textBoxFilePath.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.Size = new Size(189, 27);
|
||||||
|
textBoxFilePath.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// comboBoxSubject
|
||||||
|
//
|
||||||
|
comboBoxSubject.FormattingEnabled = true;
|
||||||
|
comboBoxSubject.Location = new Point(137, 71);
|
||||||
|
comboBoxSubject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxSubject.Name = "comboBoxSubject";
|
||||||
|
comboBoxSubject.Size = new Size(226, 28);
|
||||||
|
comboBoxSubject.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// dateTimePickerStart
|
||||||
|
//
|
||||||
|
dateTimePickerStart.Location = new Point(137, 124);
|
||||||
|
dateTimePickerStart.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||||
|
dateTimePickerStart.Size = new Size(228, 27);
|
||||||
|
dateTimePickerStart.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// dateTimePickerEnd
|
||||||
|
//
|
||||||
|
dateTimePickerEnd.Location = new Point(137, 175);
|
||||||
|
dateTimePickerEnd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||||
|
dateTimePickerEnd.Size = new Size(228, 27);
|
||||||
|
dateTimePickerEnd.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// FormSheduleReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(402, 278);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(buttonFile);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(comboBoxSubject);
|
||||||
|
Controls.Add(dateTimePickerStart);
|
||||||
|
Controls.Add(dateTimePickerEnd);
|
||||||
|
Name = "FormSheduleReport";
|
||||||
|
Text = "Отчет по прохождению учебного плана";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label4;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonBuild;
|
||||||
|
private Button buttonFile;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private ComboBox comboBoxSubject;
|
||||||
|
private DateTimePicker dateTimePickerStart;
|
||||||
|
private DateTimePicker dateTimePickerEnd;
|
||||||
|
}
|
||||||
|
}
|
70
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.cs
Normal file
70
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using ProjectShedule.Reports;
|
||||||
|
using ProjectShedule.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Forms
|
||||||
|
{
|
||||||
|
public partial class FormSheduleReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormSheduleReport(IUnityContainer container, ISubjectRepository subjectRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
|
||||||
|
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
|
||||||
|
comboBoxSubject.DisplayMember = "Name";
|
||||||
|
comboBoxSubject.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonFile_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files | *.xlsx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textBoxFilePath.Text = sfd.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
if (comboBoxSubject.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран корм");
|
||||||
|
}
|
||||||
|
if (dateTimePickerEnd.Value <= dateTimePickerStart.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxSubject.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.resx
Normal file
120
ProjectShedule/ProjectShedule/Forms/FormSheduleReport.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>
|
@ -1,10 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ProjectShedule.Repositories;
|
using ProjectShedule.Repositories;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectShedule.Reports;
|
namespace ProjectShedule.Reports;
|
||||||
internal class DocReport
|
internal class DocReport
|
||||||
|
311
ProjectShedule/ProjectShedule/Reports/ExcelBuilder.cs
Normal file
311
ProjectShedule/ProjectShedule/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Reports;
|
||||||
|
|
||||||
|
internal class ExcelBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
private readonly SheetData _sheetData;
|
||||||
|
private readonly MergeCells _mergeCells;
|
||||||
|
private readonly Columns _columns;
|
||||||
|
private uint _rowIndex = 0;
|
||||||
|
|
||||||
|
public ExcelBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
_filePath = filePath;
|
||||||
|
_sheetData = new SheetData();
|
||||||
|
_mergeCells = new MergeCells();
|
||||||
|
_columns = new Columns();
|
||||||
|
_rowIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||||
|
{
|
||||||
|
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||||
|
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||||
|
{
|
||||||
|
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
}
|
||||||
|
_mergeCells.Append(new MergeCell()
|
||||||
|
{
|
||||||
|
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||||
|
});
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||||
|
{
|
||||||
|
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(columnsWidths));
|
||||||
|
}
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint counter = 1;
|
||||||
|
int coef = 2;
|
||||||
|
_columns.Append(columnsWidths.Select(x => new Column
|
||||||
|
{
|
||||||
|
Min = counter,
|
||||||
|
Max = counter++,
|
||||||
|
Width = x * coef,
|
||||||
|
CustomWidth = true
|
||||||
|
}));
|
||||||
|
for (var j = 0; j < data.First().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
_rowIndex++;
|
||||||
|
|
||||||
|
for (var i = 1; i < data.Count - 1; ++i)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < data[i].Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||||
|
}
|
||||||
|
_rowIndex++;
|
||||||
|
}
|
||||||
|
for (var j = 0; j < data.Last().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||||
|
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||||
|
GenerateStyle(workbookpart);
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet();
|
||||||
|
|
||||||
|
if (_columns.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.Append(_columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
worksheetPart.Worksheet.Append(_sheetData);
|
||||||
|
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист 1"
|
||||||
|
};
|
||||||
|
sheets.Append(sheet);
|
||||||
|
if (_mergeCells.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||||
|
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||||
|
{
|
||||||
|
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||||
|
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
|
var fonts = new Fonts()
|
||||||
|
{
|
||||||
|
Count = 2,
|
||||||
|
KnownFonts = BooleanValue.FromBoolean(true)
|
||||||
|
};
|
||||||
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
|
{
|
||||||
|
FontSize = new FontSize() { Val = 11 },
|
||||||
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
|
{
|
||||||
|
FontSize = new FontSize() { Val = 11 },
|
||||||
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
},
|
||||||
|
Bold = new Bold() { Val = true }
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fonts);
|
||||||
|
|
||||||
|
// Default Fill
|
||||||
|
var fills = new Fills() { Count = 1 };
|
||||||
|
fills.Append(new Fill
|
||||||
|
{
|
||||||
|
PatternFill = new PatternFill()
|
||||||
|
{
|
||||||
|
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fills);
|
||||||
|
|
||||||
|
// Default Border
|
||||||
|
var borders = new Borders() { Count = 2 };
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder(),
|
||||||
|
RightBorder = new RightBorder(),
|
||||||
|
TopBorder = new TopBorder(),
|
||||||
|
BottomBorder = new BottomBorder(),
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(borders);
|
||||||
|
|
||||||
|
// Default cell format and a date cell format
|
||||||
|
var cellFormats = new CellFormats() { Count = 4 };
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Right,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum StyleIndex
|
||||||
|
{
|
||||||
|
SimpleTextWithoutBorder = 0,
|
||||||
|
SimpleTextWithBorder = 1,
|
||||||
|
BoldTextWithoutBorder = 2,
|
||||||
|
BoldTextWithBorder = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||||
|
{
|
||||||
|
var columnName = GetExcelColumnName(columnIndex);
|
||||||
|
var cellReference = columnName + rowIndex;
|
||||||
|
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||||
|
if (row == null)
|
||||||
|
{
|
||||||
|
row = new Row() { RowIndex = rowIndex };
|
||||||
|
_sheetData.Append(row);
|
||||||
|
}
|
||||||
|
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null &&
|
||||||
|
c.CellReference.Value == columnName + rowIndex);
|
||||||
|
if (newCell == null)
|
||||||
|
{
|
||||||
|
Cell? refCell = null;
|
||||||
|
foreach (Cell cell in row.Elements<Cell>())
|
||||||
|
{
|
||||||
|
if (cell.CellReference?.Value != null &&
|
||||||
|
cell.CellReference.Value.Length == cellReference.Length)
|
||||||
|
{
|
||||||
|
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||||
|
{
|
||||||
|
refCell = cell;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newCell = new Cell() { CellReference = cellReference };
|
||||||
|
row.InsertBefore(newCell, refCell);
|
||||||
|
}
|
||||||
|
newCell.CellValue = new CellValue(text);
|
||||||
|
newCell.DataType = CellValues.String;
|
||||||
|
newCell.StyleIndex = (uint)styleIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetExcelColumnName(int columnNumber)
|
||||||
|
{
|
||||||
|
columnNumber += 1;
|
||||||
|
int dividend = columnNumber;
|
||||||
|
string columnName = string.Empty;
|
||||||
|
int modulo;
|
||||||
|
while (dividend > 0)
|
||||||
|
{
|
||||||
|
modulo = (dividend - 1) % 26;
|
||||||
|
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||||
|
dividend = (dividend - modulo) / 26;
|
||||||
|
}
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
}
|
71
ProjectShedule/ProjectShedule/Reports/TableReport.cs
Normal file
71
ProjectShedule/ProjectShedule/Reports/TableReport.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectShedule.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Reports;
|
||||||
|
|
||||||
|
internal class TableReport
|
||||||
|
{
|
||||||
|
private readonly ICurriculumSubjectRepository _curriculumSubjectRepository;
|
||||||
|
private readonly ISheduleRepository _sheduleRepository;
|
||||||
|
private readonly ILogger<TableReport> _logger;
|
||||||
|
internal static readonly string[] item = ["Дата", "Количество установленных занятий", "Количество поставленных занятий"];
|
||||||
|
|
||||||
|
public TableReport(ICurriculumSubjectRepository curriculumSubjectRepository, ISheduleRepository sheduleRepository, ILogger<TableReport> logger)
|
||||||
|
{
|
||||||
|
_curriculumSubjectRepository = curriculumSubjectRepository ?? throw new ArgumentNullException(nameof(curriculumSubjectRepository));
|
||||||
|
_sheduleRepository = sheduleRepository ?? throw new ArgumentNullException(nameof(sheduleRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTable(string filePath, int subjectId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new ExcelBuilder(filePath)
|
||||||
|
.AddHeader("Сводка по прохождению учебного плана", 0, 3)
|
||||||
|
.AddParagraph("за период", 0)
|
||||||
|
.AddTable([10, 15, 15], GetData(subjectId, startDate, endDate))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetData(int subjectId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
var data = _curriculumSubjectRepository
|
||||||
|
.ReadCurriculumSubject()
|
||||||
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.SubjectSubject.Any(y => y.SubjectId == subjectId))
|
||||||
|
.Select(x => new {Date = x.Date, CountIn = x.SubjectSubject.FirstOrDefault(y => y.SubjectId == subjectId)?.LessonsCount, CountOut = (int?)null})
|
||||||
|
.Union(
|
||||||
|
_sheduleRepository
|
||||||
|
.ReadShedule()
|
||||||
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.SubjectId == subjectId)
|
||||||
|
.Select(x => new { Date = x.Date, CountIn = (int?)null, CountOut = x?.PairCount})
|
||||||
|
)
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
var groupedData = data
|
||||||
|
.GroupBy(x => x.Date)
|
||||||
|
.Select(g => new
|
||||||
|
{
|
||||||
|
Date = g.Key,
|
||||||
|
TotalIn = g.Sum(x => x.CountIn),
|
||||||
|
TotalOut = g.Sum(x => x.CountOut)
|
||||||
|
})
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
return
|
||||||
|
new List<string[]>() { item }
|
||||||
|
.Union( groupedData
|
||||||
|
.Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.TotalIn.ToString()!, x.TotalOut.ToString()! }))
|
||||||
|
.Union(
|
||||||
|
new[] { new string[] { "Всего", groupedData.Sum(x => x.TotalIn).ToString()!, groupedData.Sum(x => x.TotalOut).ToString()! } }
|
||||||
|
)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ namespace ProjectShedule.Repositories;
|
|||||||
|
|
||||||
public interface ICurriculumSubjectRepository
|
public interface ICurriculumSubjectRepository
|
||||||
{
|
{
|
||||||
IEnumerable<CurriculumSubject> ReadCurriculumSubject();
|
IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null);
|
||||||
void DeleteCurriculumSubject(int id);
|
void DeleteCurriculumSubject(int id);
|
||||||
void CreateCurriculumSubject(CurriculumSubject curriculumSubject);
|
void CreateCurriculumSubject(CurriculumSubject curriculumSubject);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace ProjectShedule.Repositories;
|
|||||||
|
|
||||||
public interface ISheduleRepository
|
public interface ISheduleRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Shedule> ReadShedule(DateTime? dateTime = null, int? groupId = null);
|
IEnumerable<Shedule> ReadShedule(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null);
|
||||||
void CreateShedule(Shedule shedule);
|
void CreateShedule(Shedule shedule);
|
||||||
void DeleteShedule(int id);
|
void DeleteShedule(int id);
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ public class CurriculumSubjectRepository : ICurriculumSubjectRepository
|
|||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert =
|
var queryInsert =
|
||||||
@"
|
@"
|
||||||
INSERT INTO CurriculumSubject (CurriculumId, Course)
|
INSERT INTO CurriculumSubject (Date, CurriculumId, Course)
|
||||||
VALUES (@CurriculumId, @Course);
|
VALUES (@Date, @CurriculumId, @Course);
|
||||||
SELECT MAX(Id) FROM CurriculumSubject";
|
SELECT MAX(Id) FROM CurriculumSubject";
|
||||||
var curriculumSubjectId =
|
var curriculumSubjectId =
|
||||||
connection.QueryFirst<int>(queryInsert, curriculumSubject, transaction);
|
connection.QueryFirst<int>(queryInsert, curriculumSubject, transaction);
|
||||||
@ -72,17 +72,19 @@ public class CurriculumSubjectRepository : ICurriculumSubjectRepository
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<CurriculumSubject> ReadCurriculumSubject()
|
public IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM CurriculumSubject";
|
var querySelect = @"SELECT cs.*, ss.SubjectId, ss.LessonsCount FROM CurriculumSubject cs
|
||||||
var curriculumSubjects = connection.Query<CurriculumSubject>(querySelect);
|
INNER JOIN SubjectSubject ss on ss.CurriculumSubjectId = cs.Id";
|
||||||
|
var curriculumSubjects = connection.Query<TempCurriculumSubject>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(curriculumSubjects));
|
JsonConvert.SerializeObject(curriculumSubjects));
|
||||||
return curriculumSubjects;
|
return curriculumSubjects.GroupBy(x => x.Id, y => y, (key, value) => CurriculumSubject.CreateCurriculumSubject(value.First(),
|
||||||
|
value.Select(z => SubjectSubject.CreateOperation(0, z.SubjectId, z.LessonsCount)))).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,8 @@ public class SheduleRepository : ISheduleRepository
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Shedule (Date, PairNumber, StudentsGroupId, TeacherId, SubjectId, ClassroomId)
|
INSERT INTO Shedule (Date, PairNumber, PairCount, StudentsGroupId, TeacherId, SubjectId, ClassroomId)
|
||||||
VALUES (@Date, @PairNumber, @StudentsGroupId, @TeacherId, @SubjectId, @ClassroomId)";
|
VALUES (@Date, @PairNumber, @PairCount, @StudentsGroupId, @TeacherId, @SubjectId, @ClassroomId)";
|
||||||
connection.Execute(queryInsert, shedule);
|
connection.Execute(queryInsert, shedule);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -53,7 +53,7 @@ public class SheduleRepository : ISheduleRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Shedule> ReadShedule(DateTime? dateTime = null, int? groupId = null)
|
public IEnumerable<Shedule> ReadShedule(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user