DataEntry.Uni Items passed in a list, w/o limits, Cfg with arrays, TODO: TestStartEndForm
This commit is contained in:
parent
b67857f658
commit
b2a7cfb0d4
@ -249,17 +249,22 @@ namespace TBF
|
|||||||
public string[] LastBgComm1;
|
public string[] LastBgComm1;
|
||||||
public string[] LastBgComm2;
|
public string[] LastBgComm2;
|
||||||
public string[] LastBgComm3;
|
public string[] LastBgComm3;
|
||||||
|
///
|
||||||
public string[] LastBgColA;
|
public string[] LastBgColA;
|
||||||
public string[] LastBgColB;
|
public string[] LastBgColB;
|
||||||
public string[] LastBgColC;
|
public string[] LastBgColC;
|
||||||
public string[] LastBgColD;
|
public string[] LastBgColD;
|
||||||
|
public string[] LastBgColE;
|
||||||
|
///
|
||||||
public string[] LastEnComm1;
|
public string[] LastEnComm1;
|
||||||
public string[] LastEnComm2;
|
public string[] LastEnComm2;
|
||||||
public string[] LastEnComm3;
|
public string[] LastEnComm3;
|
||||||
|
///
|
||||||
public string[] LastEnColA;
|
public string[] LastEnColA;
|
||||||
public string[] LastEnColB;
|
public string[] LastEnColB;
|
||||||
public string[] LastEnColC;
|
public string[] LastEnColC;
|
||||||
public string[] LastEnColD;
|
public string[] LastEnColD;
|
||||||
|
public string[] LastEnColE;
|
||||||
|
|
||||||
/// Purchase order history
|
/// Purchase order history
|
||||||
public string[] PurchaseOrderHistory;
|
public string[] PurchaseOrderHistory;
|
||||||
|
|||||||
@ -71,8 +71,9 @@ namespace TBF.Rig.Configs.ParamsProvider
|
|||||||
foreach (var p in parents) parentComboBox.Items.Add(p.Name);
|
foreach (var p in parents) parentComboBox.Items.Add(p.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
editors = new Control[paramsProvider.ParamsCount()];
|
int paramsCount = paramsProvider.ParamsCount();
|
||||||
for (int i = 0; i < paramsProvider.ParamsCount(); i++)
|
editors = new Control[paramsCount];
|
||||||
|
for (int i = 0; i < paramsCount; i++)
|
||||||
{
|
{
|
||||||
ICollection<string> values = paramsProvider.ParamValues(i);
|
ICollection<string> values = paramsProvider.ParamValues(i);
|
||||||
if (values == null)
|
if (values == null)
|
||||||
@ -130,7 +131,8 @@ namespace TBF.Rig.Configs.ParamsProvider
|
|||||||
if (parentComboBox.Visible) parentComboBox.Text = Config.ParentName;
|
if (parentComboBox.Visible) parentComboBox.Text = Config.ParentName;
|
||||||
|
|
||||||
paramsListViewEx.Items.Clear();
|
paramsListViewEx.Items.Clear();
|
||||||
for (int i = 0; i < paramsProvider.ParamsCount(); i++)
|
int paramsCount = paramsProvider.ParamsCount();
|
||||||
|
for (int i = 0; i < paramsCount; i++)
|
||||||
{
|
{
|
||||||
ListViewItem lvi = new ListViewItem(paramsProvider.ParamName(i));
|
ListViewItem lvi = new ListViewItem(paramsProvider.ParamName(i));
|
||||||
lvi.SubItems.Add(paramsProvider.ToString(i));
|
lvi.SubItems.Add(paramsProvider.ToString(i));
|
||||||
|
|||||||
@ -21,9 +21,7 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
readonly int lineSize;
|
readonly int lineSize;
|
||||||
readonly Sz sz;
|
readonly Sz sz;
|
||||||
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
|
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
|
||||||
readonly DEItem item1;
|
readonly IList<DEItem> commonItems;
|
||||||
readonly DEItem item2;
|
|
||||||
readonly DEItem item3;
|
|
||||||
readonly IList<DEItem> colItems;
|
readonly IList<DEItem> colItems;
|
||||||
readonly bool isEnd;
|
readonly bool isEnd;
|
||||||
readonly string formCloseKeys;
|
readonly string formCloseKeys;
|
||||||
@ -32,6 +30,7 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
readonly WaterMeter firstValidWM;
|
readonly WaterMeter firstValidWM;
|
||||||
readonly int wmsCount;
|
readonly int wmsCount;
|
||||||
readonly int linesCount;
|
readonly int linesCount;
|
||||||
|
readonly int commonItemsCount;
|
||||||
|
|
||||||
/// Size and layout related values
|
/// Size and layout related values
|
||||||
readonly Font font;
|
readonly Font font;
|
||||||
@ -45,13 +44,14 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
readonly int checkBoxWid;
|
readonly int checkBoxWid;
|
||||||
|
|
||||||
/// UI elements
|
/// UI elements
|
||||||
readonly ComboBox comboBox1; /// Combo box for the 1st common item
|
readonly Label[] commonLabels;
|
||||||
readonly ComboBox comboBox2; /// Combo box for the 2nd common item
|
readonly ComboBox[] commonComboBoxes;
|
||||||
readonly ComboBox comboBox3; /// Combo box for the 3rd common item
|
|
||||||
readonly Label[] labels; /// Labels for water meter numbers
|
readonly Label[] labels; /// Labels for water meter numbers
|
||||||
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
|
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
|
||||||
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
|
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
|
||||||
|
|
||||||
|
readonly LocalSettings ls;
|
||||||
|
|
||||||
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
|
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
|
||||||
|
|
||||||
/// Set to 'true' when the form closes
|
/// Set to 'true' when the form closes
|
||||||
@ -74,7 +74,7 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="wmsCount">Number of text boxes for serial numbers</param>
|
/// <param name="wmsCount">Number of text boxes for serial numbers</param>
|
||||||
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
|
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, Sz sz, bool isLrOrder, string formCloseKeys,
|
||||||
DEItem item1, DEItem item2, DEItem item3, IList<DEItem> colItems, bool isEnd = false)
|
IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ControlBox = false;
|
ControlBox = false;
|
||||||
@ -86,17 +86,20 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
this.sz = sz;
|
this.sz = sz;
|
||||||
this.isLrOrder = isLrOrder;
|
this.isLrOrder = isLrOrder;
|
||||||
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
|
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
|
||||||
this.item1 = item1;
|
this.commonItems = commonItems;
|
||||||
this.item2 = item2;
|
|
||||||
this.item3 = item3;
|
|
||||||
this.colItems = colItems;
|
this.colItems = colItems;
|
||||||
this.isEnd = isEnd;
|
this.isEnd = isEnd;
|
||||||
|
|
||||||
|
ls = Program.LocalSettings;
|
||||||
|
|
||||||
/// Readonly variables derived from arguments
|
/// Readonly variables derived from arguments
|
||||||
|
commonItemsCount = (commonItems == null) ? 0 : commonItems.Count;
|
||||||
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
|
wmsCount = (waterMeters == null) ? 0 : waterMeters.Count;
|
||||||
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
|
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
|
||||||
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
|
firstValidWM = (waterMeters != null) ? waterMeters.FirstOrDefault(x => (x != null && !x.Disabled)) : null;
|
||||||
///
|
///
|
||||||
|
commonLabels = new Label[commonItemsCount];
|
||||||
|
commonComboBoxes = new ComboBox[commonItemsCount];
|
||||||
labels = new Label[wmsCount];
|
labels = new Label[wmsCount];
|
||||||
comboBoxes = new ComboBox[colItems.Count, wmsCount];
|
comboBoxes = new ComboBox[colItems.Count, wmsCount];
|
||||||
checkBoxes = new CheckBox[wmsCount];
|
checkBoxes = new CheckBox[wmsCount];
|
||||||
@ -146,128 +149,63 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
///
|
///
|
||||||
/// Group box with common items
|
/// Group box with common items
|
||||||
///
|
///
|
||||||
int groupBoxHeight = 0;
|
|
||||||
int groupBoxWidth = 0;
|
int groupBoxWidth = 0;
|
||||||
if (item1.Content != Content.None)
|
int groupBoxHeight = 0;
|
||||||
|
if (commonItemsCount > 0)
|
||||||
{
|
{
|
||||||
var groupBox = new GroupBox();
|
var groupBox = new GroupBox();
|
||||||
|
|
||||||
int label1Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item1.Caption, font).Width);
|
int labelsWidth = 0;
|
||||||
var label1 = new Label
|
for (int ix = 0; ix < commonItemsCount; ix++)
|
||||||
{
|
{
|
||||||
Text = item1.Caption,
|
int oneLabelWidth = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(commonItems[ix].Caption, font).Width);
|
||||||
Font = font,
|
var oneLabel = new Label
|
||||||
Location = new Point(margin, 2 * spacing),
|
|
||||||
Size = new Size(label1Width + spacing, meterHeight),
|
|
||||||
TextAlign = ContentAlignment.MiddleLeft,
|
|
||||||
TabIndex = tabIndex++,
|
|
||||||
Parent = groupBox,
|
|
||||||
};
|
|
||||||
groupBox.Controls.Add(label1);
|
|
||||||
int labelsWidth = label1Width;
|
|
||||||
|
|
||||||
if (item2.Content != Content.None)
|
|
||||||
{
|
|
||||||
int label2Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item2.Caption, font).Width);
|
|
||||||
var label2 = new Label
|
|
||||||
{
|
{
|
||||||
Text = item2.Caption,
|
Text = commonItems[ix].Caption,
|
||||||
Font = font,
|
Font = font,
|
||||||
Location = new Point(margin, 3 * spacing + meterHeight),
|
Location = new Point(margin, (ix + 2) * spacing + ix * meterHeight),
|
||||||
Size = new Size(label2Width + spacing, meterHeight),
|
Size = new Size(oneLabelWidth + spacing, meterHeight),
|
||||||
TextAlign = ContentAlignment.MiddleLeft,
|
TextAlign = ContentAlignment.MiddleLeft,
|
||||||
TabIndex = tabIndex++,
|
TabIndex = tabIndex++,
|
||||||
Parent = groupBox,
|
Parent = groupBox,
|
||||||
};
|
};
|
||||||
groupBox.Controls.Add(label2);
|
groupBox.Controls.Add(oneLabel);
|
||||||
labelsWidth = Math.Max(labelsWidth, label2Width);
|
labelsWidth = Math.Max(labelsWidth, oneLabelWidth);
|
||||||
|
|
||||||
if (item3.Content != Content.None)
|
|
||||||
{
|
|
||||||
int label3Width = Convert.ToInt32(Graphics.FromImage(new Bitmap(1, 1)).MeasureString(item3.Caption, font).Width);
|
|
||||||
var label3 = new Label
|
|
||||||
{
|
|
||||||
Text = item3.Caption,
|
|
||||||
Font = font,
|
|
||||||
Location = new Point(margin, 4 * spacing + 2 * meterHeight),
|
|
||||||
Size = new Size(label3Width + spacing, meterHeight),
|
|
||||||
TextAlign = ContentAlignment.MiddleLeft,
|
|
||||||
TabIndex = tabIndex++,
|
|
||||||
Parent = groupBox,
|
|
||||||
};
|
|
||||||
groupBox.Controls.Add(label3);
|
|
||||||
labelsWidth = Math.Max(labelsWidth, label3Width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comboBox1 = new ComboBox
|
int combosWidth = 0;
|
||||||
|
for (int ix = 0; ix < commonItemsCount; ix++)
|
||||||
{
|
{
|
||||||
Name = "-1~1",
|
var cb = new ComboBox
|
||||||
Location = new Point(margin + spacing + labelsWidth, 2 * spacing),
|
|
||||||
Size = new Size(item1.Width, meterHeight),
|
|
||||||
Enabled = (item1.Action != Action.LoadReadOnly),
|
|
||||||
Font = font,
|
|
||||||
TabIndex = tabIndex++,
|
|
||||||
Parent = groupBox,
|
|
||||||
};
|
|
||||||
|
|
||||||
comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
|
||||||
comboBox1.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
|
|
||||||
comboBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
|
|
||||||
|
|
||||||
AddHistoryToCombo(comboBox1, isEnd ? Program.LocalSettings.LastEnComm1 : Program.LocalSettings.LastBgComm1);
|
|
||||||
groupBox.Controls.Add(comboBox1);
|
|
||||||
int combosWidth = item1.Width;
|
|
||||||
|
|
||||||
if (item2.Content != Content.None)
|
|
||||||
{
|
|
||||||
comboBox2 = new ComboBox
|
|
||||||
{
|
{
|
||||||
Name = "-1~2",
|
Name = string.Format("-1~{0}", ix + 1),
|
||||||
Location = new Point(margin + spacing + labelsWidth, 3 * spacing + meterHeight),
|
Location = new Point(margin + spacing + labelsWidth, (ix + 2) * spacing + ix * meterHeight),
|
||||||
Size = new Size(item2.Width, meterHeight),
|
Size = new Size(commonItems[ix].Width, meterHeight),
|
||||||
Enabled = (item2.Action != Action.LoadReadOnly),
|
Enabled = (commonItems[ix].Action != Ac.LoadReadOnly),
|
||||||
Font = font,
|
Font = font,
|
||||||
TabIndex = tabIndex++,
|
TabIndex = tabIndex++,
|
||||||
Parent = groupBox,
|
Parent = groupBox,
|
||||||
};
|
};
|
||||||
|
|
||||||
comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
cb.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
||||||
comboBox2.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
|
cb.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
|
||||||
comboBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
|
cb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
|
||||||
|
|
||||||
AddHistoryToCombo(comboBox2, isEnd ? Program.LocalSettings.LastEnComm2 : Program.LocalSettings.LastBgComm2);
|
switch (ix)
|
||||||
groupBox.Controls.Add(comboBox2);
|
|
||||||
combosWidth = Math.Max(combosWidth, item2.Width);
|
|
||||||
|
|
||||||
if (item3.Content != Content.None)
|
|
||||||
{
|
{
|
||||||
comboBox3 = new ComboBox
|
case 0: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm1 : ls.LastBgComm1); break;
|
||||||
{
|
case 1: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm2 : ls.LastBgComm2); break;
|
||||||
Name = "-1~3",
|
case 2: AddHistoryToCombo(cb, isEnd ? ls.LastEnComm3 : ls.LastBgComm3); break;
|
||||||
Location = new Point(margin + spacing + labelsWidth, 4 * spacing + 2 * meterHeight),
|
|
||||||
Size = new Size(item3.Width, meterHeight),
|
|
||||||
Enabled = (item3.Action != Action.LoadReadOnly),
|
|
||||||
Font = font,
|
|
||||||
TabIndex = tabIndex++,
|
|
||||||
Parent = groupBox,
|
|
||||||
};
|
|
||||||
|
|
||||||
comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
|
|
||||||
comboBox3.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
|
|
||||||
comboBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
|
|
||||||
|
|
||||||
AddHistoryToCombo(comboBox3, isEnd ? Program.LocalSettings.LastEnComm3 : Program.LocalSettings.LastBgComm3);
|
|
||||||
groupBox.Controls.Add(comboBox3);
|
|
||||||
combosWidth = Math.Max(combosWidth, item3.Width);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
commonComboBoxes[ix] = cb;
|
||||||
|
groupBox.Controls.Add(cb);
|
||||||
|
combosWidth = Math.Max(combosWidth, commonItems[ix].Width);
|
||||||
|
}
|
||||||
|
///
|
||||||
groupBox.Location = new Point(margin, margin - spacing);
|
groupBox.Location = new Point(margin, margin - spacing);
|
||||||
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
|
groupBoxWidth = labelsWidth + combosWidth + 2 * margin + spacing;
|
||||||
groupBoxHeight = (item3.Content != Content.None) ? 3 * meterHeight + 5 * spacing
|
groupBoxHeight = commonItemsCount * meterHeight + (commonItemsCount + 2) * spacing;
|
||||||
: (item2.Content != Content.None) ? 2 * meterHeight + 4 * spacing
|
|
||||||
: meterHeight + 3 * spacing;
|
|
||||||
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
|
groupBox.Size = new Size(groupBoxWidth, groupBoxHeight);
|
||||||
groupBox.Font = font;
|
groupBox.Font = font;
|
||||||
groupBox.TabIndex = tabIndex++;
|
groupBox.TabIndex = tabIndex++;
|
||||||
@ -331,7 +269,7 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
Name = string.Format("{0}~{1}", k, wmPos0),
|
Name = string.Format("{0}~{1}", k, wmPos0),
|
||||||
Location = new Point(left, top),
|
Location = new Point(left, top),
|
||||||
Size = new Size(ci.Width, meterHeight),
|
Size = new Size(ci.Width, meterHeight),
|
||||||
Enabled = (ci.Action != Action.LoadReadOnly && !waterMeters[wmPos0].Disabled),
|
Enabled = (ci.Action != Ac.LoadReadOnly && !waterMeters[wmPos0].Disabled),
|
||||||
Font = font,
|
Font = font,
|
||||||
TabIndex = tabIndex++,
|
TabIndex = tabIndex++,
|
||||||
Parent = this,
|
Parent = this,
|
||||||
@ -373,19 +311,17 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
InitializeBoxes();
|
InitializeBoxes();
|
||||||
|
|
||||||
/// Set focus to the first enabled ComboBox
|
/// Set focus to the first enabled ComboBox
|
||||||
if (comboBox1 != null && comboBox1.Enabled)
|
bool activeControlFound = false;
|
||||||
|
for (int ix = 0; ix < commonItemsCount; ix++)
|
||||||
{
|
{
|
||||||
ActiveControl = comboBox1;
|
if (commonComboBoxes[ix].Enabled)
|
||||||
|
{
|
||||||
|
ActiveControl = commonComboBoxes[ix];
|
||||||
|
activeControlFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (comboBox2 != null && comboBox2.Enabled)
|
if (!activeControlFound)
|
||||||
{
|
|
||||||
ActiveControl = comboBox2;
|
|
||||||
}
|
|
||||||
else if (comboBox3 != null && comboBox3.Enabled)
|
|
||||||
{
|
|
||||||
ActiveControl = comboBox3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
|
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
|
||||||
int k, j;
|
int k, j;
|
||||||
@ -421,7 +357,7 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an array of strings from Program.LocalSettings.
|
/// Returns an array of strings from ls.
|
||||||
/// Never returns null, null is converted to new string[0].
|
/// Never returns null, null is converted to new string[0].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
|
/// <param name="isEnd">false = Beginning of cycle, true = End of cycle</param>
|
||||||
@ -433,38 +369,24 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
{
|
{
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
default:
|
case 0: if (ls.LastEnColA == null) ls.LastEnColA = new string[0]; return ls.LastEnColA;
|
||||||
case 0:
|
case 1: if (ls.LastEnColB == null) ls.LastEnColB = new string[0]; return ls.LastEnColB;
|
||||||
if (Program.LocalSettings.LastEnColA == null) Program.LocalSettings.LastEnColA = new string[0];
|
case 2: if (ls.LastEnColC == null) ls.LastEnColC = new string[0]; return ls.LastEnColC;
|
||||||
return Program.LocalSettings.LastEnColA;
|
case 3: if (ls.LastEnColD == null) ls.LastEnColD = new string[0]; return ls.LastEnColD;
|
||||||
case 1:
|
case 4: if (ls.LastEnColE == null) ls.LastEnColE = new string[0]; return ls.LastEnColE;
|
||||||
if (Program.LocalSettings.LastEnColB == null) Program.LocalSettings.LastEnColB = new string[0];
|
default: return new string[0];
|
||||||
return Program.LocalSettings.LastEnColB;
|
|
||||||
case 2:
|
|
||||||
if (Program.LocalSettings.LastEnColC == null) Program.LocalSettings.LastEnColC = new string[0];
|
|
||||||
return Program.LocalSettings.LastEnColC;
|
|
||||||
case 3:
|
|
||||||
if (Program.LocalSettings.LastEnColD == null) Program.LocalSettings.LastEnColD = new string[0];
|
|
||||||
return Program.LocalSettings.LastEnColD;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
default:
|
case 0: if (ls.LastBgColA == null) ls.LastBgColA = new string[0]; return ls.LastBgColA;
|
||||||
case 0:
|
case 1: if (ls.LastBgColB == null) ls.LastBgColB = new string[0]; return ls.LastBgColB;
|
||||||
if (Program.LocalSettings.LastBgColA == null) Program.LocalSettings.LastBgColA = new string[0];
|
case 2: if (ls.LastBgColC == null) ls.LastBgColC = new string[0]; return ls.LastBgColC;
|
||||||
return Program.LocalSettings.LastBgColA;
|
case 3: if (ls.LastBgColD == null) ls.LastBgColD = new string[0]; return ls.LastBgColD;
|
||||||
case 1:
|
case 4: if (ls.LastBgColE == null) ls.LastBgColE = new string[0]; return ls.LastBgColE;
|
||||||
if (Program.LocalSettings.LastBgColB == null) Program.LocalSettings.LastBgColB = new string[0];
|
default: return new string[0];
|
||||||
return Program.LocalSettings.LastBgColB;
|
|
||||||
case 2:
|
|
||||||
if (Program.LocalSettings.LastBgColC == null) Program.LocalSettings.LastBgColC = new string[0];
|
|
||||||
return Program.LocalSettings.LastBgColC;
|
|
||||||
case 3:
|
|
||||||
if (Program.LocalSettings.LastBgColD == null) Program.LocalSettings.LastBgColD = new string[0];
|
|
||||||
return Program.LocalSettings.LastBgColD;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,30 +406,26 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
isHandlersEnabled = false;
|
isHandlersEnabled = false;
|
||||||
|
|
||||||
/// Common combo boxes
|
/// Common combo boxes
|
||||||
var commCBs = new ComboBox[] { comboBox1, comboBox2, comboBox3 };
|
for (int ix = 0; ix < commonItemsCount; ix++)
|
||||||
int ix = 0;
|
|
||||||
foreach (var commItem in new DEItem[] { item1, item2, item3 })
|
|
||||||
{
|
{
|
||||||
if (commItem.Content == Content.None) break;
|
switch (commonItems[ix].Action)
|
||||||
|
|
||||||
switch (commItem.Action)
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case Action.Clear:
|
case Ac.Clear:
|
||||||
commCBs[ix].Text = string.Empty;
|
commonComboBoxes[ix].Text = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action.HistoryLast:
|
case Ac.HistoryLast:
|
||||||
commCBs[ix].Text = commCBs[ix].Items.Count > 0 ? commCBs[ix].Items[0].ToString() : string.Empty;
|
commonComboBoxes[ix].Text = (commonComboBoxes[ix].Items.Count > 0)
|
||||||
|
? commonComboBoxes[ix].Items[0].ToString()
|
||||||
|
: string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action.Load:
|
case Ac.Load:
|
||||||
case Action.LoadReadOnly:
|
case Ac.LoadReadOnly:
|
||||||
commCBs[ix].Text = GetContent(commItem.Content, firstValidWM);
|
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ix++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Table
|
/// Table
|
||||||
@ -516,22 +434,22 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
switch (colItems[k].Action)
|
switch (colItems[k].Action)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case Action.Clear:
|
case Ac.Clear:
|
||||||
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
|
for (int i = 0; i < wmsCount; i++) comboBoxes[k, i].Text = string.Empty;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action.HistoryLast:
|
case Ac.HistoryLast:
|
||||||
for (int i = 0; i < wmsCount; i++)
|
for (int i = 0; i < wmsCount; i++)
|
||||||
{
|
{
|
||||||
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
|
comboBoxes[k, i].Text = comboBoxes[k, i].Items.Count > 0 ? comboBoxes[k, i].Items[0].ToString() : string.Empty;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Action.Load:
|
case Ac.Load:
|
||||||
case Action.LoadReadOnly:
|
case Ac.LoadReadOnly:
|
||||||
for (int i = 0; i < wmsCount; i++)
|
for (int i = 0; i < wmsCount; i++)
|
||||||
{
|
{
|
||||||
comboBoxes[k, i].Text = GetContent(colItems[k].Content, WaterMeters[i]);
|
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -551,31 +469,27 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void UpdateWMsFromBoxes()
|
void UpdateWMsFromBoxes()
|
||||||
{
|
{
|
||||||
if (item1.Content != Content.None && firstValidWM != null)
|
for (int ix = 0; ix < commonItemsCount; ix++ )
|
||||||
{
|
{
|
||||||
PutContent(item1.Content, firstValidWM, comboBox1.Text);
|
DEUtils.PutContent(commonItems[ix].Content, firstValidWM, commonComboBoxes[ix].Text);
|
||||||
if (item1.Action != Action.LoadReadOnly)
|
if (commonItems[ix].Action != Ac.LoadReadOnly)
|
||||||
{
|
{
|
||||||
if (isEnd) Program.LocalSettings.UpdateHistory(comboBox1.Text, ref Program.LocalSettings.LastEnComm1);
|
if (isEnd)
|
||||||
else Program.LocalSettings.UpdateHistory(comboBox1.Text, ref Program.LocalSettings.LastBgComm1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item2.Content != Content.None)
|
|
||||||
{
|
|
||||||
PutContent(item2.Content, firstValidWM, comboBox2.Text);
|
|
||||||
if (item2.Action != Action.LoadReadOnly)
|
|
||||||
{
|
{
|
||||||
if (isEnd) Program.LocalSettings.UpdateHistory(comboBox2.Text, ref Program.LocalSettings.LastEnComm2);
|
switch (ix)
|
||||||
else Program.LocalSettings.UpdateHistory(comboBox2.Text, ref Program.LocalSettings.LastBgComm2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item3.Content != Content.None)
|
|
||||||
{
|
|
||||||
PutContent(item3.Content, firstValidWM, comboBox3.Text);
|
|
||||||
if (item3.Action != Action.LoadReadOnly)
|
|
||||||
{
|
{
|
||||||
if (isEnd) Program.LocalSettings.UpdateHistory(comboBox3.Text, ref Program.LocalSettings.LastEnComm3);
|
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm1); break;
|
||||||
else Program.LocalSettings.UpdateHistory(comboBox3.Text, ref Program.LocalSettings.LastBgComm3);
|
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm2); break;
|
||||||
|
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastEnComm3); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (ix)
|
||||||
|
{
|
||||||
|
case 0: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm1); break;
|
||||||
|
case 1: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm2); break;
|
||||||
|
case 2: ls.UpdateHistory(commonComboBoxes[ix].Text, ref ls.LastBgComm3); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,29 +498,18 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
/// Propagate common (batch) values to water meters in case of
|
/// Propagate common (batch) values to water meters in case of
|
||||||
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
|
/// Content.BatchAndWmOrder, Content.BatchAndWmRemark, Content.YearOfCalibration and Content.ArchivePath
|
||||||
///
|
///
|
||||||
if (item1.Content == Content.BatchAndWmOrder ||
|
foreach (var wm in WaterMeters)
|
||||||
(item1.Content != Content.None && item2.Content == Content.BatchAndWmOrder) ||
|
|
||||||
(item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.BatchAndWmOrder))
|
|
||||||
{
|
{
|
||||||
foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder;
|
if (wm != null && !wm.Disabled)
|
||||||
}
|
{
|
||||||
else if (item1.Content == Content.BatchAndWmRemark ||
|
switch (commonItems[ix].Content)
|
||||||
(item1.Content != Content.None && item2.Content == Content.BatchAndWmRemark) ||
|
{
|
||||||
(item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.BatchAndWmRemark))
|
case Ct.BatchAndWmOrder: wm.PurchaseOrder = firstValidWM.Batch.PurchaseOrder; break;
|
||||||
{
|
case Ct.BatchAndWmRemark: wm.Remark = firstValidWM.Batch.Remark; break;
|
||||||
foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.Remark = firstValidWM.Batch.Remark;
|
case Ct.YearOfCalibration: wm.YearOfProduction = firstValidWM.YearOfProduction; break;
|
||||||
}
|
case Ct.ArchivePath: wm.ArchivePath = firstValidWM.ArchivePath; break;
|
||||||
else if (item1.Content == Content.YearOfCalibration ||
|
}
|
||||||
(item1.Content != Content.None && item2.Content == Content.YearOfCalibration) ||
|
}
|
||||||
(item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.YearOfCalibration))
|
|
||||||
{
|
|
||||||
foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.YearOfProduction = firstValidWM.YearOfProduction;
|
|
||||||
}
|
|
||||||
else if (item1.Content == Content.ArchivePath ||
|
|
||||||
(item1.Content != Content.None && item2.Content == Content.ArchivePath) ||
|
|
||||||
(item1.Content != Content.None && item2.Content != Content.None && item2.Content == Content.ArchivePath))
|
|
||||||
{
|
|
||||||
foreach (var wm in WaterMeters) if (wm != null && !wm.Disabled) wm.ArchivePath = firstValidWM.ArchivePath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,33 +519,33 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
var currentVals = new string[wmsCount];
|
var currentVals = new string[wmsCount];
|
||||||
for (int i = 0; i < wmsCount; i++)
|
for (int i = 0; i < wmsCount; i++)
|
||||||
{
|
{
|
||||||
PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
|
DEUtils.PutContent(colItems[k].Content, WaterMeters[i], comboBoxes[k, i].Text);
|
||||||
currentVals[i] = comboBoxes[k, i].Text;
|
currentVals[i] = comboBoxes[k, i].Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update history
|
/// Update history
|
||||||
if (colItems[k].Action != Action.LoadReadOnly)
|
if (colItems[k].Action != Ac.LoadReadOnly)
|
||||||
{
|
{
|
||||||
if (isEnd)
|
if (isEnd)
|
||||||
{
|
{
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
default:
|
case 0: ls.LastEnColA = currentVals; break;
|
||||||
case 0: Program.LocalSettings.LastEnColA = currentVals; break;
|
case 1: ls.LastEnColB = currentVals; break;
|
||||||
case 1: Program.LocalSettings.LastEnColB = currentVals; break;
|
case 2: ls.LastEnColC = currentVals; break;
|
||||||
case 2: Program.LocalSettings.LastEnColC = currentVals; break;
|
case 3: ls.LastEnColD = currentVals; break;
|
||||||
case 3: Program.LocalSettings.LastEnColD = currentVals; break;
|
case 4: ls.LastEnColE = currentVals; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
default:
|
case 0: ls.LastBgColA = currentVals; break;
|
||||||
case 0: Program.LocalSettings.LastBgColA = currentVals; break;
|
case 1: ls.LastBgColB = currentVals; break;
|
||||||
case 1: Program.LocalSettings.LastBgColB = currentVals; break;
|
case 2: ls.LastBgColC = currentVals; break;
|
||||||
case 2: Program.LocalSettings.LastBgColC = currentVals; break;
|
case 3: ls.LastBgColD = currentVals; break;
|
||||||
case 3: Program.LocalSettings.LastBgColD = currentVals; break;
|
case 4: ls.LastBgColE = currentVals; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -654,79 +557,6 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string GetContent(Content content, WaterMeter wm)
|
|
||||||
{
|
|
||||||
if (wm == null) return string.Empty;
|
|
||||||
|
|
||||||
switch (content)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case Content.None: return string.Empty;
|
|
||||||
case Content.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
|
|
||||||
case Content.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
|
|
||||||
case Content.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
|
|
||||||
case Content.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
|
|
||||||
case Content.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
|
|
||||||
case Content.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
|
|
||||||
case Content.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
|
|
||||||
|
|
||||||
case Content.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
|
|
||||||
case Content.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
|
||||||
case Content.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
|
||||||
|
|
||||||
case Content.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
|
|
||||||
case Content.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
|
|
||||||
case Content.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
|
|
||||||
#if ORACLE_DB
|
|
||||||
case Content.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
|
|
||||||
case Content.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PutContent(Content content, WaterMeter wm, string value)
|
|
||||||
{
|
|
||||||
if (wm == null || wm.Disabled) return;
|
|
||||||
|
|
||||||
int year;
|
|
||||||
|
|
||||||
switch (content)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case Content.None: return;
|
|
||||||
case Content.SerialNr: wm.SerialNr = value; return;
|
|
||||||
case Content.SerialNrAux: wm.SerialNrAux = value; return;
|
|
||||||
case Content.RadioAddress: wm.RadioAddress = value; return;
|
|
||||||
case Content.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
|
|
||||||
case Content.StartState: wm.SetStartState(value); return;
|
|
||||||
case Content.EndState: wm.EndState = value; return;
|
|
||||||
case Content.ArchivePath: wm.ArchivePath = value; return;
|
|
||||||
|
|
||||||
case Content.WmOrder:
|
|
||||||
wm.PurchaseOrder = value;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case Content.BatchOrder:
|
|
||||||
case Content.BatchAndWmOrder:
|
|
||||||
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case Content.WmRemark:
|
|
||||||
wm.Remark = value;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case Content.BatchRemark:
|
|
||||||
case Content.BatchAndWmRemark:
|
|
||||||
if (wm.Batch != null) wm.Batch.Remark = value;
|
|
||||||
return;
|
|
||||||
#if ORACLE_DB
|
|
||||||
case Content.Prefix: wm.Prefix = value; return;
|
|
||||||
case Content.Suffix: wm.Suffix = value; return;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void clearButton_Click(object sender, EventArgs e)
|
private void clearButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
InitializeBoxes();
|
InitializeBoxes();
|
||||||
@ -783,22 +613,19 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
{
|
{
|
||||||
if (k < 0)
|
if (k < 0)
|
||||||
{
|
{
|
||||||
if (j == 1 && comboBox2 != null)
|
for (int ix = j; ix < commonItemsCount; ix++)
|
||||||
{
|
{
|
||||||
comboBox2.Focus();
|
if (commonComboBoxes[ix].Enabled)
|
||||||
return;
|
{
|
||||||
}
|
commonComboBoxes[ix].Focus();
|
||||||
else if (j == 2 && comboBox3 != null)
|
return;
|
||||||
{
|
}
|
||||||
comboBox3.Focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
|
|
||||||
if (isLrOrder) { k = -1; j = 0; }
|
|
||||||
else { k = 0; j = -1; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// No next enabled common item found:
|
||||||
|
/// Initialize k,j so that after the 1st increment k = 0 and j = 0
|
||||||
|
if (isLrOrder) { k = -1; j = 0; }
|
||||||
|
else { k = 0; j = -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Change focus
|
/// Change focus
|
||||||
|
|||||||
@ -7,7 +7,10 @@ using Common;
|
|||||||
|
|
||||||
namespace TBF.Rig.DataEntry.Uni
|
namespace TBF.Rig.DataEntry.Uni
|
||||||
{
|
{
|
||||||
public enum Action
|
///
|
||||||
|
/// Ac = Action
|
||||||
|
///
|
||||||
|
public enum Ac
|
||||||
{
|
{
|
||||||
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
|
[Description("Clear")] Clear, /// Clear when the form is open, save on OK
|
||||||
[Description("Last from history")] HistoryLast,
|
[Description("Last from history")] HistoryLast,
|
||||||
@ -16,7 +19,10 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
Count,
|
Count,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Content
|
///
|
||||||
|
/// Ct = Content
|
||||||
|
///
|
||||||
|
public enum Ct
|
||||||
{
|
{
|
||||||
[Description("None")] None,
|
[Description("None")] None,
|
||||||
[Description("Serial nr.")] SerialNr,
|
[Description("Serial nr.")] SerialNr,
|
||||||
@ -41,12 +47,12 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
|
|
||||||
public class DEItem
|
public class DEItem
|
||||||
{
|
{
|
||||||
public readonly Content Content;
|
public readonly Ct Content;
|
||||||
public readonly string Caption;
|
public readonly string Caption;
|
||||||
public readonly Action Action;
|
public readonly Ac Action;
|
||||||
public readonly int Width;
|
public readonly int Width;
|
||||||
|
|
||||||
public DEItem(Content content, string caption, Action action, int width)
|
public DEItem(Ct content, string caption, Ac action, int width)
|
||||||
{
|
{
|
||||||
Content = content;
|
Content = content;
|
||||||
Caption = caption;
|
Caption = caption;
|
||||||
@ -54,11 +60,23 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
Width = width;
|
Width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static IList<DEItem> items = new List<DEItem>();
|
||||||
|
///
|
||||||
|
public static void ClearItems() { items.Clear(); }
|
||||||
|
public static void AddItem(DEItem item) { items.Add(item); }
|
||||||
|
public static void AddItem(Ct content, string caption, Ac action, int width)
|
||||||
|
{
|
||||||
|
items.Add(new DEItem(content, caption, action, width));
|
||||||
|
}
|
||||||
|
public static IList<DEItem> GetItems() { return items; }
|
||||||
|
|
||||||
|
|
||||||
static IList<DEItem> columns = new List<DEItem>();
|
static IList<DEItem> columns = new List<DEItem>();
|
||||||
///
|
///
|
||||||
public static void ClearColumns() { columns.Clear(); }
|
public static void ClearColumns() { columns.Clear(); }
|
||||||
public static void AddColumn(DEItem column) { columns.Add(column); }
|
public static void AddColumn(DEItem column) { columns.Add(column); }
|
||||||
public static void AddColumn(Content content, string caption, Action action, int width)
|
public static void AddColumn(Ct content, string caption, Ac action, int width)
|
||||||
{
|
{
|
||||||
columns.Add(new DEItem(content, caption, action, width));
|
columns.Add(new DEItem(content, caption, action, width));
|
||||||
}
|
}
|
||||||
|
|||||||
83
TBF/Rig/DataEntry/Uni/DEUtils.cs
Normal file
83
TBF/Rig/DataEntry/Uni/DEUtils.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
///
|
||||||
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
||||||
|
///
|
||||||
|
using System;
|
||||||
|
using Results.Entities;
|
||||||
|
|
||||||
|
namespace TBF.Rig.DataEntry.Uni
|
||||||
|
{
|
||||||
|
public class DEUtils
|
||||||
|
{
|
||||||
|
public static string GetContent(Ct content, WaterMeter wm)
|
||||||
|
{
|
||||||
|
if (wm == null) return string.Empty;
|
||||||
|
|
||||||
|
switch (content)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Ct.None: return string.Empty;
|
||||||
|
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
|
||||||
|
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
|
||||||
|
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
|
||||||
|
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
|
||||||
|
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
|
||||||
|
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
|
||||||
|
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
|
||||||
|
|
||||||
|
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
|
||||||
|
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||||
|
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||||
|
|
||||||
|
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
|
||||||
|
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
|
||||||
|
case Ct.BatchAndWmRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
|
||||||
|
#if ORACLE_DB
|
||||||
|
case Content.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
|
||||||
|
case Content.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PutContent(Ct content, WaterMeter wm, string value)
|
||||||
|
{
|
||||||
|
if (wm == null || wm.Disabled) return;
|
||||||
|
|
||||||
|
int year;
|
||||||
|
|
||||||
|
switch (content)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Ct.None: return;
|
||||||
|
case Ct.SerialNr: wm.SerialNr = value; return;
|
||||||
|
case Ct.SerialNrAux: wm.SerialNrAux = value; return;
|
||||||
|
case Ct.RadioAddress: wm.RadioAddress = value; return;
|
||||||
|
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
|
||||||
|
case Ct.StartState: wm.SetStartState(value); return;
|
||||||
|
case Ct.EndState: wm.EndState = value; return;
|
||||||
|
case Ct.ArchivePath: wm.ArchivePath = value; return;
|
||||||
|
|
||||||
|
case Ct.WmOrder:
|
||||||
|
wm.PurchaseOrder = value;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Ct.BatchOrder:
|
||||||
|
case Ct.BatchAndWmOrder:
|
||||||
|
if (wm.Batch != null) wm.Batch.PurchaseOrder = value;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Ct.WmRemark:
|
||||||
|
wm.Remark = value;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Ct.BatchRemark:
|
||||||
|
case Ct.BatchAndWmRemark:
|
||||||
|
if (wm.Batch != null) wm.Batch.Remark = value;
|
||||||
|
return;
|
||||||
|
#if ORACLE_DB
|
||||||
|
case Content.Prefix: wm.Prefix = value; return;
|
||||||
|
case Content.Suffix: wm.Suffix = value; return;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -132,39 +132,51 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
///
|
///
|
||||||
void OpenBeginningDlg(EntryFormNoStartEnd myRef)
|
void OpenBeginningDlg(EntryFormNoStartEnd myRef)
|
||||||
{
|
{
|
||||||
var item1 = new DEItem(myCfg.BgItem1Content, myCfg.BgItem1Caption, myCfg.BgItem1Action, myCfg.BgItem1Width);
|
DEItem.ClearItems();
|
||||||
var item2 = new DEItem(myCfg.BgItem2Content, myCfg.BgItem2Caption, myCfg.BgItem2Action, myCfg.BgItem2Width);
|
for (int i = 0; i < myCfg.GetBgItemsCount(); i++)
|
||||||
var item3 = new DEItem(myCfg.BgItem3Content, myCfg.BgItem3Caption, myCfg.BgItem3Action, myCfg.BgItem3Width);
|
{
|
||||||
|
if (myCfg.BgItemContent[i] != Ct.None)
|
||||||
|
{
|
||||||
|
DEItem.AddItem(myCfg.BgItemContent[i], myCfg.BgItemCaption[i], myCfg.BgItemAction[i], myCfg.BgItemWidth[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEItem.ClearColumns();
|
DEItem.ClearColumns();
|
||||||
if (myCfg.BgColAContent != Content.None) DEItem.AddColumn(myCfg.BgColAContent, myCfg.BgColACaption, myCfg.BgColAAction, myCfg.BgColAWidth);
|
for (int i = 0; i < myCfg.GetBgColumnsCount(); i++)
|
||||||
if (myCfg.BgColBContent != Content.None) DEItem.AddColumn(myCfg.BgColBContent, myCfg.BgColBCaption, myCfg.BgColBAction, myCfg.BgColBWidth);
|
{
|
||||||
if (myCfg.BgColCContent != Content.None) DEItem.AddColumn(myCfg.BgColCContent, myCfg.BgColCCaption, myCfg.BgColCAction, myCfg.BgColCWidth);
|
if (myCfg.BgColumnContent[i] != Ct.None)
|
||||||
if (myCfg.BgColDContent != Content.None) DEItem.AddColumn(myCfg.BgColDContent, myCfg.BgColDCaption, myCfg.BgColDAction, myCfg.BgColDWidth);
|
{
|
||||||
if (myCfg.BgColEContent != Content.None) DEItem.AddColumn(myCfg.BgColEContent, myCfg.BgColECaption, myCfg.BgColEAction, myCfg.BgColEWidth);
|
DEItem.AddColumn(myCfg.BgColumnContent[i], myCfg.BgColumnCaption[i], myCfg.BgColumnAction[i], myCfg.BgColumnWidth[i]);
|
||||||
var columns = DEItem.GetColumns();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.BgTitle, myCfg.BgSize, myCfg.BgIsLrOrder, myCfg.BgFormCloseKeys,
|
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.BgTitle, myCfg.BgSize, myCfg.BgIsLrOrder, myCfg.BgFormCloseKeys,
|
||||||
item1, item2, item3, columns, false);
|
DEItem.GetItems(), DEItem.GetColumns(), false);
|
||||||
modelessDlg.Show();
|
modelessDlg.Show();
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
void OpenEndDlg(EntryFormNoStartEnd myRef)
|
void OpenEndDlg(EntryFormNoStartEnd myRef)
|
||||||
{
|
{
|
||||||
var item1 = new DEItem(myCfg.EnItem1Content, myCfg.EnItem1Caption, myCfg.EnItem1Action, myCfg.EnItem1Width);
|
DEItem.ClearItems();
|
||||||
var item2 = new DEItem(myCfg.EnItem2Content, myCfg.EnItem2Caption, myCfg.EnItem2Action, myCfg.EnItem2Width);
|
for (int i = 0; i < myCfg.GetEnItemsCount(); i++)
|
||||||
var item3 = new DEItem(myCfg.EnItem3Content, myCfg.EnItem3Caption, myCfg.EnItem3Action, myCfg.EnItem3Width);
|
{
|
||||||
|
if (myCfg.EnItemContent[i] != Ct.None)
|
||||||
|
{
|
||||||
|
DEItem.AddItem(myCfg.EnItemContent[i], myCfg.EnItemCaption[i], myCfg.EnItemAction[i], myCfg.EnItemWidth[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEItem.ClearColumns();
|
DEItem.ClearColumns();
|
||||||
if (myCfg.EnColAContent != Content.None) DEItem.AddColumn(myCfg.EnColAContent, myCfg.EnColACaption, myCfg.EnColAAction, myCfg.EnColAWidth);
|
for (int i = 0; i < myCfg.GetEnColumnsCount(); i++)
|
||||||
if (myCfg.EnColBContent != Content.None) DEItem.AddColumn(myCfg.EnColBContent, myCfg.EnColBCaption, myCfg.EnColBAction, myCfg.EnColBWidth);
|
{
|
||||||
if (myCfg.EnColCContent != Content.None) DEItem.AddColumn(myCfg.EnColCContent, myCfg.EnColCCaption, myCfg.EnColCAction, myCfg.EnColCWidth);
|
if (myCfg.EnColumnContent[i] != Ct.None)
|
||||||
if (myCfg.EnColDContent != Content.None) DEItem.AddColumn(myCfg.EnColDContent, myCfg.EnColDCaption, myCfg.EnColDAction, myCfg.EnColDWidth);
|
{
|
||||||
if (myCfg.EnColEContent != Content.None) DEItem.AddColumn(myCfg.EnColEContent, myCfg.EnColECaption, myCfg.EnColEAction, myCfg.EnColEWidth);
|
DEItem.AddColumn(myCfg.EnColumnContent[i], myCfg.EnColumnCaption[i], myCfg.EnColumnAction[i], myCfg.EnColumnWidth[i]);
|
||||||
var columns = DEItem.GetColumns();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.EnTitle, myCfg.EnSize, myCfg.EnIsLrOrder, myCfg.EnFormCloseKeys,
|
modelessDlg = new CycleBgEnForm(waterMeters, TBF.Data.LineSize, myCfg.EnTitle, myCfg.EnSize, myCfg.EnIsLrOrder, myCfg.EnFormCloseKeys,
|
||||||
item1, item2, item3, columns, true);
|
DEItem.GetItems(), DEItem.GetColumns(), true);
|
||||||
modelessDlg.Show();
|
modelessDlg.Show();
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
@ -189,13 +201,13 @@ namespace TBF.Rig.DataEntry.Uni
|
|||||||
switch (currentOp)
|
switch (currentOp)
|
||||||
{
|
{
|
||||||
case CurrentOp.ShowFormAtCycleBeginning:
|
case CurrentOp.ShowFormAtCycleBeginning:
|
||||||
if (myCfg.ShowCycleBeginningForm)
|
if (myCfg.BgShowForm)
|
||||||
{
|
{
|
||||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
|
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CurrentOp.ShowFormAtCycleEnd:
|
case CurrentOp.ShowFormAtCycleEnd:
|
||||||
if (myCfg.ShowCycleEndForm)
|
if (myCfg.EnShowForm)
|
||||||
{
|
{
|
||||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this);
|
Program.MainWnd.Invoke(new EntryFormDlgt(OpenEndDlg), this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -541,6 +541,7 @@
|
|||||||
<DependentUpon>CycleBgEnForm.cs</DependentUpon>
|
<DependentUpon>CycleBgEnForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Rig\DataEntry\Uni\DEItem.cs" />
|
<Compile Include="Rig\DataEntry\Uni\DEItem.cs" />
|
||||||
|
<Compile Include="Rig\DataEntry\Uni\DEUtils.cs" />
|
||||||
<Compile Include="Rig\DataEntry\Uni\EntryForm.cs" />
|
<Compile Include="Rig\DataEntry\Uni\EntryForm.cs" />
|
||||||
<Compile Include="Rig\DataEntry\Uni\EntryFormCfg.cs" />
|
<Compile Include="Rig\DataEntry\Uni\EntryFormCfg.cs" />
|
||||||
<Compile Include="Rig\DataEntry\Uni\EntryFormNoStartEnd.cs" />
|
<Compile Include="Rig\DataEntry\Uni\EntryFormNoStartEnd.cs" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user