91 lines
3.3 KiB
C#
91 lines
3.3 KiB
C#
using Sunny.UI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using 激光闪光法测试仪.Data;
|
|
|
|
namespace 激光闪光法测试仪
|
|
{
|
|
public partial class frm_Add : UIForm
|
|
{
|
|
Calculate_Parameters _Parameters;
|
|
public frm_Add(Calculate_Parameters cp)
|
|
{
|
|
InitializeComponent();
|
|
_Parameters = cp;
|
|
}
|
|
|
|
private void frm_Add_Load(object sender, EventArgs e)
|
|
{
|
|
tb_厚度.Text = ConfigurationManager.AppSettings["厚度"];
|
|
tb_品名.Text = ConfigurationManager.AppSettings["品名"];
|
|
tb_密度.Text = ConfigurationManager.AppSettings["密度"];
|
|
tb_批号.Text = ConfigurationManager.AppSettings["批号"];
|
|
tb_比热容.Text = ConfigurationManager.AppSettings["比热容"];
|
|
tb_校正系数.Text = ConfigurationManager.AppSettings["矫正系数"];
|
|
}
|
|
|
|
private void btn_保存_Click(object sender, EventArgs e)
|
|
{
|
|
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
|
|
bool result1=double.TryParse(tb_厚度.Text, out double result);
|
|
if (result1)
|
|
_Parameters.Thickness = result;
|
|
else
|
|
{
|
|
MessageBox.Show("厚度输入有误!");
|
|
return;
|
|
}
|
|
bool result2=double.TryParse(tb_密度.Text, out double result3);
|
|
if (result2)
|
|
_Parameters.Density = result3;
|
|
else
|
|
{
|
|
MessageBox.Show("密度输入有误!");
|
|
return;
|
|
}
|
|
_Parameters.Batch_number=tb_批号.Text;
|
|
|
|
bool result4=double.TryParse(tb_比热容.Text, out double result5);
|
|
if (result4)
|
|
_Parameters.Specific_heat_capacity = result5;
|
|
else
|
|
{
|
|
MessageBox.Show("比热容输入有误!");
|
|
return;
|
|
}
|
|
_Parameters.Test_Name=tb_品名.Text;
|
|
bool result6=double.TryParse(tb_校正系数.Text, out double result7);
|
|
if (result6)
|
|
_Parameters.Xishu = result7;
|
|
else
|
|
{
|
|
MessageBox.Show("矫正系数输入有误!");
|
|
return;
|
|
}
|
|
// 更新appSettings中的值
|
|
config.AppSettings.Settings["批号"].Value = tb_批号.Text;
|
|
config.AppSettings.Settings["品名"].Value = tb_品名.Text;
|
|
config.AppSettings.Settings["厚度"].Value = tb_厚度.Text;
|
|
config.AppSettings.Settings["密度"].Value = tb_密度.Text;
|
|
config.AppSettings.Settings["比热容"].Value = tb_比热容.Text;
|
|
config.AppSettings.Settings["矫正系数"].Value = tb_校正系数.Text;
|
|
// 保存更改
|
|
config.Save(ConfigurationSaveMode.Modified);
|
|
// 强制重新加载配置节,以确保更改立即生效(可选)
|
|
ConfigurationManager.RefreshSection("appSettings");
|
|
FromMain.isEnter = true;
|
|
MessageBox.Show("保存成功!");
|
|
}
|
|
}
|
|
|
|
}
|