267 lines
10 KiB
C#
267 lines
10 KiB
C#
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;
|
|
oraDBTypeTextBox.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;
|
|
|
|
locationRadioButton1.Enabled = true;
|
|
locationRadioButton2.Enabled = true;
|
|
}
|
|
else if (unlockedReleased)
|
|
{
|
|
nameTextBox.Enabled = true;
|
|
descriptionTextBox.Enabled = true;
|
|
oraDBTypeTextBox.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 = 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;
|
|
|
|
locationRadioButton1.Enabled = false;
|
|
locationRadioButton2.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
nameTextBox.Enabled = false;
|
|
descriptionTextBox.Enabled = false;
|
|
oraDBTypeTextBox.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;
|
|
|
|
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;
|
|
oraDBTypeTextBox.Text = Part.OraDBType;
|
|
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);
|
|
|
|
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.OraDBType != oraDBTypeTextBox.Text) { AnyChange = true; Part.OraDBType = oraDBTypeTextBox.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 :
|
|
CodeForm.DataStream)))))));
|
|
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>
|
|
bool Verify()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
if (!Verify())
|
|
{
|
|
MessageBox.Show(Strings.Invalid_data, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
return;
|
|
}
|
|
|
|
UpdateFromForm();
|
|
|
|
DialogResult = AnyChange ? DialogResult.OK : DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
}
|
|
}
|