2022-01-06 14:41:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using Common;
|
|
|
|
|
|
using SharedDatabase;
|
|
|
|
|
|
using SharedDatabase.Entities;
|
|
|
|
|
|
using WorkflowConfigurator.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WorkflowConfigurator.Forms
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class PartDlg : Form
|
|
|
|
|
|
{
|
|
|
|
|
|
public Part Part;
|
|
|
|
|
|
public bool AnyChange; /// if AnyChange == true the dialog returns DialogResult.OK
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor when a new part is being created
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name">Part name</param>
|
|
|
|
|
|
/// <param name="process">Process</param>
|
|
|
|
|
|
public PartDlg(string name, Process process)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
Part = new Part(name, process, CodeType.UniqueNr, CodeForm.QRCode, CodeLocation.OnPart);
|
|
|
|
|
|
Text = Strings.New_part;
|
|
|
|
|
|
AnyChange = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor when a part is being editted
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="part">Part</param>
|
|
|
|
|
|
public PartDlg(Part part, bool unlockedCompletely, bool unlockedReleased)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
Part = part;
|
|
|
|
|
|
Text = Strings.Part_properties;
|
|
|
|
|
|
AnyChange = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (unlockedCompletely)
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
|
|
|
|
|
descriptionTextBox.Enabled = true;
|
|
|
|
|
|
lifetimeManagementComboBox.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
typeRadioButton1.Enabled = true;
|
|
|
|
|
|
typeRadioButton2.Enabled = true;
|
|
|
|
|
|
typeRadioButton3.Enabled = true;
|
|
|
|
|
|
typeRadioButton4.Enabled = true;
|
|
|
|
|
|
typeRadioButton5.Enabled = true;
|
|
|
|
|
|
typeRadioButton6.Enabled = true;
|
|
|
|
|
|
typeRadioButton7.Enabled = true;
|
|
|
|
|
|
typeRadioButton8.Enabled = true;
|
|
|
|
|
|
typeRadioButton9.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
formRadioButton1.Enabled = true;
|
|
|
|
|
|
formRadioButton2.Enabled = true;
|
|
|
|
|
|
formRadioButton3.Enabled = true;
|
|
|
|
|
|
formRadioButton4.Enabled = true;
|
|
|
|
|
|
formRadioButton5.Enabled = true;
|
|
|
|
|
|
formRadioButton6.Enabled = true;
|
|
|
|
|
|
formRadioButton7.Enabled = true;
|
|
|
|
|
|
formRadioButton8.Enabled = true;
|
|
|
|
|
|
formRadioButton9.Enabled = true;
|
2023-05-25 12:27:09 +00:00
|
|
|
|
formRadioButton10.Enabled = true;
|
|
|
|
|
|
formRadioButton11.Enabled = true;
|
2022-01-06 14:41:50 +00:00
|
|
|
|
|
|
|
|
|
|
locationRadioButton1.Enabled = true;
|
|
|
|
|
|
locationRadioButton2.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (unlockedReleased)
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
|
|
|
|
|
descriptionTextBox.Enabled = true;
|
|
|
|
|
|
lifetimeManagementComboBox.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
typeRadioButton1.Enabled = true;
|
|
|
|
|
|
typeRadioButton2.Enabled = true;
|
|
|
|
|
|
typeRadioButton3.Enabled = true;
|
|
|
|
|
|
typeRadioButton4.Enabled = true;
|
|
|
|
|
|
typeRadioButton5.Enabled = true;
|
|
|
|
|
|
typeRadioButton6.Enabled = true;
|
|
|
|
|
|
typeRadioButton7.Enabled = true;
|
|
|
|
|
|
typeRadioButton8.Enabled = true;
|
|
|
|
|
|
typeRadioButton9.Enabled = true;
|
|
|
|
|
|
|
2023-05-25 12:27:09 +00:00
|
|
|
|
formRadioButton1.Enabled = true;
|
|
|
|
|
|
formRadioButton2.Enabled = true;
|
|
|
|
|
|
formRadioButton3.Enabled = true;
|
|
|
|
|
|
formRadioButton4.Enabled = true;
|
|
|
|
|
|
formRadioButton5.Enabled = true;
|
|
|
|
|
|
formRadioButton6.Enabled = true;
|
|
|
|
|
|
formRadioButton7.Enabled = true;
|
|
|
|
|
|
formRadioButton8.Enabled = true;
|
|
|
|
|
|
formRadioButton9.Enabled = true;
|
|
|
|
|
|
formRadioButton10.Enabled = true;
|
|
|
|
|
|
formRadioButton11.Enabled = true;
|
2022-01-06 14:41:50 +00:00
|
|
|
|
|
|
|
|
|
|
locationRadioButton1.Enabled = false;
|
|
|
|
|
|
locationRadioButton2.Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = false;
|
|
|
|
|
|
descriptionTextBox.Enabled = false;
|
|
|
|
|
|
lifetimeManagementComboBox.Enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
typeRadioButton1.Enabled = false;
|
|
|
|
|
|
typeRadioButton2.Enabled = false;
|
|
|
|
|
|
typeRadioButton3.Enabled = false;
|
|
|
|
|
|
typeRadioButton4.Enabled = false;
|
|
|
|
|
|
typeRadioButton5.Enabled = false;
|
|
|
|
|
|
typeRadioButton6.Enabled = false;
|
|
|
|
|
|
typeRadioButton7.Enabled = false;
|
|
|
|
|
|
typeRadioButton8.Enabled = false;
|
|
|
|
|
|
typeRadioButton9.Enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
formRadioButton1.Enabled = false;
|
|
|
|
|
|
formRadioButton2.Enabled = false;
|
|
|
|
|
|
formRadioButton3.Enabled = false;
|
|
|
|
|
|
formRadioButton4.Enabled = false;
|
|
|
|
|
|
formRadioButton5.Enabled = false;
|
|
|
|
|
|
formRadioButton6.Enabled = false;
|
|
|
|
|
|
formRadioButton7.Enabled = false;
|
|
|
|
|
|
formRadioButton8.Enabled = false;
|
|
|
|
|
|
formRadioButton9.Enabled = false;
|
2023-05-25 12:27:09 +00:00
|
|
|
|
formRadioButton10.Enabled = false;
|
|
|
|
|
|
formRadioButton11.Enabled = false;
|
2022-01-06 14:41:50 +00:00
|
|
|
|
|
|
|
|
|
|
locationRadioButton1.Enabled = false;
|
|
|
|
|
|
locationRadioButton2.Enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
okButton.Visible = false;
|
|
|
|
|
|
cancelButton.Text = Strings.Close;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void PartDlg_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (LifetimeManagement lm = 0; lm < LifetimeManagement.Count; lm++)
|
|
|
|
|
|
{
|
|
|
|
|
|
lifetimeManagementComboBox.Items.Add(lm.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Text = Part.Name;
|
|
|
|
|
|
descriptionTextBox.Text = Part.Description;
|
|
|
|
|
|
lifetimeManagementComboBox.Text = Part.LifetimeManagement.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
typeRadioButton1.Checked = (Part.CodeType == (sbyte)CodeType.UniqueNr);
|
|
|
|
|
|
typeRadioButton2.Checked = (Part.CodeType == (sbyte)CodeType.FlowtubeNr);
|
|
|
|
|
|
typeRadioButton3.Checked = (Part.CodeType == (sbyte)CodeType.FlowtubeNrLU);
|
|
|
|
|
|
typeRadioButton4.Checked = (Part.CodeType == (sbyte)CodeType.BatchNr);
|
|
|
|
|
|
typeRadioButton5.Checked = (Part.CodeType == (sbyte)CodeType.BatchNrContainingPartName);
|
|
|
|
|
|
typeRadioButton6.Checked = (Part.CodeType == (sbyte)CodeType.DateMMYY);
|
|
|
|
|
|
typeRadioButton7.Checked = (Part.CodeType == (sbyte)CodeType.QualityCheck);
|
|
|
|
|
|
typeRadioButton8.Checked = (Part.CodeType == (sbyte)CodeType.PO);
|
|
|
|
|
|
typeRadioButton9.Checked = (Part.CodeType == (sbyte)CodeType.Silicon);
|
|
|
|
|
|
|
|
|
|
|
|
formRadioButton1.Checked = (Part.CodeForm == (sbyte)CodeForm.Barcode);
|
|
|
|
|
|
formRadioButton2.Checked = (Part.CodeForm == (sbyte)CodeForm.QRCode);
|
|
|
|
|
|
formRadioButton3.Checked = (Part.CodeForm == (sbyte)CodeForm.Keyboard);
|
|
|
|
|
|
formRadioButton4.Checked = (Part.CodeForm == (sbyte)CodeForm.OkNok);
|
|
|
|
|
|
formRadioButton5.Checked = (Part.CodeForm == (sbyte)CodeForm.SerialNr);
|
|
|
|
|
|
formRadioButton6.Checked = (Part.CodeForm == (sbyte)CodeForm.Camera);
|
|
|
|
|
|
formRadioButton7.Checked = (Part.CodeForm == (sbyte)CodeForm.Scale);
|
|
|
|
|
|
formRadioButton8.Checked = (Part.CodeForm == (sbyte)CodeForm.SNGenerator);
|
|
|
|
|
|
formRadioButton9.Checked = (Part.CodeForm == (sbyte)CodeForm.DataStream);
|
2023-05-25 12:27:09 +00:00
|
|
|
|
formRadioButton10.Checked = (Part.CodeForm == (sbyte)CodeForm.Spare2);
|
|
|
|
|
|
formRadioButton11.Checked = (Part.CodeForm == (sbyte)CodeForm.Spare3);
|
2022-01-06 14:41:50 +00:00
|
|
|
|
|
|
|
|
|
|
locationRadioButton1.Checked = (Part.CodeLocation == CodeLocation.OnPart);
|
|
|
|
|
|
locationRadioButton2.Checked = (Part.CodeLocation == CodeLocation.OnPallet);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UpdateFromForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Part.Name != nameTextBox.Text) { AnyChange = true; Part.Name = nameTextBox.Text; }
|
|
|
|
|
|
if (Part.Description != descriptionTextBox.Text) { AnyChange = true; Part.Description = descriptionTextBox.Text; }
|
|
|
|
|
|
|
|
|
|
|
|
for (LifetimeManagement lm = 0; lm < LifetimeManagement.Count; lm++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (lifetimeManagementComboBox.Text.Equals(lm.ToString()))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Part.LifetimeManagement != lm)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnyChange = true;
|
|
|
|
|
|
Part.LifetimeManagement = lm;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CodeType codeType = typeRadioButton1.Checked ? CodeType.UniqueNr :
|
|
|
|
|
|
(typeRadioButton2.Checked ? CodeType.FlowtubeNr :
|
|
|
|
|
|
(typeRadioButton3.Checked ? CodeType.FlowtubeNrLU :
|
|
|
|
|
|
(typeRadioButton4.Checked ? CodeType.BatchNr :
|
|
|
|
|
|
(typeRadioButton5.Checked ? CodeType.BatchNrContainingPartName :
|
|
|
|
|
|
(typeRadioButton6.Checked ? CodeType.DateMMYY :
|
|
|
|
|
|
(typeRadioButton7.Checked ? CodeType.QualityCheck :
|
|
|
|
|
|
(typeRadioButton8.Checked ? CodeType.PO :
|
|
|
|
|
|
CodeType.Silicon)))))));
|
|
|
|
|
|
if (Part.CodeType != (sbyte)codeType)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnyChange = true;
|
|
|
|
|
|
Part.CodeType = (sbyte)codeType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CodeForm codeForm = formRadioButton1.Checked ? CodeForm.Barcode :
|
|
|
|
|
|
(formRadioButton2.Checked ? CodeForm.QRCode :
|
|
|
|
|
|
(formRadioButton3.Checked ? CodeForm.Keyboard :
|
|
|
|
|
|
(formRadioButton4.Checked ? CodeForm.OkNok :
|
|
|
|
|
|
(formRadioButton5.Checked ? CodeForm.SerialNr :
|
|
|
|
|
|
(formRadioButton6.Checked ? CodeForm.Camera :
|
|
|
|
|
|
(formRadioButton7.Checked ? CodeForm.Scale :
|
|
|
|
|
|
(formRadioButton8.Checked ? CodeForm.SNGenerator :
|
2023-05-25 12:27:09 +00:00
|
|
|
|
(formRadioButton8.Checked ? CodeForm.DataStream :
|
|
|
|
|
|
(formRadioButton8.Checked ? CodeForm.Spare2 :
|
|
|
|
|
|
CodeForm.Spare3)))))))));
|
2022-01-06 14:41:50 +00:00
|
|
|
|
if (Part.CodeForm != (sbyte)codeForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnyChange = true;
|
|
|
|
|
|
Part.CodeForm = (sbyte)codeForm;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CodeLocation codeLoc = locationRadioButton1.Checked ? CodeLocation.OnPart :
|
|
|
|
|
|
CodeLocation.OnPallet;
|
|
|
|
|
|
if (Part.CodeLocation != codeLoc)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnyChange = true;
|
|
|
|
|
|
Part.CodeLocation = codeLoc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns true if verification passed OK
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2022-01-11 12:35:10 +00:00
|
|
|
|
bool Verify(out string message)
|
2022-01-06 14:41:50 +00:00
|
|
|
|
{
|
2022-01-11 12:35:10 +00:00
|
|
|
|
if (nameTextBox.Text.Length > Const.MaxPartNameLen)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = string.Format(Strings.Max_part_name_length_is_0_characters, Const.MaxPartNameLen);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message = string.Empty;
|
2022-01-06 14:41:50 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2022-01-11 12:35:10 +00:00
|
|
|
|
string message;
|
|
|
|
|
|
if (!Verify(out message))
|
2022-01-06 14:41:50 +00:00
|
|
|
|
{
|
2022-01-11 12:35:10 +00:00
|
|
|
|
MessageBox.Show(string.Format("{0}{1}{2}", Strings.Invalid_data, Environment.NewLine, message),
|
|
|
|
|
|
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
2022-01-06 14:41:50 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpdateFromForm();
|
|
|
|
|
|
|
|
|
|
|
|
DialogResult = AnyChange ? DialogResult.OK : DialogResult.Cancel;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|