2021-11-10 13:03:10 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
using Common;
|
|
|
|
|
|
using Config;
|
|
|
|
|
|
using Config.Entities;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.Rig.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.Rig.DataEntry.Double24
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg, IParamsProvider
|
|
|
|
|
|
{
|
|
|
|
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0];
|
|
|
|
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
|
|
|
|
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Serialized parameters
|
|
|
|
|
|
///
|
|
|
|
|
|
public bool EnterSerialNrsAtTheEnd;
|
|
|
|
|
|
public bool ShowCycleEndForm;
|
|
|
|
|
|
public bool HideOrderSelection;
|
|
|
|
|
|
public bool HidePrefix;
|
|
|
|
|
|
public string Column2Caption;
|
|
|
|
|
|
public Col2Dest Column2Destination;
|
|
|
|
|
|
|
|
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
|
|
|
|
EntryFormCfg() { }
|
|
|
|
|
|
|
|
|
|
|
|
public EntryFormCfg(IComponentFactory factory, string name)
|
|
|
|
|
|
: this()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Factory = factory;
|
|
|
|
|
|
this.Name = name;
|
|
|
|
|
|
ParentName = string.Empty;
|
|
|
|
|
|
InitializeAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
|
|
|
|
|
|
|
|
public void InitializeAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
EnterSerialNrsAtTheEnd = false;
|
|
|
|
|
|
ShowCycleEndForm = false;
|
|
|
|
|
|
HideOrderSelection = false;
|
|
|
|
|
|
HidePrefix = true;
|
|
|
|
|
|
Column2Caption = "Radio address";
|
|
|
|
|
|
Column2Destination = Col2Dest.RadioAddress;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
Strings.Enter_SNs_at_the_end,
|
|
|
|
|
|
Strings.Show_cycle_end_form,
|
|
|
|
|
|
"Hide order selection",
|
|
|
|
|
|
"Hide prefix selection",
|
|
|
|
|
|
"Column 2 caption",
|
|
|
|
|
|
"Column 2 destination",
|
|
|
|
|
|
};
|
|
|
|
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
|
|
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
|
|
|
|
|
|
|
|
public ICollection<string> ParamValues(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
return new string[] { Strings.yes, Strings.no };
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
for (Col2Dest c2d = 0; c2d < Col2Dest.Count; c2d++) list.Add(c2d.ToDescription());
|
|
|
|
|
|
return list;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ToString(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
return EnterSerialNrsAtTheEnd ? Strings.yes : Strings.no;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
return ShowCycleEndForm ? Strings.yes : Strings.no;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return HideOrderSelection ? Strings.yes : Strings.no;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
return HidePrefix ? Strings.yes : Strings.no;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
return Column2Caption;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
return Column2Destination.ToDescription();
|
|
|
|
|
|
default:
|
|
|
|
|
|
return string.Format("Name={0}, Enter SNs at the end={1}, Show cycle end form={2}", Name, EnterSerialNrsAtTheEnd, ShowCycleEndForm);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string str)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
EnterSerialNrsAtTheEnd = (str == Strings.yes);
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
ShowCycleEndForm = (str == Strings.yes);
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
HideOrderSelection = (str == Strings.yes);
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
HidePrefix = (str == Strings.yes);
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
Column2Caption = str;
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
for (Col2Dest c2d = 0; c2d < Col2Dest.Count; c2d++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (str == c2d.ToDescription())
|
|
|
|
|
|
{
|
|
|
|
|
|
Column2Destination = c2d;
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return CfgUpdateFlags.None;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return CfgUpdateFlags.None;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool ValidateParam(int i, string str, out string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
message = string.Empty;
|
|
|
|
|
|
if (ParamValues(i).Contains(str)) return true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
message = string.Empty;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
default:
|
|
|
|
|
|
message = "Invalid index";
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message = string.Format(Strings.Invalid_0, ParamName(i)) ;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CopyContentTo(EntryFormCfg prms)
|
|
|
|
|
|
{
|
|
|
|
|
|
prms.EnterSerialNrsAtTheEnd = EnterSerialNrsAtTheEnd;
|
|
|
|
|
|
prms.ShowCycleEndForm = ShowCycleEndForm;
|
|
|
|
|
|
prms.HideOrderSelection = HideOrderSelection;
|
|
|
|
|
|
prms.HidePrefix = HidePrefix;
|
|
|
|
|
|
prms.Column2Caption = Column2Caption;
|
|
|
|
|
|
prms.Column2Destination = Column2Destination;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-23 18:56:15 +00:00
|
|
|
|
public IParamsProvider Clone()
|
2021-11-10 13:03:10 +00:00
|
|
|
|
{
|
|
|
|
|
|
EntryFormCfg pars = new EntryFormCfg();
|
|
|
|
|
|
CopyContentTo(pars);
|
|
|
|
|
|
return pars;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
|
|
|
|
{
|
|
|
|
|
|
return true; /// =OK, do nothing
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Col2Dest
|
|
|
|
|
|
{
|
|
|
|
|
|
[Description("Radio address")] RadioAddress,
|
|
|
|
|
|
[Description("Serial nr. Aux")] SerialNrAux,
|
|
|
|
|
|
[Description("Purchase order")] OrderNr,
|
|
|
|
|
|
[Description("Remark")] Remark,
|
|
|
|
|
|
#if ORACLE_DB
|
|
|
|
|
|
[Description("Suffix")] Suffix,
|
|
|
|
|
|
#endif
|
|
|
|
|
|
Count
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|