using System;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using Forks.Utils.IO;
|
|
|
|
namespace B3ButcherWeightClient {
|
|
public partial class Parameters : Form {
|
|
public Parameters() {
|
|
InitializeComponent();
|
|
SetConfigControl();
|
|
}
|
|
|
|
|
|
// 取得设置的值
|
|
private void SetConfigControl() {
|
|
|
|
using (var reader = FS.OpenReader(ConfigUtil.ParametersPath, true)) {
|
|
var nutFile = NutFile.Parse(reader);
|
|
|
|
txtBAcc.Text = nutFile.AsString(ConfigItem.AccID, "");
|
|
txtBoxDept.Text = nutFile.AsString(ConfigItem.DeptID, "");
|
|
txtBoxStore.Text = nutFile.AsString(ConfigItem.StoreID, "");
|
|
txtBTouru.Text = nutFile.AsString(ConfigItem.TouruID, "");
|
|
txtShengchan.Text = nutFile.AsString(ConfigItem.ShengchanID, "");
|
|
bankuaiTextBox.Text = nutFile.AsString(ConfigItem.BanKuaiID, "");
|
|
}
|
|
}
|
|
|
|
private void btnSave_Click(object sender, EventArgs e) {
|
|
using (TextReader reader = FS.OpenReader(ConfigUtil.ParametersPath, true)) {
|
|
var nutFile = NutFile.Parse(reader);
|
|
nutFile.SetValue(ConfigItem.AccID, txtBAcc.Text.Trim());
|
|
nutFile.SetValue(ConfigItem.DeptID, txtBoxDept.Text.Trim());
|
|
nutFile.SetValue(ConfigItem.StoreID, txtBoxStore.Text.Trim());
|
|
nutFile.SetValue(ConfigItem.ShengchanID, txtShengchan.Text.Trim());
|
|
nutFile.SetValue(ConfigItem.TouruID, txtBTouru.Text.Trim());
|
|
nutFile.SetValue(ConfigItem.BanKuaiID, bankuaiTextBox.Text.Trim());
|
|
using (TextWriter writer = FS.OpenWriter(ConfigUtil.ParametersPath, createDirsIfNotExist: true)) {
|
|
nutFile.Write(writer);
|
|
}
|
|
}
|
|
|
|
var str = txtBAcc.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.AccID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.AccID);
|
|
}
|
|
str = txtBoxDept.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.DeptID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.DeptID);
|
|
}
|
|
str = txtBoxStore.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.StoreID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.StoreID);
|
|
}
|
|
str = txtBTouru.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.TouruID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.TouruID);
|
|
}
|
|
str = txtShengchan.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.ShengchanID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.ShengchanID);
|
|
}
|
|
str = bankuaiTextBox.Text;
|
|
if (string.IsNullOrEmpty(str)) {
|
|
ConfigUtil.BanKuaiID = 0;
|
|
} else {
|
|
long.TryParse(str, out ConfigUtil.BanKuaiID);
|
|
}
|
|
|
|
Dispose();
|
|
}
|
|
}
|
|
}
|