|
|
|
|
using DevExpress.Spreadsheet;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using KGIS.Framework.Utils.Utility;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using KUI.Windows;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
namespace Kingo.Plugin.DataDictionary.Views
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// FrmDicManage.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FrmDicManage : BaseWindow
|
|
|
|
|
{
|
|
|
|
|
#region 全局变量
|
|
|
|
|
private string connStr = string.Empty;
|
|
|
|
|
string Cold = null;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入权属单位集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<QSDWinformation> ListQsdwEntity = null;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 权属单位集合-原始数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<QSDWinformation> ExcelLists = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理掉的权属集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<QSDWinformation> RemoveQsdwEntity = null;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前工程数据库连接
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string dbPath = string.Empty;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 省级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
KeyValuePair<string, string> ShengInfo { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 市级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
KeyValuePair<string, string> ShiInfo { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 县级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
KeyValuePair<string, string> XianInfo { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 省级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
List<QSDWinformation> ShengInfo2 { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 市级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
List<QSDWinformation> ShiInfo2 { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 县级代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
List<QSDWinformation> XianInfo2 { get; set; }
|
|
|
|
|
|
|
|
|
|
public static FrmDicManage frmDicManage = new FrmDicManage();
|
|
|
|
|
|
|
|
|
|
private string XJFid = null;
|
|
|
|
|
private string FJFid = null;
|
|
|
|
|
#endregion
|
|
|
|
|
public FrmDicManage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.CustomToolTip = "权属代码可右键导入EXCEL(软件提供EXCEL模板)";
|
|
|
|
|
ListQsdwEntity = new List<QSDWinformation>();
|
|
|
|
|
RemoveQsdwEntity = new List<QSDWinformation>();
|
|
|
|
|
ExcelLists = new List<QSDWinformation>();
|
|
|
|
|
dbPath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetDicDataPath();
|
|
|
|
|
Init();
|
|
|
|
|
frmDicManage = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
LoadTree();
|
|
|
|
|
btnDetailAdd.IsEnabled = false;
|
|
|
|
|
btnDetailEdit.IsEnabled = false;
|
|
|
|
|
btnDetailDel.IsEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("字典界面初始化失败:" + ex.Message);
|
|
|
|
|
MessageHelper.ShowError("字典界面初始化失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNodss"></param>
|
|
|
|
|
/// <param name="IsParent"></param>
|
|
|
|
|
public void LoadTree()
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
DataTable dicType = rdbHelper.ExecuteDatatable("Sys_DicType", " SELECT * FROM Sys_DicType ORDER BY paixu ", true);
|
|
|
|
|
ObservableCollection<TreeNode> itemList = new ObservableCollection<TreeNode>();
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("Sys_DicManage", "SELECT * FROM Sys_DicManage ORDER BY paixu", true);
|
|
|
|
|
foreach (DataRow item in dicType.Rows)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = item["NAME"].ToString(),
|
|
|
|
|
Paixu = Convert.ToInt32(item["paixu"]),
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png",
|
|
|
|
|
IsParent = true,
|
|
|
|
|
Data = item
|
|
|
|
|
};
|
|
|
|
|
node.Nodes = new ObservableCollection<TreeNode>();
|
|
|
|
|
foreach (DataRow drvitem in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
TreeNode childNodeItem = new TreeNode();//树节点赋值属性
|
|
|
|
|
childNodeItem.Name = drvitem["NAME"].ToString();
|
|
|
|
|
childNodeItem.Paixu = Convert.ToInt32(drvitem["PAIXU"]);
|
|
|
|
|
childNodeItem.IsExpanded = true;
|
|
|
|
|
childNodeItem.Data = drvitem;
|
|
|
|
|
childNodeItem.Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png";
|
|
|
|
|
|
|
|
|
|
if (childNodeItem.Name == "权属代码")
|
|
|
|
|
{
|
|
|
|
|
QSXZchildNodeItem = childNodeItem;
|
|
|
|
|
childNodeItem.cMenu = new ContextMenu();
|
|
|
|
|
MenuItem tmpitem = new MenuItem();
|
|
|
|
|
tmpitem.Header = "导入Excel";
|
|
|
|
|
tmpitem.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
var excelfileurl = string.Empty;
|
|
|
|
|
//弹出文件选择对话框
|
|
|
|
|
var openFileDialog = new Microsoft.Win32.OpenFileDialog()
|
|
|
|
|
{
|
|
|
|
|
Filter = "Excel Files(*.xlsx)|*.xlsx"
|
|
|
|
|
};
|
|
|
|
|
var result = openFileDialog.ShowDialog();
|
|
|
|
|
if (result == true)
|
|
|
|
|
{
|
|
|
|
|
ImportExcel(openFileDialog.FileName);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
childNodeItem.cMenu.Items.Add(tmpitem);
|
|
|
|
|
tmpitem = new MenuItem();
|
|
|
|
|
tmpitem.Header = "导出样式表";
|
|
|
|
|
tmpitem.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
var excelfileurl = "";
|
|
|
|
|
//弹出文件选择对话框
|
|
|
|
|
var saveFileDialog = new Microsoft.Win32.SaveFileDialog()
|
|
|
|
|
{
|
|
|
|
|
Filter = "Excel Files(*.xlsx)|*.xlsx"
|
|
|
|
|
};
|
|
|
|
|
var result = saveFileDialog.ShowDialog();
|
|
|
|
|
if (result.Value)
|
|
|
|
|
{
|
|
|
|
|
excelfileurl = saveFileDialog.FileName;
|
|
|
|
|
var sourcesfile = AppDomain.CurrentDomain.BaseDirectory + @"工作空间\模板\字典模板\权属单位代码样式表.xlsx";
|
|
|
|
|
if (System.IO.File.Exists(sourcesfile))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Copy(sourcesfile, excelfileurl, true);
|
|
|
|
|
if (MessageHelper.ShowYesNoAndTips("样式表导出成功,是否打开?") == System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
Process.Start(excelfileurl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("导出样式表失败,错误信息:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("样式表文件不存在,导出失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
childNodeItem.cMenu.Items.Add(tmpitem);
|
|
|
|
|
}
|
|
|
|
|
node.Nodes.Add(childNodeItem);
|
|
|
|
|
}
|
|
|
|
|
itemList.Add(node);
|
|
|
|
|
}
|
|
|
|
|
this.tvTypes.ItemsSource = null;
|
|
|
|
|
this.tvTypes.ItemsSource = itemList;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("数据加载异常!" + ex.Message);
|
|
|
|
|
LogAPI.Debug("LoadTree异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("LoadTree异常:" + ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回指示文件是否已被其它程序使用的布尔值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileFullName">文件的完全限定名,例如:“C:\MyFile.txt”。</param>
|
|
|
|
|
/// <returns>如果文件已被其它程序使用,则为 true;否则为 false。</returns>
|
|
|
|
|
public Boolean FileIsUsed(String fileFullName)
|
|
|
|
|
{
|
|
|
|
|
Boolean result = false;
|
|
|
|
|
//判断文件是否存在,如果不存在,直接返回 false
|
|
|
|
|
if (!System.IO.File.Exists(fileFullName))
|
|
|
|
|
{
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//如果文件存在,则继续判断文件是否已被其它程序使用
|
|
|
|
|
//逻辑:尝试执行打开文件的操作,如果文件已经被其它程序使用,则打开失败,抛出异常,根据此类异常可以判断文件是否已被其它程序使用。
|
|
|
|
|
System.IO.FileStream fileStream = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
fileStream = System.IO.File.Open(fileFullName, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
catch (System.IO.IOException)
|
|
|
|
|
{
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
catch (System.Exception)
|
|
|
|
|
{
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (fileStream != null)
|
|
|
|
|
{
|
|
|
|
|
fileStream.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理字典数据(区分县级与村级权属代码)
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Run()
|
|
|
|
|
{
|
|
|
|
|
ListQsdwEntity.ForEach(item =>
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.ZLDWDM) == false && string.IsNullOrWhiteSpace(item.Qsdwdm) == false)
|
|
|
|
|
{
|
|
|
|
|
if (item.ZLDWDM.Length == 12)
|
|
|
|
|
{
|
|
|
|
|
item.ZLDWDM = item.ZLDWDM.PadRight(19, '0');
|
|
|
|
|
}
|
|
|
|
|
if (item.ZLDWDM.Length != 19)
|
|
|
|
|
{
|
|
|
|
|
item.HasCheck = false;
|
|
|
|
|
}
|
|
|
|
|
if (item.Qsdwdm.Length == 12)
|
|
|
|
|
{
|
|
|
|
|
item.Qsdwdm = item.Qsdwdm.PadRight(19, '0');
|
|
|
|
|
}
|
|
|
|
|
if (item.Qsdwdm.Length != 19)
|
|
|
|
|
{
|
|
|
|
|
item.HasCheck = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item.HasCheck = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<QSDWinformation> remove = ListQsdwEntity.FindAll(f => f.HasCheck == false);
|
|
|
|
|
for (int i = 0; i < remove.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
RemoveQsdwEntity.Add(remove[i]);
|
|
|
|
|
ListQsdwEntity.Remove(remove[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string QsdmID = null;
|
|
|
|
|
private List<QSDWinformation> ListQsdm = null;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 处理字典数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="XJCode"></param>
|
|
|
|
|
/// <param name="XJName"></param>
|
|
|
|
|
public void OrderBy(string XJCode, string XJName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (ListQsdwEntity != null && ListQsdwEntity.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string XJName_Temp = string.Empty;
|
|
|
|
|
ListQsdm = new List<QSDWinformation>();
|
|
|
|
|
var GroupEntity = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 19).GroupBy(x => x.ZLDWDM.Substring(0, 9)).Select(x => x.Key).ToList();
|
|
|
|
|
string skajh = string.Empty;
|
|
|
|
|
if (ListQsdwEntity.FirstOrDefault(x => x.Qsdwmc == "部队") != null)
|
|
|
|
|
skajh = ListQsdwEntity.FirstOrDefault(x => x.Qsdwmc == "部队").Qsdwdm;
|
|
|
|
|
if (ListQsdwEntity.FirstOrDefault(x => x.Qsdwdm == XJCode.PadRight(19, '0')) != null)
|
|
|
|
|
XJName_Temp = ListQsdwEntity.FirstOrDefault(x => x.Qsdwdm == XJCode.PadRight(19, '0')).Qsdwmc;
|
|
|
|
|
foreach (var item in GroupEntity)//截取乡镇权属代码
|
|
|
|
|
{
|
|
|
|
|
QSDWinformation Qsdm = new QSDWinformation();
|
|
|
|
|
Qsdm.ZLDWDM = item;
|
|
|
|
|
Qsdm.Qsdwdm = item;
|
|
|
|
|
if (item == XJCode.PadRight(9, '0') && XJName_Temp != XJName)//特殊状况(非飞入地,且与当前县级权属代码一致)
|
|
|
|
|
{
|
|
|
|
|
Qsdm.Qsdwmc = XJName_Temp;
|
|
|
|
|
Qsdm.Zldwmc = XJName_Temp;
|
|
|
|
|
Qsdm.ListQsdwInfor = null;
|
|
|
|
|
ListQsdm.Add(Qsdm);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string sXian_Temp1 = "";
|
|
|
|
|
if (ExcelLists != null && ExcelLists.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ExcelLists.Count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ExcelLists[i].ZLDWDM == item.ToString())
|
|
|
|
|
{
|
|
|
|
|
sXian_Temp1 = ExcelLists[i].Qsdwmc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Qsdm.Qsdwmc = string.IsNullOrWhiteSpace(sXian_Temp1) == true ? ExcelLists.FirstOrDefault(p => p.ZLDWDM.PadRight(19, '0').Substring(0, 9) == item.ToString()).Qsdwmc : sXian_Temp1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string sXian_Temp2 = "";
|
|
|
|
|
if (ExcelLists != null && ExcelLists.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ExcelLists.Count(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (ExcelLists[i].ZLDWDM == item.ToString())
|
|
|
|
|
{
|
|
|
|
|
sXian_Temp2 = ExcelLists[i].Zldwmc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qsdm.Zldwmc = string.IsNullOrWhiteSpace(sXian_Temp2) == true ? ExcelLists.FirstOrDefault(p => p.ZLDWDM.PadRight(19, '0').Substring(0, 9) == item.ToString()).Zldwmc : sXian_Temp2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<QSDWinformation> ListCjQsdm = new List<QSDWinformation>();
|
|
|
|
|
var CJGroupEntity = ListQsdwEntity.Where(x => x.HasCheck).GroupBy(x => x.ZLDWDM.Substring(0, 12)).OrderBy(x => x.Key).Select(x => x.Key).Distinct().ToList();
|
|
|
|
|
var tmpcjglist = CJGroupEntity.Where(x => x.Substring(0, 9) == item).ToList();
|
|
|
|
|
foreach (var CJitem in tmpcjglist)//截取村级权属代码
|
|
|
|
|
{
|
|
|
|
|
QSDWinformation CjQsdm = new QSDWinformation();
|
|
|
|
|
CjQsdm.Qsdwdm = ExcelLists.FirstOrDefault(p =>
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
if (p.ZLDWDM.Length > 12)
|
|
|
|
|
{
|
|
|
|
|
result = p.ZLDWDM.Substring(0, 12) == CJitem.ToString();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}).Qsdwdm;
|
|
|
|
|
CjQsdm.ZLDWDM = ExcelLists.FirstOrDefault(p =>
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
if (p.ZLDWDM.Length > 12)
|
|
|
|
|
{
|
|
|
|
|
result = p.ZLDWDM.Substring(0, 12) == CJitem.ToString();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}).ZLDWDM;
|
|
|
|
|
CjQsdm.Qsdwmc = ExcelLists.FirstOrDefault(p =>
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
if (p.ZLDWDM.Length > 12)
|
|
|
|
|
{
|
|
|
|
|
result = p.ZLDWDM.Substring(0, 12) == CJitem.ToString();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}).Qsdwmc;
|
|
|
|
|
CjQsdm.Zldwmc = ExcelLists.FirstOrDefault(p =>
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
if (p.ZLDWDM.Length > 12)
|
|
|
|
|
{
|
|
|
|
|
result = p.ZLDWDM.Substring(0, 12) == CJitem.ToString();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}).Zldwmc;
|
|
|
|
|
#region
|
|
|
|
|
var cjlist = ListQsdwEntity.Where(x => x.ZLDWDM.StartsWith(CJitem)).ToList();
|
|
|
|
|
var keylist = cjlist.Select(x => x.ZLDWDM).Distinct().ToList();
|
|
|
|
|
foreach (var citem in keylist)
|
|
|
|
|
{
|
|
|
|
|
List<QSDWinformation> ListCjDMQsdm = new List<QSDWinformation>();
|
|
|
|
|
var CJDMGroupEntity = ListQsdwEntity.Where(x => x.HasCheck).GroupBy(x => x.Qsdwdm).Select(x => x.Key).Distinct().ToList();
|
|
|
|
|
var tmpglist = CJDMGroupEntity.Where(x => x.Substring(0, 12) == CJitem).ToList();
|
|
|
|
|
foreach (var CJDMitem in tmpglist)//获取村级代码
|
|
|
|
|
{
|
|
|
|
|
var cjkeylist = ListQsdwEntity.Where(x => x.HasCheck && x.Qsdwdm == CJDMitem).Distinct().ToList();
|
|
|
|
|
foreach (var itemsD in cjkeylist)//获取村级小组权属代码名称
|
|
|
|
|
{
|
|
|
|
|
var cu = ListCjDMQsdm.Count(x => x.Qsdwdm == CJDMitem && x.Qsdwmc == itemsD.Qsdwmc);
|
|
|
|
|
if (cu == 0)
|
|
|
|
|
{
|
|
|
|
|
QSDWinformation CjDMQsdm = new QSDWinformation();
|
|
|
|
|
CjDMQsdm.Qsdwdm = CJDMitem;
|
|
|
|
|
CjDMQsdm.Qsdwmc = itemsD.Qsdwmc;
|
|
|
|
|
ListCjDMQsdm.Add(CjDMQsdm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CjQsdm.ListQsdwInfor = ListCjDMQsdm;
|
|
|
|
|
}
|
|
|
|
|
ListCjQsdm.Add(CjQsdm);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
Qsdm.ListQsdwInfor = ListCjQsdm;
|
|
|
|
|
ListQsdm.Add(Qsdm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查数据库是否已经存在权属单位代码字典
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void CheckExist(TreeNode selectnode)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
DataRow selectitemrow = selectnode.Data as DataRow;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("打开数据库连接失败!");
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.BeginTransaction();
|
|
|
|
|
DataTable dtDict = rdbHelper.ExecuteDatatable("Sys_DicType", "select * from Sys_DicManage where NAME='权属代码'", true);
|
|
|
|
|
|
|
|
|
|
//数据库已存在
|
|
|
|
|
if (dtDict != null && dtDict.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
QsdmID = dtDict.Rows[0]["ID"].ToString();
|
|
|
|
|
DataTable dtDetail = rdbHelper.ExecuteDatatable("Sys_DicDetail", "select * from Sys_DicDetail where OWNERDIC='" + QsdmID + "'", true);
|
|
|
|
|
if (dtDetail != null && dtDetail.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.ShowLoading("正在导入字典......", 0, 0);
|
|
|
|
|
//先删除数据库已存在的字典
|
|
|
|
|
int insertCount = rdbHelper.ExecuteSQL("DELETE FROM Sys_DicManage WHERE NAME = '权属代码' AND TYPE=1");
|
|
|
|
|
|
|
|
|
|
if (insertCount < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("删除已存在字典失败!");
|
|
|
|
|
}
|
|
|
|
|
insertCount = rdbHelper.ExecuteSQL("DELETE FROM Sys_DicDetail WHERE OWNERDIC = '" + QsdmID + "'");
|
|
|
|
|
if (insertCount < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("删除已存在字典失败!");
|
|
|
|
|
}
|
|
|
|
|
//插入Sys_DicManage表
|
|
|
|
|
insertCount = rdbHelper.ExecuteSQL("INSERT INTO Sys_DicManage (NAME,ALIASNAME,TYPE,REMARK,PAIXU)" + "VALUES ('权属代码','QSDM',1,'',0)");
|
|
|
|
|
if (insertCount < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("导入字典失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//数据库不存在权属单位代码字典
|
|
|
|
|
{
|
|
|
|
|
this.ShowLoading("正在导入字典......", 0, 0);
|
|
|
|
|
//插入Sys_DicManage表
|
|
|
|
|
int insertCount = rdbHelper.ExecuteSQL("INSERT INTO Sys_DicManage (NAME,ALIASNAME,TYPE,REMARK,PAIXU)" + "VALUES ('权属代码','QSDM',1,'',0)");
|
|
|
|
|
if (insertCount < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("导入字典失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
InserDataDic(rdbHelper);
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
if (FJFid != null)
|
|
|
|
|
{
|
|
|
|
|
selectitemrow["id"] = FJFid;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.Commit();
|
|
|
|
|
//从新加载树
|
|
|
|
|
LoadChildTree(selectnode);
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
MessageHelper.ShowTips("导入字典成功!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.Rollback();
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
MessageHelper.ShowError(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this.CloseLoading();
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool InserDataLsitSon(IRDBHelper rdbHelper, string pParendXZQDM = "")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (ListQsdm != null && ListQsdm.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in ListQsdm)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pParendXZQDM) && !item.Qsdwdm.StartsWith(pParendXZQDM))
|
|
|
|
|
continue;
|
|
|
|
|
string strSql = string.Format("insert into Sys_DicDetail(PID,NAME,CODE,OWNERDIC,REMARK,PAIXU) VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", XJFid, item.Zldwmc, item.ZLDWDM, FJFid, "", 0);
|
|
|
|
|
if (rdbHelper.ExecuteSQL(strSql) > 0)
|
|
|
|
|
{
|
|
|
|
|
DataTable dts = rdbHelper.ExecuteDatatable("XjTable", string.Format("select id from Sys_DicDetail where PID='{0}' and NAME='{1}' and CODE='{2}' and OWNERDIC='{3}'", XJFid, item.Zldwmc, item.ZLDWDM, FJFid), true);
|
|
|
|
|
if (item.ListQsdwInfor == null) continue;//特殊情况
|
|
|
|
|
foreach (var CJitem in item.ListQsdwInfor)
|
|
|
|
|
{
|
|
|
|
|
if (dts == null || dts.Rows.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string strSqlCJ = string.Format("insert into Sys_DicDetail(PID,NAME,CODE,OWNERDIC,REMARK,PAIXU) VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", dts.Rows[0]["ID"].ToString(), CJitem.Zldwmc, CJitem.ZLDWDM, FJFid, "", 0);
|
|
|
|
|
if (rdbHelper.ExecuteSQL(strSqlCJ) <= 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
DataTable dtCJDM = rdbHelper.ExecuteDatatable("CJDMTables", string.Format("select id from Sys_DicDetail where PID='{0}' and NAME='{1}' and CODE='{2}' and OWNERDIC='{3}'", dts.Rows[0]["ID"].ToString(), CJitem.Zldwmc, CJitem.ZLDWDM, FJFid), true);
|
|
|
|
|
if (CJitem.ListQsdwInfor == null || CJitem.ListQsdwInfor.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (CJitem.ListQsdwInfor == null) continue;//特殊情况
|
|
|
|
|
foreach (var CJDMitem in CJitem.ListQsdwInfor)
|
|
|
|
|
{
|
|
|
|
|
string CJDMstrSql = string.Format("insert into Sys_DicDetail(PID,NAME,CODE,OWNERDIC,REMARK,PAIXU) VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", dtCJDM.Rows[0]["ID"].ToString(), CJDMitem.Qsdwmc, CJDMitem.Qsdwdm, FJFid, "", 0);
|
|
|
|
|
if (rdbHelper.ExecuteSQL(CJDMstrSql) < 1)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false; ;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
// rdbHelper.Rollback();
|
|
|
|
|
return false;
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入字典数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="rdbHelper">数据库连接</param>
|
|
|
|
|
private void InserDataDic(IRDBHelper rdbHelper)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataTable QuerySon = rdbHelper.ExecuteDatatable("QuerySon", "SELECT ID FROM Sys_DicManage WHERE NAME='权属代码'", false);
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
if (QuerySon == null || QuerySon.Rows.Count <= 0)
|
|
|
|
|
return;
|
|
|
|
|
foreach (var item in ShengInfo2)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.Qsdwdm))
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", "", item.Qsdwmc.Trim(), item.Qsdwdm, QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", "", item.Qsdwmc.Trim(), item.Qsdwmc, QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
int insertCount = rdbHelper.ExecuteSQL(strSql);
|
|
|
|
|
if (insertCount <= 0) return;
|
|
|
|
|
DataTable QueryQSSon = null;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.Qsdwdm))
|
|
|
|
|
{
|
|
|
|
|
QueryQSSon = rdbHelper.ExecuteDatatable("QueryQS", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='' AND CODE='{1}' AND OWNERDIC='{2}'", item.Qsdwmc.Trim(), item.Qsdwdm, QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QueryQSSon = rdbHelper.ExecuteDatatable("QueryQS", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='' AND CODE='{1}' AND OWNERDIC='{2}'", item.Qsdwmc.Trim(), item.Qsdwmc.Trim(), QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
if (QueryQSSon == null || QueryQSSon.Rows.Count <= 0) return;
|
|
|
|
|
foreach (var shi in ShiInfo2)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(shi.Qsdwdm))
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", QueryQSSon.Rows[0]["ID"].ToString(), shi.Qsdwmc.Trim(), shi.Qsdwdm, QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", QueryQSSon.Rows[0]["ID"].ToString(), shi.Qsdwmc.Trim(), shi.Qsdwmc.Trim(), QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
insertCount = rdbHelper.ExecuteSQL(strSql);
|
|
|
|
|
if (insertCount <= 0) return;
|
|
|
|
|
DataTable QueryQSSons = null;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(shi.Qsdwdm))
|
|
|
|
|
{
|
|
|
|
|
QueryQSSons = rdbHelper.ExecuteDatatable("QueryQSs", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='{1}' AND CODE='{2}' AND OWNERDIC='{3}'", shi.Qsdwmc.Trim(), QueryQSSon.Rows[0]["ID"].ToString(), shi.Qsdwdm, QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QueryQSSons = rdbHelper.ExecuteDatatable("QueryQSs", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='{1}' AND CODE='{2}' AND OWNERDIC='{3}'", shi.Qsdwmc.Trim(), QueryQSSon.Rows[0]["ID"].ToString(), shi.Qsdwdm.Trim(), QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
if (QueryQSSons == null || QueryQSSons.Rows.Count <= 0) return;
|
|
|
|
|
foreach (var xian in XianInfo2)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(xian.Qsdwdm))
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", QueryQSSons.Rows[0]["ID"].ToString(), xian.Qsdwmc.Trim(), xian.Qsdwdm, QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = string.Format("insert into Sys_DicDetail (PID,NAME,CODE,OWNERDIC,REMARK,PAIXU)" + "VALUES ('{0}','{1}','{2}','{3}','{4}',{5})", QueryQSSons.Rows[0]["ID"].ToString(), xian.Qsdwmc.Trim(), xian.Qsdwmc.Trim(), QuerySon.Rows[0]["ID"].ToString(), "", 0);
|
|
|
|
|
}
|
|
|
|
|
insertCount = rdbHelper.ExecuteSQL(strSql);
|
|
|
|
|
if (insertCount <= 0) return;
|
|
|
|
|
DataTable QueryQSSonsd = null;
|
|
|
|
|
if (xian.Qsdwdm != "")
|
|
|
|
|
{
|
|
|
|
|
QueryQSSonsd = rdbHelper.ExecuteDatatable("QueryQSsd", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='{1}' AND CODE='{2}' AND OWNERDIC='{3}'", xian.Qsdwmc.Trim(), QueryQSSons.Rows[0]["ID"].ToString(), xian.Qsdwdm, QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QueryQSSonsd = rdbHelper.ExecuteDatatable("QueryQSsd", string.Format("SELECT ID FROM Sys_DicDetail WHERE NAME='{0}' AND PID='{1}' AND CODE='{2}' AND OWNERDIC='{3}'", xian.Qsdwmc.Trim(), QueryQSSons.Rows[0]["ID"].ToString(), xian.Qsdwmc.Trim(), QuerySon.Rows[0]["ID"].ToString()), true);
|
|
|
|
|
}
|
|
|
|
|
if (QueryQSSonsd != null && QueryQSSonsd.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
XJFid = QueryQSSonsd.Rows[0]["ID"].ToString();
|
|
|
|
|
FJFid = QuerySon.Rows[0]["ID"].ToString();
|
|
|
|
|
InserDataLsitSon(rdbHelper, xian.Qsdwdm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 左侧字典树选择改变事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void tvProperties_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
|
|
|
{
|
|
|
|
|
TreeNode item = this.tvTypes.SelectedItem as TreeNode;
|
|
|
|
|
LoadChildTree(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadChildTree(TreeNode item)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.btnAdd.IsEnabled = true;
|
|
|
|
|
txtDicName.Text = string.Empty;
|
|
|
|
|
txtCode.Text = string.Empty;
|
|
|
|
|
txtAliasName.Text = string.Empty;
|
|
|
|
|
txtParentName.Text = string.Empty;
|
|
|
|
|
txtRemark.Text = string.Empty;
|
|
|
|
|
tvDicDetail.ItemsSource = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item == null || item.Data == null || (item.Data as DataRow) == null)
|
|
|
|
|
return;
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
txtDicName.Text = drv["Name"] == null ? "" : drv["Name"].ToString();
|
|
|
|
|
txtRemark.Text = drv["REMARK"] == null ? "" : drv["REMARK"].ToString();
|
|
|
|
|
txtAliasName.Text = drv["ALIASNAME"] == null ? "" : drv["ALIASNAME"].ToString();
|
|
|
|
|
if (item.IsParent == false)
|
|
|
|
|
{
|
|
|
|
|
this.btnAdd.IsEnabled = false;
|
|
|
|
|
txtDicID.Text = drv["ID"] == null ? "" : drv["ID"].ToString();
|
|
|
|
|
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
DataTable dtDict = rdbHelper.ExecuteDatatable("Sys_DicType", "SELECT * FROM Sys_DicType WHERE ID = " + drv["TYPE"].ToString(), true);
|
|
|
|
|
if (dtDict != null && dtDict.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
txtParentName.Text = dtDict.Rows[0]["NAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
//绑定树
|
|
|
|
|
LoadChildTree(drv);
|
|
|
|
|
btnDetailAdd.IsEnabled = true;
|
|
|
|
|
btnDetailEdit.IsEnabled = true;
|
|
|
|
|
btnDetailDel.IsEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnDetailAdd.IsEnabled = false; ;
|
|
|
|
|
btnDetailEdit.IsEnabled = false;
|
|
|
|
|
btnDetailDel.IsEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("显示字典详情异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载左侧选中字典的子节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="drv"></param>
|
|
|
|
|
/// <param name="IsDic"></param>
|
|
|
|
|
private void LoadChildTree(DataRow drv)
|
|
|
|
|
{
|
|
|
|
|
if (drv == null)
|
|
|
|
|
return;
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
DataTable dtDic = rdbHelper.ExecuteDatatable("Sys_DicDetail", string.Format("SELECT * FROM Sys_DicDetail WHERE OWNERDIC='{0}' ORDER BY PAIXU", drv["ID"]), true);
|
|
|
|
|
ObservableCollection<DicTreeNode> itemList = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
DicTreeNode node = new DicTreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = drv["NAME"] == null ? "" : drv["NAME"].ToString(),
|
|
|
|
|
Paixu = Convert.ToInt32(drv["paixu"]),
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png",
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
IsParent = true,
|
|
|
|
|
Data = drv
|
|
|
|
|
};
|
|
|
|
|
node.Nodes = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
DataRow[] dataRow = dtDic.Select("PID IS NULL OR PID=''", "PAIXU,CODE ASC");
|
|
|
|
|
if (dataRow != null || dataRow.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow dr in dataRow)
|
|
|
|
|
{
|
|
|
|
|
DicTreeNode subNodeItem = new DicTreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = "[" + dr["CODE"].ToString() + "]" + dr["NAME"].ToString(),
|
|
|
|
|
Paixu = Convert.ToInt32(dr["paixu"]),
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png",
|
|
|
|
|
Data = dr
|
|
|
|
|
};
|
|
|
|
|
if (dr["ID"] != null && !string.IsNullOrWhiteSpace(dr["ID"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
GetSubDic(subNodeItem, dr["ID"].ToString(), dtDic);
|
|
|
|
|
}
|
|
|
|
|
node.Nodes.Add(subNodeItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
itemList.Add(node);
|
|
|
|
|
this.tvDicDetail.ItemsSource = itemList;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("数据加载异常!" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetSubDic(DicTreeNode treeNode, string id, DataTable dt)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
treeNode.Nodes = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
DataRow[] drs = null;
|
|
|
|
|
if (dt.Columns.Contains("CODE"))
|
|
|
|
|
{
|
|
|
|
|
drs = dt.Select(" PID= '" + id + "'", "PAIXU,CODE ASC");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
drs = dt.Select(" PID= '" + id + "'", "PAIXU ASC");
|
|
|
|
|
}
|
|
|
|
|
if (drs == null || drs.Count() <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (DataRow dr in drs)
|
|
|
|
|
{
|
|
|
|
|
DicTreeNode subNodeItem = new DicTreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = "[" + dr["CODE"].ToString() + "]" + dr["NAME"].ToString(),
|
|
|
|
|
Paixu = Convert.ToInt32(dr["paixu"]),
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DataDictionary;component/Resources/zrz.png",
|
|
|
|
|
Data = dr
|
|
|
|
|
};
|
|
|
|
|
if (dr["ID"] == null || string.IsNullOrWhiteSpace(dr["ID"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
continue; ;
|
|
|
|
|
}
|
|
|
|
|
GetSubDic(subNodeItem, dr["ID"].ToString(), dt);
|
|
|
|
|
treeNode.Nodes.Add(subNodeItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//关闭
|
|
|
|
|
private void btnClose_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加字典(左侧树添加)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ParentTable = null;
|
|
|
|
|
txtNames = null;
|
|
|
|
|
txtParent = false;
|
|
|
|
|
int IndexInfo = 0;
|
|
|
|
|
//白明雅 2018-12-28 bug13997
|
|
|
|
|
DicTreeNode item = GetDicTreeNodeByTreeNode(this.tvTypes.SelectedItem as TreeNode);
|
|
|
|
|
//DicTreeNode item = this.tvTypes.SelectedItem as DicTreeNode;
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请选择节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < this.tvTypes.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (item.Name.Trim() == (GetDicTreeNodeByTreeNode(this.tvTypes.Items[i] as TreeNode)).Name.Trim())
|
|
|
|
|
{
|
|
|
|
|
IndexInfo = i + 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DataDicEdit main = new DataDicEdit(IndexInfo);
|
|
|
|
|
main.actionUpdate = action_Update;
|
|
|
|
|
main.Height = 410;
|
|
|
|
|
main.Width = 550;
|
|
|
|
|
main.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
|
|
|
|
|
//关闭窗体之后刷新tree控件
|
|
|
|
|
bool temp = main.ShowInMainWindow(true).Value;
|
|
|
|
|
if (!temp)
|
|
|
|
|
{
|
|
|
|
|
//CustomLogAPI.WriteSystemOperationLog("数据新增", this.Title);
|
|
|
|
|
if (txtNames == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (item == null || ((item != null) && txtParent))
|
|
|
|
|
{
|
|
|
|
|
//白明雅 2018-12-28 bug13997
|
|
|
|
|
//ObservableCollection<DicTreeNode> treeNodes = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
ObservableCollection<DicTreeNode> treeNodes = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
treeNodes.Add(txtNames);
|
|
|
|
|
var paixu = treeNodes.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (item == null || txtParent)//判断是否是父节点
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//当前对主Treeview二级菜单进行操作 白明雅 2018-12-28
|
|
|
|
|
//ObservableCollection<DicTreeNode> itemsd = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
ObservableCollection<DicTreeNode> itemsd = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
if (ParentTable != null && ParentTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var items in itemsd)
|
|
|
|
|
{
|
|
|
|
|
DataRow itemData = items.Data as DataRow;
|
|
|
|
|
if (itemData == null || itemData["ID"].ToString() != ParentTable.Rows[0]["ID"].ToString())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (item.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> Nodesd = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
Nodesd.Add(txtNames);
|
|
|
|
|
items.Nodes = Nodesd;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Add(txtNames);
|
|
|
|
|
var paixus = items.Nodes.OrderBy(p => p.Paixu).ToArray();
|
|
|
|
|
if (paixus != null)
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixus)
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LoadTree();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//当前对根目录(第一级)菜单进行操作 白明雅 2018-12-28
|
|
|
|
|
//ObservableCollection<DicTreeNode> treeNodes = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
ObservableCollection<DicTreeNode> treeNodes = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
treeNodes.Add(txtNames);
|
|
|
|
|
treeNodes.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
ObservableCollection<DicTreeNode> treeNo = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
var sortedOC = from items in treeNodes
|
|
|
|
|
orderby items.Paixu
|
|
|
|
|
select items;
|
|
|
|
|
foreach (var i in sortedOC)
|
|
|
|
|
{
|
|
|
|
|
treeNo.Add(i);
|
|
|
|
|
}
|
|
|
|
|
this.tvTypes.ItemsSource = treeNo;
|
|
|
|
|
}
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("添加节点异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DicTreeNode txtNames = null;
|
|
|
|
|
bool txtParent = false;
|
|
|
|
|
//保存父节点信息
|
|
|
|
|
DataTable ParentTable = null;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加父级节点更新方法
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ss"></param>
|
|
|
|
|
/// <param name="ssd"></param>
|
|
|
|
|
void action_Update(bool ParentName, DicTreeNode treeNodes, string fjdID)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
ParentTable = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (fjdID == null)
|
|
|
|
|
return;
|
|
|
|
|
if (fjdID != "")
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
DataTable dtCat = rdbHelper.ExecuteDatatable("Sys_DicType", "select * from Sys_DicType where id=" + fjdID + " order by paixu", true);
|
|
|
|
|
if (dtCat != null && dtCat.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ParentTable = dtCat;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
txtParent = ParentName;
|
|
|
|
|
txtNames = treeNodes;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 由于SelectedItem转换DicTreeNode失败,加此方法,用于手动转换
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tree">要转换的树节点</param>
|
|
|
|
|
/// <returns>转换后的DicTreeNode</returns>
|
|
|
|
|
/// 白明雅 2018-12-27
|
|
|
|
|
private DicTreeNode GetDicTreeNodeByTreeNode(TreeNode tree)
|
|
|
|
|
{
|
|
|
|
|
if (tree == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
IList<TreeNode> treeNodes = tree.Nodes;
|
|
|
|
|
ObservableCollection<DicTreeNode> dicTreeNodes = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
if (treeNodes != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (TreeNode item in treeNodes)
|
|
|
|
|
{
|
|
|
|
|
dicTreeNodes.Add(GetDicTreeNodeByTreeNode(item));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DicTreeNode node = new DicTreeNode()
|
|
|
|
|
{
|
|
|
|
|
Icon = tree.Icon,
|
|
|
|
|
Data = tree.Data,
|
|
|
|
|
Checked = tree.Checked,
|
|
|
|
|
cMenu = tree.cMenu,
|
|
|
|
|
Name = tree.Name,
|
|
|
|
|
Nodes = dicTreeNodes,
|
|
|
|
|
IsExpanded = tree.IsExpanded,
|
|
|
|
|
IsOpenEdit = tree.IsOpenEdit,
|
|
|
|
|
IsParent = tree.IsParent,
|
|
|
|
|
Paixu = (int)tree.Paixu
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据TreeNode数组转化为DicTreeNode数组
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tree"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// 白明雅 2018-12-27
|
|
|
|
|
private DicTreeNode[] GetDicTreeNodeListByTreeNode(TreeNode[] tree)
|
|
|
|
|
{
|
|
|
|
|
DicTreeNode[] dicTrees = new DicTreeNode[tree.Length];
|
|
|
|
|
for (int i = 0; i < tree.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
dicTrees[i] = GetDicTreeNodeByTreeNode(tree[i]);
|
|
|
|
|
}
|
|
|
|
|
return dicTrees;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ItemsSource转化ObservableCollection<DicTreeNode>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNodes">this.tvTypes.ItemsSource.Cast<TreeNode>()</param>
|
|
|
|
|
/// <returns>ObservableCollection<DicTreeNode></returns>
|
|
|
|
|
/// 白明雅 2018-12-27
|
|
|
|
|
private ObservableCollection<DicTreeNode> IEnumerableToDicTreeNode(IEnumerable<TreeNode> treeNodes)
|
|
|
|
|
{
|
|
|
|
|
//IEnumerable<TreeNode> treeNodes = this.tvTypes.ItemsSource.Cast<TreeNode>();
|
|
|
|
|
TreeNode treeNode = treeNodes.First<TreeNode>() as TreeNode;
|
|
|
|
|
DicTreeNode dicTree = GetDicTreeNodeByTreeNode(treeNode);
|
|
|
|
|
ObservableCollection<DicTreeNode> UpdateNode = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
UpdateNode.Add(dicTree);
|
|
|
|
|
return UpdateNode;
|
|
|
|
|
}
|
|
|
|
|
//父节点编辑
|
|
|
|
|
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
txtNames = null;
|
|
|
|
|
//白明雅 2018-12-27 bug13997
|
|
|
|
|
TreeNode obj = this.tvTypes.SelectedItem as TreeNode;
|
|
|
|
|
DicTreeNode item = GetDicTreeNodeByTreeNode(obj);
|
|
|
|
|
//----------------------------
|
|
|
|
|
//父窗体中子节点修改
|
|
|
|
|
if (item == null || item.Data == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请先选中需要编辑的节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DataDicEdit main = new DataDicEdit(0, true);
|
|
|
|
|
main.Height = 410;
|
|
|
|
|
main.Width = 550;
|
|
|
|
|
main.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
|
|
|
|
|
main.actionUpdate = action_Update;
|
|
|
|
|
main.IsParent = item.IsParent;
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
main.InitPage(drv);
|
|
|
|
|
bool temp = main.ShowInMainWindow(true).Value;
|
|
|
|
|
//关闭窗体之后刷新tree控件
|
|
|
|
|
if (!temp)
|
|
|
|
|
{
|
|
|
|
|
if (txtNames == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//白明雅 2018-12-27 bug13997
|
|
|
|
|
ObservableCollection<DicTreeNode> UpdateNode = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
//------------------------------------
|
|
|
|
|
//白明雅 2018-12-27 转换失败 换上面方法
|
|
|
|
|
//ObservableCollection<DicTreeNode> UpdateNode = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
if (item.IsParent)
|
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
while ((index = UpdateNode.FindIndex(o => o == item)) >= 0)
|
|
|
|
|
{
|
|
|
|
|
UpdateNode[index].Name = txtNames.Name;
|
|
|
|
|
UpdateNode[index].Data = txtNames.Data;
|
|
|
|
|
UpdateNode[index].Paixu = txtNames.Paixu;
|
|
|
|
|
DataRow drvS = UpdateNode[index].Data as DataRow;
|
|
|
|
|
txtDicName.Text = drvS["Name"].ToString();
|
|
|
|
|
txtCode.Text = "";
|
|
|
|
|
txtAliasName.Text = drvS["ALIASNAME"].ToString();
|
|
|
|
|
txtRemark.Text = drvS["REMARK"].ToString();
|
|
|
|
|
var paixu = UpdateNode.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateNode.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
UpdateNode.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
// this.tvTypes.ItemsSource = treeNodes;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var items in UpdateNode)
|
|
|
|
|
{
|
|
|
|
|
DataRow drvs = items.Data as DataRow;
|
|
|
|
|
if (drvs["ID"].ToString() == drv["TYPE"].ToString())
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Remove(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var items in UpdateNode)
|
|
|
|
|
{
|
|
|
|
|
DataRow updateTree = txtNames.Data as DataRow;
|
|
|
|
|
DataRow drvs = items.Data as DataRow;
|
|
|
|
|
if (drvs["ID"].ToString() == updateTree["TYPE"].ToString())
|
|
|
|
|
{
|
|
|
|
|
if (items.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> NewUpdateNode = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
NewUpdateNode.Add(txtNames);
|
|
|
|
|
items.Nodes = NewUpdateNode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Add(txtNames);
|
|
|
|
|
}
|
|
|
|
|
var paixu = (items.Nodes).OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("父节点编辑异常,请重试:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//父节点删除
|
|
|
|
|
private void btnDel_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//白明雅 2018-12-17 bug13997
|
|
|
|
|
TreeNode node = this.tvTypes.SelectedItem as TreeNode;
|
|
|
|
|
DicTreeNode item = GetDicTreeNodeByTreeNode(node);
|
|
|
|
|
//------------------
|
|
|
|
|
//DicTreeNode item = this.tvTypes.SelectedItem as DicTreeNode;
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请您选择要删除的节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (MessageHelper.ShowYesNoAndWarning("您确认要删除【" + item.Name + "】节点!") == System.Windows.Forms.DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
if (drv == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string pid = drv["id"].ToString();
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
if (item.IsParent)
|
|
|
|
|
{
|
|
|
|
|
string sIDS = string.Empty;
|
|
|
|
|
int res = -1;
|
|
|
|
|
DataTable dtDic = rdbHelper.ExecuteDatatable("Sys_DicManage", string.Format("select * from Sys_DicManage where TYPE={0} ", pid), false);
|
|
|
|
|
foreach (DataRow dritem in dtDic.Rows)
|
|
|
|
|
{
|
|
|
|
|
sIDS += string.Format("'{0}',", dritem["ID"]);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(sIDS))
|
|
|
|
|
{
|
|
|
|
|
//首先删除子项
|
|
|
|
|
strSql = "delete from Sys_DicDetail where OWNERDIC in (" + sIDS.TrimEnd(',') + ")";
|
|
|
|
|
res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res < 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("删除子项出错,请联系技术人员!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//删除子项
|
|
|
|
|
strSql = string.Format("delete from Sys_DicManage where TYPE={0} ", pid);
|
|
|
|
|
res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res < 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("删除子项出错,请联系技术人员!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//然后删除本身
|
|
|
|
|
strSql = string.Format("delete from Sys_DicType where ID={0} ", pid);
|
|
|
|
|
res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
|
|
|
|
|
//白明雅 2018-12-27 bug13997 手动转换ObservableCollection<DicTreeNode>
|
|
|
|
|
ObservableCollection<DicTreeNode> UpdateNode = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
this.txtDicName.Text = "";
|
|
|
|
|
this.txtAliasName.Text = "";
|
|
|
|
|
this.txtCode.Text = "";
|
|
|
|
|
this.txtParentName.Text = "";
|
|
|
|
|
Thread.Sleep(700);
|
|
|
|
|
ObservableCollection<DicTreeNode> items = UpdateNode;
|
|
|
|
|
items.Remove(item);
|
|
|
|
|
// loadTree();
|
|
|
|
|
this.tvDicDetail.ItemsSource = null;
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 白明雅 2018-12-27 原来方法
|
|
|
|
|
//if (res > 0)
|
|
|
|
|
//{
|
|
|
|
|
// this.txtDicName.Text = "";
|
|
|
|
|
// this.txtAliasName.Text = "";
|
|
|
|
|
// this.txtCode.Text = "";
|
|
|
|
|
// this.txtParentName.Text = "";
|
|
|
|
|
// Thread.Sleep(700);
|
|
|
|
|
// ObservableCollection<DicTreeNode> items = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
// items.Remove(item);
|
|
|
|
|
// // loadTree();
|
|
|
|
|
// this.tvDicDetail.ItemsSource = null;
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//首先删除子项
|
|
|
|
|
strSql = "delete from Sys_DicDetail where OWNERDIC='" + pid + "'";
|
|
|
|
|
int res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res < 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("删除子项出错,请联系技术人员!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//然后删除本身
|
|
|
|
|
strSql = "delete from Sys_DicManage where id=" + pid;
|
|
|
|
|
res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
this.txtDicName.Text = "";
|
|
|
|
|
this.txtAliasName.Text = "";
|
|
|
|
|
this.txtCode.Text = "";
|
|
|
|
|
this.txtParentName.Text = "";
|
|
|
|
|
//白明雅 2018-12-28 bug13997
|
|
|
|
|
//ObservableCollection<DicTreeNode> items = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
ObservableCollection<DicTreeNode> items = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
DataRow DataView = item.Data as DataRow;
|
|
|
|
|
foreach (var Treeitem in items)
|
|
|
|
|
{
|
|
|
|
|
DataRow DataRow = Treeitem.Data as DataRow;
|
|
|
|
|
if (DataRow["ID"].ToString() == DataView["TYPE"].ToString())
|
|
|
|
|
{
|
|
|
|
|
Treeitem.Nodes.Remove(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(700);
|
|
|
|
|
this.tvDicDetail.ItemsSource = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowTips("数据加载异常!" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
LoadTree();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ActionChe(bool Parent, DicTreeNode treeNods, string Str)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Str != "")
|
|
|
|
|
{
|
|
|
|
|
Cold = Str;
|
|
|
|
|
txtNames = treeNods;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtNames = treeNods;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//字典子项新增
|
|
|
|
|
private void btnDetailAdd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Cold = null;
|
|
|
|
|
txtNames = null;
|
|
|
|
|
//获取选中节点
|
|
|
|
|
//白明雅 2018-12-27 bug13997
|
|
|
|
|
TreeNode node = this.tvTypes.SelectedItem as TreeNode;
|
|
|
|
|
DicTreeNode item = GetDicTreeNodeByTreeNode(node);
|
|
|
|
|
//------------------------
|
|
|
|
|
//DicTreeNode item = this.tvTypes.SelectedItem as DicTreeNode;
|
|
|
|
|
if (item == null || item.Data == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请先选择正确的父节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//详细字典值
|
|
|
|
|
DicTreeNode DetailItem = this.tvDicDetail.SelectedItem as DicTreeNode;
|
|
|
|
|
DicTreeNode TvTypesItem = GetDicTreeNodeByTreeNode(this.tvTypes.SelectedItem as TreeNode); // this.tvTypes.SelectedItem as DicTreeNode;
|
|
|
|
|
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
DataDicDetailEdit main = new DataDicDetailEdit(TvTypesItem.Name);
|
|
|
|
|
main.ActionChecked = ActionChe;
|
|
|
|
|
main.Width = 500;
|
|
|
|
|
main.Height = 350;
|
|
|
|
|
main.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
|
|
|
|
|
if (DetailItem != null && DetailItem.Data != null && !DetailItem.IsParent)
|
|
|
|
|
{
|
|
|
|
|
main.DrvNode = DetailItem.Data as DataRow;
|
|
|
|
|
}
|
|
|
|
|
main.OWNERDIC = drv["ID"].ToString();
|
|
|
|
|
//关闭窗体之后刷新tree控件
|
|
|
|
|
if (!main.ShowInMainWindow(true).Value)
|
|
|
|
|
{
|
|
|
|
|
if (txtNames == null)
|
|
|
|
|
return;
|
|
|
|
|
if (Cold == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> itemTree = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
DicTreeNode itemsd = itemTree[0];
|
|
|
|
|
if (itemsd.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> ergod = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
ergod.Add(txtNames);
|
|
|
|
|
itemsd.Nodes = ergod;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Add(txtNames);
|
|
|
|
|
var paixu = (itemsd.Nodes).OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> itemTree = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
ObservableCollection<DicTreeNode> list = itemTree[0].Nodes as ObservableCollection<DicTreeNode>;
|
|
|
|
|
foreach (var itemsd in list)
|
|
|
|
|
{
|
|
|
|
|
DataRow DataRowSubnode = itemsd.Data as DataRow;//保存当前Treevie对象遍历后的节点
|
|
|
|
|
DataRow Datarows = txtNames.Data as DataRow;//保存新增节点
|
|
|
|
|
if (DataRowSubnode["ID"].ToString() == Cold)
|
|
|
|
|
{
|
|
|
|
|
if (itemsd.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> ergod = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
ergod.Add(txtNames);
|
|
|
|
|
itemsd.Nodes = ergod;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Add(txtNames);
|
|
|
|
|
var paixu = (itemsd.Nodes).OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
itemsd.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (itemsd.Nodes != null && itemsd.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ergodicSubnode(itemsd.Nodes, Cold);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("新增节点异常!" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 遍历子节点增加节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ergodicSubnode(ObservableCollection<DicTreeNode> ergodic, string Pid)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in ergodic)
|
|
|
|
|
{
|
|
|
|
|
DataRow DataRowSubnode = item.Data as DataRow;//保存当前Treevie对象遍历后的节点
|
|
|
|
|
if (DataRowSubnode["ID"].ToString() == Pid)
|
|
|
|
|
{
|
|
|
|
|
if (item.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> ergod = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
ergod.Add(txtNames);
|
|
|
|
|
item.Nodes = (ergod);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Add(txtNames);
|
|
|
|
|
var paixu = (item.Nodes).OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (item.Nodes != null && item.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ergodicSubnode(item.Nodes, Pid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 遍历子节点删除数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ergodic"></param>
|
|
|
|
|
/// <param name="Pid"></param>
|
|
|
|
|
private void ergodicSubnodeDelete(ObservableCollection<DicTreeNode> ergodic, DicTreeNode itemud, string Pid)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in ergodic)
|
|
|
|
|
{
|
|
|
|
|
DataRow DataRowSubnode = item.Data as DataRow;//保存当前Treevie对象遍历后的节点
|
|
|
|
|
if (DataRowSubnode["ID"].ToString() == Pid)
|
|
|
|
|
{
|
|
|
|
|
if (item.Nodes != null)
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Remove(itemud);
|
|
|
|
|
var paixu = (item.Nodes).OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
item.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (item.Nodes != null && item.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ergodicSubnodeDelete(item.Nodes, itemud, Pid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public List<string> sQSCodeList;
|
|
|
|
|
public List<string> sQSNameList;
|
|
|
|
|
public bool GetExcelAllRecord(Workbook the_workbook)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
sQSCodeList = new List<string>();
|
|
|
|
|
sQSNameList = new List<string>();
|
|
|
|
|
|
|
|
|
|
bool exitload = false;
|
|
|
|
|
var rowindex = 1;
|
|
|
|
|
var worksheet = the_workbook.Worksheets[0];
|
|
|
|
|
while (!exitload)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(worksheet.Rows[rowindex][0].DisplayText))
|
|
|
|
|
{
|
|
|
|
|
if (rowindex < 5)
|
|
|
|
|
{
|
|
|
|
|
rowindex++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
exitload = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (rowindex == 1)
|
|
|
|
|
{
|
|
|
|
|
if (worksheet.Rows[rowindex][0].DisplayText != "权属单位代码" || worksheet.Rows[rowindex][1].DisplayText != "权属单位名称")
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("文件内容解析错误,请选择正确格式内容的权属样式文件!");
|
|
|
|
|
exitload = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rowindex > 1)
|
|
|
|
|
{
|
|
|
|
|
sQSCodeList.Add(worksheet.Rows[rowindex][0].Value.ToString());
|
|
|
|
|
sQSNameList.Add(worksheet.Rows[rowindex][1].DisplayText);
|
|
|
|
|
}
|
|
|
|
|
rowindex++;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("获取权属信息异常: " + ex + " ; ");
|
|
|
|
|
sQSCodeList = new List<string>();
|
|
|
|
|
sQSNameList = new List<string>();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool JudgeExistQDCode(string sQSCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(sQSCode) == true)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sQSCodeList == null || sQSCodeList.Count() <= 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool bJudge_ = false;
|
|
|
|
|
for (int i = 0; i < sQSCodeList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (sQSCodeList[i] == sQSCode)
|
|
|
|
|
{
|
|
|
|
|
bJudge_ = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bJudge_;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("验证是否存在权属代码( " + sQSCode + " ) 时异常: " + ex + " ; ");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典子项编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnDetailEdit_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
txtNames = null;
|
|
|
|
|
Cold = null;
|
|
|
|
|
//判断子项是否有选中值
|
|
|
|
|
DicTreeNode item = this.tvDicDetail.SelectedItem as DicTreeNode;
|
|
|
|
|
if (item == null || item.Data == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请先选中需要编辑的节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
if (drv == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!drv.Table.Columns.Contains("OWNERDIC"))
|
|
|
|
|
{
|
|
|
|
|
DataDicEdit DataMain = new DataDicEdit(1);
|
|
|
|
|
DataMain.Width = 550;
|
|
|
|
|
DataMain.Height = 410;
|
|
|
|
|
DataMain.actionUpdate = action_Update;
|
|
|
|
|
DataMain.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
|
|
|
|
|
DataMain.IsParent = item.IsParent;
|
|
|
|
|
DataMain.InitPage(drv);
|
|
|
|
|
//关闭窗体之后刷新tree控件
|
|
|
|
|
if (!DataMain.ShowInMainWindow(true).Value)
|
|
|
|
|
{
|
|
|
|
|
if (txtNames == null && Cold == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ObservableCollection<DicTreeNode> ListTree = tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
DicTreeNode TreesNode = ListTree[0];
|
|
|
|
|
TreesNode.Name = txtNames.Name;
|
|
|
|
|
TreesNode.Data = txtNames.Data;
|
|
|
|
|
DataRow treesData = TreesNode.Data as DataRow;
|
|
|
|
|
txtDicName.Text = treesData["Name"].ToString();
|
|
|
|
|
txtCode.Text = "";
|
|
|
|
|
txtAliasName.Text = treesData["ALIASNAME"].ToString();
|
|
|
|
|
txtRemark.Text = treesData["REMARK"].ToString();
|
|
|
|
|
//白明雅 2018-12-28
|
|
|
|
|
DicTreeNode TreesNodes = GetDicTreeNodeByTreeNode(tvTypes.SelectedItem as TreeNode);
|
|
|
|
|
TreesNodes.Name = txtNames.Name;
|
|
|
|
|
TreesNodes.Data = txtNames.Data;
|
|
|
|
|
TreesNodes.Paixu = Convert.ToInt32(treesData["PAIXU"]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DataDicDetailEdit main = new DataDicDetailEdit(txtParentName.Text);
|
|
|
|
|
main.Width = 500;
|
|
|
|
|
main.Height = 350;
|
|
|
|
|
main.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
|
|
|
|
|
main.OWNERDIC = drv["OWNERDIC"].ToString();
|
|
|
|
|
main.ActionChecked = ActionChe;
|
|
|
|
|
main.InitPage(drv);
|
|
|
|
|
//关闭窗体之后刷新tree控件
|
|
|
|
|
if (!main.ShowInMainWindow(true).Value)
|
|
|
|
|
{
|
|
|
|
|
if (txtNames == null && Cold == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Cold == null)
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> items = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
DicTreeNode treeNodes = items[0] as DicTreeNode;//当前目录中根目录节点
|
|
|
|
|
if (string.IsNullOrWhiteSpace(drv["PID"].ToString().Trim()))
|
|
|
|
|
{
|
|
|
|
|
DataRow treeNodeData = treeNodes.Data as DataRow;//将根目录节点转成DataRow
|
|
|
|
|
DataRow treeView = txtNames.Data as DataRow;
|
|
|
|
|
foreach (var itemData in treeNodes.Nodes)
|
|
|
|
|
{
|
|
|
|
|
DataRow temData = itemData.Data as DataRow;//当前第一次子目录对象
|
|
|
|
|
if (temData["OWNERDIC"].ToString() == treeNodeData["ID"].ToString() && drv["ID"].ToString().Trim() == temData["ID"].ToString().Trim())
|
|
|
|
|
{
|
|
|
|
|
DataRow temDatas = itemData.Data as DataRow;
|
|
|
|
|
itemData.Name = txtNames.Name;
|
|
|
|
|
itemData.Paixu = txtNames.Paixu;
|
|
|
|
|
itemData.Data = txtNames.Data;
|
|
|
|
|
txtDicName.Text = temDatas["Name"].ToString();
|
|
|
|
|
txtCode.Text = temDatas["CODE"].ToString();
|
|
|
|
|
txtAliasName.Text = "";
|
|
|
|
|
txtRemark.Text = temDatas["REMARK"].ToString();
|
|
|
|
|
var paixu = treeNodes.Nodes.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> items = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
DicTreeNode treeNodes = items[0] as DicTreeNode;//当前目录中根目录节点
|
|
|
|
|
if (string.IsNullOrWhiteSpace(drv["PID"].ToString().Trim()))
|
|
|
|
|
{
|
|
|
|
|
DataRow treeNodeData = treeNodes.Data as DataRow;//将根目录节点转成DataRow
|
|
|
|
|
treeNodes.Nodes.Remove(item);
|
|
|
|
|
items = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
treeNodes = items[0] as DicTreeNode;
|
|
|
|
|
DataRow treeView = txtNames.Data as DataRow;
|
|
|
|
|
foreach (var itemData in treeNodes.Nodes)
|
|
|
|
|
{
|
|
|
|
|
DataRow temData = itemData.Data as DataRow;//当前第一次子目录对象
|
|
|
|
|
if (temData["ID"].ToString() == Cold)
|
|
|
|
|
{
|
|
|
|
|
if (itemData.Nodes != null)
|
|
|
|
|
{
|
|
|
|
|
itemData.Nodes.Add(txtNames);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<DicTreeNode> itemsList = new ObservableCollection<DicTreeNode>();
|
|
|
|
|
itemsList.Add(txtNames);
|
|
|
|
|
itemData.Nodes = itemsList;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var itemNodes in treeNodes.Nodes)
|
|
|
|
|
{
|
|
|
|
|
DataRow temData = itemNodes.Data as DataRow;//当前第一次子目录对象
|
|
|
|
|
if (temData["ID"].ToString() == drv["ID"].ToString())
|
|
|
|
|
{
|
|
|
|
|
itemNodes.Name = txtNames.Name;
|
|
|
|
|
itemNodes.Data = txtNames.Data;
|
|
|
|
|
itemNodes.Paixu = txtNames.Paixu;
|
|
|
|
|
DataRow temDatas = itemNodes.Data as DataRow;
|
|
|
|
|
txtDicName.Text = temDatas["Name"].ToString();
|
|
|
|
|
txtCode.Text = "";
|
|
|
|
|
txtAliasName.Text = temDatas["CODE"].ToString();
|
|
|
|
|
txtRemark.Text = temDatas["REMARK"].ToString();
|
|
|
|
|
var paixu = treeNodes.Nodes.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
treeNodes.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (itemNodes.Nodes != null && itemNodes.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
updateDicTree(itemNodes, drv["ID"].ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改原因:不需要将字典保存到工程文件中 修改人:高山 修改时间:2019.09.21
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("数据加载异常!" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDicTree(DicTreeNode tree, string UpdatID)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in tree.Nodes)
|
|
|
|
|
{
|
|
|
|
|
DataRow temData = item.Data as DataRow;//当前第一次子目录对象
|
|
|
|
|
if (temData["ID"].ToString() == UpdatID)
|
|
|
|
|
{
|
|
|
|
|
item.Name = txtNames.Name;
|
|
|
|
|
item.Data = txtNames.Data;
|
|
|
|
|
item.Paixu = txtNames.Paixu;
|
|
|
|
|
DataRow temDatas = item.Data as DataRow;
|
|
|
|
|
txtDicName.Text = temDatas["Name"].ToString();
|
|
|
|
|
txtCode.Text = "";
|
|
|
|
|
txtAliasName.Text = temDatas["CODE"].ToString();
|
|
|
|
|
txtRemark.Text = temDatas["REMARK"].ToString();
|
|
|
|
|
var paixu = tree.Nodes.OrderBy(x => x.Paixu).ToList();
|
|
|
|
|
if (paixu != null)
|
|
|
|
|
{
|
|
|
|
|
tree.Nodes.Clear();
|
|
|
|
|
foreach (var itemd in paixu)
|
|
|
|
|
{
|
|
|
|
|
tree.Nodes.Add(itemd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (item.Nodes != null && item.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
updateDicTree(item, UpdatID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//字典子项删除
|
|
|
|
|
private void btnDetailDel_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//删除子项需要级联删除下属的所有子项
|
|
|
|
|
DicTreeNode item = this.tvDicDetail.SelectedItem as DicTreeNode;
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请您选择要删除的节点!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (MessageHelper.ShowYesNoAndWarning("您确认要删除【" + item.Name + "】节点?") == System.Windows.Forms.DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
if (drv == null)
|
|
|
|
|
{
|
|
|
|
|
if (item.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowWarning("您选择的是根节点,如果想删除请在根目录下删除");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string pid = drv["id"].ToString();
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
//判断是否根节点删除
|
|
|
|
|
if (item.IsParent)
|
|
|
|
|
{
|
|
|
|
|
//首先删除子项
|
|
|
|
|
strSql = "delete from Sys_DicDetail where OWNERDIC='" + pid + "'";
|
|
|
|
|
int res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res < 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("删除子项出错,请联系技术人员!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//然后删除本身
|
|
|
|
|
strSql = "delete from Sys_DicManage where id=" + pid;
|
|
|
|
|
res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
this.txtDicName.Text = "";
|
|
|
|
|
this.txtAliasName.Text = "";
|
|
|
|
|
this.txtCode.Text = "";
|
|
|
|
|
this.txtParentName.Text = "";
|
|
|
|
|
//ObservableCollection<DicTreeNode> itemTree = this.tvTypes.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
//item = this.tvTypes.SelectedItem as DicTreeNode;
|
|
|
|
|
//白明雅 2018-12-28
|
|
|
|
|
ObservableCollection<DicTreeNode> itemTree = IEnumerableToDicTreeNode(this.tvTypes.ItemsSource.Cast<TreeNode>());
|
|
|
|
|
item = GetDicTreeNodeByTreeNode(this.tvTypes.SelectedItem as TreeNode);
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var items in itemTree)
|
|
|
|
|
{
|
|
|
|
|
DataRow drvs = items.Data as DataRow;
|
|
|
|
|
if (drvs["ID"].ToString() == drv["TYPE"].ToString())
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Remove(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.tvDicDetail.ItemsSource = null;
|
|
|
|
|
LoadTree();//白明雅 2018-12-28
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string ids = ForeachGetID(pid, rdbHelper) + pid;
|
|
|
|
|
//执行删除操作
|
|
|
|
|
strSql = "delete from Sys_DicDetail where id in (" + ids + ")";
|
|
|
|
|
int res = rdbHelper.ExecuteNonQuery(strSql, CommandType.Text);
|
|
|
|
|
if (res > 0)
|
|
|
|
|
{
|
|
|
|
|
this.txtDicName.Text = "";
|
|
|
|
|
this.txtAliasName.Text = "";
|
|
|
|
|
this.txtCode.Text = "";
|
|
|
|
|
this.txtParentName.Text = "";
|
|
|
|
|
ObservableCollection<DicTreeNode> itemTree = this.tvDicDetail.ItemsSource as ObservableCollection<DicTreeNode>;
|
|
|
|
|
DicTreeNode drvs = itemTree[0] as DicTreeNode;
|
|
|
|
|
if (drvs != null)
|
|
|
|
|
{
|
|
|
|
|
DataRow drvsds = drvs.Data as DataRow;
|
|
|
|
|
if (drvsds != null)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(drv["PID"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
drvs.Nodes.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var items in drvs.Nodes)
|
|
|
|
|
{
|
|
|
|
|
DataRow drvsd = items.Data as DataRow;
|
|
|
|
|
if (drvsd["ID"].ToString() == drv["PID"].ToString())
|
|
|
|
|
{
|
|
|
|
|
items.Nodes.Remove(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (items.Nodes != null && items.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ergodicSubnodeDelete(items.Nodes, item, drv["PID"].ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
//SaveProjectDic();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("数据加载异常!" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//递归获取ID,一直到根节点
|
|
|
|
|
private string ForeachGetID(string ID, IRDBHelper rdbHelper)
|
|
|
|
|
{
|
|
|
|
|
string ids = string.Empty;
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("Sys_DicDetail", string.Format("select * from Sys_DicDetail where PID='{0}'", ID), true);
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow item in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
string id = item["ID"].ToString();
|
|
|
|
|
ids += id + "," + ForeachGetID(id, rdbHelper);
|
|
|
|
|
}
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 代码及名称树状菜单点击事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void tvDicDetail_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
|
|
|
{
|
|
|
|
|
DicTreeNode item = this.tvDicDetail.SelectedItem as DicTreeNode;
|
|
|
|
|
SetChangedItem(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetChangedItem(DicTreeNode item)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
txtDicName.Text = string.Empty;
|
|
|
|
|
txtCode.Text = string.Empty;
|
|
|
|
|
txtRemark.Text = string.Empty;
|
|
|
|
|
txtDicID.Text = string.Empty;
|
|
|
|
|
txtAliasName.Text = string.Empty;
|
|
|
|
|
txtParentName.Text = string.Empty;
|
|
|
|
|
if (item == null || item.Data == null || (item.Data as DataRow) == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("数据库连接打开失败:" + dbPath);
|
|
|
|
|
}
|
|
|
|
|
DataRow drv = item.Data as DataRow;
|
|
|
|
|
txtDicName.Text = drv["Name"] == null ? "" : drv["Name"].ToString();
|
|
|
|
|
if (drv.Table.Columns.Contains("CODE"))
|
|
|
|
|
{
|
|
|
|
|
txtCode.Text = drv["CODE"] == null ? "" : drv["CODE"].ToString();
|
|
|
|
|
}
|
|
|
|
|
txtDicID.Text = drv["ID"] == null ? "" : drv["ID"].ToString();
|
|
|
|
|
txtRemark.Text = drv["REMARK"] == null ? "" : drv["REMARK"].ToString();
|
|
|
|
|
|
|
|
|
|
#region 获取父级名称,代码
|
|
|
|
|
string QuerySQL = string.Empty;
|
|
|
|
|
if (item.IsParent)
|
|
|
|
|
{
|
|
|
|
|
txtAliasName.Text = drv["ALIASNAME"] == null ? "" : drv["ALIASNAME"].ToString();
|
|
|
|
|
if (drv.Table.Columns.Contains("TYPE") && drv["TYPE"] != null && !string.IsNullOrWhiteSpace(drv["TYPE"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
QuerySQL = "SELECT * FROM Sys_DicType WHERE ID= " + drv["TYPE"].ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (drv.Table.Columns.Contains("PID") && drv["PID"] != null && !string.IsNullOrWhiteSpace(drv["PID"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
QuerySQL = "SELECT * FROM Sys_DicDetail WHERE ID = " + drv["PID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (drv.Table.Columns.Contains("OWNERDIC") && drv["OWNERDIC"] != null && !string.IsNullOrWhiteSpace(drv["OWNERDIC"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
QuerySQL = "SELECT * FROM Sys_DicManage WHERE ID = " + drv["OWNERDIC"].ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(QuerySQL))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DataTable dtDict = rdbHelper.ExecuteDatatable("Sys_DicType", QuerySQL, false);
|
|
|
|
|
if (dtDict != null && dtDict.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string parentName = "[";
|
|
|
|
|
if (dtDict.Columns.Contains("CODE"))
|
|
|
|
|
{
|
|
|
|
|
parentName += dtDict.Rows[0]["CODE"] == null ? "" : dtDict.Rows[0]["CODE"].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (dtDict.Columns.Contains("ID"))
|
|
|
|
|
{
|
|
|
|
|
parentName += dtDict.Rows[0]["ID"] == null ? "" : dtDict.Rows[0]["ID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
parentName += "]";
|
|
|
|
|
if (dtDict.Columns.Contains("NAME"))
|
|
|
|
|
{
|
|
|
|
|
parentName += dtDict.Rows[0]["NAME"] == null ? "" : dtDict.Rows[0]["NAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
txtParentName.Text = parentName;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowError("数据加载异常!" + ex.Message);
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存字典
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SaveProjectDic()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string dicPaht = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetDicDataPath();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(dicPaht))
|
|
|
|
|
{
|
|
|
|
|
string tempPath = System.IO.Path.GetTempPath();
|
|
|
|
|
string dbPath = System.IO.Path.Combine(tempPath, "dic.back");
|
|
|
|
|
File.Copy(dicPaht, dbPath);
|
|
|
|
|
FileInfo dicfileInfo = new FileInfo(dbPath);
|
|
|
|
|
using (System.IO.FileStream dicStream = dicfileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.None))
|
|
|
|
|
{
|
|
|
|
|
byte[] dicByte = new byte[dicStream.Length];
|
|
|
|
|
dicStream.Read(dicByte, 0, dicByte.Length);
|
|
|
|
|
dicStream.Close();
|
|
|
|
|
File.Delete(dbPath);
|
|
|
|
|
string base64 = Convert.ToBase64String(dicByte);
|
|
|
|
|
(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DicData = base64;
|
|
|
|
|
}
|
|
|
|
|
//(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).Save();
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("保存字典失败:" + ex.Message);
|
|
|
|
|
throw new Exception("保存字典失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典导入
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnDicImport_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FrmDicManageImport frm = new FrmDicManageImport
|
|
|
|
|
{
|
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
|
|
|
|
};
|
|
|
|
|
frm.ShowInMainWindow(true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowError("字典导入出现错误,可能的原因是:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 字典导出
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnDicExport_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FrmDicManageExport frm = new FrmDicManageExport
|
|
|
|
|
{
|
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
|
|
|
|
};
|
|
|
|
|
frm.ShowInMainWindow(true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowError("字典导出出现错误,可能的原因是:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成权属字典
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btnCreateDicNew_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
KBGNewDataManage main = new KBGNewDataManage();
|
|
|
|
|
main.Refresh = LoadTree;
|
|
|
|
|
main.Width = 700;
|
|
|
|
|
main.Height = 420;
|
|
|
|
|
main.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
|
|
|
main.ShowInMainWindow(false);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowError("生成权属代码字典出现错误,可能的原因是:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void BaseWindow_Closed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* 根据国家标准库做出调整,删除ZJLX表
|
|
|
|
|
* 白明雅 2019-01-28 注释下列代码
|
|
|
|
|
* KGIS.Common.Utility.DicAPI.GetDicTypeID(KGIS.Common.Enum.DicTypeEnum.ZJLX, true);
|
|
|
|
|
*/
|
|
|
|
|
//重新获取字典
|
|
|
|
|
GetAllDic();
|
|
|
|
|
}
|
|
|
|
|
private List<DataDicTionary> GetAllDic()
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = null;
|
|
|
|
|
List<DataDicTionary> result = new List<DataDicTionary>();
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string dbPath = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetDicDataPath();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(dbPath))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + dbPath, DatabaseType.SQLite);
|
|
|
|
|
string strSQL = "select * from Sys_DicDetail";
|
|
|
|
|
dt = rdbHelper.ExecuteDatatable("Dic", strSQL, true);
|
|
|
|
|
if (dt != null)
|
|
|
|
|
{
|
|
|
|
|
//Bug-12137 霍岩 2018-11-14 使用CODE字段按顺序排序
|
|
|
|
|
result = TBToList.ToList<DataDicTionary>(dt).OrderBy(x => x.CODE).ToList();
|
|
|
|
|
result.ForEach(x => x.DisplayName = x.CODE + "-" + x.NAME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
if (dt != null)
|
|
|
|
|
{
|
|
|
|
|
dt.Clear();
|
|
|
|
|
dt.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
private void tvTypes_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var treeViewItem = VisualUpwardSearch<TreeViewItem>(e.OriginalSource as DependencyObject) as TreeViewItem;
|
|
|
|
|
if (treeViewItem != null)
|
|
|
|
|
{
|
|
|
|
|
treeViewItem.Focus();
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DependencyObject VisualUpwardSearch<T>(DependencyObject source)
|
|
|
|
|
{
|
|
|
|
|
while (source != null && source.GetType() != typeof(T))
|
|
|
|
|
source = VisualTreeHelper.GetParent(source);
|
|
|
|
|
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TreeNode QSXZchildNodeItem { get; set; }
|
|
|
|
|
public void ImportExcel(string excelfileurl)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (FileIsUsed(excelfileurl))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowWarning("文件被占用,请关闭占用文件的相关程序,或者选择其他文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
|
|
|
|
|
string Path = System.IO.Path.GetDirectoryName((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath()) + @"\BGTJ.sqlite";
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper("Data Source=" + Path, DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("打开数据库连接失败!");
|
|
|
|
|
}
|
|
|
|
|
DataTable dtDict = rdbHelper.ExecuteDatatable("Sys_DicType", "select * from Sys_DicManage where NAME='权属代码'", true);
|
|
|
|
|
//数据库已存在
|
|
|
|
|
if (dtDict != null && dtDict.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
QsdmID = dtDict.Rows[0]["ID"].ToString();
|
|
|
|
|
DataTable dtDetail = rdbHelper.ExecuteDatatable("Sys_DicDetail", "select * from Sys_DicDetail where OWNERDIC='" + QsdmID + "'", true);
|
|
|
|
|
if (dtDetail == null || dtDetail.Rows.Count == 0 || MessageHelper.ShowYesNoAndTips("确定要导入吗?导入将覆盖现有字典数据!") == System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
ListQsdwEntity.Clear();
|
|
|
|
|
RemoveQsdwEntity.Clear();
|
|
|
|
|
ExcelLists.Clear();
|
|
|
|
|
Workbook workbook = new Workbook();
|
|
|
|
|
using (FileStream stream = new FileStream(excelfileurl, FileMode.Open))
|
|
|
|
|
{
|
|
|
|
|
workbook.LoadDocument(stream, DocumentFormat.OpenXml);//打开exe表格
|
|
|
|
|
}
|
|
|
|
|
bool exitload = false;
|
|
|
|
|
var rowindex = 1;
|
|
|
|
|
var worksheet = workbook.Worksheets[0];
|
|
|
|
|
//文件解析失败,直接退出
|
|
|
|
|
if (!GetExcelAllRecord(workbook)) return;
|
|
|
|
|
|
|
|
|
|
if (sQSCodeList == null || sQSCodeList.Count <= 0 ||
|
|
|
|
|
sQSNameList == null || sQSNameList.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowWarning("信息获取异常!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (!exitload)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(worksheet.Rows[rowindex][0].DisplayText))
|
|
|
|
|
{
|
|
|
|
|
if (rowindex < 5)
|
|
|
|
|
{
|
|
|
|
|
rowindex++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
exitload = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (rowindex > 1)
|
|
|
|
|
{
|
|
|
|
|
QSDWinformation QsdwEntity = new QSDWinformation();
|
|
|
|
|
//模板-权属代码需是12位
|
|
|
|
|
if (worksheet.Rows[rowindex][0].Value.ToString().PadRight(12, '0').IndexOf("0000000000") == 2)
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString().Substring(0, 2);//省
|
|
|
|
|
}
|
|
|
|
|
else if (worksheet.Rows[rowindex][0].Value.ToString().PadRight(12, '0').IndexOf("00000000") == 4)
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString().Substring(0, 4);//市
|
|
|
|
|
}
|
|
|
|
|
else if (worksheet.Rows[rowindex][0].Value.ToString().PadRight(12, '0').IndexOf("000000") == 6 && worksheet.Rows[rowindex][0].Value.ToString().Length <= 6)
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString().Substring(0, 6);//区
|
|
|
|
|
}
|
|
|
|
|
else if (worksheet.Rows[rowindex][0].Value.ToString().Length == 9 && worksheet.Rows[rowindex][0].Value.ToString().EndsWith("000"))//特殊情况
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString().PadRight(19, '0');
|
|
|
|
|
QsdwEntity.Qsdwmc = worksheet.Rows[rowindex][1].DisplayText;
|
|
|
|
|
QsdwEntity.ZLDWDM = QsdwEntity.Qsdwdm;
|
|
|
|
|
QsdwEntity.Zldwmc = QsdwEntity.Qsdwmc;
|
|
|
|
|
QsdwEntity.HasCheck = true;
|
|
|
|
|
ListQsdwEntity.Add(QsdwEntity);
|
|
|
|
|
ExcelLists = new List<QSDWinformation>(ListQsdwEntity);
|
|
|
|
|
rowindex++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString();//村
|
|
|
|
|
}
|
|
|
|
|
//QsdwEntity.Qsdwdm = worksheet.Rows[rowindex][0].Value.ToString();
|
|
|
|
|
if (QsdwEntity.Qsdwdm.Length == 19)
|
|
|
|
|
{
|
|
|
|
|
if (QsdwEntity.Qsdwdm.EndsWith("00000000000000000"))
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = QsdwEntity.Qsdwdm.Substring(0, 2);
|
|
|
|
|
}
|
|
|
|
|
else if (QsdwEntity.Qsdwdm.EndsWith("000000000000000"))
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = QsdwEntity.Qsdwdm.Substring(0, 4);
|
|
|
|
|
}
|
|
|
|
|
else if (QsdwEntity.Qsdwdm.EndsWith("0000000000000"))
|
|
|
|
|
{
|
|
|
|
|
//判断是否存在配套的上一级(9位村/街道)数据
|
|
|
|
|
//有:不处理,原版数据
|
|
|
|
|
//没有:在判断是否所有的数据中是否存在6位本记录外同6位编码的县级;
|
|
|
|
|
// 有:不处理,成为飞入地;
|
|
|
|
|
// 没有:截取成6位;
|
|
|
|
|
string sTemp_1 = QsdwEntity.Qsdwdm;
|
|
|
|
|
if (JudgeExistQDCode(sTemp_1.Substring(0, 6) + "000") == true)
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = sTemp_1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (JudgeExistQDCode(sTemp_1.Substring(0, 6)) == true)
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = sTemp_1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = sTemp_1.Substring(0, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (QsdwEntity.Qsdwdm.EndsWith("0000000000"))
|
|
|
|
|
{
|
|
|
|
|
QsdwEntity.Qsdwdm = QsdwEntity.Qsdwdm.Substring(0, 9);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QsdwEntity.Qsdwmc = worksheet.Rows[rowindex][1].DisplayText;
|
|
|
|
|
QsdwEntity.ZLDWDM = QsdwEntity.Qsdwdm;
|
|
|
|
|
QsdwEntity.Zldwmc = QsdwEntity.Qsdwmc;
|
|
|
|
|
QsdwEntity.HasCheck = true;
|
|
|
|
|
ListQsdwEntity.Add(QsdwEntity);
|
|
|
|
|
ExcelLists = new List<QSDWinformation>(ListQsdwEntity);
|
|
|
|
|
}
|
|
|
|
|
rowindex++;
|
|
|
|
|
}
|
|
|
|
|
if (ListQsdwEntity.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
///获取省市县信息
|
|
|
|
|
var shengcode = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 2).FirstOrDefault();
|
|
|
|
|
ShengInfo = new KeyValuePair<string, string>(shengcode == null ? ListQsdwEntity.First().ZLDWDM.PadRight(12, '0').Substring(0, 2).ToString() : shengcode.ZLDWDM, shengcode == null ? "省" : shengcode.Zldwmc);
|
|
|
|
|
ShengInfo2 = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 2).ToList<QSDWinformation>();//插入循环的数据
|
|
|
|
|
|
|
|
|
|
var shicode = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 4).FirstOrDefault();
|
|
|
|
|
ShiInfo = new KeyValuePair<string, string>(shicode == null ? ListQsdwEntity.First().ZLDWDM.PadRight(12, '0').Substring(0, 4).ToString() : shicode.ZLDWDM, shicode == null ? "市" : shicode.Zldwmc);
|
|
|
|
|
ShiInfo2 = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 4).ToList<QSDWinformation>();
|
|
|
|
|
|
|
|
|
|
var xiancode = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 6).FirstOrDefault();
|
|
|
|
|
XianInfo = new KeyValuePair<string, string>(xiancode == null ? ListQsdwEntity.First().ZLDWDM.PadRight(12, '0').Substring(0, 6).ToString() : xiancode.ZLDWDM, xiancode == null ? "县" : xiancode.Zldwmc);
|
|
|
|
|
XianInfo2 = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 6).ToList<QSDWinformation>();
|
|
|
|
|
#region 2020.04.01 飞入地与县同级显示
|
|
|
|
|
var XianInfolist = ListQsdwEntity.Where(x => x.ZLDWDM.Length == 19).GroupBy(x => x.ZLDWDM.PadRight(12, '0').Substring(0, 6)).Select(x => x.Key).ToList();
|
|
|
|
|
List<QSDWinformation> Xianlist = new List<QSDWinformation>();
|
|
|
|
|
string sTemp_ = "";
|
|
|
|
|
if (XianInfo2 != null && XianInfo2.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var tt in XianInfo2)
|
|
|
|
|
{
|
|
|
|
|
sTemp_ += tt.ZLDWDM + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(sTemp_) == false)
|
|
|
|
|
{
|
|
|
|
|
sTemp_ = sTemp_.TrimStart(',').TrimEnd(',');
|
|
|
|
|
sTemp_ = "," + sTemp_ + ",";
|
|
|
|
|
foreach (var xian in XianInfolist)
|
|
|
|
|
{
|
|
|
|
|
if (sTemp_.Contains(xian) == true)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ListQsdwEntity != null && ListQsdwEntity.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int u = 0; u < ListQsdwEntity.Count(); u++)
|
|
|
|
|
{
|
|
|
|
|
if (ListQsdwEntity[u].ZLDWDM.Length > 6 && ListQsdwEntity[u].ZLDWDM.PadRight(12, '0').Substring(0, 6) == xian)
|
|
|
|
|
{
|
|
|
|
|
Xianlist.Add(ListQsdwEntity[u]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var xian in XianInfolist)
|
|
|
|
|
{
|
|
|
|
|
var xianinfo = ListQsdwEntity.Where(
|
|
|
|
|
x =>
|
|
|
|
|
{
|
|
|
|
|
bool bresult = false;
|
|
|
|
|
if (x.ZLDWDM.Length > 6 && x.ZLDWDM.PadRight(12, '0').Substring(0, 6) == xian)
|
|
|
|
|
{
|
|
|
|
|
bresult = true;
|
|
|
|
|
}
|
|
|
|
|
if (x.ZLDWDM == XianInfo.Key)
|
|
|
|
|
{
|
|
|
|
|
bresult = true;
|
|
|
|
|
}
|
|
|
|
|
return bresult;
|
|
|
|
|
}).FirstOrDefault();
|
|
|
|
|
Xianlist.Add(xianinfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//XianInfo2 = Xianlist;
|
|
|
|
|
|
|
|
|
|
//2020-7-15
|
|
|
|
|
List<QSDWinformation> XianInfo2_ = new List<QSDWinformation>();
|
|
|
|
|
if (XianInfo2 == null || XianInfo2.Count() <= 0)
|
|
|
|
|
{
|
|
|
|
|
XianInfo2 = Xianlist;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Xianlist != null && Xianlist.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
bool bIsExistMark = false;
|
|
|
|
|
for (int i = 0; i < Xianlist.Count(); i++)
|
|
|
|
|
{
|
|
|
|
|
bIsExistMark = false;
|
|
|
|
|
for (int j = 0; j < XianInfo2.Count(); j++)
|
|
|
|
|
{
|
|
|
|
|
if (XianInfo2[j].ZLDWDM == Xianlist[i].ZLDWDM)
|
|
|
|
|
{
|
|
|
|
|
bIsExistMark = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bIsExistMark == true)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XianInfo2_.Add(Xianlist[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (XianInfo2_ != null && XianInfo2_.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < XianInfo2_.Count(); k++)
|
|
|
|
|
{
|
|
|
|
|
XianInfo2.Add(XianInfo2_[k]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
Run();
|
|
|
|
|
OrderBy(XianInfo.Key, XianInfo.Value);
|
|
|
|
|
CheckExist(QSXZchildNodeItem);//childNodeItem左项子级目录
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("ImportExcel异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("ImportExcel异常:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class TreeNode
|
|
|
|
|
{
|
|
|
|
|
#region Property
|
|
|
|
|
|
|
|
|
|
private string _Text;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示的文本值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return this._Text; }
|
|
|
|
|
set { this._Text = value; }
|
|
|
|
|
}
|
|
|
|
|
private ContextMenu _cMenu;
|
|
|
|
|
public ContextMenu cMenu
|
|
|
|
|
{
|
|
|
|
|
get { return this._cMenu; }
|
|
|
|
|
set { this._cMenu = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool? _Checked;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否选中
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool? Checked
|
|
|
|
|
{
|
|
|
|
|
get { return this._Checked; }
|
|
|
|
|
set { this._Checked = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _IsExpanded;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否展开
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsExpanded
|
|
|
|
|
{
|
|
|
|
|
get { return this._IsExpanded; }
|
|
|
|
|
set { this._IsExpanded = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 节点图标:相对路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Icon { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 子节点,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IList<TreeNode> Nodes { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 该节点数据项,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual object Data { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual bool IsOpenEdit { get; set; }
|
|
|
|
|
public object Paixu { get; internal set; }
|
|
|
|
|
public bool IsParent { get; internal set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region NodeX-构造函数(初始化)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// NodeX-构造函数(初始化)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TreeNode()
|
|
|
|
|
{
|
|
|
|
|
this.Name = string.Empty;
|
|
|
|
|
this.Icon = string.Empty;
|
|
|
|
|
this.Checked = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
public class DicTreeNode : System.ComponentModel.INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
#region Property
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
private string _Text;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示的文本值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Text
|
|
|
|
|
{
|
|
|
|
|
get { return this._Text; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Text = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Text"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string _Name;
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return this._Name; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Name = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Name"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private ContextMenu _cMenu;
|
|
|
|
|
public ContextMenu cMenu
|
|
|
|
|
{
|
|
|
|
|
get { return this._cMenu; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._cMenu = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("cMenu"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool? _Checked;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否选中
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool? Checked
|
|
|
|
|
{
|
|
|
|
|
get { return this._Checked; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Checked = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Checked"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _IsExpanded;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否展开
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsExpanded
|
|
|
|
|
{
|
|
|
|
|
get { return this._IsExpanded; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._IsExpanded = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsExpanded"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 节点图标:相对路径
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _Icon;
|
|
|
|
|
public string Icon
|
|
|
|
|
{
|
|
|
|
|
get { return this._Icon; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Icon = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Icon"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否父节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool _IsParent;
|
|
|
|
|
public bool IsParent
|
|
|
|
|
{
|
|
|
|
|
get { return this._IsParent; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._IsParent = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsParent"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 子节点,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<DicTreeNode> _Nodes;
|
|
|
|
|
public ObservableCollection<DicTreeNode> Nodes
|
|
|
|
|
{
|
|
|
|
|
get { return this._Nodes; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Nodes = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Nodes"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int _Paixu;
|
|
|
|
|
public int Paixu
|
|
|
|
|
{
|
|
|
|
|
get { return this._Paixu; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Paixu = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Paixu"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 该节点数据项,默认null
|
|
|
|
|
/// </summary>
|
|
|
|
|
private object _Data;
|
|
|
|
|
public object Data
|
|
|
|
|
{
|
|
|
|
|
get { return this._Data; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._Data = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Data"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _IsOpenEdit;
|
|
|
|
|
public bool IsOpenEdit
|
|
|
|
|
{
|
|
|
|
|
get { return this._IsOpenEdit; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._IsOpenEdit = value;
|
|
|
|
|
if (this.PropertyChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsOpenEdit"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region NodeX-构造函数(初始化)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// NodeX-构造函数(初始化)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DicTreeNode()
|
|
|
|
|
{
|
|
|
|
|
this.Name = string.Empty;
|
|
|
|
|
this.Icon = string.Empty;
|
|
|
|
|
this.Checked = false;
|
|
|
|
|
this.IsParent = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
public class QSDWinformation
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 权属单位名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _qsdwmc;
|
|
|
|
|
|
|
|
|
|
public string Qsdwmc
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _qsdwmc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_qsdwmc = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 权属单位代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _qsdwdm;
|
|
|
|
|
public string Qsdwdm
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _qsdwdm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_qsdwdm = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 坐落单位代码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _zldwdm;
|
|
|
|
|
public string ZLDWDM
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _zldwdm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_zldwdm = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Zldwmc
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _zldwmc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_zldwmc = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasCheck { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 坐落单位名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _zldwmc;
|
|
|
|
|
public List<QSDWinformation> ListQsdwInfor;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|