diff --git a/BeautySalon/BeautySalon/FormCheque.Designer.cs b/BeautySalon/BeautySalon/FormCheque.Designer.cs
new file mode 100644
index 0000000..088df93
--- /dev/null
+++ b/BeautySalon/BeautySalon/FormCheque.Designer.cs
@@ -0,0 +1,129 @@
+namespace BeautySalon
+{
+ partial class FormCheque
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelPrice = new Label();
+ comboBoxClients = new ComboBox();
+ buttonCancel = new Button();
+ buttonSave = new Button();
+ labelReception = new Label();
+ comboBoxReceptions = new ComboBox();
+ client = new Label();
+ SuspendLayout();
+ //
+ // labelPrice
+ //
+ labelPrice.AutoSize = true;
+ labelPrice.Location = new Point(19, 138);
+ labelPrice.Name = "labelPrice";
+ labelPrice.Size = new Size(99, 20);
+ labelPrice.TabIndex = 21;
+ labelPrice.Text = "Дата приема";
+ //
+ // comboBoxClients
+ //
+ comboBoxClients.FormattingEnabled = true;
+ comboBoxClients.Location = new Point(176, 73);
+ comboBoxClients.Name = "comboBoxClients";
+ comboBoxClients.Size = new Size(290, 28);
+ comboBoxClients.TabIndex = 20;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(327, 202);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(133, 44);
+ buttonCancel.TabIndex = 19;
+ buttonCancel.Text = "Отмена";
+ buttonCancel.UseVisualStyleBackColor = true;
+ //
+ // buttonSave
+ //
+ buttonSave.Location = new Point(19, 202);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(133, 44);
+ buttonSave.TabIndex = 18;
+ buttonSave.Text = "Сохранить";
+ buttonSave.UseVisualStyleBackColor = true;
+ //
+ // labelReception
+ //
+ labelReception.AutoSize = true;
+ labelReception.Location = new Point(25, 23);
+ labelReception.Name = "labelReception";
+ labelReception.Size = new Size(57, 20);
+ labelReception.TabIndex = 17;
+ labelReception.Text = "Прием";
+ //
+ // comboBoxReceptions
+ //
+ comboBoxReceptions.FormattingEnabled = true;
+ comboBoxReceptions.Location = new Point(176, 20);
+ comboBoxReceptions.Name = "comboBoxReceptions";
+ comboBoxReceptions.Size = new Size(290, 28);
+ comboBoxReceptions.TabIndex = 16;
+ //
+ // client
+ //
+ client.AutoSize = true;
+ client.Location = new Point(25, 81);
+ client.Name = "client";
+ client.Size = new Size(58, 20);
+ client.TabIndex = 15;
+ client.Text = "Клиент";
+ //
+ // FormCheque
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(499, 266);
+ Controls.Add(labelPrice);
+ Controls.Add(comboBoxClients);
+ Controls.Add(buttonCancel);
+ Controls.Add(buttonSave);
+ Controls.Add(labelReception);
+ Controls.Add(comboBoxReceptions);
+ Controls.Add(client);
+ Name = "FormCheque";
+ Text = "Чек";
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelPrice;
+ private ComboBox comboBoxClients;
+ private Button buttonCancel;
+ private Button buttonSave;
+ private Label labelReception;
+ private ComboBox comboBoxReceptions;
+ private Label client;
+ }
+}
\ No newline at end of file
diff --git a/BeautySalon/BeautySalon/FormCheque.cs b/BeautySalon/BeautySalon/FormCheque.cs
new file mode 100644
index 0000000..e9d7ec2
--- /dev/null
+++ b/BeautySalon/BeautySalon/FormCheque.cs
@@ -0,0 +1,27 @@
+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
+{
+ public partial class FormCheque : Form
+ {
+
+ private int? _id;
+ public int Id
+ {
+ set { _id = value; }
+ }
+
+ public FormCheque()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/BeautySalon/BeautySalon/FormCheque.resx b/BeautySalon/BeautySalon/FormCheque.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/BeautySalon/BeautySalon/FormCheque.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/BeautySalon/BeautySalon/FormCheques.Designer.cs b/BeautySalon/BeautySalon/FormCheques.Designer.cs
index 84ec7cb..16b02b2 100644
--- a/BeautySalon/BeautySalon/FormCheques.Designer.cs
+++ b/BeautySalon/BeautySalon/FormCheques.Designer.cs
@@ -30,12 +30,14 @@
{
buttonDelete = new Button();
dataGridView = new DataGridView();
+ buttonUpdate = new Button();
+ buttonCreate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonDelete
//
- buttonDelete.Location = new Point(583, 199);
+ buttonDelete.Location = new Point(576, 352);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(147, 56);
buttonDelete.TabIndex = 13;
@@ -57,11 +59,33 @@
dataGridView.Size = new Size(493, 450);
dataGridView.TabIndex = 10;
//
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(576, 190);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(147, 56);
+ buttonUpdate.TabIndex = 15;
+ buttonUpdate.Text = "Корректровать";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(576, 43);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(147, 56);
+ buttonCreate.TabIndex = 14;
+ buttonCreate.Text = "Добавить";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
// FormCheques
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(801, 450);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
Controls.Add(buttonDelete);
Controls.Add(dataGridView);
Name = "FormCheques";
@@ -75,5 +99,7 @@
private Button buttonDelete;
private DataGridView dataGridView;
+ private Button buttonUpdate;
+ private Button buttonCreate;
}
}
\ No newline at end of file
diff --git a/BeautySalon/BeautySalon/FormCheques.cs b/BeautySalon/BeautySalon/FormCheques.cs
index 0efaf57..e18555a 100644
--- a/BeautySalon/BeautySalon/FormCheques.cs
+++ b/BeautySalon/BeautySalon/FormCheques.cs
@@ -44,15 +44,9 @@ namespace BeautySalon
public void LoadData()
{
- /* var list = chequeStorage.GetObjects();
- if(list != null)
- {
- dataGridView.DataSource = list;
- }*/
-
List cheques = chequeStorage.GetObjects();
ChequeDatabase cdb = new ChequeDatabase();
- MasterDatabase mdb = new MasterDatabase();
+ ReceptionDatabase rdb = new ReceptionDatabase();
dataGridView.Rows.Clear();
@@ -60,21 +54,50 @@ namespace BeautySalon
{
dataGridView.Columns.Add("ChequeId", "ID");
dataGridView.Columns.Add("ClientFIO", "ФИО клиента");
- dataGridView.Columns.Add("ServiceName", "Название");
+ dataGridView.Columns.Add("ServiceName", "Название услуги");
dataGridView.Columns.Add("Price", "Цена");
}
foreach (Cheque cheque in cheques)
{
- string serviceName =
- }
+ var reception = rdb.GetObject(cheque.ReceptionId);
+ var client = rdb.GetObject(cheque.ClientId);
+ if (reception != null && client != null)
+ {
+ string serviceName = rdb.GetServiceName(reception);
+ string clientFIO = cdb.GetClientFIO(cheque);
+ double servicePrice = rdb.GetServicePrice(reception);
- foreach (Service service in services)
- {
- string specialisationName = mdb.GetNameSpecialisation(service);
- dataGridView.Rows.Add(service.ServiceId, service.ServiceName, specialisationName, service.Price);
+ dataGridView.Rows.Add(cheque.ChequeId, clientFIO, serviceName, servicePrice);
+ }
}
dataGridView.Columns["ChequeId"].Visible = false;
}
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCheque));
+ if(service is FormCheque form)
+ {
+ if(form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCheque));
+ if (service is FormCheque form)
+ {
+ int index = dataGridView.CurrentCell.RowIndex;
+ form.Id = (int)dataGridView.Rows[index].Cells["ChequeId"].Value;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
}
}
diff --git a/BeautySalon/BeautySalonDBModels/Implements/ChequeDatabase.cs b/BeautySalon/BeautySalonDBModels/Implements/ChequeDatabase.cs
index f8cb881..ae1aeb8 100644
--- a/BeautySalon/BeautySalonDBModels/Implements/ChequeDatabase.cs
+++ b/BeautySalon/BeautySalonDBModels/Implements/ChequeDatabase.cs
@@ -85,5 +85,20 @@ namespace BeautySalonDBModels.Implements
cmd.Parameters.AddWithValue("@Price", cheque.Price);
cmd.ExecuteNonQuery();
}
+
+ public string GetClientFIO(Cheque cheque)
+ {
+ ClientDatabase db = new ClientDatabase();
+
+ int clientId = cheque.ClientId;
+
+ List clients = db.GetObjects();
+
+ foreach (Client c in clients)
+ {
+ if (c.ClientId == clientId) return c.FIO.ToString();
+ }
+ return string.Empty;
+ }
}
}
diff --git a/BeautySalon/BeautySalonDBModels/Implements/ReceptionDatabase.cs b/BeautySalon/BeautySalonDBModels/Implements/ReceptionDatabase.cs
index c005cae..de30c3d 100644
--- a/BeautySalon/BeautySalonDBModels/Implements/ReceptionDatabase.cs
+++ b/BeautySalon/BeautySalonDBModels/Implements/ReceptionDatabase.cs
@@ -109,5 +109,19 @@ namespace BeautySalonDBModels.Implements
}
return string.Empty;
}
+
+ public double GetServicePrice(Reception reception)
+ {
+ ServiceDatabase db = new ServiceDatabase();
+ int serviceId = reception.ServiceId;
+
+ List services = db.GetObjects();
+
+ foreach (Service service in services)
+ {
+ if (service.ServiceId == serviceId) return service.Price;
+ }
+ return 0;
+ }
}
}