267 lines
10 KiB
C#
267 lines
10 KiB
C#
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 Syncfusion.Windows.Forms.Grid;
|
|
using Syncfusion.Windows.Forms.Tools;
|
|
using Syncfusion.WinForms.Controls;
|
|
using Database;
|
|
using BarcodeLib;
|
|
using Windows.UI.Xaml.Documents;
|
|
using System.IO;
|
|
using System.Net;
|
|
|
|
namespace OnDoc.Diverses
|
|
{
|
|
public partial class EditDokMetaData : SfForm
|
|
{
|
|
|
|
private string dokumentid = "";
|
|
public EditDokMetaData()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public EditDokMetaData(string DokumentID)
|
|
{
|
|
InitializeComponent();
|
|
dokumentid = DokumentID;
|
|
}
|
|
|
|
private void EditDokMetaData_Load(object sender, EventArgs e)
|
|
{
|
|
Load_Data();
|
|
}
|
|
|
|
private void Load_Data() {
|
|
DB db = new DB(AppParams.connectionstring);
|
|
db.Get_Tabledata("Select * from dokument where dokumentid='" + dokumentid + "'", false, true);
|
|
DataTable dokument = db.dsdaten.Tables[0].Copy();
|
|
db.Get_Tabledata("Select * from dokumenttyp where dokumenttypnr=" + dokument.Rows[0]["Dokumenttypnr"].ToString(), false, true);
|
|
DataTable dokumenttyp = db.dsdaten.Tables[0].Copy();
|
|
this.txtBezeichnung.Text = dokument.Rows[0]["Bezeichnung"].ToString();
|
|
if (Convert.ToBoolean(dokumenttyp.Rows[0]["bezeichnungmut"]))
|
|
{
|
|
this.txtBezeichnung.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
this.txtBezeichnung.Enabled = false;
|
|
}
|
|
try
|
|
{
|
|
this.ChkTagesEndArchivierung.Checked = Convert.ToBoolean(dokument.Rows[0]["automatischearchivierung"]);
|
|
}
|
|
catch { this.ChkTagesEndArchivierung.Checked= false; }
|
|
|
|
this.DateDokumentDatum.Value = Convert.ToDateTime(dokument.Rows[0]["erstellungsdatum"]);
|
|
if (Convert.ToDateTime(dokument.Rows[0]["termin"]).Year < 2000)
|
|
{
|
|
this.DateTerminText.Text = "";
|
|
}
|
|
else
|
|
{
|
|
this.DateTerminText.Text = Convert.ToDateTime(dokument.Rows[0]["termin"]).ToString();
|
|
this.DateTerminText.Text = this.DateTerminText.Text.Substring(0, 10);
|
|
}
|
|
this.cbfaksimile.Enabled = true;
|
|
if (Convert.ToBoolean(dokumenttyp.Rows[0]["Unterschrift_Faksimile"]) == true) {
|
|
this.cbfaksimile.Checked = Convert.ToBoolean(dokument.Rows[0]["faksimile"]);
|
|
if (Convert.ToBoolean(dokument.Rows[0]["signiert"])) {
|
|
this.cbfaksimile.Enabled = false;
|
|
}
|
|
if (Convert.ToBoolean(dokument.Rows[0]["approved"]))
|
|
{
|
|
this.cbfaksimile.Enabled = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.cbfaksimile.Enabled = false;
|
|
}
|
|
if (Convert.ToBoolean(dokument.Rows[0]["approval1"]) || Convert.ToBoolean(dokument.Rows[0]["approval2"])){
|
|
this.cbfaksimile.Enabled = false;
|
|
}
|
|
bool barcode = false;
|
|
barcode = Convert.ToBoolean(dokumenttyp.Rows[0]["Vertrag"]) == true;
|
|
|
|
if (Convert.ToInt32(dokumenttyp.Rows[0]["doktypbedingteretournierung"]) > 0)
|
|
{
|
|
barcode = true;
|
|
}
|
|
if (barcode == true)
|
|
{
|
|
this.DateTermin.Visible = true;
|
|
this.DateTerminText.Visible = true;
|
|
this.lblTermin.Visible = true;
|
|
}
|
|
else {
|
|
|
|
this.DateTermin.Visible = false;
|
|
this.DateTerminText.Visible = false;
|
|
this.lblTermin.Visible = false;
|
|
}
|
|
db = null;
|
|
|
|
lblverantwortung.Visible = false;
|
|
if (Convert.ToInt32(dokument.Rows[0]["verantwortlich"]) != AppParams.CurrentMitarbeiter)
|
|
{
|
|
|
|
lblverantwortung.Visible = true;
|
|
}
|
|
}
|
|
|
|
private void DateTermin_ValueChanged(object sender, Syncfusion.WinForms.Input.Events.DateTimeValueChangedEventArgs e)
|
|
{
|
|
this.DateTerminText.Text = DateTermin.Value.ToString().Substring(0, 10);
|
|
}
|
|
|
|
private void sfButton2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void sfButton1_Click(object sender, EventArgs e)
|
|
{
|
|
DB dB = new DB(AppParams.connectionstring);
|
|
string automatischearchivierung = "0";
|
|
string faksimile = "0";
|
|
string bezeichnung = "";
|
|
string datum = "";
|
|
string termin = "";
|
|
if (ChkTagesEndArchivierung.Checked == true) { automatischearchivierung = "1"; }
|
|
if (cbfaksimile.Checked == true) { faksimile = "1"; }
|
|
bezeichnung=txtBezeichnung.Text;
|
|
datum = DateDokumentDatum.Value.ToString();
|
|
termin = DateTerminText.Text;
|
|
|
|
|
|
string sql = "update dokument set";
|
|
sql = sql + " bezeichnung='" + bezeichnung + "', ";
|
|
sql = sql + " automatischearchivierung=" + automatischearchivierung + ", ";
|
|
sql = sql + " faksimile="+faksimile+", ";
|
|
sql = sql + " erstellungsdatum='" + datum + "'";
|
|
if (lblverantwortung.Visible == true)
|
|
{
|
|
sql = sql + ", verantwortlich = " + AppParams.CurrentMitarbeiter.ToString();
|
|
}
|
|
if (faksimile != "0" && cbfaksimile.Enabled==true)
|
|
{
|
|
int ul;
|
|
int ur;
|
|
string tul = "";
|
|
string tur = "";
|
|
string check_error = "";
|
|
dB.Get_Tabledata("Select * from dokument where dokumentid = '" + this.dokumentid + "'", false, true);
|
|
ul = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["Unterschriftlinks"].ToString());
|
|
ur = Convert.ToInt32(dB.dsdaten.Tables[0].Rows[0]["Unterschriftrechts"].ToString());
|
|
int a1 = 0;
|
|
int a2 = 0;
|
|
if (ul > 0)
|
|
{
|
|
if (!Check_Signature(ul))
|
|
{
|
|
dB.Get_Tabledata("Select dbo.fnkt_Get_MA_Name(" + ul.ToString() + ")", false, true);
|
|
tul = dB.dsdaten.Tables[0].Rows[0][0].ToString();
|
|
if (check_error != "") { check_error = check_error + Environment.NewLine; }
|
|
check_error = check_error + "- Unterschriftenbild " + tul + " fehlt";
|
|
}
|
|
else
|
|
{
|
|
if (ul == AppParams.CurrentMitarbeiter) { a1 = 1; }
|
|
}
|
|
}
|
|
else
|
|
{
|
|
a1 = 1;
|
|
}
|
|
if (ur > 0)
|
|
{
|
|
if (!Check_Signature(ur))
|
|
{
|
|
dB.Get_Tabledata("Select dbo.fnkt_Get_MA_Name(" + ur.ToString() + ")", false, true);
|
|
tur = dB.dsdaten.Tables[0].Rows[0][0].ToString();
|
|
if (check_error != "") { check_error = check_error + Environment.NewLine; }
|
|
if (check_error != "") { check_error += Environment.NewLine; }
|
|
check_error = check_error + "- Unterschriftenbild " + tur + " fehlt";
|
|
} else { if (ur == AppParams.CurrentMitarbeiter) { a2 = 1; } }
|
|
} else
|
|
{
|
|
a2 = 1;
|
|
}
|
|
if (check_error != "")
|
|
{
|
|
MessageBox.Show("Folgende Fehler sind aufgetreten:"+Environment.NewLine+check_error,"Faksimile Unterschrifen",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
|
dB = null;
|
|
return;
|
|
}
|
|
sql = sql + ", toapprove=1, approved=0, signiert=0 ";
|
|
if (a1 == 1) { sql = sql + ", approval1=1"; } else { sql = sql + ", approval1=0"; }
|
|
if (a2 == 1) { sql = sql + ", approval2=1"; } else { sql = sql + ", approval2=0"; }
|
|
|
|
}
|
|
if (cbfaksimile.Enabled == true && faksimile=="0")
|
|
{
|
|
sql = sql + ", approval1=0, approval2=0, toapprove=0, signiert=0";
|
|
}
|
|
if (termin != "")
|
|
{
|
|
sql = sql + ", termin='" + termin + "'";
|
|
}
|
|
dB.Exec_SQL(sql + " where dokumentid='" + this.dokumentid + "'");
|
|
dB = null;
|
|
this.Close();
|
|
}
|
|
private bool Check_Signature(int mitarbeiternr)
|
|
{
|
|
DB db = new DB(AppParams.connectionstring);
|
|
try
|
|
{
|
|
db.Get_Tabledata("Select tgnummer from mitarbeiter where mitarbeiternr=" + mitarbeiternr.ToString(), false, true);
|
|
if (db.dsdaten.Tables[0].Rows[0][0].ToString() == "")
|
|
{
|
|
return false;
|
|
}
|
|
string URL = AppParams.RESTURI + "API/CheckSignature?TGNummer=" + db.dsdaten.Tables[0].Rows[0][0].ToString();
|
|
HttpWebRequest webRequest = HttpWebRequest.Create(URL) as HttpWebRequest;
|
|
webRequest.Method = WebRequestMethods.Http.Get;
|
|
webRequest.Headers["Authorization"] = "Bearer " + AppParams.apikey;
|
|
try
|
|
{
|
|
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
|
|
{
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
StreamReader reader = new StreamReader(response.GetResponseStream());
|
|
string responseContent = reader.ReadToEnd();
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Logging.Logging.Error(URL + ": " + response.StatusCode.ToString() + " / " + response.StatusDescription, "Clinet - DokList GetDocument", "");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
return false;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
finally { db = null; }
|
|
|
|
}
|
|
}
|
|
}
|