DataEntry.Standard24.CycleBeginningForm : Auto s/n feature.
This commit is contained in:
parent
31b167cd62
commit
ec9edbf04c
@ -108,6 +108,8 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
this.checkBox24 = new System.Windows.Forms.CheckBox();
|
||||
this.comboBox24 = new System.Windows.Forms.ComboBox();
|
||||
this.label24 = new System.Windows.Forms.Label();
|
||||
this.autoSnButton = new System.Windows.Forms.Button();
|
||||
this.allCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.orderGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -621,11 +623,28 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
resources.ApplyResources(this.label24, "label24");
|
||||
this.label24.Name = "label24";
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// allCheckBox
|
||||
//
|
||||
resources.ApplyResources(this.allCheckBox, "allCheckBox");
|
||||
this.allCheckBox.Name = "allCheckBox";
|
||||
this.allCheckBox.UseVisualStyleBackColor = true;
|
||||
this.allCheckBox.CheckedChanged += new System.EventHandler(this.allCheckBox_CheckedChanged);
|
||||
//
|
||||
// CycleBeginningForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.DarkGoldenrod;
|
||||
this.Controls.Add(this.allCheckBox);
|
||||
this.Controls.Add(this.autoSnButton);
|
||||
this.Controls.Add(this.checkBox24);
|
||||
this.Controls.Add(this.comboBox24);
|
||||
this.Controls.Add(this.label24);
|
||||
@ -790,5 +809,7 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
private System.Windows.Forms.CheckBox checkBox24;
|
||||
private System.Windows.Forms.ComboBox comboBox24;
|
||||
private System.Windows.Forms.Label label24;
|
||||
private System.Windows.Forms.Button autoSnButton;
|
||||
private System.Windows.Forms.CheckBox allCheckBox;
|
||||
}
|
||||
}
|
||||
@ -490,5 +490,65 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
private void comboBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox22); }
|
||||
private void comboBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox23); }
|
||||
private void comboBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox24); }
|
||||
}
|
||||
|
||||
private void allCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
foreach (var cb in checkBoxes)
|
||||
{
|
||||
cb.Checked = allCheckBox.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
private void autoSnButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
char[] digits = new char[] {'0','1','2','3','4','5','6','7','8','9'};
|
||||
///
|
||||
/// Find the 1st enabled water meter
|
||||
///
|
||||
int firstIx;
|
||||
string firstSN = string.Empty;
|
||||
for (firstIx = 0; firstIx < textBoxesCount; firstIx++)
|
||||
{
|
||||
if (checkBoxes[firstIx].Checked)
|
||||
{
|
||||
firstSN = comboBoxes[firstIx].Text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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 < textBoxesCount; ix++)
|
||||
{
|
||||
if (checkBoxes[ix].Checked)
|
||||
{
|
||||
firstSnNr++;
|
||||
string newSN = firstSnNr.ToString();
|
||||
int len = newSN.Length;
|
||||
if (len <= digitsCount)
|
||||
{
|
||||
comboBoxes[ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxes[ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user