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.
191 lines
7.4 KiB
191 lines
7.4 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.Tools;
|
|
using Syncfusion.WinForms.Controls;
|
|
using Database;
|
|
using System.Security.RightsManagement;
|
|
using Syncfusion.WinForms.DataGrid.Enums;
|
|
using NLog.LayoutRenderers.Wrappers;
|
|
|
|
namespace OnDoc.DocMgmt
|
|
{
|
|
public partial class SerienbriefTemplateLoad : SfForm
|
|
{
|
|
private string mitarbeiternr { get; set; } = "";
|
|
public string selectedID = "";
|
|
public string file = "";
|
|
public string usedfelder = "";
|
|
string basedokumenttypnr = "";
|
|
public SerienbriefTemplateLoad()
|
|
{
|
|
InitializeComponent();
|
|
this.Style.TitleBar.BackColor = Theaming.Titelbar();
|
|
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
|
|
this.Style.ShadowOpacity = Theaming.ShadowOpacity;
|
|
this.Style.InactiveShadowOpacity = Theaming.InactivShadowOpacity;
|
|
}
|
|
|
|
public SerienbriefTemplateLoad(string mitarbeiternr, string basedokumenttypnr)
|
|
{
|
|
InitializeComponent();
|
|
this.Style.TitleBar.BackColor = Theaming.Titelbar();
|
|
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
|
|
this.Style.ShadowOpacity = Theaming.ShadowOpacity;
|
|
this.Style.InactiveShadowOpacity = Theaming.InactivShadowOpacity;
|
|
this.mitarbeiternr=mitarbeiternr;
|
|
this.basedokumenttypnr =basedokumenttypnr;
|
|
|
|
}
|
|
private void SerienbriefTemplateLoad_Load(object sender, EventArgs e)
|
|
{
|
|
pictureBox1.Visible = false;
|
|
this.label1.Visible = false;
|
|
load_data();
|
|
}
|
|
private void load_data() {
|
|
DB db = new DB(AppParams.connectionstring);
|
|
db.Get_Tabledata("Select '0' as S,ID,Bezeichnung, isnull(usedfelder,'') as UsedFelder, case when isnull(doktyp,'') ='' then 'A' else doktyp end as DokTyp from ondoc_sb_vorlage where aktiv=1 and mitarbeiternr="+ mitarbeiternr, false, true);
|
|
foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
|
{
|
|
if (dr[4].ToString() != basedokumenttypnr)
|
|
{
|
|
dr[0] = '1';
|
|
}
|
|
else
|
|
{
|
|
dr[0] = '2';
|
|
}
|
|
}
|
|
db.dsdaten.Tables[0].AcceptChanges();
|
|
this.sfDataGrid1.DataSource = db.dsdaten.Tables[0];
|
|
this.sfDataGrid1.Columns[1].Visible = false;
|
|
this.sfDataGrid1.Columns[3].Visible = false;
|
|
this.sfDataGrid1.Columns[4].Visible = false;
|
|
this.sfDataGrid1.Columns[0].HeaderText = "";
|
|
sfDataGrid1.RowHeight = 28;
|
|
db = null;
|
|
}
|
|
|
|
private void sfDataGrid1_CellClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rowIndex = e.DataRow.RowIndex;
|
|
//Get the column index value
|
|
var columnIndex = e.DataColumn.ColumnIndex;
|
|
var selectedItem = e.DataRow;
|
|
var dataRow = (e.DataRow.RowData as DataRowView).Row;
|
|
selectedID = dataRow["id"].ToString();
|
|
sfButton1.Enabled=true;
|
|
sfButton3.Enabled = true;
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
private void sfDataGrid1_CellDoubleClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellClickEventArgs e)
|
|
{
|
|
|
|
sfDataGrid1_CellClick(sender, e);
|
|
sfButton1_Click(sender, e);
|
|
this.Close();
|
|
}
|
|
|
|
private void sfButton1_Click(object sender, EventArgs e)
|
|
{
|
|
if (selectedID!="")
|
|
{
|
|
DialogResult = DialogResult.OK;
|
|
DB db = new DB(AppParams.connectionstring);
|
|
db.Get_Tabledata("Select vorlage, usedfelder from ondoc_sb_vorlage where id=" + selectedID, false, true);
|
|
this.file = db.dsdaten.Tables[0].Rows[0][0].ToString();
|
|
this.usedfelder = db.dsdaten.Tables[0].Rows[0][1].ToString();
|
|
db = null;
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
private void sfButton2_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult=DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void sfButton3_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("Vorlagendatei löschen", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
DB dB = new DB(AppParams.connectionstring);
|
|
dB.Exec_SQL("update ondoc_sb_vorlage set aktiv=0, mutiert_am=getdate(), mutierer=" + AppParams.CurrentMitarbeiter.ToString() + " where id=" + selectedID.ToString());
|
|
dB = null;
|
|
sfButton1.Enabled = false;
|
|
sfButton3.Enabled = false;
|
|
load_data();
|
|
}
|
|
|
|
}
|
|
|
|
private void sfDataGrid1_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Column.MappingName == "S")
|
|
{
|
|
try
|
|
{
|
|
e.Column.CellStyle.HorizontalAlignment = HorizontalAlignment.Center;
|
|
e.Handled = true;
|
|
var selectedItem = e.DataRow;
|
|
var dataRow = (e.DataRow.RowData as DataRowView).Row;
|
|
|
|
if (Convert.ToInt32(dataRow["S"]) == 2)
|
|
{
|
|
e.Graphics.DrawImage(OnDoc.Properties.Resources.OK_24x24_32, e.Bounds.X + 10, e.Bounds.Y+2);
|
|
}
|
|
if (Convert.ToInt32(dataRow["S"]) == 1)
|
|
{
|
|
e.Graphics.DrawImage(OnDoc.Properties.Resources.Achtung_24x24_32, e.Bounds.X + 10, e.Bounds.Y+2);
|
|
}
|
|
|
|
Pen borderPen = new Pen(Color.LightGray);
|
|
e.Graphics.DrawLine(borderPen, e.Bounds.Right, e.Bounds.Top, e.Bounds.Right, e.Bounds.Bottom);
|
|
e.Graphics.DrawLine(borderPen, e.Bounds.Left-1, e.Bounds.Bottom, e.Bounds.Right, e.Bounds.Bottom);
|
|
return;
|
|
|
|
}
|
|
catch { }
|
|
e.Handled = false;
|
|
}
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
private void sfDataGrid1_QueryRowStyle(object sender, Syncfusion.WinForms.DataGrid.Events.QueryRowStyleEventArgs e)
|
|
{
|
|
if (e.RowType == RowType.DefaultRow)
|
|
{
|
|
var dataRowView = e.RowData as DataRowView;
|
|
var dataRow = dataRowView.Row;
|
|
var cellValue = dataRow[4].ToString();
|
|
if (cellValue != basedokumenttypnr)
|
|
{
|
|
//e.Style.TextColor = Color.Gray;
|
|
pictureBox1.Visible = true;
|
|
label1.Visible = true;
|
|
label1.Text = "Die Vorlage entspricht nicht dem Vorlagentyp des Serienbriefes." + Environment.NewLine;
|
|
label1.Text = label1.Text + "Das kann sich auf Einstellungen für Versandstrasse, Archivierung usw. auswirken.";
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|