|
@@ -58,6 +58,8 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
if (!File.Exists(_csvPath)) throw new Exception($"Vstupní CSV soubor '{_csvPath}' neexistuje, vyberte existující soubor.");
|
|
if (!File.Exists(_csvPath)) throw new Exception($"Vstupní CSV soubor '{_csvPath}' neexistuje, vyberte existující soubor.");
|
|
|
if (_data == null) throw new Exception($"Vstupní CSV soubor '{_csvPath}' musí být otevřen.");
|
|
if (_data == null) throw new Exception($"Vstupní CSV soubor '{_csvPath}' musí být otevřen.");
|
|
|
|
|
|
|
|
|
|
+ _data = ProcessData(_data);
|
|
|
|
|
+
|
|
|
var generator = new ExcelLabelGenerator(AppSettings.Default.LabelTemplate.Replace("{cr}","\n"));
|
|
var generator = new ExcelLabelGenerator(AppSettings.Default.LabelTemplate.Replace("{cr}","\n"));
|
|
|
|
|
|
|
|
if (generator.GenerateLabels(_data, _xlsPath, int.Parse(AppSettings.Default.LabelPerRow), int.Parse(AppSettings.Default.LabelPerCol), double.Parse(AppSettings.Default.LabelWidth), double.Parse(AppSettings.Default.LabelHeight)))
|
|
if (generator.GenerateLabels(_data, _xlsPath, int.Parse(AppSettings.Default.LabelPerRow), int.Parse(AppSettings.Default.LabelPerCol), double.Parse(AppSettings.Default.LabelWidth), double.Parse(AppSettings.Default.LabelHeight)))
|
|
@@ -67,6 +69,40 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private DataTable ProcessData(DataTable data)
|
|
|
|
|
+ {
|
|
|
|
|
+ //LabelAggegationDataExpression
|
|
|
|
|
+ var expressionParts = AppSettings.Default.LabelAggegationDataExpression.Split('=');
|
|
|
|
|
+ var expressionColumnName = expressionParts[0];
|
|
|
|
|
+ var expressionValue = expressionParts[1];
|
|
|
|
|
+ data.Columns.Add(expressionColumnName, typeof(string));
|
|
|
|
|
+
|
|
|
|
|
+ var result = data.Clone();
|
|
|
|
|
+ result.Rows.Clear();
|
|
|
|
|
+
|
|
|
|
|
+ foreach (DataRow row in data.Rows)
|
|
|
|
|
+ {
|
|
|
|
|
+ var rowNew = result.Select($"order_no = '{row["order_no"]}' AND prod_cat = '{row["prod_cat"]}'");
|
|
|
|
|
+ if (rowNew.Length == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ var newRow = result.NewRow();
|
|
|
|
|
+ newRow.ItemArray = row.ItemArray.ToArray();
|
|
|
|
|
+ newRow[expressionColumnName] = expressionValue.Replace("{prod_var_type}", row["prod_var_type"].ToString())
|
|
|
|
|
+ .Replace("{qty}",row["qty"].ToString()).Replace("{cr}","\n");
|
|
|
|
|
+ result.Rows.Add(newRow);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ rowNew[0][expressionColumnName] = rowNew[0][expressionColumnName] + expressionValue.Replace("{prod_var_type}", row["prod_var_type"].ToString())
|
|
|
|
|
+ .Replace("{qty}", row["qty"].ToString()).Replace("{cr}", "\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private void butConfig_Click(object sender, EventArgs e)
|
|
private void butConfig_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
var dlg = new dlgLabelSettings();
|
|
var dlg = new dlgLabelSettings();
|
|
@@ -105,5 +141,9 @@ namespace qdr.app.studiou.orders2printpack
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
+
|
|
|
|
|
+ #region *** Nested classes ***
|
|
|
|
|
+
|
|
|
|
|
+ #endregion
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|