yes
This commit is contained in:
parent
c77fb562f1
commit
cf95a4ed0f
11
PlumbingRepair/App.config
Normal file
11
PlumbingRepair/App.config
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="SmtpClientHost" value="smtp.gmail.com" />
|
||||
<add key="SmtpClientPort" value="587" />
|
||||
<add key="PopHost" value="pop.gmail.com" />
|
||||
<add key="PopPort" value="995" />
|
||||
<add key="MailLogin" value="labwork7turner@gmail.com" />
|
||||
<add key="MailPassword" value="daxm gvdc qdza sfza" />
|
||||
</appSettings>
|
||||
</configuration>
|
67
PlumbingRepair/FormCreateOrder.Designer.cs
generated
67
PlumbingRepair/FormCreateOrder.Designer.cs
generated
@ -36,68 +36,66 @@
|
||||
this.SumTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBoxClient = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// WorkNameLabel
|
||||
//
|
||||
this.WorkNameLabel.AutoSize = true;
|
||||
this.WorkNameLabel.Location = new System.Drawing.Point(14, 12);
|
||||
this.WorkNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.WorkNameLabel.Name = "WorkNameLabel";
|
||||
this.WorkNameLabel.Size = new System.Drawing.Size(75, 20);
|
||||
this.WorkNameLabel.Size = new System.Drawing.Size(51, 15);
|
||||
this.WorkNameLabel.TabIndex = 0;
|
||||
this.WorkNameLabel.Text = "Изделие: ";
|
||||
this.WorkNameLabel.Text = "Работа: ";
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
this.CountLabel.AutoSize = true;
|
||||
this.CountLabel.Location = new System.Drawing.Point(14, 53);
|
||||
this.CountLabel.Location = new System.Drawing.Point(12, 40);
|
||||
this.CountLabel.Name = "CountLabel";
|
||||
this.CountLabel.Size = new System.Drawing.Size(97, 20);
|
||||
this.CountLabel.Size = new System.Drawing.Size(78, 15);
|
||||
this.CountLabel.TabIndex = 1;
|
||||
this.CountLabel.Text = "Количество: ";
|
||||
//
|
||||
// SumLabel
|
||||
//
|
||||
this.SumLabel.AutoSize = true;
|
||||
this.SumLabel.Location = new System.Drawing.Point(14, 96);
|
||||
this.SumLabel.Location = new System.Drawing.Point(12, 72);
|
||||
this.SumLabel.Name = "SumLabel";
|
||||
this.SumLabel.Size = new System.Drawing.Size(62, 20);
|
||||
this.SumLabel.Size = new System.Drawing.Size(51, 15);
|
||||
this.SumLabel.TabIndex = 2;
|
||||
this.SumLabel.Text = "Сумма: ";
|
||||
//
|
||||
// WorkComboBox
|
||||
//
|
||||
this.WorkComboBox.FormattingEnabled = true;
|
||||
this.WorkComboBox.Location = new System.Drawing.Point(106, 8);
|
||||
this.WorkComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.WorkComboBox.Location = new System.Drawing.Point(93, 6);
|
||||
this.WorkComboBox.Name = "WorkComboBox";
|
||||
this.WorkComboBox.Size = new System.Drawing.Size(229, 28);
|
||||
this.WorkComboBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.WorkComboBox.TabIndex = 3;
|
||||
this.WorkComboBox.SelectedIndexChanged += new System.EventHandler(this.WorkComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
this.CountTextBox.Location = new System.Drawing.Point(106, 49);
|
||||
this.CountTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.CountTextBox.Location = new System.Drawing.Point(93, 37);
|
||||
this.CountTextBox.Name = "CountTextBox";
|
||||
this.CountTextBox.Size = new System.Drawing.Size(229, 27);
|
||||
this.CountTextBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.CountTextBox.TabIndex = 4;
|
||||
this.CountTextBox.TextChanged += new System.EventHandler(this.CountTextBox_TextChanged);
|
||||
//
|
||||
// SumTextBox
|
||||
//
|
||||
this.SumTextBox.Location = new System.Drawing.Point(106, 92);
|
||||
this.SumTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SumTextBox.Location = new System.Drawing.Point(93, 69);
|
||||
this.SumTextBox.Name = "SumTextBox";
|
||||
this.SumTextBox.Size = new System.Drawing.Size(229, 27);
|
||||
this.SumTextBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.SumTextBox.TabIndex = 5;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(250, 151);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(222, 191);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonCancel.TabIndex = 6;
|
||||
this.ButtonCancel.Text = "Отменить";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
@ -105,20 +103,38 @@
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(147, 151);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.SaveButton.Location = new System.Drawing.Point(130, 191);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(97, 31);
|
||||
this.SaveButton.Size = new System.Drawing.Size(85, 23);
|
||||
this.SaveButton.TabIndex = 7;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 106);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(49, 15);
|
||||
this.label1.TabIndex = 8;
|
||||
this.label1.Text = "Клиент:";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
this.comboBoxClient.FormattingEnabled = true;
|
||||
this.comboBoxClient.Location = new System.Drawing.Point(93, 106);
|
||||
this.comboBoxClient.Name = "comboBoxClient";
|
||||
this.comboBoxClient.Size = new System.Drawing.Size(201, 23);
|
||||
this.comboBoxClient.TabIndex = 9;
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(353, 204);
|
||||
this.ClientSize = new System.Drawing.Size(309, 226);
|
||||
this.Controls.Add(this.comboBoxClient);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SumTextBox);
|
||||
@ -127,7 +143,6 @@
|
||||
this.Controls.Add(this.SumLabel);
|
||||
this.Controls.Add(this.CountLabel);
|
||||
this.Controls.Add(this.WorkNameLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.ResumeLayout(false);
|
||||
@ -145,5 +160,7 @@
|
||||
private TextBox SumTextBox;
|
||||
private Button ButtonCancel;
|
||||
private Button SaveButton;
|
||||
private Label label1;
|
||||
private ComboBox comboBoxClient;
|
||||
}
|
||||
}
|
@ -10,23 +10,26 @@ namespace PlumbingRepair
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkLogic _logicW;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private readonly IClientLogic _logicC;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkLogic logicW, IOrderLogic logicO)
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkLogic logicW, IOrderLogic logicO, IClientLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicW = logicW;
|
||||
_logicO = logicO;
|
||||
_logicC = logicC;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
_logger.LogInformation("Загрузка Работ для заказа");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicW.ReadList(null);
|
||||
var listClients = _logicC.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
WorkComboBox.DisplayMember = "WorkName";
|
||||
@ -34,11 +37,18 @@ namespace PlumbingRepair
|
||||
WorkComboBox.DataSource = list;
|
||||
WorkComboBox.SelectedItem = null;
|
||||
}
|
||||
if(listClients != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "ClientFIO";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = listClients;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка Работ");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -93,7 +103,12 @@ namespace PlumbingRepair
|
||||
|
||||
if (WorkComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Выберите Работа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxClient.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,7 +121,8 @@ namespace PlumbingRepair
|
||||
WorkId = Convert.ToInt32(WorkComboBox.SelectedValue),
|
||||
WorkName = WorkComboBox.Text,
|
||||
Count = Convert.ToInt32(CountTextBox.Text),
|
||||
Sum = Convert.ToDouble(SumTextBox.Text)
|
||||
Sum = Convert.ToDouble(SumTextBox.Text),
|
||||
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue)
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
|
20
PlumbingRepair/FormMain.Designer.cs
generated
20
PlumbingRepair/FormMain.Designer.cs
generated
@ -30,7 +30,7 @@
|
||||
{
|
||||
MenuStrip = new MenuStrip();
|
||||
СправочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
ИзделияToolStripMenuItem = new ToolStripMenuItem();
|
||||
РаботыToolStripMenuItem = new ToolStripMenuItem();
|
||||
КомпонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
КлиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||
@ -60,17 +60,17 @@
|
||||
//
|
||||
// СправочникиToolStripMenuItem
|
||||
//
|
||||
СправочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ИзделияToolStripMenuItem, КомпонентыToolStripMenuItem, КлиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
СправочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { РаботыToolStripMenuItem, КомпонентыToolStripMenuItem, КлиентыToolStripMenuItem, исполнителиToolStripMenuItem });
|
||||
СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||
СправочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||
//
|
||||
// ИзделияToolStripMenuItem
|
||||
// РаботыToolStripMenuItem
|
||||
//
|
||||
ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||
ИзделияToolStripMenuItem.Size = new Size(185, 26);
|
||||
ИзделияToolStripMenuItem.Text = "Изделия";
|
||||
ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click;
|
||||
РаботыToolStripMenuItem.Name = "РаботыToolStripMenuItem";
|
||||
РаботыToolStripMenuItem.Size = new Size(185, 26);
|
||||
РаботыToolStripMenuItem.Text = "Работы";
|
||||
РаботыToolStripMenuItem.Click += РаботыToolStripMenuItem_Click;
|
||||
//
|
||||
// КомпонентыToolStripMenuItem
|
||||
//
|
||||
@ -104,14 +104,14 @@
|
||||
//
|
||||
WorksToolStripMenuItem.Name = "WorksToolStripMenuItem";
|
||||
WorksToolStripMenuItem.Size = new Size(273, 26);
|
||||
WorksToolStripMenuItem.Text = "Список изделий";
|
||||
WorksToolStripMenuItem.Text = "Список Работ";
|
||||
WorksToolStripMenuItem.Click += WorksToolStripMenuItem_Click;
|
||||
//
|
||||
// WorkComponentToolStripMenuItem
|
||||
//
|
||||
WorkComponentToolStripMenuItem.Name = "WorkComponentToolStripMenuItem";
|
||||
WorkComponentToolStripMenuItem.Size = new Size(273, 26);
|
||||
WorkComponentToolStripMenuItem.Text = "Изделия по компонентам";
|
||||
WorkComponentToolStripMenuItem.Text = "Работы по компонентам";
|
||||
WorkComponentToolStripMenuItem.Click += WorkComponentToolStripMenuItem_Click;
|
||||
//
|
||||
// OrdersToolStripMenuItem
|
||||
@ -198,7 +198,7 @@
|
||||
|
||||
private MenuStrip MenuStrip;
|
||||
private ToolStripMenuItem СправочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem ИзделияToolStripMenuItem;
|
||||
private ToolStripMenuItem РаботыToolStripMenuItem;
|
||||
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem КлиентыToolStripMenuItem;
|
||||
private Button CreateOrderButton;
|
||||
|
@ -63,7 +63,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
}
|
||||
|
||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void РаботыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorks));
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
// work
|
||||
//
|
||||
this.work.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.work.HeaderText = "Изделие";
|
||||
this.work.HeaderText = "Работа";
|
||||
this.work.Name = "work";
|
||||
//
|
||||
// component
|
||||
@ -83,7 +83,7 @@
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Name = "FormReportWorkComponents";
|
||||
this.Text = "Изделия по компонентам";
|
||||
this.Text = "Работы по компонентам";
|
||||
this.Load += new System.EventHandler(this.FormReportWorkComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -32,13 +32,13 @@ namespace PlumbingRepair
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
||||
_logger.LogInformation("Сохранение списка Работ по компонентам");
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
_logger.LogError(ex, "Ошибка сохранения списка Работ по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
@ -65,11 +65,11 @@ namespace PlumbingRepair
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузки списка изделий по компонентам");
|
||||
_logger.LogInformation("Загрузки списка Работ по компонентам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка Работ по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
2
PlumbingRepair/FormWork.Designer.cs
generated
2
PlumbingRepair/FormWork.Designer.cs
generated
@ -223,7 +223,7 @@
|
||||
this.Controls.Add(this.PriceLabel);
|
||||
this.Controls.Add(this.WorkNameLabel);
|
||||
this.Name = "FormWork";
|
||||
this.Text = "Изделие";
|
||||
this.Text = "Работа";
|
||||
this.ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -29,7 +29,7 @@ namespace PlumbingRepair
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
_logger.LogInformation("Загрузка Работы");
|
||||
|
||||
try
|
||||
{
|
||||
@ -48,14 +48,14 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
_logger.LogError(ex, "Ошибка загрузки Работы");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
_logger.LogInformation("Загрузка компонент Работы");
|
||||
|
||||
try
|
||||
{
|
||||
@ -71,7 +71,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент Работы");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -178,7 +178,7 @@ namespace PlumbingRepair
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
_logger.LogInformation("Сохранение Работы");
|
||||
|
||||
try
|
||||
{
|
||||
@ -203,7 +203,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||
_logger.LogError(ex, "Ошибка сохранения Работы");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
2
PlumbingRepair/FormWorkComponent.Designer.cs
generated
2
PlumbingRepair/FormWorkComponent.Designer.cs
generated
@ -106,7 +106,7 @@
|
||||
this.Controls.Add(this.ComponentSelectLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormWorkComponent";
|
||||
this.Text = "Компонент изделия";
|
||||
this.Text = "Компонент Работы";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
2
PlumbingRepair/FormWorks.Designer.cs
generated
2
PlumbingRepair/FormWorks.Designer.cs
generated
@ -103,7 +103,7 @@
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormWorks";
|
||||
this.Text = "Изделия";
|
||||
this.Text = "Работы";
|
||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -35,12 +35,12 @@ namespace PlumbingRepair
|
||||
DataGridView.Columns["WorkComponents"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
_logger.LogInformation("Загрузка Работ");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий");
|
||||
_logger.LogError(ex, "Ошибка загрузки Работ");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ namespace PlumbingRepair
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
_logger.LogInformation("Удаление Работы");
|
||||
|
||||
try
|
||||
{
|
||||
@ -97,7 +97,7 @@ namespace PlumbingRepair
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
_logger.LogError(ex, "Ошибка удаления Работы");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Изделие</Value>
|
||||
<Value>Работа</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
|
@ -122,12 +122,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
|
||||
if (model.WorkId < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.WorkId));
|
||||
throw new ArgumentNullException("Некорректный идентификатор Работы", nameof(model.WorkId));
|
||||
}
|
||||
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||
throw new ArgumentNullException("Количество Работ в заказе должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
|
||||
if (model.Sum <= 0)
|
||||
|
@ -76,7 +76,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
Title = "Список Работ",
|
||||
Works = _workStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
@ -85,7 +85,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
Title = "Список Работ",
|
||||
Works = GetWork()
|
||||
});
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
|
||||
if (string.IsNullOrEmpty(model.WorkName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия изделия", nameof(model.WorkName));
|
||||
throw new ArgumentNullException("Нет названия Работы", nameof(model.WorkName));
|
||||
}
|
||||
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена изделия должна быть больше 0", nameof(model.Price));
|
||||
throw new ArgumentNullException("Цена Работы должна быть больше 0", nameof(model.Price));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Work. WorkName:{WorkName}.Price:{ Cost}. Id: { Id}", model.WorkName, model.Price, model.Id);
|
||||
@ -130,7 +130,7 @@ namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Изделие с таким названием уже есть");
|
||||
throw new InvalidOperationException("Работа с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
89
PlumbingRepairBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
89
PlumbingRepairBusinessLogic/MailWorker/AbstractMailWorker.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.MailWorker
|
||||
{
|
||||
public abstract class AbstractMailWorker
|
||||
{
|
||||
protected string _mailLogin = string.Empty;
|
||||
protected string _mailPassword = string.Empty;
|
||||
protected string _smtpClientHost = string.Empty;
|
||||
protected int _smtpClientPort;
|
||||
protected string _popHost = string.Empty;
|
||||
protected int _popPort;
|
||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageInfoLogic = messageInfoLogic;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
_mailLogin = config.MailLogin;
|
||||
_mailPassword = config.MailPassword;
|
||||
_smtpClientHost = config.SmtpClientHost;
|
||||
_smtpClientPort = config.SmtpClientPort;
|
||||
_popHost = config.PopHost;
|
||||
_popPort = config.PopPort;
|
||||
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
|
||||
}
|
||||
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
|
||||
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
|
||||
public async void MailCheck()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_messageInfoLogic == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var list = await ReceiveMailAsync();
|
||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||
|
||||
foreach (var mail in list)
|
||||
{
|
||||
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
|
||||
_messageInfoLogic.Create(mail);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
||||
}
|
||||
}
|
78
PlumbingRepairBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
78
PlumbingRepairBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PlumbingRepairContracts.BindingModels;
|
||||
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MailKit.Net.Pop3;
|
||||
using MailKit.Security;
|
||||
|
||||
namespace PlumbingRepairBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
|
||||
|
||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||
|
||||
try
|
||||
{
|
||||
objMailMessage.From = new MailAddress(_mailLogin);
|
||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||
objMailMessage.Subject = info.Subject;
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
||||
{
|
||||
var list = new List<MessageInfoBindingModel>();
|
||||
using var client = new Pop3Client();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
||||
client.Authenticate(_mailLogin, _mailPassword);
|
||||
for (int i = 0; i < client.Count; i++)
|
||||
{
|
||||
var message = client.GetMessage(i);
|
||||
foreach (var mail in message.From.Mailboxes)
|
||||
{
|
||||
list.Add(new MessageInfoBindingModel
|
||||
{
|
||||
DateDelivery = message.Date.DateTime,
|
||||
MessageId = message.MessageId,
|
||||
SenderName = mail.Address,
|
||||
Subject = message.Subject,
|
||||
Body = message.TextBody
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{ }
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ namespace PlumbingRepairBusinessLogic.OfficePackage
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "2cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата создания", "Изделие", "Статус", "Стоимость" },
|
||||
Texts = new List<string> { "Номер", "Дата создания", "Работа", "Статус", "Стоимость" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
@ -1,21 +1,21 @@
|
||||
{
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:30871",
|
||||
"sslPort": 44346
|
||||
"applicationUrl": "http://localhost:52125/",
|
||||
"sslPort": 44355
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"PlumbingRepairClientApp": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7083;http://localhost:5037",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"applicationUrl": "https://localhost:7083;http://localhost:5037",
|
||||
"dotnetRunMessages": true
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
@ -25,4 +25,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Изделие:</div>
|
||||
<div class="col-4">Работа:</div>
|
||||
<div class="col-8">
|
||||
<select id="work" name="work" class="form-control" asp-items="@(new SelectList(@ViewBag.Works,"Id", "WorkName"))"></select>
|
||||
</div>
|
||||
|
@ -24,7 +24,7 @@
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Изделие
|
||||
Работа
|
||||
</th>
|
||||
<th>
|
||||
Дата создания
|
||||
|
@ -9,7 +9,7 @@ namespace PlumbingRepairContracts.ViewModels
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int WorkId { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
[DisplayName("Название Работы")]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
|
@ -6,7 +6,7 @@ namespace PlumbingRepairContracts.ViewModels
|
||||
public class WorkViewModel : IWorkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
[DisplayName("Название Работы")]
|
||||
public string WorkName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
|
261
PlumbingRepairDatabaseImplement/Migrations/20231012052812_init.Designer.cs
generated
Normal file
261
PlumbingRepairDatabaseImplement/Migrations/20231012052812_init.Designer.cs
generated
Normal file
@ -0,0 +1,261 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using PlumbingRepairDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlumbingRepairDataBase))]
|
||||
[Migration("20231012052812_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("WorkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Works");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("WorkComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Implementers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Works",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Works", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||
WorkName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Implementers_ImplementerId",
|
||||
column: x => x.ImplementerId,
|
||||
principalTable: "Implementers",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WorkComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WorkComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_WorkComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_WorkComponents_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ImplementerId",
|
||||
table: "Orders",
|
||||
column: "ImplementerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_WorkId",
|
||||
table: "Orders",
|
||||
column: "WorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WorkComponents_ComponentId",
|
||||
table: "WorkComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WorkComponents_WorkId",
|
||||
table: "WorkComponents",
|
||||
column: "WorkId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "WorkComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Implementers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Works");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,258 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using PlumbingRepairDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PlumbingRepairDataBase))]
|
||||
partial class PlumbingRepairDataBaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ImplementerFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Qualification")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkExperience")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Implementers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("ImplementerId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("WorkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ImplementerId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Works");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
b.ToTable("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Implementer", "Implementer")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ImplementerId");
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Implementer");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.WorkComponent", b =>
|
||||
{
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("WorkComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PlumbingRepairDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("WorkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Implementer", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PlumbingRepairDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace PlumbingRepairDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=IS-431-02\SQLEXPRESS;Initial Catalog=PlumbingRepairDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=IS-424-2-01\SQLEXPRESS;Initial Catalog=PlumbingRepairDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user