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

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

View File

@ -20,9 +20,19 @@ namespace BeautySalon
InitializeComponent(); InitializeComponent();
} }
/// <summary>
/// это для услуг ес че
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e) 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) private void добавитьСпециализациюToolStripMenuItem_Click(object sender, EventArgs e)
@ -42,5 +52,37 @@ namespace BeautySalon
form.ShowDialog(); 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;
using BeautySalonDBModels.Implements; using BeautySalonDBModels.Implements;
using BeautySalonDBModels.Models; 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 namespace BeautySalon
{ {

View File

@ -28,12 +28,116 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); buttonCancel = new Button();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; buttonSave = new Button();
this.ClientSize = new System.Drawing.Size(800, 450); labelSpecialisation = new Label();
this.Text = "FormService"; 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 #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 BeautySalonDBModels;
using System.Collections.Generic; using BeautySalonDBModels.Models;
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 namespace BeautySalon
{ {
public partial class FormService : Form 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(); 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

@ -28,12 +28,77 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); dataGridView = new DataGridView();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; buttonDelete = new Button();
this.ClientSize = new System.Drawing.Size(800, 450); buttonUpdate = new Button();
this.Text = "FormServices"; 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 #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.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -7,14 +9,88 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using BeautySalonDBModels.Implements;
namespace BeautySalon namespace BeautySalon
{ {
public partial class FormServices : Form 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(); 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

@ -49,10 +49,24 @@ namespace BeautySalon
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormHello>(); services.AddTransient<FormHello>();
services.AddTransient<FormSpecialisations>(); services.AddTransient<FormSpecialisations>();
services.AddTransient<FormSpecialisation>(); services.AddTransient<FormSpecialisation>();
services.AddTransient<FormMasters>(); services.AddTransient<FormMasters>();
services.AddTransient<FormMaster>(); 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.Parameters.AddWithValue("@id", service.ServiceId);
cmd.ExecuteNonQuery(); 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;
}
} }
} }