в бд добавила в чек еще одну колонку - цену

This commit is contained in:
Елена Бакальская 2024-05-08 17:43:52 +04:00
parent 2a009156e1
commit ce5da9b2da
8 changed files with 150 additions and 223 deletions

View File

@ -1,39 +0,0 @@
namespace BeautySalon
{
partial class FormCheque
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </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 = "FormCheque";
}
#endregion
}
}

View File

@ -1,20 +0,0 @@
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
{
public FormCheque()
{
InitializeComponent();
}
}
}

View File

@ -1,120 +0,0 @@
<?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
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<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
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
mimetype set.
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
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: 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
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -28,12 +28,52 @@
/// </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 = "FormCheques";
buttonDelete = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonDelete
//
buttonDelete.Location = new Point(583, 199);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(147, 56);
buttonDelete.TabIndex = 13;
buttonDelete.Text = "Уничтожить...";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// dataGridView
//
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
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 = 10;
//
// FormCheques
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonDelete);
Controls.Add(dataGridView);
Name = "FormCheques";
Text = "Чеки";
Load += FormCheques_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonDelete;
private DataGridView dataGridView;
}
}

View File

@ -1,20 +1,80 @@
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.Implements;
using BeautySalonDBModels.Models;
namespace BeautySalon
{
public partial class FormCheques : Form
{
public FormCheques()
private int? _id;
public int Id
{
set { _id = value; }
}
private readonly AbstractWorkWithStorage<Cheque> chequeStorage;
private readonly AbstractWorkWithStorage<Client> clientStorage;
private readonly AbstractWorkWithStorage<Service> serviceStorage;
public FormCheques(AbstractWorkWithStorage<Cheque> chequeStorage,
AbstractWorkWithStorage<Client> clientStorage,
AbstractWorkWithStorage<Service> serviceStorage)
{
this.chequeStorage = chequeStorage;
InitializeComponent();
this.clientStorage = clientStorage;
this.serviceStorage = serviceStorage;
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ChequeId"].Value);
chequeStorage.Remove(id);
LoadData();
}
}
private void FormCheques_Load(object sender, EventArgs e)
{
LoadData();
}
public void LoadData()
{
/* var list = chequeStorage.GetObjects();
if(list != null)
{
dataGridView.DataSource = list;
}*/
List<Cheque> cheques = chequeStorage.GetObjects();
ChequeDatabase cdb = new ChequeDatabase();
MasterDatabase mdb = new MasterDatabase();
dataGridView.Rows.Clear();
if (dataGridView.ColumnCount == 0)
{
dataGridView.Columns.Add("ChequeId", "ID");
dataGridView.Columns.Add("ClientFIO", "ФИО клиента");
dataGridView.Columns.Add("ServiceName", "Название");
dataGridView.Columns.Add("Price", "Цена");
}
foreach (Cheque cheque in cheques)
{
string serviceName =
}
foreach (Service service in services)
{
string specialisationName = mdb.GetNameSpecialisation(service);
dataGridView.Rows.Add(service.ServiceId, service.ServiceName, specialisationName, service.Price);
}
dataGridView.Columns["ChequeId"].Visible = false;
}
}
}

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

@ -14,9 +14,11 @@ namespace BeautySalonDBModels.Implements
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand("INSERT INTO cheques (cheque_id, client_id, reception_id) VALUES ((nextval('seq_cheque')), @ClientId, @ReceptionId)", conn);
using var cmd = new NpgsqlCommand("INSERT INTO cheques (cheque_id, client_id, reception_id, price)" +
" VALUES ((nextval('seq_cheque')), @ClientId, @ReceptionId. @Price)", conn);
cmd.Parameters.AddWithValue("@ClientId", cheque.ClientId);
cmd.Parameters.AddWithValue("@ReceptionId", cheque.ReceptionId);
cmd.Parameters.AddWithValue("@Price", cheque.Price);
cmd.ExecuteNonQuery();
}
@ -33,7 +35,8 @@ namespace BeautySalonDBModels.Implements
{
ChequeId = reader.GetInt32(0),
ClientId = reader.GetInt32(1),
ReceptionId = reader.GetInt32(2)
ReceptionId = reader.GetInt32(2),
Price = reader.GetDouble(3)
};
}
return null;
@ -52,7 +55,8 @@ namespace BeautySalonDBModels.Implements
{
ChequeId = reader.GetInt32(0),
ClientId = reader.GetInt32(1),
ReceptionId = reader.GetInt32(2)
ReceptionId = reader.GetInt32(2),
Price = reader.GetDouble(3)
});
}
return cheques;
@ -73,11 +77,12 @@ namespace BeautySalonDBModels.Implements
{
using var conn = GetConnection();
conn.Open();
using var cmd = new NpgsqlCommand("update cheque set client_id = @ClientId, " +
"reception_id = @ReceptionId where cheque_id = @ChequeId", conn);
using var cmd = new NpgsqlCommand("update cheques set client_id = @ClientId, " +
"reception_id = @ReceptionId, price = @Price where cheque_id = @ChequeId", conn);
cmd.Parameters.AddWithValue("@ClientId", cheque.ClientId);
cmd.Parameters.AddWithValue("@ReceptionId", cheque.ReceptionId);
cmd.Parameters.AddWithValue("@ChequeId", cheque.ChequeId);
cmd.Parameters.AddWithValue("@Price", cheque.Price);
cmd.ExecuteNonQuery();
}
}

View File

@ -5,5 +5,6 @@
public int ChequeId { get; set; }
public int ClientId { get; set; }
public int ReceptionId { get; set; }
public double Price { get; set; }
}
}