# Cambios en la etiqueta

Se agregaron dos variables nuevas para las etiquetas
$V4$ - Número consecutivo
$V5$ - Fecha/Hora de ejecución-impresión

Se agregó una condición para que el consecutivo se reinicie cada dia.

Se arreglaron algunos errores de compilación
This commit is contained in:
2026-03-12 11:40:14 -06:00
parent 22ca33b671
commit 7c8fcb16ae
3 changed files with 48 additions and 17 deletions

View File

@@ -49,7 +49,7 @@ namespace ScaBox30.Controller
#endregion #endregion
#region ZEBRA -> buildPrn() #region ZEBRA -> buildPrn()
public void buildPrn(String v1, String v2, String v3, String barcode) public void buildPrn(String v1, String v2, String v3, String v4, DateTime v5, String barcode)
{ {
try try
{ {
@@ -85,6 +85,15 @@ namespace ScaBox30.Controller
{ {
etiqueta += line.Replace("$V3$", v3); etiqueta += line.Replace("$V3$", v3);
} }
else if (line.Contains("$V4$"))
{
etiqueta += line.Replace("$V4$", v4.ToString()); //consecutivo
}
else if (line.Contains("$V5$"))
{
// Insert formatted date/time for V5
etiqueta += line.Replace("$V5$", v5.ToString("dd/MM/yyyy HH:mm:ss")); // fecha y hora
}
else else
{ {
etiqueta += line; etiqueta += line;
@@ -94,7 +103,6 @@ namespace ScaBox30.Controller
} }
} }
#endregion #endregion

View File

@@ -22,6 +22,8 @@ namespace ScaBox30
public static Boolean debug = false; public static Boolean debug = false;
public static Boolean boxcapacity = false; public static Boolean boxcapacity = false;
public static Config cfg = new Config(); public static Config cfg = new Config();
public static int consec = 00000;
public static DateTime consecDate = DateTime.MinValue;
//Fields //Fields
@@ -139,7 +141,7 @@ namespace ScaBox30
codigo + ":028," + codigo + ":028," +
codigo + ":029," + codigo + ":029," +
codigo + ":030"; codigo + ":030";
//"0199170978" + ":030"; //"0199170978" + ":030";
//"ERROR"; //"ERROR";
} }
} }

View File

@@ -188,6 +188,9 @@ namespace ScaBox30
// CARGA DE CONFIGURACIONES // CARGA DE CONFIGURACIONES
LoadConfigJson(Globals.config_json); LoadConfigJson(Globals.config_json);
// Initialize daily consecutive date to today to avoid unexpected reset on first print
Globals.consecDate = DateTime.Today;
if (Globals.cfg.printerenabled) if (Globals.cfg.printerenabled)
{ {
btnPrinter.ForeColor = Color.White; btnPrinter.ForeColor = Color.White;
@@ -371,8 +374,6 @@ namespace ScaBox30
string found_code = keyOfMaxCount; string found_code = keyOfMaxCount;
element = Globals.actual_data.Find(x => x.CCE.Equals(found_code)); //Busca el elemento que coincide con el codigo -> obtiene fila con la informacion de la etiqueta element = Globals.actual_data.Find(x => x.CCE.Equals(found_code)); //Busca el elemento que coincide con el codigo -> obtiene fila con la informacion de la etiqueta
Console.WriteLine($"Buscando código: '{found_code}'");
Console.WriteLine($"Total registros en BD: {Globals.actual_data.Count}");
Globals.found_element = element; Globals.found_element = element;
} }
@@ -409,8 +410,6 @@ namespace ScaBox30
System.Threading.Thread.Sleep(Globals.cfg.interval); System.Threading.Thread.Sleep(Globals.cfg.interval);
} }
Console.WriteLine("[DEBUG] BLOAD completado, esperando 300ms para estabilización...");
System.Threading.Thread.Sleep(300); // El sensor necesita tiempo después de cambiar programa
response = ""; response = "";
@@ -744,9 +743,6 @@ namespace ScaBox30
//disable image clear timer //disable image clear timer
timer1.Enabled = false; timer1.Enabled = false;
//Disable button for re-clic and master barcode from being scanned //Disable button for re-clic and master barcode from being scanned
TgrBtn.Enabled = false; TgrBtn.Enabled = false;
UpdateTgrBtn(); UpdateTgrBtn();
@@ -815,10 +811,25 @@ namespace ScaBox30
} }
private Form CreateDataUIInstance()
{
// Use reflection to instantiate the Form type named "DataUI" (avoids compiler ambiguity if a generated resource class shares the name)
var asm = typeof(Principal).Assembly;
var dataUiType = asm.GetTypes().FirstOrDefault(t => t.Name == "DataUI" && typeof(Form).IsAssignableFrom(t));
if (dataUiType != null)
{
return Activator.CreateInstance(dataUiType) as Form;
}
return null;
}
private void btnBD_MouseClick(object sender, MouseEventArgs e) private void btnBD_MouseClick(object sender, MouseEventArgs e)
{ {
DataUI data = new DataUI(); var dataForm = CreateDataUIInstance();
data.ShowDialog(); if (dataForm != null)
{
dataForm.ShowDialog();
}
} }
@@ -920,7 +931,6 @@ namespace ScaBox30
string sr2000w_ip; string sr2000w_ip;
sr2000w_ip = Globals.cfg.ipscanner; sr2000w_ip = Globals.cfg.ipscanner;
if (reader_found) if (reader_found)
{ {
//Stop liveview. //Stop liveview.
@@ -1165,16 +1175,26 @@ namespace ScaBox30
if (Globals.cfg.printerenabled) if (Globals.cfg.printerenabled)
{ {
// Reset daily consecutive counter if day changed
if (Globals.consecDate.Date != DateTime.Today)
{
Globals.consec = 0;
Globals.consecDate = DateTime.Today;
}
string etiqueta = barcode_lbl.Text; string etiqueta = barcode_lbl.Text;
if (Globals.found_element.CCE == etiqueta) if (Globals.found_element.CCE == etiqueta)
{ {
String v1 = Globals.found_element.nom_1; String v1 = Globals.found_element.nom_1;
String v2 = Globals.found_element.@base + " / " + Globals.found_element.addition + " " + Globals.found_element.oeil; String v2 = Globals.found_element.@base + " / " + Globals.found_element.addition + " " + Globals.found_element.oeil;
String v3 = btnToogleMode.Text == operation_mode.manual ? "" : completa_parcial + " contiene: " + ok_count.ToString() + " de: " + Globals.found_element.Box_Capacity.Substring(0, 2); //String v3 = btnToogleMode.Text == operation_mode.manual ? "" : completa_parcial + " contiene: " + ok_count.ToString() + " de: " + Globals.found_element.Box_Capacity.Substring(0,2);
String v3 = btnToogleMode.Text == operation_mode.manual ? "" : completa_parcial + ok_count.ToString() + " de " + Globals.found_element.Box_Capacity.Substring(0, 2);
String v4 = Globals.consec.ToString(); //Numero consecutivo
DateTime v5 = DateTime.Now; //Fecha y hora de impresión
String barcode = Globals.found_element.CCE; String barcode = Globals.found_element.CCE;
ZT231.buildPrn(v1, v2, v3, barcode); ZT231.buildPrn(v1, v2, v3, v4, v5, barcode);
switch (Globals.cfg.printertype) switch (Globals.cfg.printertype)
{ {
@@ -1186,6 +1206,7 @@ namespace ScaBox30
break; break;
} }
} }
Globals.consec++;
} }
} }
@@ -1258,4 +1279,4 @@ namespace ScaBox30
} }
} }