Skip to content

Commit

Permalink
bug corrections
Browse files Browse the repository at this point in the history
Views bug corrections
  • Loading branch information
ginopc committed Dec 5, 2014
1 parent 2db4788 commit e99556d
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 60 deletions.
8 changes: 6 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/// <summary>
/// The main entry point for the application.
/// </summary>
[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));
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SelfDC.Utils
public static class ScsUtils
{
public static IDevice bcReader;

/*
public static int EsportaOrdine(List<OrderItem> Items, string FileName)
{
int result = -1;
Expand Down Expand Up @@ -76,7 +76,7 @@ public static int EsportaEtichette(List<LabelItem> Items, string FileName)
return result;
}

*/
/// <summary>
/// Write log message into log file
/// </summary>
Expand Down
39 changes: 22 additions & 17 deletions Views/InventoryForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace SelfDC.Views
public partial class InventoryForm : Form
{
bool ItemEdit = false;
bool ItemValid = false;
private List<InventoryItem> listaProdotti;
private IDevice bcReader;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -265,15 +264,23 @@ 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);
actFieldReset();
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;
Expand All @@ -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
{
Expand All @@ -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();
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}
}
2 changes: 0 additions & 2 deletions Views/InventoryForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions Views/LabelsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace SelfDC.Views
public partial class LabelsForm : Form
{
bool ItemEdit = false;
bool ItemValid = false;
private List<LabelItem> listaProdotti;
private IDevice bcReader;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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
{
Expand All @@ -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();
}

Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}
}
}
2 changes: 0 additions & 2 deletions Views/LabelsForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e99556d

Please sign in to comment.