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.
107 lines
3.8 KiB
C#
107 lines
3.8 KiB
C#
using DevExpress.XtraEditors;
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using ZJ_BYD.Common;
|
|
using ZJ_BYD.DB;
|
|
using ZJ_BYD.Model;
|
|
using ZJ_BYD.Untils;
|
|
|
|
namespace ZJ_BYD.UserControls
|
|
{
|
|
public partial class CurrentConfig : XtraUserControl
|
|
{
|
|
private static int _id = 0;
|
|
public CurrentConfig()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void CurrentConfig_Load(object sender, EventArgs e)
|
|
{
|
|
BindCombox.BindAreaForLookUp(lkArea);
|
|
GetData();
|
|
}
|
|
|
|
private void GetData()
|
|
{
|
|
var model = CurrentConfigHelper.QueryCurrentConfigs().Where(m => m.IpcId == Program.CurrentIpcId).First();
|
|
if (model != null)
|
|
{
|
|
_id = model.Id;
|
|
txtlinename.Text = model.LineName;
|
|
txtmesip.Text = model.MesIp;
|
|
txtmesport.Text = model.MesPort;
|
|
txtplcip.Text = model.PlcIp;
|
|
txtplcport.Text = model.PlcPort;
|
|
txthightpwd.Text = model.HightPwd;
|
|
txtmenupwd.Text = model.MenuPwd;
|
|
lkArea.EditValue = model.AreaCode;
|
|
lkDept.EditValue = model.DeptCode;
|
|
}
|
|
else
|
|
{
|
|
txtplcport.Text = "44818";
|
|
}
|
|
}
|
|
|
|
private void lkArea_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
BindCombox.BindDeptForLookUp(lkDept, lkArea.EditValue?.ToString());
|
|
}
|
|
|
|
private void btnsave_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult dialogResult = MessageBox.Show("修改配置后需重启系统,确认要修改配置吗?", "提示", MessageBoxButtons.OKCancel);
|
|
if (dialogResult == DialogResult.OK)
|
|
{
|
|
var flag = this.RegexSave(new Control[] { txtlinename, lkArea, lkDept, txtmesip, txtmesport, txtplcport, txthightpwd, txtmenupwd }, out _);
|
|
if (!flag)
|
|
{
|
|
return;
|
|
}
|
|
splashScreenManager1.ShowWaitForm();
|
|
var t_CurrentConfig = new T_CurrentConfig
|
|
{
|
|
IpcId = Program.CurrentIpcId,
|
|
LineCode = Program.CurrentLineCode,
|
|
LineName = txtlinename.Text,
|
|
MesIp = txtmesip.Text,
|
|
MesPort = txtmesport.Text,
|
|
PlcIp = txtplcip.Text,
|
|
PlcPort = txtplcport.Text,
|
|
HightPwd = txthightpwd.Text,
|
|
MenuPwd = txtmenupwd.Text,
|
|
AreaCode = lkArea.EditValue.ToString(),
|
|
DeptCode = lkDept.EditValue.ToString()
|
|
};
|
|
int row;
|
|
if (_id == 0)
|
|
{
|
|
t_CurrentConfig.CreatedTime = DateTime.Now;
|
|
t_CurrentConfig.CreatedBy = CurrentUser.UserName;
|
|
row = CurrentConfigHelper.AddCurrentConfig(t_CurrentConfig);
|
|
}
|
|
else
|
|
{
|
|
t_CurrentConfig.Id = _id;
|
|
t_CurrentConfig.UpdatedTime = DateTime.Now;
|
|
t_CurrentConfig.UpdatedBy = CurrentUser.UserName;
|
|
row = CurrentConfigHelper.UpdateCurrentConfig(t_CurrentConfig);
|
|
}
|
|
if (row <= 0)
|
|
{
|
|
splashScreenManager1.CloseWaitForm();
|
|
XtraMessageBox.Show("操作失败!");
|
|
return;
|
|
}
|
|
splashScreenManager1.CloseWaitForm();
|
|
var result = XtraMessageBox.Show("操作成功,请重启系统!", "系统提示", MessageBoxButtons.OK);
|
|
if (result == DialogResult.OK)
|
|
{
|
|
Environment.Exit(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|