Update 20260717

This commit is contained in:
Stefan Hutter committed 2026-07-17 14:43:33 +02:00
1 parent 58cd45116c
commit ebc8101626
1004 files changed
+1174234 -84840

No files matched your search

+3
View File
@@ -13,6 +13,9 @@
<setting name="Datapath" serializeAs="String">
<value>E:\Software-Projekte\OnDoc\Vorlagen\BatchAPI\</value>
</setting>
<setting name="Connectionstring" serializeAs="String">
<value>data source=shu01\shu00;initial catalog=edoka_dms;packet size=4096;user id=sa;password=*shu29</value>
</setting>
</Tool_API_Dokumentgenerator.Properties.Settings>
</userSettings>
</configuration>
File diff suppressed because it is too large. Load diff
+559 -103
View File
@@ -2,24 +2,38 @@
using FastExcel;
using Syncfusion.Windows.Forms.Edit;
using Syncfusion.XlsIO;
using Syncfusion.XlsIO.Implementation.Security;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using System.Data.Sql;
using System.Data.SqlClient;
namespace Tool_API_Dokumentgenerator
{
public partial class Form1 : Form
{
string partnernr = "";
string unterschriftlinks = "";
string unterschriftrechts = "";
public class ControlState
{
public string Name { get; set; }
@@ -36,12 +50,14 @@ namespace Tool_API_Dokumentgenerator
string tabelle2 = "";
string tabelle3 = "";
string tabelle4 = "";
DataTable ExcelMapping = new DataTable();
DataTable ExcelMapping = new DataTable();
private void start()
{
ExcelMapping.Columns.Clear();
ExcelMapping.Columns.Add("Tag");
ExcelMapping.Columns.Add("Excelspalte");
ExcelMapping.Columns.Add("FixText");
ExcelMapping.Columns.Add("Formatierung");
ExcelMapping.TableName = "ExcelMappoing";
}
@@ -52,10 +68,13 @@ namespace Tool_API_Dokumentgenerator
}
private void button5_Click(object sender, EventArgs e)
{
// editControl1.Save();
System.IO.File.WriteAllText(datapath + txttextinput.Text, editControl1.Text);
Generate(true);
}
private void Generate(bool demo) {
private void Generate(bool demo)
{
int processed = 0;
System.Data.DataTable importdata = new System.Data.DataTable();
ExcelNet.ExcelReader reader = new ExcelNet.ExcelReader();
@@ -63,7 +82,7 @@ namespace Tool_API_Dokumentgenerator
var sheets = new List<string>();
try
{
sheets = reader.Get_ExcelSheets(datapath+txtexcelinput.Text);
sheets = reader.Get_ExcelSheets(datapath + txtexcelinput.Text);
}
catch
{
@@ -74,9 +93,35 @@ namespace Tool_API_Dokumentgenerator
selected_sheetname = sheets[0];
Import_sf_Excel(datapath+txtexcelinput.Text, selected_sheetname, ref importdata);
DataView dv = new DataView(importdata ); dv.Sort = txtspalten.Text.Replace(";", ",");
Import_sf_Excel(datapath + txtexcelinput.Text, selected_sheetname, ref importdata);
for (int i = 0; i < importdata.Rows.Count; i++)
{
DataRow dr = importdata.Rows[i];
if (dr[0].ToString() == "")
dr.Delete();
}
importdata.AcceptChanges();
if (demo && txtTestKunde.Text != "") {
for (int i = 0; i < importdata.Rows.Count; i++)
{
DataRow dr = importdata.Rows[i];
if (dr[txttestspalte.Text].ToString().Trim().Replace(".", "") != txtTestKunde.Text.Trim().Replace(".", ""))
dr.Delete();
}
}
importdata.AcceptChanges();
DataView dv = new DataView(importdata);
dv.Sort = txtspalten.Text.Replace(";", ",");
importdata.DefaultView.Sort = txtspalten.Text.Replace(";", ",");
for (int i = 0; i < importdata.Rows.Count; i++)
{
DataRow dr = importdata.Rows[i];
if (dr[0].ToString() == "")
dr.Delete();
}
progressBarAdv1.Visible = true;
string oldkey = "";
int counter = 0;
@@ -84,127 +129,349 @@ namespace Tool_API_Dokumentgenerator
progressBarAdv1.Maximum = dv.Count;
progressBarAdv1.Value = 0;
System.Windows.Forms.Application.DoEvents();
lblgeneriert.Text = "Datensätze verarbeitet: ";
lblgeneriertdoks.Text = "JSON generiert:";
lblgeneriert.Visible = true;
lblgeneriertdoks.Visible = true;
DataRow rowsave = null;
foreach (DataRowView rowView in dv)
{
progressBarAdv1.Value++;
progressBarAdv1.Value++;
DataRow row = rowView.Row;
partnernr = "";
unterschriftlinks = "";
unterschriftrechts = "";
//if (txtPartnerNr.Text != "") { try { partnernr = row[txtPartnerNr.Text].ToString().Replace(".", ""); } catch { partnernr = ""; } }
//if (txtUnterschriftRechts.Text != "") { try { unterschriftrechts = row[txtUnterschriftRechts.Text].ToString().Replace(".", ""); } catch { unterschriftrechts = ""; } }
//if (txtUnterschriftRechts.Text != "") { try { unterschriftrechts = row[txtUnterschriftRechts.Text].ToString().Replace(".", ""); } catch { unterschriftrechts = ""; } }
if (oldkey != row[txtdokumenttrenner.Text].ToString())
{
if (counter > 0)
{
if (tabelle1 != "")
{
tabelle1= "<p><table>" + tabelle1 + "</table>";
inputdata = inputdata.Replace(txttag1.Text, tabelle1);
if (txtueberschrift1.Text != "") { inputdata = inputdata.Replace(txttagueberschrift1.Text, txtueberschrift1.Text); }
}
if (tabelle2 != "")
{
tabelle2 = "<p><table>" + tabelle2 + "</table>";
inputdata = inputdata.Replace(txttag2.Text, tabelle2);
if (txtueberschrift2.Text != "") { inputdata = inputdata.Replace(txttagueberschrift2.Text, txtueberschrift2.Text); }
}
if (tabelle3 != "")
{
tabelle3 = "<p><table>" + tabelle3 + "</table>";
inputdata = inputdata.Replace(txttag3.Text, tabelle3);
if (txtueberschrift3.Text != "") { inputdata = inputdata.Replace(txttagueberschrift3.Text, txtueberschrift3.Text); }
}
if (tabelle4 != "")
{
tabelle4 = "<p><table>" + tabelle4 + "</table>";
inputdata = inputdata.Replace(txttag4.Text, tabelle4);
if (txtueberschrift4.Text != "") { inputdata = inputdata.Replace(txttagueberschrift4.Text, txtueberschrift4.Text); }
}
if (tabelle1 == "" && txttag1.Text!="")
{
inputdata=inputdata.Replace(txttag1.Text,"");
inputdata=inputdata.Replace(txttagueberschrift1.Text, "");
}
if (tabelle2 == "" && txttag2.Text!="")
{
inputdata = inputdata.Replace(txttag2.Text, "");
inputdata = inputdata.Replace(txttagueberschrift2.Text, "");
}
if (tabelle3 == "" && txttag3.Text != "")
{
inputdata = inputdata.Replace(txttag3.Text, "");
inputdata = inputdata.Replace(txttagueberschrift3.Text, "");
}
if (tabelle4 == "" && txttag4.Text != "")
{
inputdata = inputdata.Replace(txttag4.Text, "");
inputdata = inputdata.Replace(txttagueberschrift4.Text, "");
}
System.IO.File.WriteAllText(datapath+@"\output\"+this.txtname.Text+"_Data_" + oldkey + ".json", inputdata);
if (counter > 0)
{
processed = processed + 1;
//WriteTable(ref rowsave);
Update_Excelspalten(ref rowsave);
Abschluss_Dokument(oldkey,demo);
if (demo)
{
this.editControl2.Text = inputdata;
panel1.Visible = true;
panel1.Dock = DockStyle.Right;
panel1.Dock = DockStyle.Bottom;
editControl1.Visible = false;
groupBox2.Visible = false;
//groupBox3.Visible = true;
//groupBox3.Dock = DockStyle.Fill;
editControl2.MoveToBeginning();
progressBarAdv1.Visible = false;
editControl2.Visible = true;
toolStrip1.Visible = true;
return;
}
}
}
lblgeneriertdoks.Text= "JSON generiert: " + processed.ToString();
rowsave = row;
oldkey = row[txtdokumenttrenner.Text].ToString();
inputdata = System.IO.File.ReadAllText(datapath + txttextinput.Text);
tabelle1 = "";tabelle2 = "";tabelle3 = "";tabelle4 = "";
editControl1.Text=inputdata;
counter++;
tabelle1 = ""; tabelle2 = ""; tabelle3 = ""; tabelle4 = "";
}
if (txttnr1.Text != "" && row["tabelle"].ToString() == txttnr1.Text)
editControl1.Text = inputdata;
counter++;
WriteTable(ref row);
progressBarAdv1.Value = counter;
lblgeneriert.Text = "Datensätze verarbeitet: " + counter.ToString();
System.Windows.Forms.Application.DoEvents();
}
Update_Excelspalten(ref rowsave);
Abschluss_Dokument(oldkey);
if (demo)
{
this.editControl2.Text = inputdata;
panel1.Visible = true;
panel1.Dock = DockStyle.Bottom;
editControl1.Visible = false;
groupBox2.Visible = false;
//groupBox3.Visible = true;
//groupBox3.Dock = DockStyle.Fill;
editControl2.MoveToBeginning();
progressBarAdv1.Visible = false;
lblgeneriert.Visible = false;
lblgeneriertdoks.Visible = false;
editControl2.Visible = true;
toolStrip1.Visible = true; processed = processed + 1;
MessageBox.Show(processed.ToString() + " Dokumente wurden erfolgreich erstellt.", "Dokumentgenerator", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
processed = processed + 1;
lblgeneriertdoks.Text = "JSON generiert: " + processed.ToString();
MessageBox.Show(processed.ToString() + " Dokumente wurden erfolgreich erstellt.", "Dokumentgenerator", MessageBoxButtons.OK, MessageBoxIcon.Information);
progressBarAdv1.Visible = false;
lblgeneriert.Visible = false;
lblgeneriertdoks.Visible = false;
}
private void Abschluss_Dokument(string oldkey, bool demo = false)
{
string headers = "";
if (tabelle1 != "")
{
headers = "";
if (txtcolheader1.ToString() != "")
{
tabelle1 += "<row>" ;
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
tabelle1 = tabelle1 + "<col>" + row[cols[i]].ToString() + "</col>";
}
tabelle1 += "</row>" ;
headers = "<row><col>" + txtcolheader1.Text.Replace(";", "</col>") + "</col></row>";
}
if (txttnr2.Text != "" && row["tabelle"].ToString() == txttnr2.Text)
tabelle1 = "<p><table" + txtformat1.Text + ">" + headers + tabelle1 + "</table><p>";
inputdata = inputdata.Replace(txttag1.Text, tabelle1);
if (txtueberschrift1.Text != "") { inputdata = inputdata.Replace(txttagueberschrift1.Text, txtueberschrift1.Text); }
}
if (tabelle2 != "")
{
headers = "";
if (txtcolheader2.ToString() != "")
{
tabelle2 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
tabelle2 = tabelle2 + "<col>" + row[cols[i]].ToString() + "</col>";
}
tabelle2 += "</row>";
headers = "<row><col>" + txtcolheader2.Text.Replace(";", "</col>") + "</col></row>";
}
if (txttnr3.Text != "" && row["tabelle"].ToString() == txttnr2.Text)
tabelle2 = "<p><table" + txtformat2.Text + ">" + headers + tabelle2 + "</table><p>";
inputdata = inputdata.Replace(txttag2.Text, tabelle2);
if (txtueberschrift2.Text != "") { inputdata = inputdata.Replace(txttagueberschrift2.Text, txtueberschrift2.Text); }
}
if (tabelle3 != "")
{
headers = "";
if (txtcolheader3.ToString() != "")
{
tabelle3 += "<row>" ;
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
tabelle3 = tabelle3 + "<col>" + row[cols[i]].ToString() + "</col>";
}
tabelle3 += "</row>";
headers = "<row><col>" + txtcolheader3.Text.Replace(";", "</col>") + "</col></row>";
}
if (txttnr4.Text != "" && row["tabelle"].ToString() == txttnr2.Text)
tabelle3 = "<p><table" + txtformat3.Text + ">" + headers + tabelle3 + "</table><p>";
inputdata = inputdata.Replace(txttag3.Text, tabelle3);
if (txtueberschrift3.Text != "") { inputdata = inputdata.Replace(txttagueberschrift3.Text, txtueberschrift3.Text); }
}
if (tabelle4 != "")
{
headers = "";
if (txtcolheader4.ToString() != "")
{
tabelle4 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
tabelle4 = tabelle4 + "<col>" + row[cols[i]].ToString() + "</col>";
}
tabelle4 += "</row>";
headers = "<row><col>" + txtcolheader4.Text.Replace(";", "</col>") + "</col></row>";
}
foreach (DataRow dr in ExcelMapping.Rows)
tabelle4 = "<p><table" + txtformat4.Text + ">" + headers + tabelle4 + "</table><p>";
inputdata = inputdata.Replace(txttag4.Text, tabelle4);
if (txtueberschrift4.Text != "") { inputdata = inputdata.Replace(txttagueberschrift4.Text, txtueberschrift4.Text); }
}
if (tabelle1 == "" && txttag1.Text != "")
{
inputdata = inputdata.Replace(txttag1.Text, "");
inputdata = inputdata.Replace(txttagueberschrift1.Text, "");
}
if (tabelle2 == "" && txttag2.Text != "")
{
inputdata = inputdata.Replace(txttag2.Text, "");
inputdata = inputdata.Replace(txttagueberschrift2.Text, "");
}
if (tabelle3 == "" && txttag3.Text != "")
{
inputdata = inputdata.Replace(txttag3.Text, "");
inputdata = inputdata.Replace(txttagueberschrift3.Text, "");
}
if (tabelle4 == "" && txttag4.Text != "")
{
inputdata = inputdata.Replace(txttag4.Text, "");
inputdata = inputdata.Replace(txttagueberschrift4.Text, "");
}
//if (partnernr != "")
//{
// inputdata = inputdata.Replace("$$PARTNERNR$$", partnernr.Replace(".", ""));
//}
//if (unterschriftlinks != "")
//{
// inputdata = inputdata.Replace("$$UNTERSCHRIFTLINKS$$", unterschriftlinks.ToString());
//}
//if (unterschriftrechts != "")
//{
// inputdata = inputdata.Replace("$$UNTERSCHRIFTRECHTS$$", unterschriftrechts.ToString());
//}
if (!demo)
{
System.IO.File.WriteAllText(datapath + @"\output\" + this.txtname.Text + "_Data_" + oldkey + ".json", inputdata);
}
else
{
System.IO.File.WriteAllText(datapath + @"\test-json.json", inputdata);
}
}
public string formatvalue(string data, string format)
{
if (format.ToUpper().Contains("REPLACE"))
{
string[] parts = format.Split('|');
return data.Replace(parts[1], parts[2]);
}
if (format.ToUpper().Contains("UPPER"))
{
return data.ToUpper();
}
if (format.ToUpper().Contains("LOWER"))
{
return data.ToLower();
}
return data;
}
private void Update_Excelspalten(ref DataRow row)
{
string value = "";
foreach (DataRow dr in ExcelMapping.Rows)
{
value = "";
if (dr["Tag"].ToString() != "") // && row[dr["Excelspalte"].ToString()] != "")
{
if (dr["Tag"].ToString() != "" && row[dr["Excelspalte"].ToString()] != "")
if (dr["Excelspalte"].ToString() != "")
{
inputdata = inputdata.Replace(dr["Tag"].ToString(), row[dr["Excelspalte"].ToString()].ToString());
try
{
if (row[dr["Excelspalte"].ToString()] != "") { inputdata = inputdata.Replace(dr["Tag"].ToString(), formatvalue(row[dr["Excelspalte"].ToString()].ToString(), dr["Formatierung"].ToString())); }
//if (row[dr["Excelspalte"].ToString()] != "") { inputdata = inputdata.Replace(dr["Tag"].ToString(), row[dr["Excelspalte"].ToString()].ToString()); }
}
catch
{
}
}
if (dr["FixText"].ToString().Trim() != "")
{
switch (dr["FixText"].ToString())
{
case "Date()":
inputdata = inputdata.Replace(dr["Tag"].ToString(), DateTime.Now.ToString("dd.MM.yyyy"));
break;
default:
inputdata = inputdata.Replace(dr["Tag"].ToString(), dr["FixText"].ToString().ToString());
break;
}
}
}
}
progressBarAdv1.Visible = false;
}
private string FormatColumn(ref DataRow row, string col)
{
if (!col.Contains("{") && !col.Contains("|"))
{
return "<col>" + row[col].ToString() + "</col>";
}
string[] parts = col.Split('|');
string resultat = "";
foreach (string part in parts)
{
if (resultat != "") { resultat = resultat + " "; }
resultat = resultat + getpartvalue(ref row, part);
int i = 0;
}
return "<col>" + resultat + "</col>";
//
}
private string getpartvalue(ref DataRow row, string col)
{
string[] cols = col.Split('}');
if (cols.Length > 1) { col = cols[1]; } else { col = cols[0]; }
string value = row[col].ToString();
if (cols.Length > 1)
{
cols[0] = cols[0].Replace("}", "");
cols[0] = cols[0].Replace("{", "");
switch (cols[0].ToUpper())
{
case "CURRENCY":
decimal zahl = decimal.Parse(value);
string currency = zahl.ToString("N2");
value = currency;
break;
default:
break;
}
}
return value;
}
private void WriteTable(ref DataRow row)
{
if (txttnr1.Text != "" && row["tabelle"].ToString() == txttnr1.Text)
{
tabelle1 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
// tabelle1 = tabelle1 + "<col>" + row[cols[i]].ToString() + "</col>";
tabelle1 = tabelle1 + FormatColumn(ref row, cols[i]);
}
tabelle1 += "</row>";
}
if (txttnr2.Text != "" && row["tabelle"].ToString() == txttnr2.Text)
{
tabelle2 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
//tabelle2 = tabelle2 + "<col>" + row[cols[i]].ToString() + "</col>";
tabelle2 = tabelle2 + FormatColumn(ref row, cols[i]);
}
tabelle2 += "</row>";
}
if (txttnr3.Text != "" && row["tabelle"].ToString() == txttnr3.Text)
{
tabelle3 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
//tabelle3 = tabelle3 + "<col>" + row[cols[i]].ToString() + "</col>";
tabelle3 = tabelle3 + FormatColumn(ref row, cols[i]);
}
tabelle3 += "</row>";
}
if (txttnr4.Text != "" && row["tabelle"].ToString() == txttnr4.Text)
{
tabelle4 += "<row>";
string[] cols = txttabellenspalten.Text.Split(';');
for (int i = 0; i < cols.Length; i++)
{
//tabelle4 = tabelle4 + "<col>" + row[cols[i]].ToString() + "</col>";
tabelle4 = tabelle4 + FormatColumn(ref row, cols[i]);
}
tabelle4 += "</row>";
}
}
private void Import_sf_Excel(string filename, string sheetname, ref System.Data.DataTable importdata)
{
@@ -228,14 +495,19 @@ namespace Tool_API_Dokumentgenerator
{
start();
sfDataGrid1.DataSource = ExcelMapping;
sfDataGrid1.Columns[0].Width = sfDataGrid1.Width / 4 - 5;
sfDataGrid1.Columns[1].Width = sfDataGrid1.Width / 4 - 5;
sfDataGrid1.Columns[2].Width = sfDataGrid1.Width / 4 - 5;
sfDataGrid1.Columns[3].Width = sfDataGrid1.Width / 4 - 5;
groupBox2.Dock = DockStyle.Fill;
}
private void button1_Click(object sender, EventArgs e)
{
SaveControlsToJson(this, datapath+txtname.Text+".json");
SaveControlsToJson(this, datapath + txtname.Text + ".json");
ExcelMapping.AcceptChanges();
ExcelMapping.WriteXml(datapath + txtname.Text + "_mapping.xml", XmlWriteMode.WriteSchema);
System.IO.File.WriteAllText(datapath + txttextinput.Text,editControl1.Text);
System.IO.File.WriteAllText(datapath + txttextinput.Text, editControl1.Text);
}
private void button3_Click(object sender, EventArgs e)
@@ -243,9 +515,10 @@ namespace Tool_API_Dokumentgenerator
LoadControlsFromJson(this, datapath + txtname.Text + ".json");
ExcelMapping.Rows.Clear();
ExcelMapping.ReadXml(datapath + txtname.Text + "_mapping.xml");
inputdata = System.IO.File.ReadAllText(datapath+txttextinput.Text);
inputdata = System.IO.File.ReadAllText(datapath + txttextinput.Text);
tabelle1 = ""; tabelle2 = ""; tabelle3 = ""; tabelle4 = "";
editControl1.Text = inputdata;
editControl1.MoveToBeginning();
}
public void SaveControlsToJson(Control parent, string filePath)
@@ -358,10 +631,193 @@ namespace Tool_API_Dokumentgenerator
private void button4_Click(object sender, EventArgs e)
{
panel1.Visible = false;
editControl1.Visible= true;
}
private void label14_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
groupBox3.Visible = false;
groupBox2.Visible = true;
panel1.Visible = false;
editControl2.Visible = false;
toolStrip1.Visible = false;
editControl1.Visible = true;
}
private void button4_Click_1(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = datapath;
openFileDialog1.Filter = "JSON-Dateien (*.json)|*.json|Alle Dateien (*.*)|*.*";
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != "")
{
this.txtbasedir.Text = Path.GetDirectoryName(openFileDialog1.FileName);
this.txtname.Text = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
button3_Click(sender, e);
//if (this.txtbasedir.Text == "")
//{
//}
}
}
private void button6_Click(object sender, EventArgs e)
{
button1_Click(sender, e);
}
private void button7_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = datapath;
openFileDialog1.Filter = "Excel-Dateien (*.xlsx)|*.xlsx|Alle Dateien (*.*)|*.*";
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != "")
{
this.txtexcelinput.Text = Path.GetFileName(openFileDialog1.FileName);
}
}
private void button8_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = datapath;
openFileDialog1.Filter = "Text-Dateien (*.txt)|*.txt|Alle Dateien (*.*)|*.*";
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName != "")
{
this.txttextinput.Text = Path.GetFileName(openFileDialog1.FileName);
}
}
private void button9_Click(object sender, EventArgs e)
{
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
{
this.txtbasedir.Text = fbd.SelectedPath;
}
}
}
private void check_outputdir()
{
datapath = txtbasedir.Text;
if (!datapath.EndsWith(@"\"))
{
datapath = datapath + @"\";
}
if (!System.IO.Directory.Exists(datapath + @"\output"))
{
System.IO.Directory.CreateDirectory(datapath + @"\output");
}
}
private void txtbasedir_TextChanged(object sender, EventArgs e)
{
if (!System.IO.Directory.Exists(txtbasedir.Text))
{
MessageBox.Show("Das angegebene Verzeichnis existiert nicht. Bitte geben Sie ein gültiges Verzeichnis an.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
check_outputdir();
}
private void btnbpcheck_Click(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
System.Data.DataTable importdata = new System.Data.DataTable();
ExcelNet.ExcelReader reader = new ExcelNet.ExcelReader();
string selected_sheetname = "";
var sheets = new List<string>();
try
{
sheets = reader.Get_ExcelSheets(datapath + txtexcelinput.Text);
}
catch
{
MessageBox.Show("Auf die gewählte Excel-Datei kann aktuell nicht zugegriffen werden. Evtl. ist diese noch geöffnet.", "Excel-Import", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
System.Data.DataTable testdata = new System.Data.DataTable();
ExcelNet.ExcelReader testreader = new ExcelNet.ExcelReader();
string testselected_sheetname = "";
var testsheets = new List<string>();
try
{
testsheets = reader.Get_ExcelSheets(datapath + txtexcelinput.Text);
}
catch
{
MessageBox.Show("Auf die gewählte Excel-Datei kann aktuell nicht zugegriffen werden. Evtl. ist diese noch geöffnet.", "Excel-Import", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
selected_sheetname = sheets[0];
Cursor = Cursors.WaitCursor;
Import_sf_Excel(datapath + txtexcelinput.Text, selected_sheetname, ref importdata);
int bperror = 0;
string connectionstring = Properties.Settings.Default.Connectionstring;
for (int i = 0; i < importdata.Rows.Count; i++)
{
DataRow dr = importdata.Rows[i];
if (!bp_exists(connectionstring, dr[txtpartner.Text].ToString()))
{
System.IO.File.AppendAllText(datapath + @"\partnercheck.log", dr[txtpartner.Text].ToString() + " NOK"+Environment.NewLine);
bperror++;
}
}
if (bperror > 0)
{
MessageBox.Show($"Es wurden {bperror} Partner nicht gefundenen.", "Partnercheck", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} else
{
MessageBox.Show($"Es wurden {importdata.Rows.Count} Partner gefundenen.", "Partnercheck", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Cursor = Cursors.Default;
}
private bool bp_exists(string connectionString, string bpnr)
{
bpnr = bpnr.Trim().Replace(".", "");
string sql = "SELECT COUNT(*) FROM partner WHERE nrpar00 = @Nummer";
using (SqlConnection conn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddWithValue("@Nummer", bpnr);
conn.Open();
int anzahl = (int)cmd.ExecuteScalar();
return anzahl > 0;
}
}
}
}
+73
View File
@@ -117,4 +117,77 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>261, 17</value>
</metadata>
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADA
CAAAAk1TRnQBSQFMAgEBAgEAAUABAAFAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
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/wEAAf8BAAL/AgAD/wEAAv8B8wHxAQcBzwVl
Ac8BCQHwAfIB9AH/AfMB8QG8Ac8BiwVlAYsBzwEHAfEB8yAAAf8B8wHxAQcJZQHsAfAB8wH0AfIBBwHP
CWUBkAEHAfEgAAH/AfIBBwGLCWUBpgEHAvIB8AGuC2UBhgHwIAAB9AHxDWUBvAHxAc8NZQHPIAAB8wG7
A2UBswa6A2UBugHxAYsDZQe6A2UBiiAAAfMBtANlAboFZQHzA2UBtAHwBGUBugVlAboEZSAAAfMBtANl
AbMCZQH/AmUBiwNlAa4BvARlAbMBZQG6Af8BGQFlAbMEZSAAAfMBtAZlAf8GZQGQAbwFZQHvAboB/wG6
Af8FZSAAAfMBtAVlAbMB/wGzAboEZQG0AfEFZQGzAWUB/wFlAZEFZSAAAfQBkQVlAcEC/wVlAZEB8Qdl
Af8HZSAAAf8B8wVlAYsB7wGzBWUBuwHzAYsGZQH/BmUBiyAAAf8B9AHxDGUB8wH0AZENZQGRIAAC/wHz
AZEJZQGRAfMC/wH0AZELZQGRAfMgAAP/AfMBZghlAfME/wH0AZEJZQGRAfQB/yAABf8BGQGRAbQBawKR
AQcB9Ab/AfQBCAGRBWUBtAG1AfQC/yAABv8C9AHzAvQK/wL0A/MC9AT/IAABQgFNAT4HAAE+AwABKAMA
AUADAAEQAwABAQEAAQEFAAGAFwAD/4EACw==
</value>
</data>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIFSURBVDhPpZLtS1NhGMbPPxJmmlYSgqHiKzGU1EDxg4iK
YKyG2WBogqMYJQOtCEVRFBGdTBCJfRnkS4VaaWNT5sqx1BUxRXxDHYxAJLvkusEeBaPAB+5z4Jzn+t3X
/aLhnEfjo8m+dCoa+7/C3O2Hqe0zDC+8KG+cRZHZhdzaaWTVTCLDMIY0vfM04Nfh77/G/sEhwpEDbO3t
I7TxE8urEVy99fT/AL5gWDLrTB/hnF4XsW0khCu5ln8DmJliT2AXrcNBsU1gj/MH4nMeKwBrPktM28xM
cX79DFKrHHD5d9D26hvicx4pABt2lpg10zYzU0zr7+e3xXGcrkEB2O2TNec9nJFwB3alZn5jZorfeDZh
6Q3g8s06BeCoKF4MRURoH1+BY2oNCbeb0TIclIYxOhzf8frTOuo7FxCbbVIAzpni0iceEc8vhzEwGkJD
lx83ymxifejdKjRNk/8PWnyIyTQqAJek0jqHwfEVscu31baIu8+90sTE4nY025dQ2/5FIPpnXlzKuK8A
HBUzHot52djqQ6HZhfR7IwK4mKpHtvEDMqvfCiQ6zaAAXM8x94aIWTNrLLG4kVUzgaTSPlzLtyJOZxbb
1wtfyg4Q+AfA3aZlButjSfxGcUJBk4g5tuP3haQKRKXcUQDOmbvNTpPOJeFFjordZmbWTNvMTHFUcpUC
nOccAdABIDXXE1nzAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>372, 17</value>
</metadata>
</root>
+14 -1
View File
@@ -12,7 +12,7 @@ namespace Tool_API_Dokumentgenerator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.6.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -34,5 +34,18 @@ namespace Tool_API_Dokumentgenerator.Properties {
this["Datapath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("data source=shu01\\shu00;initial catalog=edoka_dms;packet size=4096;user id=sa;pas" +
"sword=*shu29")]
public string Connectionstring {
get {
return ((string)(this["Connectionstring"]));
}
set {
this["Connectionstring"] = value;
}
}
}
}
@@ -5,5 +5,8 @@
<Setting Name="Datapath" Type="System.String" Scope="User">
<Value Profile="(Default)">E:\Software-Projekte\OnDoc\Vorlagen\BatchAPI\</Value>
</Setting>
<Setting Name="Connectionstring" Type="System.String" Scope="User">
<Value Profile="(Default)">data source=shu01\shu00;initial catalog=edoka_dms;packet size=4096;user id=sa;password=*shu29</Value>
</Setting>
</Settings>
</SettingsFile>
@@ -55,6 +55,7 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Text.Json, Version=9.0.0.11, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
@@ -13,6 +13,9 @@
<setting name="Datapath" serializeAs="String">
<value>E:\Software-Projekte\OnDoc\Vorlagen\BatchAPI\</value>
</setting>
<setting name="Connectionstring" serializeAs="String">
<value>data source=shu01\shu00;initial catalog=edoka_dms;packet size=4096;user id=sa;password=*shu29</value>
</setting>
</Tool_API_Dokumentgenerator.Properties.Settings>
</userSettings>
<runtime>
@@ -1 +1 @@
5a5b769a10c6eee14ab411f91ca01be4c37025499ec520b58e80bf2f89dd149e
8a0407be845c7ef31eefa6237436703b3eaa76707debd5b7c3804766c11fd0da
@@ -30,8 +30,6 @@ E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.SfListView.WinForms.xml
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Shared.Base.xml
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.DataSource.WinForms.xml
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Memory.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Text.Json.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Numerics.Vectors.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Buffers.dll
@@ -41,7 +39,6 @@ E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Microsoft.
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\obj\Debug\Tool_API_Dokumentgenerator.csproj.SuggestedBindingRedirects.cache
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\obj\Debug\Tool_API_Dokumentgenerator.exe.config
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\obj\Debug\Tool_API_Dokumentgenerator.Form1.resources
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.Threading.Tasks.Extensions.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Edit.Windows.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Tools.Windows.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Grid.Windows.dll
@@ -57,3 +54,4 @@ E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Grid.Base.xml
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Tools.Base.xml
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\Syncfusion.Grid.Windows.XmlSerializers.dll
E:\Software-Projekte\OnDoc\OnDoc\Tool_API_Dokumentgenerator\bin\Debug\System.ValueTuple.dll
@@ -13,6 +13,9 @@
<setting name="Datapath" serializeAs="String">
<value>E:\Software-Projekte\OnDoc\Vorlagen\BatchAPI\</value>
</setting>
<setting name="Connectionstring" serializeAs="String">
<value>data source=shu01\shu00;initial catalog=edoka_dms;packet size=4096;user id=sa;password=*shu29</value>
</setting>
</Tool_API_Dokumentgenerator.Properties.Settings>
</userSettings>
<runtime>