|
|
|
|
using MahApps.Metro.Controls;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
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.Shapes;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Audit.ViewModel;
|
|
|
|
|
|
|
|
|
|
namespace Audit.Windows
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set_up.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Set_up_Sql : MetroWindow
|
|
|
|
|
{
|
|
|
|
|
ReadIni readini = new ReadIni();
|
|
|
|
|
string filePath = "" + System.Environment.CurrentDirectory + "\\config_Audit.ini";//获取当前文件目录
|
|
|
|
|
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\AuditLog.txt";//日志文件
|
|
|
|
|
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
|
|
|
|
|
|
|
|
|
///<Summary>
|
|
|
|
|
/// Set_up
|
|
|
|
|
///</Summary>
|
|
|
|
|
public Set_up_Sql()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
SQL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SQL()
|
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
MessageBoxResult config = System.Windows.MessageBox.Show("未发现配置信息是否创建新的配置信息", "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否创建配置信息
|
|
|
|
|
if (config == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
ReadIni.WriteData("Database", "BatchDyeingCentral_SQL", ".\\express", filePath);//创建配置信息
|
|
|
|
|
ReadIni.WriteData("Database", "BatchDyeingCentral_NAME", "sa", filePath);
|
|
|
|
|
ReadIni.WriteData("Database", "BatchDyeingCentral_PW", "sunlight", filePath);
|
|
|
|
|
ReadIni.WriteData("Database", "Ticket_SQL", ".\\express", filePath);
|
|
|
|
|
ReadIni.WriteData("Database", "Ticket_NAME", "sa", filePath);
|
|
|
|
|
ReadIni.WriteData("Database", "Ticket_PW", "sunlight", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT1", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT2", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT3", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT4", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT5", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT6", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT7", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT8", "", filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT9", "", filePath);
|
|
|
|
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
|
|
|
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|
|
|
|
wr.WriteLine(Log_time + "Audit创建配置信息文件");
|
|
|
|
|
wr.Close();//写入配置文件
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.DBCSQL.Text = ReadIni.ReadIniData("Database", "BatchDyeingCentral_SQL", "***", filePath);//读取配置信息
|
|
|
|
|
this.DBCID.Text = ReadIni.ReadIniData("Database", "BatchDyeingCentral_NAME", "***", filePath);
|
|
|
|
|
this.DBCPW.Text = ReadIni.ReadIniData("Database", "BatchDyeingCentral_PW", "***", filePath);
|
|
|
|
|
this.TISQL.Text = ReadIni.ReadIniData("Database", "Ticket_SQL", "***", filePath);
|
|
|
|
|
this.TIID.Text = ReadIni.ReadIniData("Database", "Ticket_NAME", "***", filePath);
|
|
|
|
|
this.TIPW.Text = ReadIni.ReadIniData("Database", "Ticket_PW", "***", filePath);
|
|
|
|
|
this.time1.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT1", "", filePath);
|
|
|
|
|
this.time2.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT2", "", filePath);
|
|
|
|
|
this.time3.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT3", "", filePath);
|
|
|
|
|
this.time4.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT4", "", filePath);
|
|
|
|
|
this.time5.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT5", "", filePath);
|
|
|
|
|
this.time6.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT6", "", filePath);
|
|
|
|
|
this.time7.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT7", "", filePath);
|
|
|
|
|
this.time8.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT8", "", filePath);
|
|
|
|
|
this.time9.Text = ReadIni.ReadIniData("WORKER TIME", "WORKERT9", "", filePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetExit_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();//关闭当前窗口
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Save_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
|
|
|
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|
|
|
|
int DBCSQL = ReadIni.WriteData("Database", "BatchDyeingCentral_SQL", this.DBCSQL.Text, filePath);//修改配置文件
|
|
|
|
|
int DBCID = ReadIni.WriteData("Database", "BatchDyeingCentral_NAME", this.DBCID.Text, filePath);
|
|
|
|
|
int DBCWP = ReadIni.WriteData("Database", "BatchDyeingCentral_PW", this.DBCPW.Text, filePath);
|
|
|
|
|
int TISQL = ReadIni.WriteData("Database", "Ticket_SQL", this.TISQL.Text, filePath);
|
|
|
|
|
int TIID = ReadIni.WriteData("Database", "Ticket_NAME", this.TIID.Text, filePath);
|
|
|
|
|
int TIWP = ReadIni.WriteData("Database", "Ticket_PW", this.TIPW.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT1", this.time1.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT2", this.time2.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT3", this.time3.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT4", this.time4.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT5", this.time5.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT6", this.time6.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT7", this.time7.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT8", this.time8.Text, filePath);
|
|
|
|
|
ReadIni.WriteData("WORKER TIME", "WORKERT9", this.time9.Text, filePath);
|
|
|
|
|
if (DBCSQL == 0 && DBCID == 0 && DBCWP == 0)
|
|
|
|
|
{
|
|
|
|
|
wr.WriteLine(Log_time + "BatchDyeingCentral配置修改失败");
|
|
|
|
|
wr.Close();//写入配置文件
|
|
|
|
|
MessageBox.Show("BatchDyeingCentral配置保存失败");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (TISQL == 0 && TIID == 0 && TIWP == 0)
|
|
|
|
|
{
|
|
|
|
|
wr.WriteLine(Log_time + "Ticket配置修改失败");
|
|
|
|
|
wr.Close();//写入配置文件
|
|
|
|
|
MessageBox.Show("Ticket配置保存失败");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wr.WriteLine(Log_time + "Audit修改配置信息文件");
|
|
|
|
|
wr.Close();//写入配置文件
|
|
|
|
|
MessageBox.Show("保存完成");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|