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.

170 lines
6.0 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 Syncfusion.Windows.Forms.Grid;
using Syncfusion.Windows.Forms.Tools;
using Syncfusion.WinForms.Controls;
using Database;
using BarcodeLib;
using Windows.UI.Xaml.Documents;
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)
{
sql = sql + ", toapprove=1 ";
}
if (cbfaksimile.Enabled == true && faksimile=="0")
{
sql = sql + ", approval1=0, approval2=0, toapprove=0";
}
if (termin != "")
{
sql = sql + ", termin='" + termin + "'";
}
dB.Exec_SQL(sql + " where dokumentid='" + this.dokumentid + "'");
dB = null;
this.Close();
}
}
}