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.
2279 lines
98 KiB
2279 lines
98 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using edoka_dms;
|
|
using System.IO;
|
|
using System.Xml.Linq;
|
|
using Model;
|
|
using System.Security.Cryptography;
|
|
using System.Diagnostics.Eventing.Reader;
|
|
using Logging;
|
|
using System.Configuration;
|
|
using System.Runtime.CompilerServices;
|
|
using NLog.LayoutRenderers;
|
|
using Helper;
|
|
using System.Transactions;
|
|
using System.Net.NetworkInformation;
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
|
|
|
|
namespace Database
|
|
{
|
|
public class DB
|
|
{
|
|
public string connectionstring;
|
|
public DataSet dsdaten = new DataSet();
|
|
private static DataTable SP_Parameters = new DataTable();
|
|
|
|
public DB(string connectionstring)
|
|
{
|
|
this.connectionstring = connectionstring;
|
|
}
|
|
|
|
public DB()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void add_parameter(string name, string value)
|
|
{
|
|
|
|
DataRow r = SP_Parameters.NewRow();
|
|
r[0] = name;
|
|
r[1] = value;
|
|
SP_Parameters.Rows.Add(r);
|
|
}
|
|
public void clear_parameter()
|
|
{
|
|
SP_Parameters.Columns.Clear();
|
|
SP_Parameters.Rows.Clear();
|
|
SP_Parameters.Clear();
|
|
SP_Parameters.Columns.Add("Paramname");
|
|
SP_Parameters.Columns.Add("Paramvalue");
|
|
|
|
}
|
|
|
|
#region "Allgemein"
|
|
public DataTable Get_Tabledata(string Tablename, bool StoredProc = false, bool is_SQL_String = false, DataTable sp_params = null)
|
|
{
|
|
try
|
|
{
|
|
Logging.Logging.Debug("", "EDOKA_DB:Get_Tabledata Start:" + Tablename, "");
|
|
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;
|
|
da.SelectCommand = sqlcmd;
|
|
sqlconnect.Open();
|
|
da.Fill(dsdaten, "Daten1");
|
|
sqlconnect.Close();
|
|
Logging.Logging.Debug("", "EDOKA_DB:Get_Tabledata:" + Tablename, "");
|
|
return dsdaten.Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
Logging.Logging.Error(ex.Message, "EDOKA_DB:Get_Tabledata:" + Tablename, "");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public DataTable Get_Tabledata_Addvar(string Tablename, bool StoredProc = false, bool is_SQL_String = false, DataTable sp_params = null)
|
|
{
|
|
try
|
|
{
|
|
Logging.Logging.Debug("", "EDOKA_DB:Get_Tabledata Start:" + Tablename, "");
|
|
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();
|
|
Logging.Logging.Debug("", "EDOKA_DB:Get_Tabledata:" + Tablename, "");
|
|
return dsdaten.Tables[0];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
Logging.Logging.Error(ex.Message, "EDOKA_DB:Get_Tabledata:" + Tablename, "");
|
|
return null;
|
|
}
|
|
}
|
|
public void Exec_SQL(string sql)
|
|
{
|
|
SqlConnection sqlconnect = new SqlConnection();
|
|
SqlCommand sqlcmd = new SqlCommand();
|
|
sqlcmd.Connection = sqlconnect;
|
|
sqlconnect.ConnectionString = this.connectionstring;
|
|
sqlcmd.CommandType = CommandType.Text;
|
|
sqlcmd.CommandText = sql;
|
|
sqlcmd.Connection.Open();
|
|
sqlcmd.ExecuteNonQuery();
|
|
sqlcmd.Connection.Close();
|
|
|
|
}
|
|
|
|
private SqlDataAdapter da;
|
|
private SqlCommandBuilder qb = new SqlCommandBuilder();
|
|
public DataSet daten = new DataSet();
|
|
public void Get_Tabledata_for_Update(string Tablename, bool StoredProc = false, bool is_SQL_String = false)
|
|
{
|
|
var sqlconnect = new SqlConnection();
|
|
var ds = new DataSet();
|
|
ds.Tables.Clear();
|
|
sqlconnect.ConnectionString = connectionstring;
|
|
sqlconnect.Open();
|
|
da = new SqlDataAdapter("", sqlconnect);
|
|
var sqlcmd = new SqlCommand();
|
|
sqlcmd.Connection = sqlconnect;
|
|
if (StoredProc == true)
|
|
{
|
|
sqlcmd.CommandType = CommandType.StoredProcedure;
|
|
sqlcmd.CommandText = Tablename;
|
|
}
|
|
else
|
|
{
|
|
sqlcmd.CommandType = CommandType.Text;
|
|
sqlcmd.CommandText = "Select * from " + Tablename;
|
|
}
|
|
if (is_SQL_String == true)
|
|
{
|
|
sqlcmd.CommandText = Tablename;
|
|
}
|
|
// sqlcmd.CommandType = CommandType.StoredProcedure
|
|
// sqlcmd.CommandText = "Berufsliste"
|
|
|
|
da.SelectCommand = sqlcmd;
|
|
da.Fill(daten, "Daten");
|
|
qb = new SqlCommandBuilder(da);
|
|
//return default;
|
|
}
|
|
public void Update_Data()
|
|
{
|
|
|
|
int i = da.Update(daten, "Daten");
|
|
//SqlDataAdapter dadaten = new SqlDataAdapter();
|
|
//var cb = new SqlCommandBuilder(dadaten);
|
|
//dadaten.Update(dsdaten, dsdaten.Tables[0].TableName);
|
|
//cb.Dispose();
|
|
|
|
}
|
|
|
|
#endregion
|
|
public string generate_key(string dbkey)
|
|
{
|
|
string skey = "OFFEDK008";
|
|
string s = "";
|
|
s = DateTime.Now.Year.ToString().Trim();
|
|
string dt = s;
|
|
skey = skey + s;
|
|
|
|
while (dbkey.Length < 8)
|
|
{
|
|
dbkey = "0" + dbkey;
|
|
}
|
|
skey = skey + dbkey;
|
|
s = Helper.DivFnkt.modulo10(skey.Substring(skey.Length - 15, 15)).ToString();
|
|
skey = skey + s;
|
|
return skey;
|
|
}
|
|
public string get_dbkey(string Tablename)
|
|
{
|
|
clsMyKey_Tabelle myKey_Tabelle = new clsMyKey_Tabelle();
|
|
myKey_Tabelle.connectionstring = connectionstring;
|
|
string dbkey = myKey_Tabelle.get_dbkey(Tablename).ToString();
|
|
if (Tablename == "Dokument")
|
|
{
|
|
return generate_key(dbkey);
|
|
|
|
}
|
|
else { return dbkey; }
|
|
}
|
|
|
|
|
|
public int Get_Mitarbeiternr(string mitarbeiter)
|
|
{
|
|
try
|
|
{
|
|
if (mitarbeiter == "")
|
|
{
|
|
return 0;
|
|
}
|
|
if (Helper.DivFnkt.IsNumeric(mitarbeiter))
|
|
{
|
|
return Convert.ToInt32(mitarbeiter);
|
|
}
|
|
|
|
Get_Tabledata("Select * from mitarbeiter where tgnummer='" + mitarbeiter + "'", false, true);
|
|
if (dsdaten.Tables[0].Rows.Count < 1)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(dsdaten.Tables[0].Rows[0]["mitarbeiternr"].ToString());
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
public int Get_Teamnr(string mitarbeiternr)
|
|
{
|
|
try
|
|
{
|
|
if (mitarbeiternr == "")
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
Get_Tabledata("Select team from profil where standard=1 and aktiv=1 and mitarbeiternr=" + mitarbeiternr + "", false, true);
|
|
if (dsdaten.Tables[0].Rows.Count < 1)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(dsdaten.Tables[0].Rows[0]["team"].ToString());
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
public DataTable Get_Vorlage_By_DokumentID(string dokumentid, bool useoffice = false, string tempdir = "", bool editdoc=false)
|
|
{
|
|
string sql = "";
|
|
if (!editdoc)
|
|
{
|
|
sql = "Select dbo.BinaryToBase64(vorlage) as Data, dbo.office_vorlage.office_vorlagenr as nr from dbo.Office_Vorlage_Datei INNER JOIN ";
|
|
sql = sql + " dbo.office_vorlage ON dbo.Office_Vorlage_Datei.office_vorlage_dateinr = dbo.office_vorlage.office_vorlagenr INNER JOIN ";
|
|
sql = sql + "dbo.dokumenttyp INNER JOIN ";
|
|
sql = sql + "dbo.dokument ON dbo.dokumenttyp.dokumenttypnr = dbo.dokument.dokumenttypnr ON dbo.office_vorlage.office_vorlagenr = dbo.dokumenttyp.office_vorlagenr ";
|
|
sql = sql + "WHERE dbo.dokument.dokumentid = '" + dokumentid + "' ";
|
|
}
|
|
else
|
|
{
|
|
sql = "SELECT dbo.BinaryToBase64(dbo.Doks.Dokument) AS Data, dbo.office_vorlage.office_vorlagenr AS nr ";
|
|
sql = sql + " FROM dbo.Office_Vorlage_Datei INNER JOIN ";
|
|
sql = sql + " dbo.office_vorlage ON dbo.Office_Vorlage_Datei.office_vorlage_dateinr = dbo.office_vorlage.office_vorlagenr INNER JOIN";
|
|
sql = sql + " dbo.dokumenttyp INNER JOIN ";
|
|
sql = sql + " dbo.dokument ON dbo.dokumenttyp.dokumenttypnr = dbo.dokument.dokumenttypnr ON dbo.office_vorlage.office_vorlagenr = dbo.dokumenttyp.office_vorlagenr INNER JOIN ";
|
|
sql = sql + " dbo.Doks ON dbo.dokument.dokumentid = dbo.Doks.DokumentID ";
|
|
sql = sql + " WHERE(dbo.dokument.dokumentid = '" + dokumentid + "')";
|
|
}
|
|
|
|
Get_Tabledata(sql, false, true);
|
|
|
|
if (!useoffice || editdoc) { return dsdaten.Tables[0]; }
|
|
else
|
|
{
|
|
VBFileManagement.VBFileManagement vm = new VBFileManagement.VBFileManagement();
|
|
if (!editdoc)
|
|
{
|
|
vm.Get_From_DB(Convert.ToInt32(dsdaten.Tables[0].Rows[0][1]), tempdir + dokumentid, connectionstring, false);
|
|
}else
|
|
{
|
|
vm.Get_Dok_From_DB(dokumentid, tempdir + dokumentid, connectionstring);
|
|
}
|
|
|
|
clsFileHelper fh = new clsFileHelper();
|
|
dsdaten.Tables[0].Rows[0][0] = fh.Base64FromFile(tempdir + dokumentid);
|
|
fh = null;
|
|
vm = null;
|
|
System.IO.File.Delete(tempdir + dokumentid);
|
|
return dsdaten.Tables[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public string Get_Office_Vorlage_asBase64(string nr)
|
|
{
|
|
string sql = "Select dbo.BinaryToBase64(vorlage) as Data from office_vorlage_datei where office_vorlage_dateinr=" + nr;
|
|
Get_Tabledata(sql, false, true);
|
|
return dsdaten.Tables[0].Rows[0][0].ToString();
|
|
}
|
|
public string get_vorlage_for_file(string nr, string tempdir, string dokumentid)
|
|
{
|
|
|
|
string sql = "Select dbo.BinaryToBase64(vorlage) from office_vorlage_datei where dbo.office_vorlage_datei.office_vorlage_dateinr=" + nr;
|
|
Get_Tabledata(sql, false, true);
|
|
return dsdaten.Tables[0].Rows[0][0].ToString();
|
|
//string filename = "";
|
|
//SqlConnection conn = new SqlConnection(connectionstring);
|
|
//SqlCommand sc = new SqlCommand("Select dbo.BinaryToBase64(vorlage) from office_vorlage_datei where dbo.office_vorlage_datei.office_vorlage_dateinr=" + nr, conn);
|
|
//conn.Open();
|
|
//SqlDataReader sqldr = sc.ExecuteReader();
|
|
//while (sqldr.Read())
|
|
//{
|
|
// filename = tempdir + @"\" + dokumentid;
|
|
// byte[] attachment = (byte[])sqldr.GetValue(0);
|
|
// FileStream fs = new FileStream(filename, FileMode.Create);
|
|
// fs.Write(attachment, 0, attachment.Length);
|
|
// fs.Close();
|
|
//}
|
|
//conn.Close();
|
|
|
|
//return filename;
|
|
}
|
|
|
|
public DataTable Get_ApplicationType_from_Vorlage(int vorlagenr)
|
|
{
|
|
string sql = "SELECT RIGHT(dbo.anwendung.bezeichnung, CHARINDEX(' ', REVERSE(dbo.anwendung.bezeichnung)) - 1) AS ApplType, ";
|
|
sql = sql + " RIGHT(dbo.Office_Vorlage_Datei.dateiname, CHARINDEX('.', REVERSE(dbo.Office_Vorlage_Datei.dateiname)) - 1) as Extension, isnull(prefix_dokumentname,'') as prefix ";
|
|
sql = sql + " FROM dbo.office_vorlage INNER JOIN dbo.anwendung ON dbo.office_vorlage.anwendungnr = dbo.anwendung.anwendungnr INNER JOIN";
|
|
sql = sql + " dbo.Office_Vorlage_Datei ON dbo.office_vorlage.office_vorlagenr = dbo.Office_Vorlage_Datei.office_vorlage_dateinr ";
|
|
sql = sql + " WHERE dbo.office_vorlage.office_vorlagenr = " + vorlagenr.ToString();
|
|
// string sql = "Select RIGHT(dbo.anwendung.bezeichnung, CHARINDEX(' ', REVERSE(dbo.anwendung.bezeichnung)) - 1) AS Expr1 FROM dbo.office_vorlage INNER JOIN dbo.anwendung ON dbo.office_vorlage.anwendungnr = dbo.anwendung.anwendungnr where dbo.office_vorlage.office_vorlagenr=" + vorlagenr.ToString();
|
|
Get_Tabledata(sql, false, true);
|
|
return dsdaten.Tables[0];
|
|
|
|
}
|
|
|
|
|
|
#region "EDOKA_Datenbank"
|
|
public string Create_EDOKA_Doc(clsDocData DocData, bool editdoc, string dokumentid)
|
|
{
|
|
DB db = new DB(connectionstring);
|
|
|
|
|
|
|
|
clsDokument dok = new clsDokument();
|
|
clsDokumenttyp doktyp = new clsDokumenttyp();
|
|
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
|
edoka_conn.sConnectionString = this.connectionstring;
|
|
|
|
if (dokumentid == "")
|
|
{
|
|
dokumentid = db.get_dbkey("Dokument");
|
|
}
|
|
else
|
|
{
|
|
dok.sDokumentid= dokumentid;
|
|
dok.cpMainConnectionProvider=edoka_conn;
|
|
dok.SelectOne();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doktyp.cpMainConnectionProvider = edoka_conn;
|
|
doktyp.iDokumenttypnr = Convert.ToInt32(DocData.DokumenttypNr);
|
|
doktyp.SelectOne();
|
|
|
|
dok.cpMainConnectionProvider = edoka_conn;
|
|
dok.sDokumentid = dokumentid;
|
|
dok.bAktiv = true;
|
|
dok.bAmsdokument = false;
|
|
dok.bAuserstuebernahme = false;
|
|
dok.bAusgangsarchiviert = false;
|
|
|
|
|
|
dok.daTermin = Convert.ToDateTime("1900.01.01");
|
|
dok.bBereit_zur_archivierung = false;
|
|
dok.bEingangsarchiviert = false;
|
|
dok.bGesperrt = false;
|
|
dok.bUnvollstaendig = false;
|
|
dok.iBck = 0;
|
|
dok.iColdstatus = 0;
|
|
dok.iPostzustellung = 0;
|
|
try
|
|
{
|
|
dok.iPostzustellung = Convert.ToInt32(DocData.postzustellung);
|
|
}
|
|
catch { }
|
|
if (DocData.Unterschrift_Links == "") { DocData.Unterschrift_Links = "0"; }
|
|
if (DocData.Unterschrift_Rechts == "") { DocData.Unterschrift_Rechts = "0"; }
|
|
dok.iUnterschriftlinks = Convert.ToInt32(DocData.Unterschrift_Links);
|
|
dok.iUnterschriftrechts = Convert.ToInt32(DocData.Unterschrift_Rechts);
|
|
//db.Get_Mitarbeiternr(DocData.Unterschrift_Links);
|
|
//dok.iUnterschriftrechts = db.Get_Mitarbeiternr(DocData.Unterschrift_Rechts);
|
|
|
|
dok.iVerantwortlich = Convert.ToInt32(DocData.Verantwortlich);
|
|
dok.sBezeichnung = DocData.Bezeichnung;
|
|
dok.daTermin = Convert.ToDateTime(DocData.Termin);
|
|
dok.bVertraulich = false;
|
|
dok.sZustelladresse = "";
|
|
dok.sAnredezustelladresse = "";
|
|
dok.iZustaendiger = Convert.ToInt32(DocData.Zustaendig);
|
|
dok.bZustaendig_kube = DocData.Zustaendig_Kube == "1";
|
|
//dok.iPostzustellung = 0;
|
|
dok.iMa_ausgangsarchivierung = 0;
|
|
dok.iMa_eingangsarchivierung = 0;
|
|
dok.sBemerkung = "";
|
|
dok.sColddokumentid = "";
|
|
dok.iDokdurchkubeweitergegeben = 0;
|
|
dok.sBedRDokumentid = "";
|
|
dok.iDokumenttypnr = doktyp.iDokumenttypnr;
|
|
dok.bZu_retournieren = doktyp.bZu_retournieren;
|
|
dok.iAufbewahrung_elektronisch = doktyp.iAufbewahrungsfrist_elektronisch;
|
|
dok.iAufbewahrung_phaysisch = doktyp.iAufbewahrungsfrist_physisch;
|
|
dok.iBearbeitung_nach_abschluss = doktyp.iTage_mutation;
|
|
dok.iBearbeitungszeit_in_minuten = doktyp.iDbearbeitungszeit;
|
|
dok.iMonierung_in_tagen = doktyp.iAnzahl_tage;
|
|
// dok.sBezeichnung = doktyp.sBezeichnung;
|
|
dok.iNrpar00 = Convert.ToInt32(DocData.PartnerNr);
|
|
dok.iMutierer = dok.iErsteller;
|
|
dok.iMutierer = Convert.ToInt32(DocData.Ersteller);
|
|
dok.iMitarbeiternr = dok.iErsteller;
|
|
dok.iMitarbeiternr = Convert.ToInt32(DocData.Ersteller);
|
|
dok.daMutiertam = DateTime.Now;
|
|
if (!editdoc) {
|
|
dok.daErstelltam = DateTime.Now;
|
|
dok.iErsteller = Convert.ToInt32(DocData.Ersteller);
|
|
}
|
|
dok.iMutiererteam = Convert.ToInt32(DocData.Team);
|
|
dok.iMutierertieam = Convert.ToInt32(DocData.Team);
|
|
dok.iErstellerteam = Convert.ToInt32(DocData.Team); ;
|
|
dok.daErstellungsdatum = Convert.ToDateTime(DocData.DokumentDatum);
|
|
dok.sZustelladresse = DocData.zustelladresse;
|
|
dok.sAnredezustelladresse = DocData.anrede;
|
|
if (doktyp.bElDokImport == true)
|
|
{
|
|
dok.iColdstatus = 1;
|
|
}
|
|
else
|
|
{
|
|
dok.iColdstatus = 0;
|
|
}
|
|
if (doktyp.bNurnative == true)
|
|
{
|
|
dok.bAktiv = false;
|
|
dok.sLoeschgrund = "Einzeldokument";
|
|
}
|
|
|
|
db.Get_Tabledata("Select * from office_vorlage where office_vorlagenr=" + doktyp.iOffice_vorlagenr.ToString(), false, true);
|
|
string dokumentname = "";
|
|
string ext = "";
|
|
switch (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["Anwendungnr"]))
|
|
{
|
|
case 1: { ext = ".doc"; break; }
|
|
case 2: { ext = ".xls"; break; }
|
|
case 3: { ext = ".pdf"; break; }
|
|
case 4: { ext = ".docx"; break; }
|
|
case 5: { ext = ".docm"; break; }
|
|
case 6: { ext = ".dotx"; break; }
|
|
case 7: { ext = ".dotm"; break; }
|
|
case 8: { ext = ".xlsx"; break; }
|
|
case 9: { ext = ".xlsm"; break; }
|
|
case 10: { ext = ".xltx"; break; }
|
|
case 11: { ext = ".xltm"; break; }
|
|
case 12: { ext = ".pdf"; break; }
|
|
case 13: { ext = ".pdf"; break; }
|
|
}
|
|
if (DocData.Result_as_PDF == "True") { ext = ".pdf"; }
|
|
dokumentname = db.dsdaten.Tables[0].Rows[0]["Prefix_Dokumentname"].ToString() + dokumentid + ext;
|
|
|
|
dok.sDokumentname = dokumentname;
|
|
|
|
dok.cpMainConnectionProvider = edoka_conn;
|
|
|
|
edoka_conn.OpenConnection();
|
|
if (!editdoc)
|
|
{
|
|
dok.Insert();
|
|
}
|
|
else
|
|
{
|
|
dok.Update();
|
|
}
|
|
edoka_conn.CloseConnection(true);
|
|
|
|
if (!editdoc)
|
|
{
|
|
COLD_Index_Sichern(1, dokumentid);
|
|
if (dok.bZu_retournieren == true)
|
|
{
|
|
COLD_Index_Sichern(2, dokumentid);
|
|
}
|
|
Status_Erstellen(dokumentid, false);
|
|
dok.iStatusnr = Convert.ToInt32(get_current_Status(dokumentid).ToString());
|
|
edoka_conn.OpenConnection();
|
|
dok.Update();
|
|
edoka_conn.CloseConnection(true);
|
|
}
|
|
//DokumentInfoWert
|
|
foreach (DataRow dr in DocData.dokumentwerte.Rows)
|
|
{
|
|
if (dr["cold_indexfeld"].ToString() == "") { dr["cold_indexfeld"] = 0; }
|
|
if (dr["cold_indexfeld"].ToString() == "0")
|
|
{
|
|
db.clear_parameter();
|
|
db.add_parameter("@dokumentid", dokumentid);
|
|
db.add_parameter("@vorlagenfeldnr", dr["vorlagenfeldnr"].ToString());
|
|
db.add_parameter("@value", dr["feldwert"].ToString());
|
|
db.Get_Tabledata("dbo.SP_Dokument_Information_Wert", true, false);
|
|
}
|
|
else
|
|
{
|
|
db.Get_Tabledata("Select count(*) from dokumentcoldindexwert where dokumentid='" + dokumentid + "'", false, true);
|
|
if (Convert.ToInt32(db.dsdaten.Tables[0].Rows[0][0]) == 0)
|
|
{
|
|
db.clear_parameter();
|
|
db.add_parameter("@dokumentid", dokumentid);
|
|
db.add_parameter("@indextyp", "1");
|
|
db.Get_Tabledata("SP_Dokument_Cold_Index", true, false);
|
|
}
|
|
else
|
|
{
|
|
db.clear_parameter();
|
|
db.add_parameter("@dokumentid", dokumentid);
|
|
db.add_parameter("@coldfeldnr", dr["cold_indexfeld"].ToString());
|
|
db.add_parameter("@value", dr["feldwert"].ToString());
|
|
db.Get_Tabledata("SP_Dokument_Cold_Index_Update", true, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
db.Get_Tabledata("Select * from dokumenttyp where dokumenttypnr=" + dok.iDokumenttypnr.ToString(), false, true);
|
|
int toapprove = DocData.toapprove;
|
|
int approved = DocData.approved;
|
|
int approved1 = DocData.approval1;
|
|
int approved2 = DocData.approval2;
|
|
if (Convert.ToBoolean(db.dsdaten.Tables[0].Rows[0]["Unterschrift_Pruefung"]) == true || DocData.As_Faksimile == "True")
|
|
{
|
|
//toapprove = 1;
|
|
//if (dok.iUnterschriftlinks == dok.iErsteller) { approved1 = 1; }
|
|
//if (dok.iUnterschriftrechts == dok.iErsteller) { approved2 = 1; }
|
|
}
|
|
int unterschriftlinks = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["Unterschrift_links"]);
|
|
int unterschriftrechts = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["Unterschrift_rechts"]);
|
|
int bearbeitung_zwingend = Convert.ToInt32(db.dsdaten.Tables[0].Rows[0]["bearbeitung_zwingend"]);
|
|
if (editdoc) { bearbeitung_zwingend = 0; }
|
|
int as_faksimile = 0;
|
|
if (DocData.As_Faksimile == "True") { as_faksimile = 1; }
|
|
int signiert = 0;
|
|
if (DocData.sign==true) { signiert = 1; }
|
|
|
|
//if (bearbeitung_zwingend == 4) { bearbeitung_zwingend = 1; } else { bearbeitung_zwingend = 0; }
|
|
//if (unterschriftlinks == 1 && unterschriftrechts == 0 && approved1 == 1) { approved = 1; }
|
|
|
|
db.Exec_SQL("Update dokument set faksimile=" + as_faksimile.ToString() + ", bearbeitung_zwingend = " + bearbeitung_zwingend.ToString() + ", toapprove=" + toapprove.ToString() + ", approved=" + approved.ToString() + ", approval1=" + approved1.ToString() + ", approval2=" + approved2.ToString() + ", signiert="+signiert.ToString()+" where dokumentid = '" + dokumentid + "'");
|
|
|
|
try
|
|
{
|
|
if (DocData.avq_authl_ref.Count() > 0)
|
|
{
|
|
foreach (clsav_authl_ref avqref in DocData.avq_authl_ref)
|
|
{
|
|
db.clear_parameter();
|
|
db.add_parameter("@dokumentid", dokumentid);
|
|
db.add_parameter("@avq_auto_extl_refr", avqref.auth_ref.ToString());
|
|
db.add_parameter("@FNKT", "1");
|
|
db.add_parameter("@newdocid", "");
|
|
db.add_parameter("@manr", dok.iErsteller.ToString());
|
|
db.Get_Tabledata("dbo.sp_insert_update_avq_auth_extl_ref", true, false);
|
|
|
|
}
|
|
}
|
|
} catch { }
|
|
|
|
return dokumentid;
|
|
}
|
|
public void set_approvalstate(string dokumentid, bool init = false)
|
|
{
|
|
int toapprove = 0;
|
|
int approved = 0;
|
|
int approval1 = 0;
|
|
int approval2 = 0;
|
|
if (init)
|
|
{
|
|
|
|
}
|
|
Get_Tabledata("Select * from dokument where dokumentid='" + dokumentid + "'", false, true);
|
|
if (Convert.ToBoolean(dsdaten.Tables[0].Rows[0]["toapprove"]) == true)
|
|
{
|
|
if (dsdaten.Tables[0].Rows[0]["unterschriftlinks"].ToString() == dsdaten.Tables[0].Rows[0]["ersteller"].ToString()) approval1 = 1;
|
|
if (dsdaten.Tables[0].Rows[0]["unterschriftrechts"].ToString() == dsdaten.Tables[0].Rows[0]["ersteller"].ToString()) approval2 = 1;
|
|
if (approval1 != approval2) approved = 0;
|
|
Exec_SQL("Update dokument set approved=" + approved.ToString() + ", approval1=" + approval1.ToString() + ", approval2=" + approval2.ToString() + " where dokumentid = '" + dokumentid + "'");
|
|
|
|
}
|
|
|
|
}
|
|
public DataTable COLD_Index_Sichern(int indextyp, string dokumentid)
|
|
{
|
|
SqlCommand scmCmdToExecute = new SqlCommand();
|
|
scmCmdToExecute.CommandText = "dbo.SP_Dokument_Cold_Index";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
DataTable dtToReturn = new DataTable();
|
|
SqlDataAdapter sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
scmCmdToExecute.Connection = conn;
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumentid));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@indextyp", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, indextyp));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
return dtToReturn;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("Dokumenterstellung::Generic_Select::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
}
|
|
public object Status_Erstellen(string dokumentid, bool blsequenz)
|
|
{
|
|
|
|
// Status_Erstellen_Overwrite(dokumentid, 0)
|
|
var scmCmdToExecute = new SqlCommand();
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
scmCmdToExecute.CommandText = "dbo.sp_dokumentberabeigung_status_erstellen";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
scmCmdToExecute.Connection = conn;
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumentid));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@bck", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@blsequenz", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
return dtToReturn;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// // some error occured. Bubble it to caller and encapsulate Exception object
|
|
throw new Exception("Dokument_Information_Wert::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
}
|
|
private long get_current_Status(string dokumentid)
|
|
{
|
|
long get_current_StatusRet = default;
|
|
var scmCmdToExecute = new SqlCommand();
|
|
scmCmdToExecute.CommandText = "dbo.SP_Dokumentbearbeitung_current_status";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
scmCmdToExecute.Connection = conn;
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@statustext", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, "In Bearbeitung"));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumentid));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@currentstatus", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
get_current_StatusRet = Convert.ToInt64(scmCmdToExecute.Parameters[2].Value);
|
|
return get_current_StatusRet;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// // some error occured. Bubble it to caller and encapsulate Exception object
|
|
throw new Exception("Dokumenterstellung::Generic_Select::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
}
|
|
#endregion
|
|
public DataTable Get_Partnerstruktur(int partnernr, bool partnerlist, int mitarbeiternr, int profilnr)
|
|
{
|
|
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
var scmCmdToExecute = new SqlCommand();
|
|
scmCmdToExecute.Connection = conn;
|
|
scmCmdToExecute.CommandText = "dbo.[sp_trefferliste_getdata_new_relaunch]";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
scmCmdToExecute.Connection.ConnectionString = connectionstring;
|
|
try
|
|
{
|
|
if (partnernr == -1) { partnernr = 0; }
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@profilnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, profilnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@inrpar00", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, partnernr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@isprache", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@imandant", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklist", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@partnerlist", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklistdokumentartnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklistpartnernr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
if (partnernr == 0)
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@vollstaendig", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
|
|
}
|
|
else
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@vollstaendig", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
}
|
|
|
|
if (partnerlist && partnernr != 0)
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@partnereingegeben", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
}
|
|
else
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@partnereingegeben", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
}
|
|
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@ihasmessage", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@firstentry", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@lastentry", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1000000));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@pagedirection", SqlDbType.Int, 4, ParameterDirection.InputOutput, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@searchstring", SqlDbType.VarChar, 25, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ""));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@fanummer3", SqlDbType.VarChar, 128, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ""));
|
|
conn.Open();
|
|
sdaAdapter.Fill(dtToReturn);
|
|
return dtToReturn;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
try
|
|
{
|
|
//MessageBox.Show(ex.Message, "Fehler Partnerstruktur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
conn.Close();
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
|
|
return default;
|
|
}
|
|
|
|
public DataTable Get_Dokumente(int partnernr, int dokumentartnr, int profilnr, int ForMa, string searchdocid, bool alleDokumente = false)
|
|
{
|
|
int i;
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
var scmCmdToExecute = new SqlCommand();
|
|
scmCmdToExecute.Connection = conn;
|
|
scmCmdToExecute.CommandText = "dbo.SP_Trefferliste_getdata_new_relaunch";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
scmCmdToExecute.Connection.ConnectionString = connectionstring;
|
|
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@profilnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, profilnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@inrpar00", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, partnernr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@iforMA", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ForMa));
|
|
// ObjPerson - fehler bei der Partnernr
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@isprache", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@imandant", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklist", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@partnerlist", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklistdokumentartnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumentartnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@doklistpartnernr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, partnernr));
|
|
// if (this.txtnrpar00.Text != "")
|
|
// {
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@vollstaendig", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
// }
|
|
// else
|
|
// {
|
|
// scmCmdToExecute.Parameters.Add(new SqlParameter("@vollstaendig", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
// }
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@partnereingegeben", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
if (alleDokumente == true)
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@alledokumente", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
}
|
|
else
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@alledokumente", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
}
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@searchdocid", SqlDbType.VarChar, 22, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, searchdocid));
|
|
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
|
|
//if (this.txtnrpar00.Text.Length > 0)
|
|
//{
|
|
// if (this.LblSearch.Text == this.MenuItemValorSuche.Text + ":" & this.txtnrpar00.Text != "")
|
|
// {
|
|
// scmCmdToExecute.Parameters.Add(new SqlParameter("@searchstring", SqlDbType.VarChar, 25, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, "VA:" + this.txtnrpar00.Text));
|
|
// }
|
|
// if (this.LblSearch.Text == this.MenuItemISINSUche.Text + ":" & this.txtnrpar00.Text != "")
|
|
// {
|
|
// scmCmdToExecute.Parameters.Add(new SqlParameter("@searchstring", SqlDbType.VarChar, 25, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, "IS:" + this.txtnrpar00.Text));
|
|
// }
|
|
// if (this.LblSearch.Text == this.MenuItemVVSuche.Text + ":" & this.txtnrpar00.Text != "")
|
|
// {
|
|
// scmCmdToExecute.Parameters.Add(new SqlParameter("@searchstring", SqlDbType.VarChar, 25, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, "VV:" + this.txtnrpar00.Text));
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@searchstring", SqlDbType.VarChar, 25, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ""));
|
|
// }
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@fanummer3", SqlDbType.VarChar, 255, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, ""));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
return dtToReturn;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// MsgBox(ex.Message)
|
|
// ' // some error occured. Bubble it to caller and encapsulate Exception object
|
|
throw new Exception("Dokumente lesen::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
}
|
|
|
|
public clsdok GetDocumentAsBase64(string dokumentid)
|
|
{
|
|
try
|
|
{
|
|
|
|
string sql = "Select dbo.BinaryToBase64(dokument) as Data, isnull(doktype,'') as doktype from doks ";
|
|
sql = sql + "WHERE dbo.doks.dokumentid = '" + dokumentid + "' ";
|
|
sql = "Select * from View_Get_Base64Doc where dokumentid='" + dokumentid + "' ";
|
|
Get_Tabledata(sql, false, true);
|
|
if (dsdaten.Tables[0].Rows.Count < 1)
|
|
{
|
|
return new clsdok("", "", "", "");
|
|
}
|
|
else
|
|
{
|
|
if (dsdaten.Tables[0].Rows[0][1].ToString() == "")
|
|
{
|
|
try
|
|
{
|
|
dsdaten.Tables[0].Rows[0][1] = dsdaten.Tables[0].Rows[0][2].ToString().Substring(0, 1).ToUpper();
|
|
}
|
|
catch { }
|
|
|
|
}
|
|
return new clsdok(dsdaten.Tables[0].Rows[0][0].ToString(), dsdaten.Tables[0].Rows[0][1].ToString(), dsdaten.Tables[0].Rows[0][2].ToString(), dsdaten.Tables[0].Rows[0][4].ToString());
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
return new clsdok("", "", "", "");
|
|
}
|
|
|
|
finally
|
|
{
|
|
}
|
|
|
|
|
|
|
|
}
|
|
public bool Save_To_DB(string sDokumentID, string sDokumentName, string base64document = "", int serienbriefnr = 0)
|
|
{
|
|
try
|
|
{
|
|
string DokumentID = sDokumentID;
|
|
string Dokumentname = sDokumentName;
|
|
SqlConnection Connection = new SqlConnection();
|
|
string sql = "";
|
|
if (serienbriefnr == 0) { sql = "select * from doks where dokumentid='" + DokumentID + "'"; }
|
|
if (serienbriefnr != 0)
|
|
{
|
|
sql = "select top 1 * from edex_sb_vorlage where serienbriefnr=" + serienbriefnr.ToString();
|
|
DokumentID = serienbriefnr.ToString();
|
|
}
|
|
SqlDataAdapter DA = new SqlDataAdapter(sql, Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
byte[] mydata = null;
|
|
if (base64document == "")
|
|
{
|
|
FileStream fs = new FileStream(Dokumentname, FileMode.Open, FileAccess.Read);
|
|
mydata = new byte[fs.Length];
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
fs = null;
|
|
}
|
|
else
|
|
{
|
|
mydata = System.Convert.FromBase64String(base64document);
|
|
}
|
|
try
|
|
{
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "docs");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[0] = DokumentID;
|
|
myRow[1] = mydata;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "docs");
|
|
}
|
|
else
|
|
{
|
|
myRow = ds.Tables[0].Rows[0];
|
|
myRow[1] = mydata;
|
|
DA.Update(ds, "docs");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
//fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public int Dok_in_Bearbeitung(int typ, string dokumentid, int mitarbeiter)
|
|
{
|
|
switch (typ)
|
|
{
|
|
case 1:
|
|
string sql = "Insert DokInBearbeitung (dokumentid, mitarbeiternr,datum,erstellung,dokumentname,stationsname) ";
|
|
sql = sql + " values('" + dokumentid + "'," + mitarbeiter.ToString() + ",getdate(),'','','')";
|
|
Exec_SQL(sql);
|
|
return 1;
|
|
case 2:
|
|
Exec_SQL("Delete from dokinbearbeitung where dokumentid='" + dokumentid + "'");
|
|
return 1;
|
|
case 3:
|
|
//Get_Tabledata("Select count(*) from dokinbearbeitung where dokumentid='" + dokumentid + "'", false, true);
|
|
//if (Convert.ToInt32(dsdaten.Tables[0].Rows[0][0]) > 0) return false; else return true;
|
|
//Get_Tabledata("Select count(*) from dokinbearbeitung where dokumentid='" + dokumentid + "'", false, true);
|
|
Get_Tabledata("Select * from dokinbearbeitung where dokumentid='" + dokumentid + "'", false, true);
|
|
if (dsdaten.Tables[0].Rows.Count == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
if (Convert.ToInt32(dsdaten.Tables[0].Rows[0]["mitarbeiternr"]) == mitarbeiter)
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 2;
|
|
}
|
|
//if (Convert.ToInt32(dsdaten.Tables[0].Rows[0][0]) > 0) return false; else return true;
|
|
break;
|
|
default:
|
|
return 1;
|
|
}
|
|
//if (typ == 2)
|
|
//{
|
|
//}
|
|
//else
|
|
//{
|
|
// string sql = "Insert DokInBearbeitung (dokumentid, mitarbeiternr,datum,erstellung,dokumentname,stationsname) ";
|
|
// sql = sql + " values('" + dokumentid + "'," + mitarbeiter.ToString() + ",getdate(),'','','')";
|
|
// Exec_SQL(sql);
|
|
// return true;
|
|
//}
|
|
|
|
}
|
|
public Boolean save_vorlage_to_db(string filename, string office_vorlage_nr)
|
|
{
|
|
try
|
|
{
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from office_vorlage_datei where office_vorlage_dateinr='" + office_vorlage_nr + "'", Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "vorlage");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[0] = "";
|
|
myRow[1] = mydata;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "docs");
|
|
}
|
|
else
|
|
{
|
|
myRow = ds.Tables[0].Rows[0];
|
|
myRow["vorlage"] = mydata;
|
|
DA.Update(ds, "vorlage");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public DataTable Get_DokumentWertList(string dokumentid, int dokumenttypnr, int CreateNew)
|
|
{
|
|
|
|
var scmCmdToExecute = new SqlCommand();
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
SqlConnection Connection = new SqlConnection();
|
|
Connection.ConnectionString = connectionstring;
|
|
scmCmdToExecute.CommandText = "dbo.SP_Dokumentbearbeitung_Dokumentwerte";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
scmCmdToExecute.Connection = Connection;
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumentid", SqlDbType.VarChar, 22, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumentid));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumenttypnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumenttypnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@CreateNew", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, CreateNew));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
|
|
// Release 4.0 KC 01.06.2007 XMl Daten berücksichtigen (DokumentBearbeitung.edka)
|
|
|
|
//var objDokumentWert = default(AvaloqDokumentWert);
|
|
//for (int i = 0, loopTo = dtToReturn.Rows.Count - 1; i <= loopTo; i++)
|
|
//{
|
|
// if (!object.ReferenceEquals(dtToReturn.Rows[i][0], DBNull.Value))
|
|
// {
|
|
// // objperson
|
|
// // objDokumentWert = avqwerte.getAvaloqDokumentWertByName(dtToReturn.Rows(i).Item(0))
|
|
// try
|
|
// {
|
|
// objDokumentWert = avqwerte.getAvaloqDokumentWertByName(avqwerte.ADokumentwerte, this.DokWertList.Item(i, 0), this.DokWertList.Item(i, 12));
|
|
// }
|
|
// catch
|
|
// {
|
|
// }
|
|
// // objDokumentWert = objAvaloqDokumentWerte.getAvaloqDokumentWertByName(dtToReturn.Rows(i).Item(0))
|
|
// }
|
|
// if (objDokumentWert is null == false)
|
|
// {
|
|
// dtToReturn.Rows[i][2] = objDokumentWert.value;
|
|
// }
|
|
// objDokumentWert = default;
|
|
//}
|
|
|
|
return dtToReturn;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// // some error occured. Bubble it to caller and encapsulate Exception object
|
|
throw new Exception("Dokument_Information_Wert::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
// Returns a string containing all the fields in the table
|
|
|
|
public string BuildAllFieldsSQL(DataTable table)
|
|
{
|
|
string sql = "";
|
|
foreach (DataColumn column in table.Columns)
|
|
{
|
|
if (sql.Length > 0)
|
|
sql += ", ";
|
|
sql += column.ColumnName;
|
|
}
|
|
return sql;
|
|
}
|
|
|
|
// Returns a SQL INSERT command. Assumes autoincrement is identity (optional)
|
|
|
|
public string BuildInsertSQL(DataTable table)
|
|
{
|
|
StringBuilder sql = new StringBuilder("INSERT INTO " + table.TableName + " (");
|
|
StringBuilder values = new StringBuilder("VALUES (");
|
|
bool bFirst = true;
|
|
bool bIdentity = false;
|
|
string identityType = null;
|
|
|
|
foreach (DataColumn column in table.Columns)
|
|
{
|
|
if (column.AutoIncrement)
|
|
{
|
|
bIdentity = true;
|
|
|
|
switch (column.DataType.Name)
|
|
{
|
|
case "Int16":
|
|
identityType = "smallint";
|
|
break;
|
|
case "SByte":
|
|
identityType = "tinyint";
|
|
break;
|
|
case "Int64":
|
|
identityType = "bigint";
|
|
break;
|
|
case "Decimal":
|
|
identityType = "decimal";
|
|
break;
|
|
default:
|
|
identityType = "int";
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bFirst)
|
|
bFirst = false;
|
|
else
|
|
{
|
|
sql.Append(", ");
|
|
values.Append(", ");
|
|
}
|
|
|
|
sql.Append(column.ColumnName);
|
|
values.Append("@");
|
|
values.Append(column.ColumnName);
|
|
}
|
|
}
|
|
sql.Append(") ");
|
|
sql.Append(values.ToString());
|
|
sql.Append(")");
|
|
|
|
if (bIdentity)
|
|
{
|
|
sql.Append("; SELECT CAST(scope_identity() AS ");
|
|
sql.Append(identityType);
|
|
sql.Append(")");
|
|
}
|
|
|
|
return sql.ToString(); ;
|
|
}
|
|
|
|
|
|
// Creates a SqlParameter and adds it to the command
|
|
|
|
|
|
public void InsertParameter(SqlCommand command,
|
|
string parameterName,
|
|
string sourceColumn,
|
|
object value)
|
|
{
|
|
SqlParameter parameter = new SqlParameter(parameterName, value);
|
|
|
|
parameter.Direction = ParameterDirection.Input;
|
|
parameter.ParameterName = parameterName;
|
|
parameter.SourceColumn = sourceColumn;
|
|
parameter.SourceVersion = DataRowVersion.Current;
|
|
|
|
command.Parameters.Add(parameter);
|
|
}
|
|
|
|
// Creates a SqlCommand for inserting a DataRow
|
|
public SqlCommand CreateInsertCommand(DataRow row)
|
|
{
|
|
DataTable table = row.Table;
|
|
string sql = BuildInsertSQL(table);
|
|
SqlCommand command = new SqlCommand(sql);
|
|
command.CommandType = System.Data.CommandType.Text;
|
|
|
|
foreach (DataColumn column in table.Columns)
|
|
{
|
|
if (!column.AutoIncrement)
|
|
{
|
|
string parameterName = "@" + column.ColumnName;
|
|
InsertParameter(command, parameterName,
|
|
column.ColumnName,
|
|
row[column.ColumnName]);
|
|
}
|
|
}
|
|
return command;
|
|
}
|
|
|
|
// Inserts the DataRow for the connection, returning the identity
|
|
public object InsertDataRow(DataRow row, string connectionString)
|
|
{
|
|
SqlCommand command = CreateInsertCommand(row);
|
|
|
|
using (SqlConnection connection = new SqlConnection(connectionString))
|
|
{
|
|
command.Connection = connection;
|
|
command.CommandType = System.Data.CommandType.Text;
|
|
connection.Open();
|
|
return command.ExecuteScalar();
|
|
}
|
|
}
|
|
|
|
public int insert_note(int ersteller, string gbetreff, string note, string dokumentid)
|
|
{
|
|
Get_Tabledata_for_Update("Select top 1 * from notizen where notiznr=-1", false, true);
|
|
DataRow dr = daten.Tables[0].NewRow();
|
|
dr["dokumentid"] = dokumentid;
|
|
dr["betreff"] = gbetreff;
|
|
dr["notiz"] = note;
|
|
dr["mandantnr"] = 1;
|
|
dr["aktiv"] = 1;
|
|
dr["erstellt_am"] = DateTime.Now;
|
|
dr["mutiert_am"] = DateTime.Now;
|
|
dr["mutierer"] = ersteller;
|
|
dr["ersteller"] = ersteller;
|
|
daten.Tables[0].Rows.Add(dr);
|
|
Update_Data();
|
|
Get_Tabledata("select top 1 * from notizen where dokumentid='" + dokumentid + "' order by notiznr desc", false, true);
|
|
return Convert.ToInt32(dsdaten.Tables[0].Rows[0][0]);
|
|
}
|
|
|
|
public void Insert_Vorlagenfeld(int vorlagenfeldregelnr, int dokumenttypnr, int mitarbeiternr)
|
|
{
|
|
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
var scmCmdToExecute = new SqlCommand();
|
|
scmCmdToExecute.Connection = conn;
|
|
scmCmdToExecute.CommandText = "dbo.[sp_trefferliste_getdata_new_relaunch]";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
scmCmdToExecute.Connection.ConnectionString = connectionstring;
|
|
|
|
|
|
var iErrorcode = default(int);
|
|
|
|
scmCmdToExecute.Connection.Open();
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
scmCmdToExecute.CommandText = "dbo.[sp_vorlagenfeld_insert]";
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumenttypnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, dokumenttypnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@vorlagenfeldregelnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, vorlagenfeldregelnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@mitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, mitarbeiternr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@mandantnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, iErrorcode));
|
|
try
|
|
{
|
|
scmCmdToExecute.ExecuteNonQuery();
|
|
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("sp_vorlagenfeld_standard_insert:Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Connection.Close();
|
|
scmCmdToExecute.Dispose();
|
|
|
|
}
|
|
scmCmdToExecute.Dispose();
|
|
}
|
|
|
|
public serienbrief Load_Serienbrief(serienbrief sb, string temppath)
|
|
{
|
|
clsEdex_sb_serienbrief dbsb = new clsEdex_sb_serienbrief();
|
|
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
|
edoka_conn.sConnectionString = this.connectionstring;
|
|
dbsb.cpMainConnectionProvider = edoka_conn;
|
|
dbsb.iSerienbriefnr = sb.serienbriefnr;
|
|
dbsb.SelectOne();
|
|
|
|
sb.bezeichnung = dbsb.sBezeichnung.ToString();
|
|
sb.serienbriefnr = Convert.ToInt32(dbsb.iSerienbriefnr.Value);
|
|
sb.verantwortlich = Convert.ToInt32(dbsb.iVerantwortlich.Value);
|
|
sb.postzustellung = Convert.ToInt32(dbsb.iPostzustellung.Value);
|
|
sb.dokumentdatum = Convert.ToDateTime(dbsb.daDokumentdatum.Value);
|
|
sb.zustaendig = Convert.ToInt32(dbsb.iZustaendig.Value);
|
|
sb.unterschriftlinks = Convert.ToInt32(dbsb.iUnterschriftlinks.Value);
|
|
sb.unterschriftrechts = Convert.ToInt32(dbsb.iUnterschriftrechts.Value);
|
|
sb.team = Convert.ToInt32(dbsb.iTeam.Value);
|
|
sb.archivdatum = Convert.ToDateTime(dbsb.daArchivdatum.Value);
|
|
try { sb.termin = Convert.ToDateTime(dbsb.daTermin.Value); } catch { }
|
|
sb.bemerkung = dbsb.sBemerkung.ToString();
|
|
sb.erstellt_am = Convert.ToDateTime(dbsb.daErstellt_am.Value);
|
|
sb.mutiert_am = Convert.ToDateTime(dbsb.daMutiert_am.Value);
|
|
sb.team = Convert.ToInt32(dbsb.iMutierer.Value);
|
|
sb.aktiv = Convert.ToBoolean(dbsb.bAktiv.Value);
|
|
sb.status = Convert.ToInt32(dbsb.iStatus.Value);
|
|
sb.dokumenttypnr = Convert.ToInt32(dbsb.iDokumenttypnr.Value);
|
|
sb.windowwidth = Convert.ToInt32(dbsb.iWindowwidth.Value);
|
|
sb.windowheight = Convert.ToInt32(dbsb.iWindowwidth.Value);
|
|
sb.treewidth = Convert.ToInt32(dbsb.iTreewidth.Value);
|
|
sb.inBearbeitung = Convert.ToInt32(dbsb.iInBearbeitung.Value);
|
|
sb.fehlerhaft = Convert.ToInt32(dbsb.iFehlerhaft.Value);
|
|
sb.erstellt = Convert.ToInt32(dbsb.iErstellt.Value);
|
|
sb.gedruckt = Convert.ToInt32(dbsb.iGedruckt.Value);
|
|
sb.bestaetigt = Convert.ToInt32(dbsb.iBestaetigt.Value);
|
|
sb.ausgeloest = Convert.ToInt32(dbsb.iAusgeloest.Value);
|
|
try { sb.vertrag = Convert.ToInt32(dbsb.iBldossier.Value); } catch { };
|
|
string fn = read_empfaengerdata(sb.serienbriefnr, temppath);
|
|
if (fn != "")
|
|
{
|
|
sb.dsempfaenger.Tables.Clear();
|
|
sb.dsempfaenger.ReadXml(fn);
|
|
System.IO.File.Delete(fn);
|
|
}
|
|
Get_Tabledata("Select isnull(faktura,0), isnull(office_vorlagenr,0), isnull(toapprove,0), isnull(approved,0), isnull(approval1,0), isnull(approval2,0), isnull(faksimile,0), isnull(ohneunterschrift,0) from edex_sb_serienbrief where serienbriefnr=" + sb.serienbriefnr.ToString(), false, true);
|
|
sb.ppfaktura = Convert.ToInt32(dsdaten.Tables[0].Rows[0][0]);
|
|
sb.officevorlagenr = Convert.ToInt32(dsdaten.Tables[0].Rows[0][1]);
|
|
sb.toapproval = Convert.ToInt32(dsdaten.Tables[0].Rows[0][2]);
|
|
sb.approved = Convert.ToInt32(dsdaten.Tables[0].Rows[0][3]);
|
|
sb.approval1 = Convert.ToInt32(dsdaten.Tables[0].Rows[0][4]);
|
|
sb.approval2 = Convert.ToInt32(dsdaten.Tables[0].Rows[0][5]);
|
|
sb.faksimile = Convert.ToInt32(dsdaten.Tables[0].Rows[0][6]);
|
|
sb.ohneunterschrift = Convert.ToInt32(dsdaten.Tables[0].Rows[0][7]);
|
|
|
|
return sb;
|
|
}
|
|
public int Save_Serienbrief(serienbrief sb, string temppath)
|
|
{
|
|
clsEdex_sb_serienbrief dbsb = new clsEdex_sb_serienbrief();
|
|
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
|
edoka_conn.sConnectionString = this.connectionstring;
|
|
|
|
dbsb.cpMainConnectionProvider = edoka_conn;
|
|
if (sb.serienbriefnr != 0)
|
|
{
|
|
dbsb.iSerienbriefnr = sb.serienbriefnr;
|
|
dbsb.SelectOne();
|
|
}
|
|
|
|
dbsb.sBezeichnung = sb.bezeichnung;
|
|
dbsb.iSerienbriefnr = sb.serienbriefnr;
|
|
dbsb.iVerantwortlich = sb.verantwortlich;
|
|
dbsb.iPostzustellung = sb.postzustellung;
|
|
dbsb.daDokumentdatum = sb.dokumentdatum;
|
|
dbsb.iZustaendig = sb.zustaendig;
|
|
dbsb.iUnterschriftlinks = sb.unterschriftlinks;
|
|
dbsb.iUnterschriftrechts = sb.unterschriftrechts;
|
|
dbsb.iTeam = sb.team;
|
|
dbsb.daArchivdatum = sb.archivdatum;
|
|
dbsb.daTermin = sb.termin;
|
|
dbsb.sBemerkung = sb.bemerkung;
|
|
dbsb.daErstellt_am = sb.erstellt_am;
|
|
dbsb.daMutiert_am = sb.mutiert_am;
|
|
dbsb.iMutierer = sb.mutierer;
|
|
dbsb.bAktiv = sb.aktiv;
|
|
dbsb.iStatus = sb.status;
|
|
dbsb.iDokumenttypnr = sb.dokumenttypnr;
|
|
dbsb.iWindowwidth = sb.windowwidth;
|
|
dbsb.iWindowheight = sb.windowwidth;
|
|
dbsb.iTreewidth = sb.treewidth;
|
|
dbsb.iInBearbeitung = sb.inBearbeitung;
|
|
dbsb.iFehlerhaft = sb.fehlerhaft;
|
|
dbsb.iErstellt = sb.erstellt;
|
|
dbsb.iGedruckt = sb.gedruckt;
|
|
dbsb.iBestaetigt = sb.bestaetigt;
|
|
dbsb.iAusgeloest = sb.ausgeloest;
|
|
dbsb.iBldossier = sb.vertrag;
|
|
|
|
edoka_conn.OpenConnection();
|
|
if (sb.serienbriefnr == 0)
|
|
{
|
|
dbsb.Insert();
|
|
sb.serienbriefnr = Convert.ToInt32(dbsb.iSerienbriefnr.ToString());
|
|
}
|
|
else
|
|
{
|
|
dbsb.Update();
|
|
|
|
}
|
|
save_empfaengerdata(sb.serienbriefnr, temppath, sb.dsempfaenger);
|
|
edoka_conn.CloseConnection(true);
|
|
|
|
Exec_SQL("Update edex_sb_serienbrief set faktura=" + sb.ppfaktura.ToString() + ", office_vorlagenr=" + sb.officevorlagenr.ToString() + " where serienbriefnr = " + sb.serienbriefnr.ToString());
|
|
Exec_SQL("update edex_sb_serienbrief set toapprove=" + sb.toapproval.ToString() + ", approved=" + sb.approved.ToString() + ", approval1=" + sb.approval1.ToString() + ", approval2=" + sb.approval2.ToString() + " where serienbriefnr=" + sb.serienbriefnr.ToString());
|
|
Exec_SQL("update edex_sb_serienbrief set faksimile=" + sb.faksimile.ToString() + ", ohneunterschrift=" + sb.ohneunterschrift.ToString() + " where serienbriefnr=" + sb.serienbriefnr.ToString());
|
|
|
|
return sb.serienbriefnr;
|
|
}
|
|
|
|
public string read_empfaengerdata(int serienbriefnr, string temppath)
|
|
{
|
|
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
|
|
|
|
|
Get_Tabledata("Select dbo.BinaryToBase64(xmldata) from edex_sb_empfaenger where serienbriefnr=" + serienbriefnr.ToString(), false, true);
|
|
try
|
|
{
|
|
File.WriteAllBytes(filename, Convert.FromBase64String(dsdaten.Tables[0].Rows[0][0].ToString()));
|
|
}
|
|
catch
|
|
{
|
|
filename = "";
|
|
}
|
|
return filename;
|
|
|
|
}
|
|
public Boolean save_empfaengerdata(int serienbriefnr, string temppath, DataSet empf)
|
|
{
|
|
try
|
|
{
|
|
|
|
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
|
//filename = temppath + "sbbase1.xml";
|
|
//serienbriefnr = -1;
|
|
empf.WriteXml(filename);
|
|
|
|
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_empfaenger where serienbriefnr=" + serienbriefnr.ToString() + "", Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "empfaenger");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[1] = serienbriefnr.ToString();
|
|
myRow[2] = mydata;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "empfaenger");
|
|
}
|
|
else
|
|
{
|
|
myRow = ds.Tables[0].Rows[0];
|
|
myRow[2] = mydata;
|
|
DA.Update(ds, "empfaenger");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
System.IO.File.Delete(filename);
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public string save_serienbrief_datei(int serienbriefnr, int eintragnr, string filename, string dokumentid)
|
|
{
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_serienbrief_dokument where dokumentid='" + dokumentid + "'", Connection);
|
|
//SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_serienbrief_dokument where inteintragnr = " + eintragnr.ToString() + " and serienbriefnr = " + serienbriefnr.ToString(), Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "sbdokument");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[1] = serienbriefnr.ToString();
|
|
myRow[2] = eintragnr.ToString();
|
|
myRow[3] = mydata;
|
|
myRow[4] = dokumentid;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "sbdokument");
|
|
}
|
|
else
|
|
{
|
|
myRow = ds.Tables[0].Rows[0];
|
|
myRow[3] = mydata;
|
|
DA.Update(ds, "sbdokument");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "";
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return filename;
|
|
}
|
|
|
|
|
|
public string save_sb_vorlage_to_db(string filename, string doctype, int serienbriefnr)
|
|
{
|
|
try
|
|
{
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select top 1 * from edex_sb_vorlage where serienbriefnr=" + serienbriefnr.ToString(), Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "vorlage");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[0] = serienbriefnr.ToString();
|
|
myRow[1] = mydata;
|
|
myRow[2] = doctype;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "vorlage");
|
|
}
|
|
else
|
|
{
|
|
myRow = ds.Tables[0].Rows[0];
|
|
myRow[1] = mydata;
|
|
DA.Update(ds, "vorlage");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return filename;
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return filename;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
return "";
|
|
}
|
|
return "";
|
|
}
|
|
public string get_sb_vorlage(int serienbriefnr, string temppath)
|
|
{
|
|
|
|
string filename = temppath + serienbriefnr.ToString() + ".xml";
|
|
|
|
|
|
Get_Tabledata("Select dbo.BinaryToBase64(vorlage), doctype from edex_sb_vorlage where serienbriefnr=" + serienbriefnr.ToString(), false, true);
|
|
try
|
|
{
|
|
filename = temppath + serienbriefnr.ToString() + "." + dsdaten.Tables[0].Rows[0][1].ToString();
|
|
File.WriteAllBytes(filename, Convert.FromBase64String(dsdaten.Tables[0].Rows[0][0].ToString()));
|
|
}
|
|
catch
|
|
{
|
|
filename = "";
|
|
}
|
|
return filename;
|
|
|
|
}
|
|
public string get_vorlage_to_file(string nr, string tempdir, string dokumentid)
|
|
{
|
|
string filename = "";
|
|
SqlConnection conn = new SqlConnection(connectionstring);
|
|
SqlCommand sc = new SqlCommand("Select vorlage from office_vorlage_datei where dbo.office_vorlage_datei.office_vorlage_dateinr=" + nr, conn);
|
|
conn.Open();
|
|
SqlDataReader sqldr = sc.ExecuteReader();
|
|
while (sqldr.Read())
|
|
{
|
|
filename = tempdir + @"\" + dokumentid;
|
|
byte[] attachment = (byte[])sqldr.GetValue(0);
|
|
FileStream fs = new FileStream(filename, FileMode.Create);
|
|
fs.Write(attachment, 0, attachment.Length);
|
|
fs.Close();
|
|
}
|
|
conn.Close();
|
|
|
|
return filename;
|
|
}
|
|
public void create_sb_check_table(int mitarbeiternr)
|
|
{
|
|
clear_parameter();
|
|
add_parameter("@manr", mitarbeiternr.ToString());
|
|
Get_Tabledata("dbo.sp_edex_sb_check_partner_create_table", true, false);
|
|
}
|
|
public void save_sb_checkdata(int mitarbeiternr, serienbrief sb)
|
|
{
|
|
var tdt = new DataTable("TMPSB_" + mitarbeiternr.ToString());
|
|
DataRow tdr;
|
|
//Logging.Logging.Debug("save sb check data ", "OnDoc","");
|
|
|
|
int i;
|
|
tdt.Columns.Add("Partnernr");
|
|
tdt.Columns.Add("Status");
|
|
tdt.Columns.Add("Rowid");
|
|
tdt.Columns.Add("Fehlercode");
|
|
// Rel 4.1 - BLKunde
|
|
tdt.Columns.Add("BLKunde");
|
|
|
|
DataRow[] dv;
|
|
|
|
dv = sb.dsempfaenger.Tables[0].Select();
|
|
i = 0;
|
|
|
|
//Logging.Logging.Debug("save_sb_checkdata: " + sb.dsempfaenger.Tables[0].Rows.ToString(), "OnDoc", "");
|
|
foreach (System.Data.DataRow dr in sb.dsempfaenger.Tables[0].Rows)
|
|
{
|
|
|
|
int ii = 0;
|
|
ii = Convert.ToInt32(dr["status"]);
|
|
Logging.Logging.Debug("checkdata 1", "OnDoc", ii.ToString());
|
|
if (ii.ToString() != "1")
|
|
{
|
|
//dr["Status"] = -1;
|
|
tdr = tdt.NewRow();
|
|
if (dr["Partnernr"].ToString() == "")
|
|
{
|
|
tdr[0] = 0;
|
|
tdr[1] = -1;
|
|
tdr[2] = i;
|
|
tdr[3] = 0;
|
|
// Rel. 4.1 BLKunde initialisieren
|
|
tdr[4] = 0;
|
|
}
|
|
else
|
|
{
|
|
tdr[0] = dr["Partnernr"];
|
|
tdr[1] = 0;
|
|
tdr[2] = i;
|
|
tdr[3] = 0;
|
|
// Rel. 4.1 BLKunde initialisieren
|
|
tdr[4] = 0;
|
|
}
|
|
Logging.Logging.Debug("checkdata addrow ", "OnDoc", tdr[0].ToString());
|
|
|
|
tdt.Rows.Add(tdr);
|
|
}
|
|
i = i + 1; ;
|
|
}
|
|
|
|
//foreach (var DR in dv)
|
|
//{
|
|
// int ii;
|
|
// try
|
|
// {
|
|
// ii = Convert.ToInt32(DR["Status"]);
|
|
// }
|
|
// catch
|
|
// {
|
|
// ii = 0;
|
|
// }
|
|
// if (ii !=1 )
|
|
// {
|
|
// DR["Status"] = -1;
|
|
// tdr = tdt.NewRow();
|
|
// if (DR["Partnernr"].ToString() == "")
|
|
// {
|
|
// tdr[0] = 0;
|
|
// tdr[1] = -1;
|
|
// tdr[2] = i;
|
|
// tdr[3] = 0;
|
|
// // Rel. 4.1 BLKunde initialisieren
|
|
// tdr[4] = 0;
|
|
// }
|
|
// else
|
|
// {
|
|
// tdr[0] = DR["Partnernr"];
|
|
// tdr[1] = 0;
|
|
// tdr[2] = i;
|
|
// tdr[3] = 3;
|
|
// // Rel. 4.1 BLKunde initialisieren
|
|
// tdr[4] = 0;
|
|
// }
|
|
// tdt.Rows.Add(tdr);
|
|
// }
|
|
// i = i + 1;
|
|
//}
|
|
//tdt.AcceptChanges();
|
|
var connection = new SqlConnection();
|
|
var da = new SqlDataAdapter("Select * from TMPSB_" + mitarbeiternr.ToString(), connection);
|
|
var cb = new SqlCommandBuilder(da);
|
|
connection.ConnectionString = connectionstring;
|
|
connection.Open();
|
|
da.Update(tdt);
|
|
connection.Close();
|
|
//Logging.Logging.Debug("Update data ", "OnDoc", tdt.Rows.Count.ToString());
|
|
return;
|
|
}
|
|
|
|
public DataTable Check_sb_Data(int mitarbeiternr, serienbrief sb)
|
|
{
|
|
clear_parameter();
|
|
add_parameter("@manr", mitarbeiternr.ToString());
|
|
add_parameter("@vertrag", "0");
|
|
add_parameter("@doktypnr", sb.dokumenttypnr.ToString());
|
|
Get_Tabledata("dbo.OnDoc_sb_check_partner", true, false);
|
|
return dsdaten.Tables[0];
|
|
}
|
|
|
|
public void Create_sb_SQL_Server_Table(ref DataTable dt, serienbrief sb)
|
|
{
|
|
string s;
|
|
string s1;
|
|
int i;
|
|
// dt.Columns.Add("NRPAR00")
|
|
// dt.Columns.Add("IntEintragNr")
|
|
|
|
s1 = "Drop Table DBO.EDKB09_" + sb.serienbriefnr.ToString();
|
|
|
|
// s = "Create Table EDKB09_" + Me.Serienbriefnr.ToString + "( NRPAR00 int, intEintragNr int,"
|
|
s = "Create Table DBO.EDKB09_" + sb.serienbriefnr.ToString() + "( NRPAR00 varchar(11),";
|
|
var loopTo = dt.Columns.Count - 1;
|
|
for (i = 0; i <= loopTo; i++)
|
|
s = s + "[" + dt.Columns[i].ColumnName + "] varchar(255),";
|
|
s = s.Substring(0, s.Length - 1);
|
|
s = s + "";
|
|
s = s + " " + ",CONSTRAINT [PK_EDKB09_" + sb.serienbriefnr.ToString() + "] PRIMARY KEY CLUSTERED ([IntEintragnr] ASC)) ON[DEFAULT]";
|
|
|
|
|
|
|
|
|
|
var conn = new SqlConnection();
|
|
conn.ConnectionString = connectionstring;
|
|
conn.Open();
|
|
var sqlcmd0 = new SqlCommand(s1, conn);
|
|
try
|
|
{
|
|
sqlcmd0.ExecuteNonQuery();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
var sqlcmd = new SqlCommand(s, conn);
|
|
sqlcmd.ExecuteNonQuery();
|
|
conn.Close();
|
|
}
|
|
public void Save_sb_Data_To_Temptable(ref DataTable dt, serienbrief sb)
|
|
{
|
|
Get_Tabledata_for_Update("Select * from EDKB09_" + sb.serienbriefnr.ToString() + " where inteintragnr=-1", false, true);
|
|
System.Data.DataTable ndt = dt.Copy();
|
|
ndt.Columns[0].ColumnName = "NRPAR00";
|
|
ndt.AcceptChanges();
|
|
foreach (System.Data.DataRow dr in ndt.Rows)
|
|
{
|
|
System.Data.DataRow nr = daten.Tables[0].NewRow();
|
|
foreach (System.Data.DataColumn col in ndt.Columns)
|
|
{
|
|
nr[col.ColumnName] = dr[col.ColumnName].ToString();
|
|
}
|
|
daten.Tables[0].Rows.Add(nr);
|
|
}
|
|
Update_Data();
|
|
Get_Tabledata_for_Update("Select * from EDKB09_" + sb.serienbriefnr.ToString() + " where inteintragnr=-1", false, true);
|
|
|
|
foreach (System.Data.DataRow dr in ndt.Rows)
|
|
{
|
|
DataRow nrow = daten.Tables[0].NewRow();
|
|
foreach (System.Data.DataColumn col in ndt.Columns)
|
|
{
|
|
nrow[col.ColumnName.ToString()] = dr[col.ColumnName.ToString()];
|
|
|
|
}
|
|
}
|
|
Update_Data();
|
|
|
|
// string s = "insert into edkb09_" + sb.serienbriefnr.ToString();
|
|
// s = s + "(";
|
|
// foreach (System.Data.DataColumn col in ndt.Columns)
|
|
// {
|
|
// s = s + "[" + col.ColumnName.ToString() + "],";
|
|
// }
|
|
// s = s.Substring(0, s.Length - 1);
|
|
// s = s + ") values (";
|
|
// foreach (System.Data.DataColumn col in ndt.Columns)
|
|
// {
|
|
// s = s + "'" + dr[col.ColumnName].ToString() + "',";
|
|
// }
|
|
// s = s.Substring(0, s.Length - 1);
|
|
// s = s + ")";
|
|
|
|
// Exec_SQL(s);
|
|
|
|
//}
|
|
return;
|
|
|
|
//var connection = new SqlConnection();
|
|
//var da = new SqlDataAdapter("Select * from EDKB09_" + sb.serienbriefnr.ToString(), connection);
|
|
//var cb = new SqlCommandBuilder(da);
|
|
//connection.ConnectionString = connectionstring;
|
|
//connection.Open();
|
|
//da.Update(ndt);
|
|
//connection.Close();
|
|
|
|
|
|
//daten.AcceptChanges();
|
|
//Update_Data();
|
|
//da.Update(dt);
|
|
|
|
//var tdt = new DataTable("EDKB09_" + sb.serienbriefnr.ToString());
|
|
//DataRow tdr;
|
|
//int i;
|
|
//int ii;
|
|
//tdt = dt.Copy();
|
|
//tdt.Columns[0].ColumnName = "NRPAR00";
|
|
|
|
//daten.Tables.Clear();
|
|
//daten.Tables.Add(tdt.Copy());
|
|
//daten.Tables[0].TableName = "Daten";
|
|
//daten.WriteXml(@"x:\gaga.xml");
|
|
//daten.AcceptChanges();
|
|
//Update_Data();
|
|
////var connection = new SqlConnection();
|
|
////var da = new SqlDataAdapter("Select * from EDKB09_" + sb.serienbriefnr.ToString(), connection);
|
|
////var cb = new SqlCommandBuilder(da);
|
|
////connection.ConnectionString = connectionstring;
|
|
////connection.Open();
|
|
////da.Update(tdt);
|
|
////connection.Close();
|
|
}
|
|
|
|
public DataTable Fill_And_Get_Data(serienbrief sb)
|
|
{
|
|
var scmCmdToExecute = new SqlCommand();
|
|
int i;
|
|
SqlConnection con = new SqlConnection(connectionstring);
|
|
var dtToReturn = new DataTable();
|
|
var sdaAdapter = new SqlDataAdapter(scmCmdToExecute);
|
|
scmCmdToExecute.CommandText = "dbo.sp_edex_sb_fill_sbdata";
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure;
|
|
scmCmdToExecute.Connection = con;
|
|
string Dokid = "";
|
|
try
|
|
{
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@serienbriefnr", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, sb.serienbriefnr));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@ROWCOUNT", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, sb.dsempfaenger.Tables[0].Rows.Count));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@dokumentid", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@bedr", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, 0));
|
|
scmCmdToExecute.Parameters.Add(new SqlParameter("@preview", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, 1));
|
|
sdaAdapter.Fill(dtToReturn);
|
|
Dokid = scmCmdToExecute.Parameters["@dokumentid"].Value.ToString();
|
|
var loopTo = dtToReturn.Rows.Count - 1;
|
|
for (i = 0; i <= loopTo; i++)
|
|
{
|
|
dtToReturn.Rows[i]["Dokumentid"] = generate_key(Dokid);
|
|
Dokid = Dokid + 1;
|
|
if (scmCmdToExecute.Parameters["@bedr"].Value.ToString() == "1")
|
|
{
|
|
dtToReturn.Rows[i]["dokumentidbdr"] = generate_key(Dokid);
|
|
Dokid = Dokid + 1;
|
|
}
|
|
}
|
|
return dtToReturn;
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("sp_check_dokumentreaktivierung::" + scmCmdToExecute.CommandText + "::Error occured." + ex.Message, ex);
|
|
}
|
|
finally
|
|
{
|
|
scmCmdToExecute.Dispose();
|
|
sdaAdapter.Dispose();
|
|
}
|
|
}
|
|
|
|
public bool dokument_abschliessen(string dokumentid)
|
|
{
|
|
try
|
|
{
|
|
string newstatus = "";
|
|
clear_parameter();
|
|
add_parameter("@dokumentid", dokumentid);
|
|
Get_Tabledata("SP_Dokumentstatus_statushandling_Select", true, false);
|
|
foreach (System.Data.DataRow dr in dsdaten.Tables[0].Rows)
|
|
{
|
|
if (Convert.ToInt32(dr["status_bezeichnungnr"]) == -2)
|
|
{
|
|
clear_parameter();
|
|
add_parameter("@fnkt", "3");
|
|
add_parameter("@dokumentid", dokumentid);
|
|
newstatus = dr["dokument_statusnr"].ToString();
|
|
add_parameter("@value1", newstatus);
|
|
Get_Tabledata("sp_edoka_onbase", true, false);
|
|
|
|
clear_parameter();
|
|
add_parameter("@fnkt", "4");
|
|
add_parameter("@dokumentid", dokumentid);
|
|
add_parameter("@value1", newstatus);
|
|
Get_Tabledata("sp_edoka_onbase", true, false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
catch { return false; }
|
|
|
|
}
|
|
|
|
public bool save_edkdata(string filename, string tgnummer)
|
|
{
|
|
try
|
|
{
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select * from edk_data where rowid=-1 ", Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "edk_data");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[1] = tgnummer;
|
|
myRow[2] = DateTime.Now;
|
|
myRow[3] = "0";
|
|
myRow[4] = DateTime.Now;
|
|
myRow[5] = mydata;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "edk_data");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
public Boolean save_edk(string filename, int mitarbeiternr)
|
|
{
|
|
try
|
|
{
|
|
SqlConnection Connection = new SqlConnection();
|
|
SqlDataAdapter DA = new SqlDataAdapter("select * from edk_log where rowid=-1 ", Connection);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(DA);
|
|
DataSet ds = new DataSet();
|
|
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
|
byte[] mydata = new byte[fs.Length];
|
|
try
|
|
{
|
|
fs.Read(mydata, 0, Convert.ToInt32(fs.Length));
|
|
fs.Close();
|
|
Connection.ConnectionString = connectionstring;
|
|
Connection.Open();
|
|
DA.Fill(ds, "edk_log");
|
|
DataRow myRow;
|
|
if (ds.Tables[0].Rows.Count == 0)
|
|
{
|
|
myRow = ds.Tables[0].NewRow();
|
|
myRow[1] = "0";
|
|
myRow[2] = mitarbeiternr;
|
|
myRow[5] = DateTime.Now;
|
|
myRow[6] = mydata;
|
|
myRow[7] = filename;
|
|
ds.Tables[0].Rows.Add(myRow);
|
|
DA.Update(ds, "edk_log");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
fs = null;
|
|
cb = null;
|
|
ds = null;
|
|
DA = null;
|
|
Connection.Close();
|
|
Connection = null;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception EX)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public string copydoc(string dokumentid, int manr)
|
|
{
|
|
try
|
|
{
|
|
string newdokumentid = get_dbkey("Dokument");
|
|
clear_parameter();
|
|
add_parameter("UrsprungID", dokumentid);
|
|
add_parameter("NewDokID", newdokumentid);
|
|
|
|
clsDokument dok = new clsDokument();
|
|
clsConnectionProvider edoka_conn = new clsConnectionProvider();
|
|
edoka_conn.sConnectionString = this.connectionstring;
|
|
dok.cpMainConnectionProvider = edoka_conn;
|
|
edoka_conn.OpenConnection();
|
|
dok.sDokumentid = dokumentid;
|
|
dok.SelectOne();
|
|
dok.sDokumentid = newdokumentid;
|
|
dok.daErstelltam = DateTime.Now;
|
|
dok.daMutiertam = DateTime.Now;
|
|
dok.iErsteller = manr;
|
|
dok.iMutierer = manr;
|
|
dok.Insert();
|
|
|
|
COLD_Index_Sichern(1, newdokumentid);
|
|
if (dok.bZu_retournieren == true)
|
|
{
|
|
COLD_Index_Sichern(2, newdokumentid);
|
|
}
|
|
Status_Erstellen(newdokumentid, false);
|
|
dok.iStatusnr = Convert.ToInt32(get_current_Status(newdokumentid).ToString());
|
|
//edoka_conn.OpenConnection();
|
|
dok.Update();
|
|
edoka_conn.CloseConnection(true);
|
|
|
|
//Get_Tabledata("Select * from dokumentcoldindexwert where dokumentid='" + dokumentid + "'", false, true);
|
|
//Get_Tabledata_for_Update("Select * from dokumentcoldindexwert where dokumentid='" + newdokumentid + "'", false, true);
|
|
//foreach (DataRow dr in dsdaten.Tables[0].Rows)
|
|
//{
|
|
// daten.Tables[0].Rows.Add(dr);
|
|
//}
|
|
//daten.AcceptChanges();
|
|
//Update_Data();
|
|
|
|
Get_Tabledata("Select * from dokumentcoldindexwert where dokumentid='" + dokumentid + "'", false, true);
|
|
Get_Tabledata_for_Update("Select * from dokumentcoldindexwert where dokumentid='" + newdokumentid + "'", false, true);
|
|
foreach (DataRow dr in dsdaten.Tables[0].Rows)
|
|
{
|
|
dr["dokumentid"] = newdokumentid;
|
|
daten.Tables[0].ImportRow(dr);
|
|
}
|
|
daten.AcceptChanges();
|
|
Update_Data();
|
|
|
|
Get_Tabledata("Select * from dokumentinfo_wert where dokumentid='" + dokumentid + "'", false, true);
|
|
Get_Tabledata_for_Update("Select * from dokumentinfo_wert where dokumentid='" + newdokumentid + "'", false, true);
|
|
foreach (DataRow dr in dsdaten.Tables[0].Rows)
|
|
{
|
|
dr["dokumentid"] = newdokumentid;
|
|
daten.Tables[0].ImportRow(dr);
|
|
}
|
|
daten.AcceptChanges();
|
|
Update_Data();
|
|
|
|
Exec_SQL("insert doks (dokumentid, dokument, doktype) select '" + newdokumentid + "', dokument,doktype from doks where dokumentid='" + dokumentid + "'");
|
|
|
|
Get_Tabledata("Select * from dokumenttyp where dokumenttypnr=" + dok.iDokumenttypnr.ToString(), false, true);
|
|
int toapprove = 0;
|
|
int approved = 0;
|
|
int approved1 = 0;
|
|
int approved2 = 0;
|
|
int signiert = 0;
|
|
int faksimile = 0;
|
|
|
|
if (Convert.ToBoolean(dsdaten.Tables[0].Rows[0]["Unterschrift_Pruefung"]) == true)
|
|
{
|
|
toapprove = 1;
|
|
if (dok.iUnterschriftlinks == dok.iErsteller) { approved1 = 1; }
|
|
if (dok.iUnterschriftrechts == dok.iErsteller) { approved2 = 1; }
|
|
}
|
|
int unterschriftlinks = Convert.ToInt32(dsdaten.Tables[0].Rows[0]["Unterschrift_links"]);
|
|
int unterschriftrechts = Convert.ToInt32(dsdaten.Tables[0].Rows[0]["Unterschrift_rechts"]);
|
|
int bearbeitung_zwingend = Convert.ToInt32(dsdaten.Tables[0].Rows[0]["bearbeitung_zwingend"]);
|
|
//if (unterschriftlinks == 1 && unterschriftrechts == 0 && approved1 == 1) { approved = 1; }
|
|
Get_Tabledata("Select faksimile from dokument where dokumentid='" + dokumentid+"'", false, true);
|
|
try
|
|
{
|
|
faksimile = Convert.ToInt32(dsdaten.Tables[0].Rows[0][0]);
|
|
} catch { faksimile = 0; }
|
|
bearbeitung_zwingend = 1;
|
|
Exec_SQL("Update dokument set bearbeitung_zwingend = " + bearbeitung_zwingend.ToString() + ", toapprove=" + toapprove.ToString() + ", approved=" + approved.ToString() + ", approval1=" + approved1.ToString() + ", approval2=" + approved2.ToString() + ", signiert="+signiert.ToString()+", faksimile="+faksimile.ToString()+" where dokumentid = '" + newdokumentid + "'");
|
|
|
|
return newdokumentid;
|
|
}
|
|
catch { return ""; }
|
|
//return true;
|
|
}
|
|
|
|
public bool dokument_reaktivieren(string dokumentid, string mitarbeiternr)
|
|
{
|
|
clear_parameter();
|
|
add_parameter("@fnkt", "11");
|
|
add_parameter("@dokumentid", dokumentid);
|
|
add_parameter("@value1", mitarbeiternr);
|
|
Get_Tabledata("sp_edoka_onbase", true, false);
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|