так, добавила формы услуг

не работает пока что добавление
This commit is contained in:
Елена Бакальская 2024-05-08 03:05:15 +04:00
parent bbd7523df4
commit 77a0ad2708
11 changed files with 459 additions and 80 deletions

View File

@ -74,18 +74,21 @@
добавитьToolStripMenuItem1.Name = обавитьToolStripMenuItem1";
добавитьToolStripMenuItem1.Size = new Size(83, 24);
добавитьToolStripMenuItem1.Text = "Клиенты";
добавитьToolStripMenuItem1.Click += добавитьToolStripMenuItem1_Click;
//
// создатьПриемToolStripMenuItem
//
создатьПриемToolStripMenuItem.Name = "создатьПриемToolStripMenuItem";
создатьПриемToolStripMenuItem.Size = new Size(82, 24);
создатьПриемToolStripMenuItem.Text = "Приемы";
создатьПриемToolStripMenuItem.Click += создатьПриемToolStripMenuItem_Click;
//
// посмотретьЧекиToolStripMenuItem
//
посмотретьЧекиToolStripMenuItem.Name = "посмотретьЧекиToolStripMenuItem";
посмотретьЧекиToolStripMenuItem.Size = new Size(143, 24);
посмотретьЧекиToolStripMenuItem.Text = "Посмотреть чеки";
посмотретьЧекиToolStripMenuItem.Click += посмотретьЧекиToolStripMenuItem_Click;
//
// FormMain
//

View File

@ -20,9 +20,19 @@ namespace BeautySalon
InitializeComponent();
}
/// <summary>
/// это для услуг ес че
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormServices));
if (service is FormServices form)
{
form.ShowDialog();
}
}
private void добавитьСпециализациюToolStripMenuItem_Click(object sender, EventArgs e)
@ -42,5 +52,37 @@ namespace BeautySalon
form.ShowDialog();
}
}
/// <summary>
/// эт клиенты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void добавитьToolStripMenuItem1_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
private void создатьПриемToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReceptions));
if (service is FormReceptions form)
{
form.ShowDialog();
}
}
private void посмотретьЧекиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCheques));
if (service is FormCheques form)
{
form.ShowDialog();
}
}
}
}

View File

@ -1,15 +1,6 @@
using BeautySalonDBModels;
using BeautySalonDBModels.Implements;
using BeautySalonDBModels.Models;
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;
namespace BeautySalon
{

View File

@ -28,12 +28,116 @@
/// </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 = "FormService";
buttonCancel = new Button();
buttonSave = new Button();
labelSpecialisation = new Label();
comboBoxSpecialisation = new ComboBox();
FIO = new Label();
textBoxName = new TextBox();
numericUpDownPrice = new NumericUpDown();
label = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(334, 224);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(133, 44);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(26, 224);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(133, 44);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// labelSpecialisation
//
labelSpecialisation.AutoSize = true;
labelSpecialisation.Location = new Point(26, 83);
labelSpecialisation.Name = "labelSpecialisation";
labelSpecialisation.Size = new Size(122, 20);
labelSpecialisation.TabIndex = 9;
labelSpecialisation.Text = "Специализация:";
//
// comboBoxSpecialisation
//
comboBoxSpecialisation.FormattingEnabled = true;
comboBoxSpecialisation.Location = new Point(177, 80);
comboBoxSpecialisation.Name = "comboBoxSpecialisation";
comboBoxSpecialisation.Size = new Size(290, 28);
comboBoxSpecialisation.TabIndex = 8;
//
// FIO
//
FIO.AutoSize = true;
FIO.Location = new Point(26, 28);
FIO.Name = "FIO";
FIO.Size = new Size(57, 20);
FIO.TabIndex = 7;
FIO.Text = "Услуга:";
//
// textBoxName
//
textBoxName.Location = new Point(177, 21);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(290, 27);
textBoxName.TabIndex = 6;
//
// numericUpDownPrice
//
numericUpDownPrice.Location = new Point(177, 140);
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(290, 27);
numericUpDownPrice.TabIndex = 12;
//
// label
//
label.AutoSize = true;
label.Location = new Point(26, 147);
label.Name = "label";
label.Size = new Size(45, 20);
label.TabIndex = 13;
label.Text = "Цена";
//
// FormService
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(537, 304);
Controls.Add(label);
Controls.Add(numericUpDownPrice);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelSpecialisation);
Controls.Add(comboBoxSpecialisation);
Controls.Add(FIO);
Controls.Add(textBoxName);
Name = "FormService";
Text = "FormService";
Load += FormService_Load;
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label labelSpecialisation;
private ComboBox comboBoxSpecialisation;
private Label FIO;
private TextBox textBoxName;
private NumericUpDown numericUpDownPrice;
private Label label;
}
}

View File

@ -1,20 +1,91 @@
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 BeautySalonDBModels;
using BeautySalonDBModels.Models;
namespace BeautySalon
{
public partial class FormService : Form
{
public FormService()
private int? _id;
public int Id
{
set { _id = value; }
}
private readonly AbstractWorkWithStorage<Specialisation> specialisationStorage;
private readonly AbstractWorkWithStorage<Service> serviceStorage;
private readonly List<Specialisation> specialisations;
public FormService(AbstractWorkWithStorage<Service> serviceStorage, AbstractWorkWithStorage<Specialisation> specialisationStorage)
{
this.serviceStorage = serviceStorage;
this.specialisationStorage = specialisationStorage;
InitializeComponent();
specialisations = specialisationStorage.GetObjects();
foreach (Specialisation specialisation in specialisations)
{
comboBoxSpecialisation.Items.Add(specialisation).ToString();
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (_id != null)
{
var newService = new Service
{
ServiceId = _id ?? 0,
SpecialisationId = (comboBoxSpecialisation.SelectedItem as Service)!.ServiceId,
Price = (int)numericUpDownPrice.Value
};
serviceStorage.Update(newService);
}
else
{
var newService = new Service
{
SpecialisationId = (comboBoxSpecialisation.SelectedItem as Service)!.ServiceId,
Price = (int)numericUpDownPrice.Value
};
serviceStorage.Add(newService);
}
DialogResult = DialogResult.OK;
Close();
}
catch (Exception)
{
throw;
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel; Close();
}
private void FormService_Load(object sender, EventArgs e)
{
if(_id != null)
{
try
{
var serviceObject = serviceStorage.GetObject(_id.Value);
if (serviceObject != null)
{
comboBoxSpecialisation.SelectedItem = serviceObject;
textBoxName.Text = serviceObject.ServiceName;
numericUpDownPrice.Value = (decimal)serviceObject.Price;
}
}
catch (Exception)
{
throw;
}
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,77 @@
/// </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 = "FormServices";
dataGridView = new DataGridView();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonCreate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.BackgroundColor = SystemColors.ActiveCaption;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(493, 450);
dataGridView.TabIndex = 0;
//
// buttonDelete
//
buttonDelete.Location = new Point(553, 365);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(147, 56);
buttonDelete.TabIndex = 9;
buttonDelete.Text = "Уничтожить...";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(553, 195);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(147, 56);
buttonUpdate.TabIndex = 8;
buttonUpdate.Text = "Корректровать";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonCreate
//
buttonCreate.Location = new Point(553, 34);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(147, 56);
buttonCreate.TabIndex = 7;
buttonCreate.Text = "Добавить";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += buttonCreate_Click;
//
// FormServices
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(752, 450);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView);
Name = "FormServices";
Text = "Услуги";
Load += FormServices_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonCreate;
}
}

View File

@ -1,4 +1,6 @@
using System;
using BeautySalonDBModels.Models;
using BeautySalonDBModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -7,14 +9,88 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BeautySalonDBModels.Implements;
namespace BeautySalon
{
public partial class FormServices : Form
{
public FormServices()
private int? _id;
public int Id
{
set { _id = value; }
}
private readonly AbstractWorkWithStorage<Service> serviceStorage;
private readonly AbstractWorkWithStorage<Specialisation> specialisationStorage;
public FormServices(AbstractWorkWithStorage<Service> serviceStorage,
AbstractWorkWithStorage<Specialisation> specialisationStorage)
{
this.serviceStorage = serviceStorage;
this.specialisationStorage = specialisationStorage;
InitializeComponent();
}
private void LoadData()
{
List<Service> services = serviceStorage.GetObjects();
ServiceDatabase mdb = new ServiceDatabase();
dataGridView.Rows.Clear();
if (dataGridView.ColumnCount == 0)
{
dataGridView.Columns.Add("ServiceName", "Название");
dataGridView.Columns.Add("Specialisation", "Специализация");
dataGridView.Columns.Add("Price", "Цена");
}
foreach (Service service in services)
{
string specialisationName = mdb.GetNameSpecialisation(service);
dataGridView.Rows.Add(service.ServiceName, specialisationName, service.Price);
}
}
private void buttonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormService));
if (service is FormService form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormService));
if (service is FormService form)
{
if (form.ShowDialog() == DialogResult.OK)
{
int rowIndex = dataGridView.CurrentCell.RowIndex;
form.Id = (int)dataGridView.Rows[rowIndex].Cells["ServiceId"].Value;
LoadData();
}
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if(dataGridView.SelectedRows.Count == 1)
{
int rowIndex = dataGridView.CurrentCell.RowIndex;
serviceStorage.Remove(rowIndex);
LoadData();
}
}
private void FormServices_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -49,10 +49,24 @@ namespace BeautySalon
services.AddTransient<FormMain>();
services.AddTransient<FormHello>();
services.AddTransient<FormSpecialisations>();
services.AddTransient<FormSpecialisation>();
services.AddTransient<FormMasters>();
services.AddTransient<FormMaster>();
services.AddTransient<FormCheques>();
services.AddTransient<FormCheque>();
services.AddTransient<FormReceptions>();
services.AddTransient<FormReception>();
services.AddTransient<FormClients>();
services.AddTransient<FormClient>();
services.AddTransient<FormServices>();
services.AddTransient<FormService>();
}
}
}

View File

@ -85,5 +85,18 @@ namespace BeautySalonDBModels.Implements
cmd.Parameters.AddWithValue("@id", service.ServiceId);
cmd.ExecuteNonQuery();
}
public string GetNameSpecialisation(Service service)
{
SpecialisationDatabase db = new SpecialisationDatabase();
int specId = service.SpecialisationId;
List<Specialisation> specialisations = db.GetObjects();
foreach (Specialisation specialisation in specialisations)
{
if (specialisation.SpecialisationId == specId) return specialisation.Name.ToString();
}
return string.Empty;
}
}
}