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

This commit is contained in:
Milan Hanajik 2023-11-27 12:16:33 +01:00 committed by Milan Hanajik
parent dfc0661300
commit b1f3b72a96
8 changed files with 208 additions and 17 deletions

View File

@ -109,6 +109,7 @@ namespace Results.Entities
///
public virtual string Workflow { get; set; } /// Not mapped to DB !!! Production tracing workflow name
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; }
@ -467,6 +468,7 @@ namespace Results.Entities
#if IPERL
FWVersion = string.Empty;
#endif
PrintLabel = true;
}
@ -529,6 +531,7 @@ namespace Results.Entities
Workflow = src.Workflow; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@ -723,6 +726,7 @@ namespace Results.Entities
writer.Write(Workflow);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@ -823,6 +827,7 @@ namespace Results.Entities
Workflow = reader.ReadString();
LastRecordIsNok = reader.ReadBoolean();
PrintLabel = reader.ReadBoolean();
/// Retrieve TestData
if (reader.ReadBoolean())

View File

@ -108,6 +108,7 @@ namespace SharedDatabase.Entities
///
public virtual string Workflow { get; set; } /// Not mapped to DB !!! Production tracing workflow name
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; }
@ -469,6 +470,7 @@ namespace SharedDatabase.Entities
#if IPERL
FWVersion = string.Empty;
#endif
PrintLabel = true;
}
@ -531,6 +533,7 @@ namespace SharedDatabase.Entities
Workflow = src.Workflow; /// Not mapped to DB
LastRecordIsNok = src.LastRecordIsNok; /// Not mapped to DB
PrintLabel = src.PrintLabel; /// Not mapped to DB
foreach (var mtr in MeterTestRslts)
{
@ -725,6 +728,7 @@ namespace SharedDatabase.Entities
writer.Write(Workflow);
writer.Write(LastRecordIsNok);
writer.Write(PrintLabel);
/// Save WaterMeterData or WaterMeterData.Id
if (WaterMeterData != null && savedWMDatas != null && !savedWMDatas.Contains(WaterMeterData))
@ -825,6 +829,7 @@ namespace SharedDatabase.Entities
Workflow = reader.ReadString();
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,
}
@ -39,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,

View File

@ -3,6 +3,7 @@
///
using System.Windows.Forms;
using Results.Entities;
using TBF.Resources;
namespace TBF.Rig.DataEntry
{
@ -30,9 +31,10 @@ namespace TBF.Rig.DataEntry
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;
@ -77,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++)
{
@ -294,14 +308,22 @@ namespace TBF.Rig.DataEntry.Uni
TabIndex = tabIndex++,
Parent = this,
};
comboBox.SelectedIndexChanged += new System.EventHandler(this.comboBox_SelectedIndexChanged);
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;
this.Controls.Add(comboBox);
@ -316,10 +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);
}
///
@ -327,7 +365,7 @@ namespace TBF.Rig.DataEntry.Uni
///
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleBarHeight = screenRectangle.Top - this.Top;
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + buttonsWidth),
Size = new Size(Math.Max(meterWidth * linesCount + margin * (linesCount + 1), margin + groupBoxWidth + this.buttonsWidth),
titleBarHeight + columnsTop + lineSize * (meterHeight + spacing) + margin);
Localize();
@ -445,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;
}
}
@ -472,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;
}
}
@ -577,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;
@ -599,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

@ -563,6 +563,7 @@ namespace TBF.Rig.DataEntry.Uni
Ct.ArchivePath.ToDescription(),
Ct.WmOrder.ToDescription(),
Ct.WmRemark.ToDescription(),
Ct.PrintLabel.ToDescription(),
};
}
case 2: