代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace UFTools
{
/// <summary>
/// SelectSetPage.xaml 的交互逻辑
/// </summary>
public partial class SelectSetPage : Page
{
public SelectSetPage(MainWindow mainWindow)
{
InitializeComponent();
_mainWindow = mainWindow;
LoadData();
}
private MainWindow _mainWindow;
private void LoadData()
{
var set = _mainWindow.DBHelper.ExeSql("select [name] from sysdatabases where [name] = 'UFSystem'", "master");
if (!set.Item1)
{
_mainWindow.Message("数据库连接失败", MessageType.Error);
return;
}
if(!(set.Item2.Tables?[0]?.Rows?.Count > 0))
{
_mainWindow.Message("数据库中没有检测到账套\n请初始化数据库", MessageType.Warning);
return;
}
var items = _mainWindow.DBHelper.ExeSql("select * from UA_Account", "UFSystem").Item2.Tables[0].AsEnumerable().Select(row => new ACSet() { Id = row["cAcc_Id"]?.ToString(), Name = row["cAcc_Name"]?.ToString(), Year = row["iYear"]?.ToString(), Path = row["cAcc_Path"]?.ToString() }).ToList();
items.ForEach(item =>
{
listView.Items.Add(item);
});
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
if(listView.SelectedItem == null)
{
return;
}
_mainWindow.ACSet = listView.SelectedItem as ACSet;
_mainWindow.Next();
}
private void LastButton_Click(object sender, RoutedEventArgs e)
{
_mainWindow.Last();
}
}
public class ACSet
{
public string Id { get; set; }
public string Name { get; set; }
public string Year { get; set; }
public string Path { get; set; }
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。