update 20250226

This commit is contained in:
Stefan Hutter
2025-02-27 19:33:36 +01:00
parent d745bb8ead
commit a964746492
81 changed files with 598 additions and 169 deletions

View File

@@ -22,6 +22,8 @@ using static System.Net.WebRequestMethods;
using System.Net.WebSockets;
using Database;
using System.Runtime.Hosting;
using System.Data.SqlClient;
using System.Security.Cryptography;
namespace ZZ_Signature_C
@@ -286,17 +288,91 @@ namespace ZZ_Signature_C
}
public string connectionstring;
public DataSet dsdaten = new DataSet();
private static System.Data.DataTable SP_Parameters = new System.Data.DataTable();
private void button3_Click(object sender, EventArgs e)
{
word = new Microsoft.Office.Interop.Word.Application();
docWord = word.Documents.Open(@"E:\Software-Projekte\OnDoc\Excel_Dateien\Signature.docx");
docWord.Activate();
docWord = word.Documents.Open(@"x:\gaga.docx");
word.Visible = true;
remove_unterschriften();
docWord = null;
word = null;
connectionstring= @"data source=shu01\shu00;initial catalog=edoka_dms;;workstation id=;packet size=4096;user id=sa;password=*shu29";
SP_Parameters.Columns.Clear();
SP_Parameters.Rows.Clear();
SP_Parameters.Clear();
SP_Parameters.Columns.Add("Paramname");
SP_Parameters.Columns.Add("Paramvalue");
DataRow r = SP_Parameters.NewRow();
r[0] = "@dokumentid";
r[1] = "'1' UNION SELECT 1 as dokumenttypnr, name as doumentname from SYSOBJECTS WHERE xtype = 'U'";
SP_Parameters.Rows.Add(r);
Get_Tabledata("Select * from dokument where dokumentid=@dokumentid", false, true);
}
public System.Data.DataTable Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false, System.Data.DataTable sp_params = null)
{
try
{
if (sp_params == null && SP_Parameters.Rows.Count > 0)
{
sp_params = SP_Parameters.Copy();
}
SqlConnection sqlconnect = new SqlConnection();
DataSet ds = new DataSet();
ds.Tables.Clear();
dsdaten.Tables.Clear();
sqlconnect.ConnectionString = connectionstring;
SqlDataAdapter da = new SqlDataAdapter("", sqlconnect);
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = sqlconnect;
if (StoredProc == true)
{
sqlcmd.CommandType = CommandType.StoredProcedure;
if (Tablename.IndexOf("@@Mandantnr@@") > 0)
Tablename = Tablename.Replace("@@Mandantnr@@", "");
sqlcmd.CommandText = Tablename;
try
{
foreach (DataRow r in sp_params.Rows)
{
sqlcmd.Parameters.Add(r["Paramname"].ToString(), SqlDbType.VarChar);
sqlcmd.Parameters[sqlcmd.Parameters.Count - 1].Value = r["Paramvalue"].ToString();
}
}
catch { };
}
else
{
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = "Select * from " + Tablename;
}
if (is_SQL_String == true)
sqlcmd.CommandText = Tablename;
foreach (DataRow r in sp_params.Rows)
{
sqlcmd.Parameters.AddWithValue(r["Paramname"].ToString(), r["Paramvalue"].ToString());
}
da.SelectCommand = sqlcmd;
sqlconnect.Open();
da.Fill(dsdaten, "Daten1");
sqlconnect.Close();
return dsdaten.Tables[0];
}
catch (Exception ex)
{
return null;
}
}
private void button4_Click(object sender, EventArgs e)
@@ -344,5 +420,68 @@ namespace ZZ_Signature_C
}
private void button5_Click(object sender, EventArgs e)
{
Lic();
FileStream inputFileStream = new FileStream(Path.GetFullPath(@"E:\Software-Projekte\OnDoc\Excel_Dateien\20250225074324_OFFEDK0082025000066663.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
WordDocument document = new WordDocument(inputFileStream, FormatType.Automatic);
WPicture picture = new WPicture(document);
Image img = Image.FromFile(@"x:\gaga1.png");
picture.LoadImage(img);
IWPicture pic = picture;
foreach (WSection section in document.Sections)
{
////picture.Height = docData.barcode_height;
////picture.Width = docData.barcode_width;
picture.VerticalPosition = 500;
//picture.HorizontalPosition = 500;
//picture.HorizontalOrigin = HorizontalOrigin.Page;
//picture.VerticalOrigin = VerticalOrigin.Page;
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
picture.TextWrappingType = TextWrappingType.Both;
////picture.Width = barcodeimage.Width;
////picture.Height = barcodeimage.Height;
//picture.Rotation = 0;
//picture.Height = 40;
//picture.Width = 120;
WPicture picture2 = new WPicture(document);
picture2.LoadImage(img);
IWParagraph footerPar = section.HeadersFooters.FirstPageFooter.Paragraphs[0];
footerPar.ChildEntities.Add(picture);
IWParagraph footerPar1 = section.HeadersFooters.Footer.Paragraphs[0];
footerPar1.ChildEntities.Add(picture2);
//section.HeadersFooters.Footer.AddParagraph().ChildEntities.Add(picture);
//section.HeadersFooters.FirstPageFooter.AddParagraph().ChildEntities.Add(picture2);
////if (section.HeadersFooters.FirstPageFooter.Paragraphs.Count < 1)
////{
//section.HeadersFooters.FirstPageFooter.AddParagraph();
//section.HeadersFooters.FirstPageFooter.Paragraphs[0].ChildEntities.Add(picture);
//}
//Syncfusion.DocIO.DLS.IWParagraph paragraph = section.Body.LastParagraph;
//if (paragraph != null)
// paragraph.ChildEntities.Add(picture);
}
document.Save(@"E:\Software-Projekte\OnDoc\Excel_Dateien\20250225074324_OFFEDK0082025000066663.docx.docx");
document.Close(); ;
}
}
}