From 92e75d295e8f571a1a2830de63a83cb8a7677736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Wed, 8 May 2024 22:57:40 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B0=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA?= =?UTF-8?q?=20=D1=87=D0=B5=D0=BA=D0=BE=D0=B2,=20=D0=BE=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D1=81=D1=8C=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5/=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=87=D0=B5?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2=20=D0=B8=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=80?= =?UTF-8?q?=D1=8B=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20(=D0=BD?= =?UTF-8?q?=D1=83=20=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8,=20=D0=BA=D0=BE=D0=BD=D0=B5=D1=87=D0=BD=D0=BE=20=D0=B6?= =?UTF-8?q?=D0=B5...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeautySalon/FormCheque.Designer.cs | 129 ++++++++++++++++++ BeautySalon/BeautySalon/FormCheque.cs | 27 ++++ BeautySalon/BeautySalon/FormCheque.resx | 120 ++++++++++++++++ .../BeautySalon/FormCheques.Designer.cs | 30 +++- BeautySalon/BeautySalon/FormCheques.cs | 51 +++++-- .../Implements/ChequeDatabase.cs | 15 ++ .../Implements/ReceptionDatabase.cs | 14 ++ 7 files changed, 370 insertions(+), 16 deletions(-) create mode 100644 BeautySalon/BeautySalon/FormCheque.Designer.cs create mode 100644 BeautySalon/BeautySalon/FormCheque.cs create mode 100644 BeautySalon/BeautySalon/FormCheque.resx 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; + } } }