2020-12-07 13:36:21 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using Config.Entities;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
using TBF.Resources;
|
2021-08-29 10:21:33 +00:00
|
|
|
|
using TBF.UI.Bench.Components;
|
2020-12-07 13:36:21 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.DataEntry.S620
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl
|
|
|
|
|
|
{
|
2021-02-02 11:30:27 +00:00
|
|
|
|
ComponentParametersDlg parent;
|
|
|
|
|
|
|
|
|
|
|
|
public bool ShowMore { get { return false; } }
|
2020-12-07 13:36:21 +00:00
|
|
|
|
|
|
|
|
|
|
EntryFormCfg config;
|
|
|
|
|
|
public IComponentCfg Config
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return config as IComponentCfg; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
config = value as EntryFormCfg;
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public EntryFormCfgCtrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Localize();
|
2021-02-02 11:30:27 +00:00
|
|
|
|
|
|
|
|
|
|
parent = ParentForm as ComponentParametersDlg;
|
|
|
|
|
|
if (parent == null) return;
|
|
|
|
|
|
|
2021-08-29 10:21:33 +00:00
|
|
|
|
if (parent.CmpntEntities != null)
|
2021-02-02 11:30:27 +00:00
|
|
|
|
{
|
2021-08-29 10:21:33 +00:00
|
|
|
|
foreach (var cmpnt in parent.CmpntEntities)
|
2021-02-02 11:30:27 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Output.DB.ProductionTracing.Factory)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentNameComboBox.Items.Add(cmpnt.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
closeButtonComboBox.Items.Add("<none>");
|
|
|
|
|
|
closeButtonComboBox.Items.Add("Tab");
|
|
|
|
|
|
closeButtonComboBox.Items.Add("+");
|
|
|
|
|
|
|
2020-12-07 13:36:21 +00:00
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Localize()
|
|
|
|
|
|
{
|
|
|
|
|
|
productionTracingCheckBox.Text = "Sledovanie výroby";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Closing()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
|
|
|
|
|
classNameLabel.Text = config.Factory.ClassName;
|
|
|
|
|
|
nameTextBox.Text = config.Name;
|
2021-02-02 11:30:27 +00:00
|
|
|
|
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
|
|
|
|
|
maxWMsCountTextBox.Text = config.MaxWMsCount.ToString();
|
|
|
|
|
|
closeButtonComboBox.Text = (config.CloseButton == '+') ? "+" : (config.CloseButton == '\t') ? "Tab" : "<none>";
|
2020-12-07 13:36:21 +00:00
|
|
|
|
productionTracingCheckBox.Checked = config.ProductionTracing;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
2021-02-02 11:30:27 +00:00
|
|
|
|
parentNameComboBox.Enabled = true;
|
|
|
|
|
|
maxWMsCountTextBox.Enabled = true;
|
|
|
|
|
|
closeButtonComboBox.Enabled = true;
|
2020-12-07 13:36:21 +00:00
|
|
|
|
productionTracingCheckBox.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
|
|
|
|
{
|
2021-02-02 11:30:27 +00:00
|
|
|
|
int dummy;
|
2020-12-07 13:36:21 +00:00
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
2021-02-02 11:30:27 +00:00
|
|
|
|
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "Invalid 'Parent Name'";
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!int.TryParse(maxWMsCountTextBox.Text, out dummy) || dummy <= 0 || dummy > 40)
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "Invalid 'Max. water meters count'";
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!closeButtonComboBox.Items.Contains(closeButtonComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "Invalid 'Close button'";
|
|
|
|
|
|
}
|
|
|
|
|
|
return flags;
|
2020-12-07 13:36:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags UpdateCfg()
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
|
|
|
|
|
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
|
|
|
|
|
|
|
|
|
|
|
config.Name = nameTextBox.Text;
|
2021-02-02 11:30:27 +00:00
|
|
|
|
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
|
|
|
|
|
config.MaxWMsCount = int.Parse(maxWMsCountTextBox.Text);
|
|
|
|
|
|
config.CloseButton = (closeButtonComboBox.Text == "+") ? '+' : (closeButtonComboBox.Text == "Tab") ? '\t' : '\0';
|
2020-12-07 13:36:21 +00:00
|
|
|
|
config.ProductionTracing = productionTracingCheckBox.Checked;
|
|
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|