138 lines
3.3 KiB
C#
138 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using SharedDatabase.Entities;
|
|
|
|
namespace Workplace.CheckItems
|
|
{
|
|
public partial class OkNok : UserControl, ICheckItem
|
|
{
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Ok/Nok: {0} {1}", IxPolozky, Part.Name);
|
|
}
|
|
|
|
WorkplaceDlg parent;
|
|
|
|
public Part Part { get { return part; } }
|
|
Part part;
|
|
|
|
public int IxPolozky
|
|
{
|
|
get { return ixPolozky; }
|
|
set { ixPolozky = value; }
|
|
}
|
|
int ixPolozky;
|
|
|
|
public IList<string> BlackListedCodes
|
|
{
|
|
get { return blackList; }
|
|
set { blackList = value; }
|
|
}
|
|
IList<string> blackList;
|
|
|
|
public string ScannedCode
|
|
{
|
|
get { return checkBox1.Checked ? "OK" : "NOK"; }
|
|
set
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
checkBox1.Checked = false;
|
|
checkBox2.Checked = false;
|
|
}
|
|
else if (value.ToLower().Equals("ok"))
|
|
{
|
|
checkBox1.Checked = true;
|
|
checkBox2.Checked = false;
|
|
}
|
|
else if (value.ToLower().Equals("nok"))
|
|
{
|
|
checkBox1.Checked = false;
|
|
checkBox2.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
checkBox1.Checked = false;
|
|
checkBox2.Checked = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
OkNok()
|
|
{
|
|
InitializeComponent();
|
|
blackList = new List<string>();
|
|
}
|
|
|
|
public OkNok(WorkplaceDlg parent, SharedDatabase.Entities.Part part)
|
|
: this()
|
|
{
|
|
this.parent = parent;
|
|
this.part = part;
|
|
kodMaterialuLabel.Text = part.Name;
|
|
descriptionMaterialuLabel.Text = part.Description;
|
|
}
|
|
|
|
public void ClearCode()
|
|
{
|
|
checkBox1.Checked = false;
|
|
checkBox2.Checked = false;
|
|
}
|
|
|
|
public void SubmitCode(string code)
|
|
{
|
|
ScannedCode = code;
|
|
scannedCodeTextBox_KeyPress(null, new KeyPressEventArgs('\r'));
|
|
}
|
|
|
|
public void ResetFocus()
|
|
{
|
|
setFocusButton.Text = "";
|
|
}
|
|
|
|
public void SetFocus()
|
|
{
|
|
setFocusButton.Text = ">";
|
|
checkBox1.Checked = false;
|
|
checkBox2.Checked = false;
|
|
checkBox1.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;
|
|
|
|
parent.OnBarcodeReceived(this, new BarcodeReceivedEventArgs(ScannedCode, IxPolozky, Part.CodeLocation));
|
|
return;
|
|
}
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (checkBox1.Checked)
|
|
{
|
|
checkBox2.Checked = false;
|
|
parent.OnBarcodeReceived(this, new BarcodeReceivedEventArgs(ScannedCode, IxPolozky, Part.CodeLocation));
|
|
}
|
|
return;
|
|
}
|
|
|
|
private void checkBox2_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
if (checkBox2.Checked)
|
|
{
|
|
checkBox1.Checked = false;
|
|
parent.OnBarcodeReceived(this, new BarcodeReceivedEventArgs(ScannedCode, IxPolozky, Part.CodeLocation));
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|