You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.6 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OnDoc.Klassen;
using Model;
using Syncfusion.Windows.Forms.Tools;
using Syncfusion.WinForms.Controls;
using Syncfusion.WinForms.DataGrid;
using Syncfusion.WinForms.DataGrid.Interactivity;
using Database;
namespace OnDoc.DocMgmt
{
public partial class Dokumenterstellung : SfForm
{
public int partnernr { get; set; } = 0;
public int profilnr { get; set; } = 0;
public int dokumenttypnr { get; set; } = 0;
public string interaktion { get; set; } = "";
public string showdoc { get; set; } = "";
public int DocFunction = 0;
public string dokumentid = "";
public Dokumenterstellung()
{
InitializeComponent();
}
public Dokumenterstellung(int Partnernr, int Dokumenttpynr, int Profilnr)
{
InitializeComponent();
partnernr = Partnernr;
dokumenttypnr = Dokumenttpynr;
profilnr = Profilnr;
}
public Dokumenterstellung(int Partnernr, int Dokumenttypnr, int Profilnr, string Interaktion, string Showdoc)
{
InitializeComponent();
partnernr = Partnernr;
dokumenttypnr = Dokumenttypnr;
profilnr = Profilnr;
interaktion= Interaktion;
showdoc = Showdoc;
}
private void Dokumenterstellung_Load(object sender, EventArgs e)
{
this.Style.TitleBar.BackColor = Theaming.Titelbar();
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
ucAllgemeineDokumentParam1.dokumenttypnr = dokumenttypnr;
ucAllgemeineDokumentParam1.partnernr = partnernr;
ucAllgemeineDokumentParam1.profilnr = profilnr;
ucAllgemeineDokumentParam1.Refresh_Details();
}
private void sfButton2_Click(object sender, EventArgs e)
{
Dokument_Erstellen();
}
public void Dokument_Erstellen()
{
ucAllgemeineDokumentParam1.Update_DocGenData();
clsDocData dokdata = new clsDocData();
ucAllgemeineDokumentParam1.update_dokdata(ref dokdata);
DOCGEN.DocGen docgen = new DOCGEN.DocGen(AppParams.connectionstring);
string dokumentid = docgen.GenDocID(dokdata);
dokdata.Dokumentid = dokumentid;
this.dokumentid=dokdata.Dokumentid;
if (dokumentid != "")
{
DOCGEN.Generator.DocGenerator_from_EDOKA Generator = new DOCGEN.Generator.DocGenerator_from_EDOKA(AppParams.connectionstring, AppParams.tempdir);
clsdok dok = new clsdok("", "", "");
dok = Generator.Generate_Doc_EDOKA(dokumentid, ref dokdata);
if (ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.DokumentBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
System.Diagnostics.Process.Start("winword.exe", filename);
clsProcessWatch.AddToList(dokdata.Dokumentid, filename, "Word");
}
if (ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.DokumentAlsPDF)
{
//Generator.DocToPDF(dokumentid, ref dok);
dok.extension = "pdf";
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
}
if (ucAllgemeineDokumentParam1.docgendata.erstellungsart == Erstellungsart.DokumentSpäterBearbeiten)
{
string filename = AppParams.tempdir + dokumentid + "." + dok.extension;
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(dok.dokument));
DB db = new DB(AppParams.connectionstring);
db.Save_To_DB(dokdata.Dokumentid, filename);
db = null;
}
PnlPreview.Visible = true;
docPreview1.Show_Doc(dokumentid);
docPreview1.Hide_Editbuttons();
}
}
private void sfButton3_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Abort;
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
DocFunction = 1;
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
DocFunction = 2;
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
DocFunction = 3;
PnlPreview.Visible = false;
}
private void button4_Click(object sender, EventArgs e)
{
DocFunction = 4;
this.Close();
}
private void button5_Click(object sender, EventArgs e)
{
DocFunction = 5;
this.Close();
}
}
}