From e99556d9592f95bdf9b962a1b094900e8bda8ee2 Mon Sep 17 00:00:00 2001 From: ginopc Date: Fri, 5 Dec 2014 16:09:19 +0100 Subject: [PATCH] bug corrections Views bug corrections --- Program.cs | 8 +++++-- Properties/AssemblyInfo.cs | 2 +- README.txt | 5 +++++ Utils/Utils.cs | 4 ++-- Views/InventoryForm.cs | 39 +++++++++++++++++++-------------- Views/InventoryForm.designer.cs | 2 -- Views/LabelsForm.cs | 31 +++++++++++++------------- Views/LabelsForm.designer.cs | 2 -- Views/OrderForm.cs | 30 ++++++++++++------------- Views/OrderForm.designer.cs | 2 -- 10 files changed, 65 insertions(+), 60 deletions(-) diff --git a/Program.cs b/Program.cs index 187b755..d921131 100644 --- a/Program.cs +++ b/Program.cs @@ -3,19 +3,23 @@ using SelfDC.Utils; using System.Reflection; using SelfDC.Views; +using System.Threading; +using System.Diagnostics; namespace SelfDC { static class Program { + static string appName = Assembly.GetExecutingAssembly().GetName().Name; + static string appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static string appGuid = "abf2a777-ace8-40f3-a0ff-0aac712264c5"; + /// /// The main entry point for the application. /// [MTAThread] static void Main() { - String appName = Assembly.GetExecutingAssembly().GetName().Name; - String appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); /* Load app settings */ ScsUtils.WriteLog(string.Format("=== {0} ver. {1} ===", appName, appVersion)); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index cd0e7e9..423e6ea 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -30,7 +30,7 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.0.6.*")] +[assembly: AssemblyVersion("0.0.7.*")] // Below attribute is to suppress FxCop warning "CA2232 : Microsoft.Usage : Add STAThreadAttribute to assembly" // as Device app does not support STA thread. diff --git a/README.txt b/README.txt index 92c7eb3..90e9b16 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,11 @@ Self DataColletor (SelfDC) ========================== +##> Versione 0.0.7 +Eliminate da Utils le funzioni di esportazione file Ordini e etichette perchè non più usate. +correzione bug + + ##> Versione 0.0.6 (build 23637 del 02.12.2014) Correzione bug su esportazione Inventario diff --git a/Utils/Utils.cs b/Utils/Utils.cs index 69c6564..e3ea643 100644 --- a/Utils/Utils.cs +++ b/Utils/Utils.cs @@ -8,7 +8,7 @@ namespace SelfDC.Utils public static class ScsUtils { public static IDevice bcReader; - +/* public static int EsportaOrdine(List Items, string FileName) { int result = -1; @@ -76,7 +76,7 @@ public static int EsportaEtichette(List Items, string FileName) return result; } - +*/ /// /// Write log message into log file /// diff --git a/Views/InventoryForm.cs b/Views/InventoryForm.cs index c6469ca..93b3abd 100644 --- a/Views/InventoryForm.cs +++ b/Views/InventoryForm.cs @@ -11,7 +11,6 @@ namespace SelfDC.Views public partial class InventoryForm : Form { bool ItemEdit = false; - bool ItemValid = false; private List listaProdotti; private IDevice bcReader; @@ -118,13 +117,13 @@ private void actRemove(object sender, EventArgs e) { if (listBox.Items.Count == 0) { - MessageBox.Show("Non ci sono righe da esportare", "Elimina Riga", + MessageBox.Show("Non ci sono righe da eliminare", "Elimina Riga", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (listBox.SelectedIndices.Count == 0) { - MessageBox.Show("Seleziona l'elemento da eliminare","Elimina Riga"); + MessageBox.Show("Seleziona l'elemento da eliminare", "Elimina Riga"); return; } @@ -265,6 +264,8 @@ private void listBox_SelectedIndexChanged(object sender, EventArgs e) /** Salva modifica */ private void actSave(object sender, EventArgs e) { + bool ItemValid = false; + if (txtCode.Text == "") { MessageBox.Show("Niente da inserire", "Salva", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); @@ -272,8 +273,14 @@ private void actSave(object sender, EventArgs e) return; } + ItemValid = Validate(); + // se la qta non è un dato valido annulla il salvataggio - if (!ItemValid) return; + if (!ItemValid) + { + txtQta.Focus(); + return; + } // se ci sono elementi selezionati => è una modifica ListViewItem item; @@ -286,6 +293,7 @@ private void actSave(object sender, EventArgs e) item.Text = txtCode.Text; // ean item.SubItems[2].Text = txtQta.Text; // qta ItemEdit = false; + ScsUtils.WriteLog("In " + this.Name + ", salvataggio modifiche alla riga " + txtCode.Text); } else // Nuovo inserimento manuale { @@ -309,13 +317,12 @@ private void actSave(object sender, EventArgs e) item.SubItems.Add(txtQta.Text); listBox.Items.Add(item); - ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + item.Text); + ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + txtCode.Text); } this.statusBar.Text = string.Format("{0} record", listBox.Items.Count); // pulisco e disabilito i campi - ItemValid = false; actFieldReset(); } @@ -427,18 +434,20 @@ private void InventoryForm_Deactivate(object sender, EventArgs e) { ScsUtils.WriteLog(string.Format("Maschera {0} disattivata", this.Name)); bcReader.Close(); - this.bcReader.OnScan -= new EventHandler(this.bcReader_OnScan); + if (!Visible) + this.bcReader.OnScan -= new EventHandler(this.bcReader_OnScan); + } - private void txtQta_Validating(object sender, CancelEventArgs e) + /* valida i dati inseriti nei campi di input */ + private bool Validate() { double Num; // Se non c'è testo esco - if (txtQta.Text.Trim().Length == 0) + if ((txtCode.Text.Trim().Length == 0) && (txtQta.Text.Trim().Length == 0)) { - e.Cancel = true; - return; + return false; } try @@ -448,19 +457,15 @@ private void txtQta_Validating(object sender, CancelEventArgs e) catch (FormatException ex) { MessageBox.Show("Errore nel campo Q.ta"); - e.Cancel = true; - return; + return false; } if (Num > 0) { // formatto il numero txtQta.Text = string.Format("{0:#0.000}", Num); } - } - private void txtQta_Validated(object sender, EventArgs e) - { - ItemValid = true; + return true; } } } \ No newline at end of file diff --git a/Views/InventoryForm.designer.cs b/Views/InventoryForm.designer.cs index 17eadfe..bc82be9 100644 --- a/Views/InventoryForm.designer.cs +++ b/Views/InventoryForm.designer.cs @@ -216,9 +216,7 @@ private void InitializeComponent() this.txtQta.Size = new System.Drawing.Size(58, 23); this.txtQta.TabIndex = 1; this.txtQta.Text = "123.12"; - this.txtQta.Validated += new System.EventHandler(this.txtQta_Validated); this.txtQta.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtQta_KeyPress); - this.txtQta.Validating += new System.ComponentModel.CancelEventHandler(this.txtQta_Validating); // // txtCode // diff --git a/Views/LabelsForm.cs b/Views/LabelsForm.cs index b202718..e5dfd3b 100644 --- a/Views/LabelsForm.cs +++ b/Views/LabelsForm.cs @@ -12,7 +12,6 @@ namespace SelfDC.Views public partial class LabelsForm : Form { bool ItemEdit = false; - bool ItemValid = false; private List listaProdotti; private IDevice bcReader; @@ -114,7 +113,7 @@ private void actRemove(object sender, EventArgs e) { if (listBox.Items.Count == 0) { - MessageBox.Show("Non ci sono righe da esportare", "Elimina Riga", + MessageBox.Show("Non ci sono righe da eliminare", "Elimina Riga", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } @@ -270,6 +269,8 @@ private void listBox_SelectedIndexChanged(object sender, EventArgs e) /** Salva modifica */ private void actSave(object sender, EventArgs e) { + bool ItemValid = false; + if (txtCode.Text == "") { MessageBox.Show("Niente da inserire", "Salva", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); @@ -291,10 +292,10 @@ private void actSave(object sender, EventArgs e) item.SubItems[2].Text = txtQta.Text; // qta ItemEdit = false; - // nuovo inserimento con OrderItem + // nuovo inserimento con LabelItem LabelItem newItem = new LabelItem(item.Text, item.SubItems[1].Text, Convert.ToInt32(item.SubItems[2].Text)); - ScsUtils.WriteLog("In " + this.Name + ", salvataggio modifiche alla riga " + item.Text); + ScsUtils.WriteLog("In " + this.Name + ", salvataggio modifiche alla riga " + txtCode.Text); } else // Nuovo inserimento manuale { @@ -312,21 +313,19 @@ private void actSave(object sender, EventArgs e) if (txtQta.Text == "") { - ItemValid = true; txtQta.Text = "1"; } item.SubItems.Add(txtQta.Text); // se la quantità non è valida annulla il salvataggio - if (!ItemValid) return; + if (!Validate()) return; listBox.Items.Add(item); - ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + item.Text); + ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + txtCode.Text); } this.statusBar.Text = string.Format("{0} record", listBox.Items.Count); // pulisco e disabilito i campi - ItemValid = false; actFieldReset(); } @@ -449,12 +448,16 @@ private void LabelsForm_Deactivate(object sender, EventArgs e) this.bcReader.OnScan -= new EventHandler(this.bcReader_OnScan); } - private void txtQta_Validating(object sender, CancelEventArgs e) + private bool Validate() { double Num; // Se non c'è testo esco - if (txtQta.Text.Trim().Length == 0) return; + if (txtCode.Text.Trim().Length == 0) + { + MessageBox.Show("Inserire il codice"); + return false; + } try { @@ -463,19 +466,15 @@ private void txtQta_Validating(object sender, CancelEventArgs e) catch (FormatException ex) { MessageBox.Show("Errore nel campo Q.ta"); - e.Cancel = true; - return; + return false; } if (Num > 0) { // formatto il numero txtQta.Text = string.Format("{0:#0}", Num); } - } - private void txtQta_Validated(object sender, EventArgs e) - { - ItemValid = true; + return true; } } } \ No newline at end of file diff --git a/Views/LabelsForm.designer.cs b/Views/LabelsForm.designer.cs index f4515a2..9bb2a56 100644 --- a/Views/LabelsForm.designer.cs +++ b/Views/LabelsForm.designer.cs @@ -217,9 +217,7 @@ private void InitializeComponent() this.txtQta.Size = new System.Drawing.Size(58, 23); this.txtQta.TabIndex = 1; this.txtQta.Text = "123.12"; - this.txtQta.Validated += new System.EventHandler(this.txtQta_Validated); this.txtQta.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtQta_KeyPress); - this.txtQta.Validating += new System.ComponentModel.CancelEventHandler(this.txtQta_Validating); // // txtCode // diff --git a/Views/OrderForm.cs b/Views/OrderForm.cs index 48df40b..bfe5933 100644 --- a/Views/OrderForm.cs +++ b/Views/OrderForm.cs @@ -11,7 +11,6 @@ namespace SelfDC.Views public partial class OrderForm : Form { bool ItemEdit = false; - bool ItemValid = false; private List listaProdotti; private IDevice bcReader; @@ -119,13 +118,13 @@ private void actRemove(object sender, EventArgs e) { if (listBox.Items.Count == 0) { - MessageBox.Show("Non ci sono righe da esportare", "Elimina Riga", + MessageBox.Show("Non ci sono righe da eliminare", "Elimina Riga", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (listBox.SelectedIndices.Count == 0) { - MessageBox.Show("Seleziona l'elemento da eliminare","Elimina Riga"); + MessageBox.Show("Seleziona l'elemento da eliminare", "Elimina Riga"); return; } @@ -282,9 +281,10 @@ private void actSave(object sender, EventArgs e) else item.Text = txtCode.Text; // ean - if (!ItemValid) return; + if (!Validate()) return; item.SubItems[2].Text = txtQta.Text; // qta ItemEdit = false; + ScsUtils.WriteLog("In " + this.Name + ", salvataggio modifiche alla riga " + txtCode.Text); } else // Nuovo inserimento manuale { @@ -303,20 +303,18 @@ private void actSave(object sender, EventArgs e) if (txtQta.Text == "") { txtQta.Text = "1"; - ItemValid = true; } item.SubItems.Add(txtQta.Text); // se la quantità non è valida annulla il salvataggio - if (!ItemValid) return; + if (!Validate()) return; listBox.Items.Add(item); - ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + item.Text); + ScsUtils.WriteLog("In " + this.Name + ", nuovo inserimento della riga " + txtCode.Text); } this.statusBar.Text = string.Format("{0} record", listBox.Items.Count); // pulisco e disabilito i campi - ItemValid = false; actFieldReset(); } @@ -417,12 +415,16 @@ private void OrderForm_Deactivate(object sender, EventArgs e) } /* valida il contenuto della casella quantità */ - private void txtQta_Validating(object sender, CancelEventArgs e) + private bool Validate() { double Num; // Se non c'è testo esco - if (txtQta.Text.Trim().Length == 0) return; + if (txtCode.Text.Trim().Length == 0) + { + MessageBox.Show("Inserire il codice"); + return false; + } try { @@ -431,19 +433,15 @@ private void txtQta_Validating(object sender, CancelEventArgs e) catch (FormatException ex) { MessageBox.Show("Errore nel campo Q.ta"); - e.Cancel = true; - return; + return false; } if (Num > 0) { // formatto il numero txtQta.Text = string.Format("{0:#0}", Num); } - } - private void txtQta_Validated(object sender, EventArgs e) - { - ItemValid = true; + return true; } } } \ No newline at end of file diff --git a/Views/OrderForm.designer.cs b/Views/OrderForm.designer.cs index dacc4ee..ea4be38 100644 --- a/Views/OrderForm.designer.cs +++ b/Views/OrderForm.designer.cs @@ -216,9 +216,7 @@ private void InitializeComponent() this.txtQta.Size = new System.Drawing.Size(58, 23); this.txtQta.TabIndex = 1; this.txtQta.Text = "123.12"; - this.txtQta.Validated += new System.EventHandler(this.txtQta_Validated); this.txtQta.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtQta_KeyPress); - this.txtQta.Validating += new System.ComponentModel.CancelEventHandler(this.txtQta_Validating); // // txtCode //