Newer
Older
RbFreqStand / RbFreqStandMeasure / setting / SettingCtrlForm.cs
yangqianqian on 30 Apr 2021 4 KB 4.30
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model;
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service;
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl;
using Casic.Birmm.RbFreqStandMeasure.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace Casic.Birmm.RbFreqStandMeasure.setting
{
    public partial class SettingCtrlForm : UserControl
    {
        DictService dictService = new DictServiceImpl();
        //CounterParam

        public SettingCtrlForm()
        {
            InitializeComponent();

            CounterParam counterParam = dictService.getCounterParam();
            text_generatorIp.Text = counterParam.GeneratorIp;
            text_exportPath.Text = ConfigHelper.GetAppConfig("exportPath").ToString().Trim() ;
            initCheckParam();
        }

        private void initCheckParam()
        {
            CounterCheckParam counterCheckParam = dictService.getCounterCheckParam();
            text_soOutDelay.Text = counterCheckParam.SoOutDelay;
            text_soEleFrequency.Text = counterCheckParam.SoEleFrequency;
            text_soEleAlarm.Text = counterCheckParam.SoEleAlarm;
            text_soEleAddValue.Text = counterCheckParam.SoEleAddValue;

            text_freThreshold1.Text = counterCheckParam.FreThreshold1;
            text_freThreshold2.Text = counterCheckParam.FreThreshold2;

            text_cycThreshold1.Text = counterCheckParam.CycThreshold1;
            text_cycThreshold2.Text = counterCheckParam.CycThreshold2;

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //if (text_generatorIp.Text.Trim().Equals(""))
                //{
                //    MessageBox.Show("请输入计数器IP");
                //    return;
                //}
                if (text_exportPath.Text.Trim().Equals(""))
                {
                    MessageBox.Show("请选择数据导出默认路径");
                    return;
                }
                ConfigHelper.UpdateAppConfig("exportPath", text_exportPath.Text.Trim());
                dictService.updateCounterIp(text_generatorIp.Text.Trim());

                MessageBox.Show("保存成功!");
            }
            catch(Exception ex)
            {
                LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "保存失败:"+ ex.Message);
                MessageBox.Show("保存失败!");
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            CounterParam counterParam = dictService.getCounterParam();
            text_generatorIp.Text = counterParam.GeneratorIp;
            text_exportPath.Text = ConfigHelper.GetAppConfig("exportPath").ToString().Trim();
        }

        private void roundButton1_Click(object sender, EventArgs e)
        {
            initCheckParam();
        }

        private void roundButton2_Click(object sender, EventArgs e)
        {
            CounterCheckParam counterCheckParam = new CounterCheckParam();
            counterCheckParam.SoOutDelay = text_soOutDelay.Text;
            counterCheckParam.SoEleFrequency  = text_soEleFrequency.Text;
            counterCheckParam.SoEleAlarm  =  text_soEleAlarm.Text ;
            counterCheckParam.SoEleAddValue =  text_soEleAddValue.Text ;

            counterCheckParam.FreThreshold1= text_freThreshold1.Text ;
            counterCheckParam.FreThreshold2= text_freThreshold2.Text  ;

            counterCheckParam.CycThreshold1= text_cycThreshold1.Text  ;
            counterCheckParam.CycThreshold2= text_cycThreshold2.Text  ;

            dictService.updateCheckParam(counterCheckParam);

            MessageBox.Show("保存成功");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择路径";
            
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string strSaveFileLocation = dialog.SelectedPath;//文件路径
                text_exportPath.Text = strSaveFileLocation;
            }
        }
    }
}