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.
195 lines
7.1 KiB
195 lines
7.1 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 OnDoc.UIControls.Administrator;
|
|
using Syncfusion.Windows.Forms;
|
|
using Syncfusion.Windows.Forms.Tools;
|
|
using Syncfusion.WinForms.Controls;
|
|
using Syncfusion.WinForms.DataGrid;
|
|
using Syncfusion.WinForms.DataGrid.Interactivity;
|
|
using Database;
|
|
|
|
namespace OnDoc.DocMgmt
|
|
{
|
|
public partial class DokTypSelect : SfForm
|
|
{
|
|
|
|
public int dokumenttypnr { get; set; } = 0;
|
|
public DokTypSelect()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void DokTypSelect_Load_1(object sender, EventArgs e)
|
|
{
|
|
this.Style.TitleBar.BackColor = Theaming.Titelbar();
|
|
this.Style.TitleBar.ForeColor = Theaming.TitelFontColor();
|
|
load_standard("");
|
|
}
|
|
|
|
|
|
public void load_standard(string filter)
|
|
{
|
|
if (AppParams.connectionstring == "")
|
|
{
|
|
AppParams.init();
|
|
}
|
|
treeViewAdv1.Enabled = false;
|
|
treeViewAdv1.Visible= false;
|
|
treeViewAdv1.BeginEdit();
|
|
treeViewAdv1.Nodes.Clear();
|
|
string where = "";
|
|
if (filter != "")
|
|
{
|
|
where = "and bezeichnung like '%" + filter.Replace(" ", "%") + "%'";
|
|
}
|
|
|
|
DB db = new DB(AppParams.connectionstring);
|
|
db.Get_Tabledata("Select dokumenttypnr as id, bezeichnung, node, OnBase_Dokumenttyp from View_Dokumenttypen_Relaunch where aktiv=1 " + where + " order by bezeichnung", false, true);
|
|
|
|
DataTable vorlagen = new DataTable();
|
|
DataTable Struktur = new DataTable();
|
|
DataSet ds = new DataSet();
|
|
vorlagen = db.dsdaten.Tables[0].Copy();
|
|
db.Get_Tabledata("Select * from Dokumentart_Relaunch order by id", false, true);
|
|
Struktur = db.dsdaten.Tables[0].Copy();
|
|
|
|
ds.Tables.Add(Struktur.Copy());
|
|
ds.Tables[0].TableName = "Struktur";
|
|
ds.Tables.Add(vorlagen.Copy());
|
|
ds.Relations.Add("TreeParentChild", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["ParentID"],false);
|
|
ds.Relations.Add("VorlagenParent", ds.Tables[0].Columns["id"], ds.Tables[1].Columns["node"], false);
|
|
|
|
|
|
foreach ( System.Data. DataRow dr in ds.Tables[0].Rows)
|
|
{
|
|
if (dr["Parentid"].ToString() == "0")
|
|
{
|
|
//Creates a TreeNode if the parent equals 0
|
|
TreeNodeAdv root = new TreeNodeAdv(dr["bezeichnung"].ToString());
|
|
root.Tag = Convert.ToInt32(dr["id"]) * 1;
|
|
treeViewAdv1.Nodes.Add(root);
|
|
//Recursively builds the tree
|
|
PopulateTree(dr, root);
|
|
|
|
}
|
|
}
|
|
//Expands all the tree nodes
|
|
treeViewAdv1.ExpandAll();
|
|
treeViewAdv1.SelectedNode = treeViewAdv1.Nodes[0];
|
|
treeViewAdv1.EndEdit();
|
|
treeViewAdv1.Enabled = true;
|
|
treeViewAdv1.Visible=true;
|
|
if (ExternalCall.struktur != "")
|
|
{
|
|
treeViewAdv1.CollapseAll();
|
|
TreeViewAdvFindReplaceDialog dialog = new TreeViewAdvFindReplaceDialog(this.treeViewAdv1);
|
|
dialog.Find(ExternalCall.struktur, Syncfusion.Windows.Forms.Tools.TreeViewSearchOption.MatchWholeText, Syncfusion.Windows.Forms.Tools.TreeViewSearchRange.TreeView);
|
|
}
|
|
}
|
|
void treeViewAdv1_OnNodeAfterFound(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvAfterFindArgs e)
|
|
{
|
|
treeViewAdv1.CollapseAll();
|
|
treeViewAdv1.SelectedNode = e.Node;
|
|
treeViewAdv1.SelectedNode.ExpandAll();
|
|
treeViewAdv1.EnsureVisible(treeViewAdv1.SelectedNode);
|
|
}
|
|
public void PopulateSubTree(System.Data.DataRow dr, TreeNodeAdv pNode)
|
|
{
|
|
//To iterate through all the rows in the DataSet
|
|
foreach (System.Data.DataRow row in dr.GetChildRows("VorlagenParent"))
|
|
{
|
|
//Creating a TreeNode for each row
|
|
TreeNodeAdv cChild = new TreeNodeAdv(row["bezeichnung"].ToString() + " (" + row["OnBase_Dokumenttyp"].ToString() + ")");
|
|
cChild.Tag = Convert.ToInt32(row["id"]) * 1;
|
|
//Add cChild node to the pNode
|
|
pNode.Nodes.Add(cChild);
|
|
//Recursively build the tree
|
|
PopulateSubTree(row, cChild);
|
|
}
|
|
}
|
|
public void PopulateTree(System.Data.DataRow dr, TreeNodeAdv pNode)
|
|
{
|
|
//To iterate through all the rows in the DataSet
|
|
foreach (System.Data.DataRow row in dr.GetChildRows("TreeParentChild"))
|
|
{
|
|
//Creating a TreeNode for each row
|
|
TreeNodeAdv cChild = new TreeNodeAdv(row["bezeichnung"].ToString());
|
|
cChild.Tag = Convert.ToInt32(row["id"]) * 1;
|
|
//Add cChild node to the pNode
|
|
pNode.Nodes.Add(cChild);
|
|
//Recursively build the tree
|
|
PopulateTree(row, cChild);
|
|
PopulateSubTree(row, cChild);
|
|
}
|
|
}
|
|
private void ribbonButton1_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
private void sfListView1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
foreach (DataRowView item in sfListView1.SelectedItems)
|
|
{
|
|
dokumenttypnr = Convert.ToInt32(item.Row[0].ToString());
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
}
|
|
|
|
private void RibbonButtonSearch_Click(object sender, EventArgs e)
|
|
{
|
|
if (RibbonTextSearch.TextBoxText.Trim().Length > 0)
|
|
{
|
|
load_standard(RibbonTextSearch.TextBoxText);
|
|
}
|
|
}
|
|
|
|
private void RibbonTextSearch_TextBoxKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
load_standard(RibbonTextSearch.TextBoxText);
|
|
}
|
|
}
|
|
|
|
private void treeViewAdv1_NodeMouseDoubleClick(object sender, TreeViewAdvMouseClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
dokumenttypnr = Convert.ToInt32(e.Node.Tag);
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
private void ribbonButtonCreate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
dokumenttypnr = Convert.ToInt32(treeViewAdv1.SelectedNode.Tag);
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
private void ctxmenuerstellen_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
dokumenttypnr = Convert.ToInt32(treeViewAdv1.SelectedNode.Tag);
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
}
|