148 lines
4.3 KiB
C#
148 lines
4.3 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using TracingDB;
|
|
using TracingDB.Entities;
|
|
|
|
namespace TBF.BenchControl.DataEntry.S620.CheckItems
|
|
{
|
|
public partial class Keyboard : UserControl, ICheckItem
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Kbd: {0} {1}({2})", IxPolozky, Part.Name, string.IsNullOrEmpty(Part.OraDBType) ? string.Empty : Part.OraDBType);
|
|
}
|
|
|
|
FormForMechanicalMetersWithTracing parent;
|
|
|
|
public Part Part { get { return part; } }
|
|
Part part;
|
|
|
|
public int IxPolozky
|
|
{
|
|
get { return ixPolozky; }
|
|
set { ixPolozky = value; }
|
|
}
|
|
int ixPolozky;
|
|
|
|
public string ScannedCode
|
|
{
|
|
get { return scannedCodeTextBox.Text; }
|
|
set
|
|
{
|
|
#if false
|
|
if (part.CodeType == CodeType.PO && parent.ValidOrderNumbers != null)
|
|
{
|
|
/// Counting pieces produced for a specified PO
|
|
|
|
if (!parent.ValidOrderNumbers.Contains(value))
|
|
{
|
|
/// Code is not a valid order number
|
|
scannedCodeTextBox.Text = string.Format("{0} !!!", value);
|
|
}
|
|
else
|
|
{
|
|
scannedCodeTextBox.Text = value;
|
|
int pcsCount;
|
|
if (parent.TargetPcsCounts.TryGetValue(scannedCodeTextBox.Text, out pcsCount))
|
|
{
|
|
parent.UpdateTargetPiecesCount(scannedCodeTextBox.Text, pcsCount, Part.Id);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
scannedCodeTextBox.Text = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
Keyboard()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public Keyboard(FormForMechanicalMetersWithTracing parent, Part part)
|
|
: this()
|
|
{
|
|
this.parent = parent;
|
|
this.part = part;
|
|
scannedCodeTextBox.Text = (part.DefaultCode != null) ? part.DefaultCode : string.Empty;
|
|
kodMaterialuLabel.Text = part.Name;
|
|
descriptionMaterialuLabel.Text = part.Description;
|
|
}
|
|
|
|
public void ClearCode()
|
|
{
|
|
if (part.CodeType != CodeType.Silicon)
|
|
{
|
|
scannedCodeTextBox.Text = (part.DefaultCode != null) ? part.DefaultCode : string.Empty;
|
|
}
|
|
}
|
|
|
|
public void SubmitCode(string code)
|
|
{
|
|
scannedCodeTextBox.Text = code;
|
|
scannedCodeTextBox_KeyPress(null, new KeyPressEventArgs('\r'));
|
|
}
|
|
|
|
public void ResetFocus()
|
|
{
|
|
setFocusButton.Text = "";
|
|
}
|
|
|
|
public void SetFocus()
|
|
{
|
|
ClearCode();
|
|
setFocusButton.Text = ">";
|
|
scannedCodeTextBox.Focus();
|
|
}
|
|
|
|
private void setFocusButton_Click(object sender, EventArgs e)
|
|
{
|
|
setFocusButton.Text = ">";
|
|
parent.OnFocusPressed(this, new FocusPressedEventArgs(IxPolozky, Part.CodeLocation));
|
|
}
|
|
|
|
private void scannedCodeTextBox_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
if (e.KeyChar != '\r') return;
|
|
|
|
PartError error = PartError.None;
|
|
///
|
|
if (string.IsNullOrEmpty(scannedCodeTextBox.Text))
|
|
{
|
|
error = PartError.FieldEmpty;
|
|
}
|
|
#if false
|
|
else if (part.CodeType == CodeType.PO && parent.ValidOrderNumbers != null)
|
|
{
|
|
/// Counting pieces produced for a specified PO
|
|
|
|
int pcsCount;
|
|
if (!parent.ValidOrderNumbers.Contains(scannedCodeTextBox.Text))
|
|
{
|
|
parent.UpdateTargetPiecesCount(string.Empty, -1, 0);
|
|
error = PartError.WrongPart;
|
|
}
|
|
else if (parent.TargetPcsCounts.TryGetValue(scannedCodeTextBox.Text, out pcsCount))
|
|
{
|
|
parent.UpdateTargetPiecesCount(scannedCodeTextBox.Text, pcsCount, Part.Id);
|
|
}
|
|
else
|
|
{
|
|
parent.UpdateTargetPiecesCount(string.Empty, -1, 0);
|
|
}
|
|
}
|
|
#endif
|
|
parent.OnBarcodeReceived(this, new BarcodeReceivedEventArgs(scannedCodeTextBox.Text, IxPolozky, Part.CodeLocation, error));
|
|
return;
|
|
}
|
|
}
|
|
}
|