bool WaterMeter.PrintLabel (initially set), DataEntry.Uni : 1. "Auto s/n" function, 2. common check box, 3. Ct.PrintLabel (yes/no)

This commit is contained in:
Milan Hanajik 2023-11-28 14:52:13 +01:00
parent 0181294872
commit a625e2dfdb
7 changed files with 245 additions and 26 deletions

View File

@ -100,6 +100,7 @@ namespace Results.Entities
#endif
public virtual int ProcessId { get; set; } /// Not mapped to DB !!! Tracing DB Process ID
public virtual bool LastRecordIsNok { get; set; } /// Not mapped to DB !!! Previous record verification result
public virtual bool PrintLabel { get; set; } /// Not mapped to DB !!!
public virtual WaterMeterData WaterMeterData { get; set; }
public virtual Batch Batch { get; set; }
@ -458,6 +459,7 @@ namespace Results.Entities
#endif
ProcessId = 0;
LastRecordIsNok = false;
PrintLabel = true;
}
@ -519,6 +521,7 @@ namespace Results.Entities
#endif
ProcessId = src.ProcessId; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@ -698,6 +701,7 @@ namespace Results.Entities
#endif
writer.Write(ProcessId);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@ -777,6 +781,7 @@ namespace Results.Entities
#endif
ProcessId = reader.ReadInt32();
LastRecordIsNok = reader.ReadBoolean();
PrintLabel = reader.ReadBoolean();
/// Retrieve TestData
if (reader.ReadBoolean())

View File

@ -15,6 +15,7 @@ namespace TBF.Rig.DataEntry
[Description("Last from history")] HistoryLast,
[Description("Load")] Load, /// Load from water meters when the form is open, save on OK
[Description("Load (readonly)")] LoadReadOnly, /// Load from water meters when the form is open, prevent changes, do not save
[Description("Set")] Set, /// Set to 'yes' when the form is open
Count,
}
@ -29,7 +30,9 @@ namespace TBF.Rig.DataEntry
[Description("Radio address")] RadioAddress,
[Description("Year of calibration")] YearOfCalibration,
[Description("Start state")] StartState,
[Description("Start state aux")] StartStateAux,
[Description("End state")] EndState,
[Description("End state aux")] EndStateAux,
[Description("Archive path")] ArchivePath,
[Description("WM Order")] WmOrder,
[Description("Batch order")] BatchOrder,
@ -37,6 +40,7 @@ namespace TBF.Rig.DataEntry
[Description("WM Remark")] WmRemark,
[Description("Batch remark")] BatchRemark,
[Description("Batch and WM remark")] BatchAndWmRemark,
[Description("Print label")] PrintLabel,
#if ORACLE_DB
[Description("Prefix")] Prefix,
[Description("Suffix")] Suffix,
@ -44,6 +48,28 @@ namespace TBF.Rig.DataEntry
Count
}
///
/// Identifies image instance
///
public enum Tst
{
Start,
End,
Both,
}
///
/// Image rotation
///
public enum Rotation
{
R0,
R90,
R180,
R270,
Count
}
public class DEItem
{
public readonly Ct Content;

View File

@ -3,6 +3,7 @@
///
using System.Windows.Forms;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry
{
@ -15,22 +16,25 @@ namespace TBF.Rig.DataEntry
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.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.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
case Ct.StartStateAux: return string.Empty;
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
case Ct.EndStateAux: return (!wm.Disabled && wm.GetEndStateAux() != null) ? wm.GetEndStateAux() : 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.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;
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;
case Ct.PrintLabel: return wm.PrintLabel ? Strings.yes : Strings.no;
#if ORACLE_DB
case Ct.Prefix: return (!wm.Disabled && wm.Prefix != null) ? wm.Prefix : string.Empty;
case Ct.Suffix: return (!wm.Disabled && wm.Suffix != null) ? wm.Suffix : string.Empty;
@ -53,7 +57,9 @@ namespace TBF.Rig.DataEntry
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.StartStateAux: return;
case Ct.EndState: wm.EndState = value; return;
case Ct.EndStateAux: wm.SetEndStateAux(value); return;
case Ct.ArchivePath: wm.ArchivePath = value; return;
case Ct.WmOrder:
@ -73,6 +79,10 @@ namespace TBF.Rig.DataEntry
case Ct.BatchAndWmRemark:
if (wm.Batch != null) wm.Batch.Remark = value;
return;
case Ct.PrintLabel:
wm.PrintLabel = (value == Strings.yes);
return;
#if ORACLE_DB
case Ct.Prefix: wm.Prefix = value; return;
case Ct.Suffix: wm.Suffix = value; return;

View File

@ -124,6 +124,18 @@ namespace TBF.Rig.DataEntry.Uni
comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount];
/// Make Auto s/n button visible if there is either Ct.SerialNr or Ct.SerialNrAux column
int buttonsWidth = 350;
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
autoSNButton.Visible = true;
buttonsWidth += 147;
break;
}
}
/// Layout related readonly variables derived from argument 'sz'
switch (sz)
{
@ -132,7 +144,7 @@ namespace TBF.Rig.DataEntry.Uni
meterHeight = 26; /// Height of a ComboBox control
margin = 20;
spacing = 8;
buttonsWidth = 350;
this.buttonsWidth = buttonsWidth;
hdrHeight = 120;
labelWid = 31;
checkBoxWid = 23;
@ -144,7 +156,7 @@ namespace TBF.Rig.DataEntry.Uni
meterHeight = 31; /// Height of a ComboBox control
margin = 25;
spacing = 10;
buttonsWidth = 350;
this.buttonsWidth = buttonsWidth;
hdrHeight = 140;
labelWid = 34;
checkBoxWid = 23;
@ -155,7 +167,7 @@ namespace TBF.Rig.DataEntry.Uni
meterHeight = 37; /// Height of a ComboBox control
margin = 30;
spacing = 12;
buttonsWidth = 350;
this.buttonsWidth = buttonsWidth;
hdrHeight = 160;
labelWid = 40;
checkBoxWid = 23;
@ -236,6 +248,8 @@ namespace TBF.Rig.DataEntry.Uni
///
/// Table
///
int commonCheckBoxLeft = 0;
int commonCheckBoxTop = 0;
int columnsTop = Math.Max(hdrHeight, groupBoxHeight + 2 * margin + spacing);
for (int j = 0; j < linesCount; j++)
{
@ -299,8 +313,16 @@ namespace TBF.Rig.DataEntry.Uni
comboBox.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
comboBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_KeyPress);
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
if (ci.Content == Ct.PrintLabel)
{
comboBox.Items.Add(Strings.yes);
comboBox.Items.Add(Strings.no);
}
else
{
var lastVals = GetHistoryFromLS(isEnd, k);
comboBox.Items.Add(lastVals.Length > wmPos0 ? lastVals[wmPos0] : string.Empty); /// History in drop-down menu
}
left += ci.Width + spacing;
comboBoxes[k, wmPos0] = comboBox;
@ -316,7 +338,26 @@ namespace TBF.Rig.DataEntry.Uni
};
checkBoxes[wmPos0] = checkBox;
this.Controls.Add(checkBox);
if (commonCheckBoxLeft == 0)
{
commonCheckBoxLeft = left;
commonCheckBoxTop = columnsTop - meterHeight;
}
}
okButton.TabIndex = tabIndex++;
clearButton.TabIndex = tabIndex++;
var commonCheckBox = new CheckBox
{
Location = new Point(commonCheckBoxLeft, commonCheckBoxTop + 6),
Size = new Size(checkBoxWid, 23),
TabIndex = tabIndex++,
Parent = this,
};
commonCheckBox.CheckedChanged += new System.EventHandler(commonCheckBox_CheckedChanged);
this.Controls.Add(commonCheckBox);
}
///
@ -442,6 +483,10 @@ namespace TBF.Rig.DataEntry.Uni
case Ac.LoadReadOnly:
commonComboBoxes[ix].Text = DEUtils.GetContent(commonItems[ix].Content, firstValidWM);
break;
case Ac.Set:
commonComboBoxes[ix].Text = Strings.yes;
break;
}
}
@ -469,6 +514,13 @@ namespace TBF.Rig.DataEntry.Uni
comboBoxes[k, i].Text = DEUtils.GetContent(colItems[k].Content, WaterMeters[i]);
}
break;
case Ac.Set:
for (int i = 0; i < wmsCount; i++)
{
comboBoxes[k, i].Text = Strings.yes;
}
break;
}
}
@ -574,18 +626,94 @@ namespace TBF.Rig.DataEntry.Uni
}
}
private void clearButton_Click(object sender, EventArgs e)
private void commonCheckBox_CheckedChanged(object sender, EventArgs e)
{
InitializeBoxes();
bool state = (sender as CheckBox).Checked;
for (int i = 0; i < wmsCount; i++)
{
checkBoxes[i].Checked = state;
}
}
private void okButton_Click(object sender, EventArgs e)
private void okButton_Click(object sender, EventArgs e)
{
UpdateWMsFromBoxes();
completed = true;
Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
InitializeBoxes();
}
private void autoSNButton_Click(object sender, EventArgs e)
{
///
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{
if (checkBoxes[firstIx].Checked) break;
}
if (firstIx == wmsCount)
{
return; /// There is not any enabled water meter
}
char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{
///
/// Column with serial numbers found => perform an auto s/n assignment
///
string firstSN = comboBoxes[k, firstIx].Text;
int firstSnNr;
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0)
{
int lastDigitPosPlus1 = startIx + 1;
var listOfDigits = new List<char>(digits);
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1]))
{
lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0)
{
for (int ix = firstIx + 1; ix < wmsCount; ix++)
{
if (checkBoxes[ix].Checked)
{
firstSnNr++;
string newSN = firstSnNr.ToString();
int len = newSN.Length;
if (len <= digitsCount)
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
}
else
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
}
}
}
}
}
}
}
}
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)
{
if (!isHandlersEnabled) return;
@ -596,7 +724,7 @@ namespace TBF.Rig.DataEntry.Uni
isHandlersEnabled = false;
if (k >= 0 && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
if (k >= 0 && colItems[k].Content != Ct.PrintLabel && comboBoxes[k, j].Text == comboBoxes[k, j].Items[0].ToString())
{
for (int i = 0; i < wmsCount; i++)
{

View File

@ -34,6 +34,7 @@ namespace TBF.Rig.DataEntry.Uni
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.autoSNButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// okButton
@ -52,11 +53,20 @@ namespace TBF.Rig.DataEntry.Uni
this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// autoSNButton
//
resources.ApplyResources(this.autoSNButton, "autoSNButton");
this.autoSNButton.ForeColor = System.Drawing.Color.Black;
this.autoSNButton.Name = "autoSNButton";
this.autoSNButton.UseVisualStyleBackColor = true;
this.autoSNButton.Click += new System.EventHandler(this.autoSNButton_Click);
//
// CycleBgEnForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.autoSNButton);
this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black;
@ -71,5 +81,6 @@ namespace TBF.Rig.DataEntry.Uni
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button autoSNButton;
}
}

View File

@ -148,7 +148,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;okButton.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="clearButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
@ -181,6 +181,42 @@
<value>$this</value>
</data>
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="autoSNButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="autoSNButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value>
</data>
<data name="autoSNButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="autoSNButton.Location" type="System.Drawing.Point, System.Drawing">
<value>648, 26</value>
</data>
<data name="autoSNButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value>
</data>
<data name="autoSNButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="autoSNButton.Text" xml:space="preserve">
<value>Auto s/n</value>
</data>
<data name="autoSNButton.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;autoSNButton.Name" xml:space="preserve">
<value>autoSNButton</value>
</data>
<data name="&gt;&gt;autoSNButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;autoSNButton.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;autoSNButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -539,10 +539,13 @@ namespace TBF.Rig.DataEntry.Uni
Ct.RadioAddress.ToDescription(),
Ct.YearOfCalibration.ToDescription(),
Ct.StartState.ToDescription(),
Ct.StartStateAux.ToDescription(),
Ct.EndState.ToDescription(),
Ct.EndStateAux.ToDescription(),
Ct.ArchivePath.ToDescription(),
Ct.WmOrder.ToDescription(),
Ct.WmRemark.ToDescription(),
Ct.PrintLabel.ToDescription(),
};
}
case 2: