переименовала до конца классы хранилища, добавила (внедрила :)) ) зависимости - абстрактный класс и его реализации, делаю формы для мастеров
This commit is contained in:
parent
8f68e44d08
commit
975b5f9463
87
BeautySalon/BeautySalon/FormMaster.Designer.cs
generated
87
BeautySalon/BeautySalon/FormMaster.Designer.cs
generated
@ -28,12 +28,91 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormMaster";
|
||||
textBoxFIO = new TextBox();
|
||||
FIO = new Label();
|
||||
comboBoxSpecialisation = new ComboBox();
|
||||
labelSpecialisation = new Label();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(163, 21);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(290, 27);
|
||||
textBoxFIO.TabIndex = 0;
|
||||
//
|
||||
// FIO
|
||||
//
|
||||
FIO.AutoSize = true;
|
||||
FIO.Location = new Point(12, 28);
|
||||
FIO.Name = "FIO";
|
||||
FIO.Size = new Size(103, 20);
|
||||
FIO.TabIndex = 1;
|
||||
FIO.Text = "ФИО мастера";
|
||||
//
|
||||
// comboBoxSpecialisation
|
||||
//
|
||||
comboBoxSpecialisation.FormattingEnabled = true;
|
||||
comboBoxSpecialisation.Location = new Point(163, 80);
|
||||
comboBoxSpecialisation.Name = "comboBoxSpecialisation";
|
||||
comboBoxSpecialisation.Size = new Size(290, 28);
|
||||
comboBoxSpecialisation.TabIndex = 2;
|
||||
//
|
||||
// labelSpecialisation
|
||||
//
|
||||
labelSpecialisation.AutoSize = true;
|
||||
labelSpecialisation.Location = new Point(12, 83);
|
||||
labelSpecialisation.Name = "labelSpecialisation";
|
||||
labelSpecialisation.Size = new Size(122, 20);
|
||||
labelSpecialisation.TabIndex = 3;
|
||||
labelSpecialisation.Text = "Специализация:";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(320, 142);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(133, 44);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(12, 142);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(133, 44);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// FormMaster
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(482, 216);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(labelSpecialisation);
|
||||
Controls.Add(comboBoxSpecialisation);
|
||||
Controls.Add(FIO);
|
||||
Controls.Add(textBoxFIO);
|
||||
Name = "FormMaster";
|
||||
Text = "Мастер";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxFIO;
|
||||
private Label FIO;
|
||||
private ComboBox comboBoxSpecialisation;
|
||||
private Label labelSpecialisation;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using BeautySalonDBModels;
|
||||
using BeautySalonDBModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -12,9 +14,43 @@ namespace BeautySalon
|
||||
{
|
||||
public partial class FormMaster : Form
|
||||
{
|
||||
public FormMaster()
|
||||
private int? _id;
|
||||
public int Id
|
||||
{
|
||||
set { _id = value; }
|
||||
}
|
||||
|
||||
private readonly AbstractWorkWithStorage<Master> storage;
|
||||
|
||||
public FormMaster(AbstractWorkWithStorage<Master> storage)
|
||||
{
|
||||
this.storage = storage;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (_id != null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,17 +39,41 @@ namespace BeautySalon
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMaster));
|
||||
if (service is FormMaster form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMaster));
|
||||
if (service is FormMaster form)
|
||||
{
|
||||
int rowIndex = dataGridView.CurrentCell.RowIndex;
|
||||
form.Id = (int)dataGridView.Rows[rowIndex].Cells["MasterId"].Value;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["MasterId"].Value);
|
||||
masterDb.Remove(id);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMasters_Load(object sender, EventArgs e)
|
||||
|
@ -31,11 +31,12 @@
|
||||
buttonSave = new Button();
|
||||
textBoxNameSpecialisation = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
labelName = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(37, 86);
|
||||
buttonSave.Location = new Point(37, 159);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(133, 44);
|
||||
buttonSave.TabIndex = 0;
|
||||
@ -52,7 +53,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(178, 86);
|
||||
buttonCancel.Location = new Point(178, 159);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(133, 44);
|
||||
buttonCancel.TabIndex = 2;
|
||||
@ -60,11 +61,21 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(133, 76);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(77, 20);
|
||||
labelName.TabIndex = 3;
|
||||
labelName.Text = "Название";
|
||||
//
|
||||
// FormSpecialisation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(345, 170);
|
||||
ClientSize = new Size(345, 236);
|
||||
Controls.Add(labelName);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(textBoxNameSpecialisation);
|
||||
Controls.Add(buttonSave);
|
||||
@ -80,5 +91,6 @@
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxNameSpecialisation;
|
||||
private Button buttonCancel;
|
||||
private Label labelName;
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ namespace BeautySalon
|
||||
if (service is FormSpecialisation form)
|
||||
{
|
||||
int rowIndex = dataGridView.CurrentCell.RowIndex;
|
||||
form.Id = (int)dataGridView.Rows[rowIndex].Cells["SpecialisationId"].Value; ;
|
||||
form.Id = (int)dataGridView.Rows[rowIndex].Cells["SpecialisationId"].Value;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
@ -39,10 +39,20 @@ namespace BeautySalon
|
||||
});
|
||||
////services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Specialisation>, SpecialisationDB>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Master>, MasterDatabase>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Cheque>, ChequeDatabase>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Client>, ClientDatabase>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Reception>, ReceptionDatabase>();
|
||||
services.AddSingleton<AbstractWorkWithStorage<Service>, ServiceDatabase>();
|
||||
|
||||
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormHello>();
|
||||
services.AddTransient<FormSpecialisations>();
|
||||
services.AddTransient<FormSpecialisation>();
|
||||
services.AddTransient<FormMasters>();
|
||||
services.AddTransient<FormMaster>();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonDBModels.Implements
|
||||
{
|
||||
public class MasterDB : AbstractWorkWithStorage<Master>
|
||||
public class MasterDatabase : AbstractWorkWithStorage<Master>
|
||||
{
|
||||
public override void Add(Master master)
|
||||
{
|
||||
using var conn = GetConnection();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO masters (specialisation_id, fio) VALUES ((nextval('seq_master'), @SpecialisationId, @FIO)", conn);
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO masters (master_id, specialisation_id, fio) VALUES ((nextval('seq_master'), @SpecialisationId, @FIO)", conn);
|
||||
cmd.Parameters.AddWithValue("@SpecialisationId", master.SpecialisationId);
|
||||
cmd.Parameters.AddWithValue("@FIO", master.FIO);
|
||||
cmd.ExecuteNonQuery();
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonDBModels.Implements
|
||||
{
|
||||
public class ReceptionBD : AbstractWorkWithStorage<Reception>
|
||||
public class ReceptionDatabase : AbstractWorkWithStorage<Reception>
|
||||
{
|
||||
public override void Add(Reception reception)
|
||||
{
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeautySalonDBModels.Implements
|
||||
{
|
||||
public class ServiceDB : AbstractWorkWithStorage<Service>
|
||||
public class ServiceDatabase : AbstractWorkWithStorage<Service>
|
||||
{
|
||||
public override void Add(Service service)
|
||||
{
|
Loading…
Reference in New Issue
Block a user