14 Commits

8 changed files with 515 additions and 35 deletions

View File

@@ -10,9 +10,9 @@ namespace PizzaExpress_Client
private readonly ListBox _lstPizze;
private readonly TextBox _txtId, _txtNome, _txtPrezzo, _txtRicerca, _txtNote;
private readonly ComboBox _cmbCategoria;
private readonly ComboBox _cmbCategoria, _cmbStato;
private readonly Button _btnAggiungi, _btnAggiorna, _btnElimina, _btnElenco, _btnCosto;
private readonly Button _btnAggiungi, _btnAggiorna, _btnElimina, _btnElenco, _btnIngredienti, _btnNuovaPizza;
public GestionePizzeForm()
{
@@ -48,16 +48,16 @@ namespace PizzaExpress_Client
AutoSize = true
};
_btnCosto = new Button
_btnIngredienti = new Button
{
Text = "Costo",
Location = new Point(900, 15),
Size = new Size(70, 30)
Text = "Ingredienti",
Location = new Point(870, 15),
Size = new Size(104, 30)
};
_btnCosto.Click += BtnCosto_Click;
_btnIngredienti.Click += BtnIngredienti_Click;
pnlTop.Controls.Add(lblTitolo);
pnlTop.Controls.Add(_btnCosto);
pnlTop.Controls.Add(_btnIngredienti);
// ======================================================
// PANNELLO SINISTRO
@@ -92,9 +92,17 @@ namespace PizzaExpress_Client
};
_lstPizze.SelectedIndexChanged += LstPizze_SelectedIndexChanged;
_btnNuovaPizza = new Button
{
Text = "Nuova pizza",
Dock = DockStyle.Bottom,
Height = 35
};
pnlLeft.Controls.Add(_lstPizze);
pnlLeft.Controls.Add(_btnElenco);
pnlLeft.Controls.Add(_txtRicerca);
pnlLeft.Controls.Add(_btnNuovaPizza);
// ======================================================
// PANNELLO DESTRO — ALLINEAMENTO PERFETTO A SINISTRA
@@ -166,6 +174,17 @@ namespace PizzaExpress_Client
pnlRight.Controls.Add(_txtNote, 1, 5);
//Stato
pnlRight.Controls.Add(new Label { Text = "Stato:" }, 0, 6);
_cmbStato = new ComboBox
{
Width = 200,
DropDownStyle = ComboBoxStyle.DropDown,
Anchor = AnchorStyles.Left
};
_cmbStato.Items.AddRange(new[] { "Rifiutata", "Ordinata", "In preparazione", "Preparata", "Servita"});
pnlRight.Controls.Add(_cmbStato, 1, 6);
// ======================================================
// PANNELLO PULSANTI — ALLINEATO COL CAMPO NOME (SX)
// ======================================================
@@ -177,19 +196,20 @@ namespace PizzaExpress_Client
Padding = new Padding(0, 10, 0, 0)
};
_btnAggiungi = new Button { Text = "Aggiungi", Width = 120 };
_btnAggiorna = new Button { Text = "Aggiorna", Width = 120 };
_btnElimina = new Button { Text = "Elimina", Width = 120 };
_btnAggiungi = new Button { Text = "Aggiungi", Width = 120, Enabled = false };
_btnAggiorna = new Button { Text = "Aggiorna", Width = 120, Enabled = false };
_btnElimina = new Button { Text = "Elimina", Width = 120, Enabled = false };
_btnAggiungi.Click += async (s, e) => await AggiungiPizza();
_btnAggiorna.Click += async (s, e) => await AggiornaPizza();
_btnElimina.Click += async (s, e) => await EliminaPizza();
_btnNuovaPizza.Click += (s, e) => PulisciCampi();
pnlButtons.Controls.Add(_btnAggiungi);
pnlButtons.Controls.Add(_btnAggiorna);
pnlButtons.Controls.Add(_btnElimina);
pnlRight.Controls.Add(pnlButtons, 1, 6);
pnlRight.Controls.Add(pnlButtons, 1, 7);
// ======================================================
Controls.Add(pnlRight);
@@ -197,6 +217,10 @@ namespace PizzaExpress_Client
Controls.Add(pnlTop);
Load += async (s, e) => await CaricaPizze();
var formUrl = new UrlForm(_httpClient.BaseAddress.ToString());
formUrl.Show();
}
// ======================================================================
@@ -207,9 +231,9 @@ namespace PizzaExpress_Client
var pizze = await _httpClient.GetFromJsonAsync<List<Pizza>>("api/pizze");
_tutteLePizze = pizze ?? new List<Pizza>();
}
catch
catch(Exception ex)
{
MessageBox.Show("Errore nella connessione al server.");
MessageBox.Show("Errore nella connessione al server.\n" + ex.Message);
_tutteLePizze = new List<Pizza>();
}
@@ -244,6 +268,12 @@ namespace PizzaExpress_Client
_txtPrezzo.Text = p.Prezzo.ToString();
_cmbCategoria.Text = p.Categoria;
_txtNote.Text = p.Note;
_cmbStato.Text = p.Stato;
_btnAggiungi.Enabled = false;
_btnElimina.Enabled = true;
_btnAggiorna.Enabled = true;
_btnIngredienti.Enabled = true;
}
// ======================================================================
@@ -260,7 +290,8 @@ namespace PizzaExpress_Client
Nome = _txtNome.Text,
Prezzo = prezzo,
Categoria = _cmbCategoria.Text,
Note = _txtNote.Text
Note = _txtNote.Text,
Stato = _cmbStato.Text
};
var resp = await _httpClient.PostAsJsonAsync("api/pizze", pizza);
@@ -296,7 +327,8 @@ namespace PizzaExpress_Client
Nome = _txtNome.Text,
Prezzo = prezzo,
Categoria = _cmbCategoria.Text,
Note = _txtNote.Text
Note = _txtNote.Text,
Stato = _cmbStato.Text
};
var resp = await _httpClient.PutAsJsonAsync($"api/pizze/{id}", pizza);
@@ -317,23 +349,24 @@ namespace PizzaExpress_Client
if (!int.TryParse(_txtId.Text, out int id))
{
MessageBox.Show("Seleziona una pizza da eliminare.");
return;
}
else if (MessageBox.Show("Confermi l'eliminazione della pizza selezionata?", "Conferma eliminazione", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
await _httpClient.DeleteAsync($"api/pizze/{id}");
await _httpClient.DeleteAsync($"api/pizze/{id}");
await CaricaPizze();
await CaricaPizze();
_lstPizze.ClearSelected();
_txtId.Clear();
_txtNome.Clear();
_txtPrezzo.Clear();
_txtNote.Clear();
_cmbCategoria.SelectedIndex = -1;
_lstPizze.ClearSelected();
_txtId.Clear();
_txtNome.Clear();
_txtPrezzo.Clear();
_txtNote.Clear();
_cmbCategoria.SelectedIndex = -1;
}
}
// ======================================================================
private void BtnCosto_Click(object? sender, EventArgs e)
private void BtnIngredienti_Click(object? sender, EventArgs e)
{
if (_lstPizze.SelectedItem == null)
{
@@ -341,15 +374,22 @@ namespace PizzaExpress_Client
return;
}
var s = _lstPizze.SelectedItem.ToString();
var parts = s.Split('-');
MessageBox.Show("Funzionalità Ingredienti non ancora implementata.");
}
if (parts.Length >= 3)
{
string nome = parts[1].Trim();
string prezzo = parts[2].Replace("€", "").Trim();
MessageBox.Show($"La pizza {nome} costa {prezzo}€.");
}
private void PulisciCampi()
{
_txtId.Clear();
_txtNome.Clear();
_txtPrezzo.Clear();
_txtNote.Clear();
_cmbCategoria.SelectedIndex = -1;
_cmbStato.SelectedIndex = -1;
_btnAggiungi.Enabled = true;
_btnElimina.Enabled = false;
_btnAggiorna.Enabled = false;
_btnIngredienti.Enabled = false;
}
}
}

View File

@@ -16,5 +16,10 @@ namespace PizzaExpress_Client
public int Tavolo { get; set; }
public string Stato { get; set; } = string.Empty;
public override string ToString()
{
return $"{Id}) {Nome} - {Categoria} [{Stato}]";
}
}
}

86
RecipeSearch.Designer.cs generated Normal file
View File

@@ -0,0 +1,86 @@
namespace PizzaExpress_Client
{
partial class RecipeSearch
{
/// <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()
{
listBox1 = new ListBox();
cancelBtn = new Button();
confirmBtn = new Button();
SuspendLayout();
//
// listBox1
//
listBox1.FormattingEnabled = true;
listBox1.ItemHeight = 15;
listBox1.Location = new Point(12, 12);
listBox1.Name = "listBox1";
listBox1.Size = new Size(337, 379);
listBox1.TabIndex = 0;
//
// cancelBtn
//
cancelBtn.Location = new Point(12, 397);
cancelBtn.Name = "cancelBtn";
cancelBtn.Size = new Size(140, 31);
cancelBtn.TabIndex = 1;
cancelBtn.Text = "Annulla";
cancelBtn.UseVisualStyleBackColor = true;
//
// confirmBtn
//
confirmBtn.Location = new Point(158, 397);
confirmBtn.Name = "confirmBtn";
confirmBtn.Size = new Size(191, 31);
confirmBtn.TabIndex = 2;
confirmBtn.Text = "OK";
confirmBtn.UseVisualStyleBackColor = true;
//
// RecipeSearch
//
AcceptButton = confirmBtn;
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
CancelButton = cancelBtn;
ClientSize = new Size(361, 440);
Controls.Add(confirmBtn);
Controls.Add(cancelBtn);
Controls.Add(listBox1);
FormBorderStyle = FormBorderStyle.FixedDialog;
Name = "RecipeSearch";
StartPosition = FormStartPosition.CenterScreen;
Text = "Ricerca ingredienti";
ResumeLayout(false);
}
#endregion
private ListBox listBox1;
private Button cancelBtn;
private Button confirmBtn;
}
}

20
RecipeSearch.cs Normal file
View File

@@ -0,0 +1,20 @@
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 PizzaExpress_Client
{
public partial class RecipeSearch : Form
{
public RecipeSearch()
{
InitializeComponent();
}
}
}

120
RecipeSearch.resx Normal file
View File

@@ -0,0 +1,120 @@
<?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>

62
UrlForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,62 @@
namespace PizzaExpress_Client
{
partial class UrlForm
{
/// <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()
{
urlTxt = new Label();
SuspendLayout();
//
// urlTxt
//
urlTxt.Dock = DockStyle.Fill;
urlTxt.Font = new Font("Arial", 20.25F, FontStyle.Bold, GraphicsUnit.Point, 0);
urlTxt.Location = new Point(0, 0);
urlTxt.Name = "urlTxt";
urlTxt.Size = new Size(416, 105);
urlTxt.TabIndex = 0;
urlTxt.Text = "https://pizzeriadegitto.andrestork.moe:10469";
urlTxt.TextAlign = ContentAlignment.MiddleCenter;
//
// UrlForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(416, 105);
Controls.Add(urlTxt);
FormBorderStyle = FormBorderStyle.SizableToolWindow;
Name = "UrlForm";
Text = "Server URL";
Load += UrlForm_Load;
ResumeLayout(false);
}
#endregion
private Label urlTxt;
}
}

27
UrlForm.cs Normal file
View File

@@ -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 PizzaExpress_Client
{
public partial class UrlForm : Form
{
public UrlForm(string srvUrl)
{
InitializeComponent();
urlTxt.Text = srvUrl;
}
private void UrlForm_Load(object sender, EventArgs e)
{
}
}
}

120
UrlForm.resx Normal file
View File

@@ -0,0 +1,120 @@
<?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>