You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.0 KiB
C#
156 lines
5.0 KiB
C#
using MaterialTraceability.Business;
|
|
using MaterialTraceability.Entity.DAO;
|
|
using MaterialTraceability.Entity.DTO;
|
|
using MaterialTraceability.SqlSugar;
|
|
using MaterialTraceability.SqlSugar.ServiceImpl;
|
|
using MaterialTraceabilityUI.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
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 MaterialTraceabilityUI
|
|
{
|
|
/// <summary>
|
|
/// SysConfigPage.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class SysConfigPage : UserControl
|
|
{
|
|
private IBaseServices<SysClient> baseServices = new BaseServices<SysClient>();
|
|
private AppConfigDto appConfig = AppConfigDto.Instance;
|
|
/// <summary>
|
|
/// 系统配置页面
|
|
/// </summary>
|
|
public SysConfigPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
List<SysClient> info = getList();
|
|
this.SysCientDataGrid.ItemsSource = info;
|
|
|
|
var paramTypeInfo = info.GroupBy(x => x.paramType).Distinct().Select(a => a.Key).ToList();
|
|
paramTypeInfo.Add("");
|
|
this.paramType.ItemsSource = paramTypeInfo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Seach_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.SysCientDataGrid.ItemsSource = getList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Save_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
List<SysClient> sysClients = getList();
|
|
List<SysClient> clients = (List<SysClient>)this.SysCientDataGrid.ItemsSource;
|
|
|
|
foreach(var x in clients)
|
|
{
|
|
var info = sysClients.Where(z => z.paramType == x.paramType && z.paramKey == x.paramKey).FirstOrDefault();
|
|
|
|
if (info == null)
|
|
{
|
|
baseServices.Add(new SysClient()
|
|
{
|
|
paramKey = x.paramKey,
|
|
paramType = x.paramType,
|
|
paramValue = x.paramValue,
|
|
remark = x.remark,
|
|
processId = appConfig.processId,
|
|
});
|
|
}
|
|
else
|
|
{
|
|
x.processId = appConfig.processId;
|
|
baseServices.Update(x);
|
|
}
|
|
}
|
|
}catch(Exception ex)
|
|
{
|
|
LogHelperBusiness.LogError("参数配置保存异常",ex);
|
|
}
|
|
}
|
|
|
|
private List<SysClient> getList()
|
|
{
|
|
Expression<Func<SysClient, bool>> exp = s1 => true;
|
|
|
|
if (StringExtension.IsNotBlank(this.paramKey.Text))
|
|
{
|
|
exp = exp.And(x => x.paramKey == this.paramKey.Text);
|
|
}
|
|
|
|
if (StringExtension.IsNotBlank(Convert.ToString(this.paramType.SelectedItem)))
|
|
{
|
|
exp = exp.And(x => x.paramType == this.paramType.SelectedItem.ToString());
|
|
}
|
|
|
|
exp = exp.And(x => x.processId == appConfig.processId);
|
|
|
|
List<SysClient> info = baseServices.Query(exp).Result;
|
|
|
|
return info;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑Sys_Client表
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Edit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (!"1".Equals(ConfigHelper.GetConfig("roleId")) && !"2".Equals(ConfigHelper.GetConfig("roleId")))
|
|
{
|
|
System.Windows.MessageBox.Show("请登录系统管理账号进行操作");
|
|
}
|
|
else
|
|
{
|
|
|
|
string deleteStr = @"delete from Sys_Client";
|
|
baseServices.QueryBySql<SysClient>(deleteStr, null);
|
|
|
|
string sqlStr = @"ALTER TABLE Sys_Client ADD processId VARCHAR(64) ";
|
|
var info = baseServices.QueryBySql<SysClient>(sqlStr, null);
|
|
|
|
List<SysClient> clients = baseServices.Query().Result;
|
|
clients.ForEach(x => x.processId = appConfig.processId);
|
|
|
|
baseServices.Update(clients);
|
|
}
|
|
|
|
}catch(Exception ex)
|
|
{
|
|
LogHelperBusiness.LogError("编辑Sys_Client表异常", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|