Create Form for create LabWork.
This commit is contained in:
parent
af7eb58283
commit
911fd9d6c6
162
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.Designer.cs
generated
Normal file
162
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
||||
namespace VisualComponentsForm
|
||||
{
|
||||
partial class FormCreateLabWork
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dropDownList = new COP_lab.DropDownList();
|
||||
inputInRange = new VisualComponents.InputInRange();
|
||||
textBoxStudents = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxQuestions = new TextBox();
|
||||
label4 = new Label();
|
||||
buttonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dropDownList
|
||||
//
|
||||
dropDownList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dropDownList.Location = new Point(12, 88);
|
||||
dropDownList.Name = "dropDownList";
|
||||
dropDownList.Selected = "";
|
||||
dropDownList.Size = new Size(191, 72);
|
||||
dropDownList.TabIndex = 0;
|
||||
//
|
||||
// inputInRange
|
||||
//
|
||||
inputInRange.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
inputInRange.Location = new Point(12, 34);
|
||||
inputInRange.MaxValue = null;
|
||||
inputInRange.MinValue = null;
|
||||
inputInRange.Name = "inputInRange";
|
||||
inputInRange.Size = new Size(191, 24);
|
||||
inputInRange.TabIndex = 1;
|
||||
inputInRange.Value = null;
|
||||
//
|
||||
// textBoxStudents
|
||||
//
|
||||
textBoxStudents.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxStudents.Location = new Point(12, 192);
|
||||
textBoxStudents.Name = "textBoxStudents";
|
||||
textBoxStudents.Size = new Size(191, 23);
|
||||
textBoxStudents.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 163);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(113, 15);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Сдавшие студенты:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 70);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(79, 15);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Дисциплина:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 9);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(120, 15);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "Тема лабораторной:";
|
||||
//
|
||||
// textBoxQuestions
|
||||
//
|
||||
textBoxQuestions.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxQuestions.Location = new Point(12, 270);
|
||||
textBoxQuestions.Name = "textBoxQuestions";
|
||||
textBoxQuestions.Size = new Size(191, 23);
|
||||
textBoxQuestions.TabIndex = 6;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(12, 238);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(152, 15);
|
||||
label4.TabIndex = 7;
|
||||
label4.Text = "Вопросы к лабораторной:";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonCreate.Location = new Point(224, 34);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(75, 23);
|
||||
buttonCreate.TabIndex = 8;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// FormCreateLabWork
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(314, 317);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(textBoxQuestions);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxStudents);
|
||||
Controls.Add(inputInRange);
|
||||
Controls.Add(dropDownList);
|
||||
Name = "FormCreateLabWork";
|
||||
Text = "Создание лабораторной работы";
|
||||
Load += FormCreateLabWork_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private COP_lab.DropDownList dropDownList;
|
||||
private VisualComponents.InputInRange inputInRange;
|
||||
private TextBox textBoxStudents;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxQuestions;
|
||||
private Label label4;
|
||||
private Button buttonCreate;
|
||||
}
|
||||
}
|
104
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.cs
Normal file
104
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Contracts.BindingModel;
|
||||
using Contracts.SearchModel;
|
||||
using Contracts.StorageContracts;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VisualComponentsLib;
|
||||
|
||||
namespace VisualComponentsForm
|
||||
{
|
||||
public partial class FormCreateLabWork : Form
|
||||
{
|
||||
public readonly ILabWorkStorage _labWorkStorage;
|
||||
|
||||
public readonly IDisciplineStorage _disciplineStorage;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCreateLabWork(ILabWorkStorage labWorkStorage, IDisciplineStorage disciplineStorage)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_labWorkStorage = labWorkStorage;
|
||||
_disciplineStorage = disciplineStorage;
|
||||
|
||||
//выставляем ограничения на длинну названия дисциплины
|
||||
inputInRange.MinValue = 1;
|
||||
inputInRange.MaxValue = 50;
|
||||
}
|
||||
|
||||
private void FormCreateLabWork_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var model = new LabWorkBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Theme = dropDownList.Selected,
|
||||
FCs = textBoxStudents.Text,
|
||||
Discipline = inputInRange.Text,
|
||||
Questions = textBoxQuestions.Text,
|
||||
};
|
||||
|
||||
if (!_id.HasValue)
|
||||
{
|
||||
_labWorkStorage.Insert(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_labWorkStorage.Update(model);
|
||||
}
|
||||
}
|
||||
|
||||
//загрузка данных для комбобокса
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _disciplineStorage.GetFullList();
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
dropDownList.AddingToList(item.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (_id.HasValue)
|
||||
{
|
||||
var model = _labWorkStorage.GetElement(new LabWorkSearchModel
|
||||
{
|
||||
Id = _id.Value,
|
||||
});
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
inputInRange.Value = model.Theme;
|
||||
dropDownList.Selected = model.Discipline;
|
||||
textBoxStudents.Text = model.FCs;
|
||||
textBoxQuestions.Text = model.Questions;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.resx
Normal file
120
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.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>
|
@ -57,7 +57,14 @@ namespace VisualComponentsForm
|
||||
{
|
||||
if (e.KeyCode == Keys.A)
|
||||
{
|
||||
//createOrderEntityItem_Click(sender, e);
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork));
|
||||
|
||||
if (service is FormCreateLabWork form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
|
||||
//LoadData();
|
||||
}
|
||||
}
|
||||
if (e.KeyCode == Keys.U)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ namespace VisualComponentsForm
|
||||
services.AddTransient<IDisciplineStorage, DisciplineStorage>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormCreateDiscipline>();
|
||||
services.AddTransient<FormCreateLabWork>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user