LaserMarking added to OrderInfo, OrderInfo printing, bug fixes.

This commit is contained in:
Milan Hanajik 2021-11-16 23:15:30 +01:00
parent 0494054171
commit 351157dbba
18 changed files with 726 additions and 121 deletions

View File

@ -19,12 +19,13 @@ namespace Common
public string Variant;
public string Order;
public string Workflow;
public string LaserMarking;
public bool IsNative;
public ProcedureSelection ResolvedSource; /// ProcedureSelection.FromLocalDB or ProcedureSelection.FromSharedDB when Resolved==true
public string ResolvedName;
public ProcedureInfo(ProcedureSelection source, int itemNr, string name, string signature = null,
string variant = null, string order = null, string workflow = null)
string variant = null, string order = null, string workflow = null, string laserMarking = null)
{
Source = source;
ItemNr = itemNr;
@ -33,6 +34,7 @@ namespace Common
Variant = (variant == null) ? string.Empty : variant;
Order = order;
Workflow = workflow;
LaserMarking = laserMarking;
if (source == ProcedureSelection.FromLocalDB || source == ProcedureSelection.FromSharedDB)
{

View File

@ -14,10 +14,9 @@ namespace OrderManagement
public partial class EditOrderDlg : Form
{
ISession session;
OrderInfo order;
OrderInfo oriOrder;
IList<OrderInfo> listOfOrders;
bool editMode;
string oriPOName;
EditParametersCtrl editParametersCtrl;
@ -26,12 +25,11 @@ namespace OrderManagement
InitializeComponent();
this.session = session;
this.order = order;
this.oriOrder = order;
this.listOfOrders = listOfOrders;
this.editMode = editMode;
oriPOName = order.POName;
editParametersCtrl = new EditParametersCtrl(this.order);
editParametersCtrl = new EditParametersCtrl(oriOrder.Clone());
editParametersCtrl.Dock = DockStyle.Fill;
editParametersCtrl.Unlock();
splitContainer1.Panel1.Controls.Add(editParametersCtrl);
@ -47,19 +45,36 @@ namespace OrderManagement
private void okButton_Click(object sender, EventArgs e)
{
OrderInfo orderWithTheSameName = listOfOrders.FirstOrDefault(x => (x.POName == order.POName));
OrderInfo modifiedOrder = editParametersCtrl.ParamsProvider as OrderInfo;
if (orderWithTheSameName != null && (!editMode || order.POName != oriPOName))
OrderInfo orderWithTheSameName = listOfOrders.FirstOrDefault(x => (x.POName == modifiedOrder.POName));
if (orderWithTheSameName != null && (!editMode || modifiedOrder.POName != oriOrder.POName))
{
MessageBox.Show(Strings.Order_with_the_same_ID_already_exists);
return;
}
DialogResult = Save() ? DialogResult.OK : DialogResult.Cancel;
modifiedOrder.CopyContentTo(oriOrder);
if (Save(oriOrder))
{
DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("Saving the modified order to the database failed");
DialogResult = DialogResult.Cancel;
}
Close();
}
bool Save()
/// <summary>
/// Saves the new or modified order to the database
/// </summary>
/// <returns>true when successful</returns>
bool Save(OrderInfo order)
{
ITransaction transaction = session.BeginTransaction();

View File

@ -14,7 +14,7 @@ namespace OrderManagement
{
static readonly ILog log = LogManager.GetLogger(typeof(EditParametersCtrl));
IParamsProvider paramsProvider;
public IParamsProvider ParamsProvider;
Control[] editors;
CfgUpdateFlags flags;
@ -31,13 +31,13 @@ namespace OrderManagement
public EditParametersCtrl(object paramsProvider)
: this()
{
this.paramsProvider = paramsProvider as IParamsProvider;
if (this.paramsProvider == null) throw(new ArgumentException("paramsProvider"));
this.ParamsProvider = paramsProvider as IParamsProvider;
if (this.ParamsProvider == null) throw(new ArgumentException("paramsProvider"));
editors = new Control[this.paramsProvider.ParamsCount()];
for (int i = 0; i < this.paramsProvider.ParamsCount(); i++)
editors = new Control[this.ParamsProvider.ParamsCount()];
for (int i = 0; i < this.ParamsProvider.ParamsCount(); i++)
{
ICollection<string> values = this.paramsProvider.ParamValues(i);
ICollection<string> values = this.ParamsProvider.ParamValues(i);
if (values == null)
{
editors[i] = new TextBox();
@ -72,13 +72,13 @@ namespace OrderManagement
void Redraw()
{
if (paramsProvider == null) return; /// Control was not loaded, settings were not changed
if (ParamsProvider == null) return; /// Control was not loaded, settings were not changed
paramsListViewEx.Items.Clear();
for (int i = 0; i < paramsProvider.ParamsCount(); i++)
for (int i = 0; i < ParamsProvider.ParamsCount(); i++)
{
ListViewItem lvi = new ListViewItem(paramsProvider.ParamName(i));
lvi.SubItems.Add(paramsProvider.ToString(i));
ListViewItem lvi = new ListViewItem(ParamsProvider.ParamName(i));
lvi.SubItems.Add(ParamsProvider.ToString(i));
lvi.Tag = i;
paramsListViewEx.Items.Add(lvi);
}
@ -96,7 +96,7 @@ namespace OrderManagement
public CfgUpdateFlags UpdateCfg()
{
if (paramsProvider == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
if (ParamsProvider == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
CfgUpdateFlags f = this.flags;
@ -116,9 +116,9 @@ namespace OrderManagement
int itemNr = (int)e.Item.Tag;
string message;
if (paramsProvider.ValidateParam(itemNr, e.DisplayText, out message))
if (ParamsProvider.ValidateParam(itemNr, e.DisplayText, out message))
{
flags |= paramsProvider.UpdateParam(itemNr, e.DisplayText);
flags |= ParamsProvider.UpdateParam(itemNr, e.DisplayText);
}
else
{

View File

@ -42,6 +42,9 @@
<Reference Include="FluentNHibernate">
<HintPath>..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll</HintPath>
</Reference>
<Reference Include="Gma.QrCodeNet.Encoding">
<HintPath>..\packages\QrCode.Net.0.4.0.0\net40\Gma.QrCodeNet.Encoding.dll</HintPath>
</Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\packages\Iesi.Collections.4.0.0.4000\lib\net40\Iesi.Collections.dll</HintPath>
</Reference>
@ -78,6 +81,9 @@
<Compile Include="EditOrderDlg.Designer.cs">
<DependentUpon>EditOrderDlg.cs</DependentUpon>
</Compile>
<Compile Include="OrderPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="LocalSettings.cs" />
<Compile Include="OrderManagementDlg.cs">
<SubType>Form</SubType>
@ -85,6 +91,12 @@
<Compile Include="OrderManagementDlg.Designer.cs">
<DependentUpon>OrderManagementDlg.cs</DependentUpon>
</Compile>
<Compile Include="OrderStateDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="OrderStateDlg.Designer.cs">
<DependentUpon>OrderStateDlg.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\Strings.Designer.cs">
@ -107,6 +119,9 @@
<EmbeddedResource Include="OrderManagementDlg.resx">
<DependentUpon>OrderManagementDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="OrderStateDlg.resx">
<DependentUpon>OrderStateDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -142,6 +157,10 @@
<Project>{c8939821-ba5c-4988-a3d0-bf53b74865c7}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\GenCode128\GenCode128.csproj">
<Project>{32817bf9-e380-4467-9c7f-936f4b122bc7}</Project>
<Name>GenCode128</Name>
</ProjectReference>
<ProjectReference Include="..\SharedDatabase\SharedDatabase.csproj">
<Project>{211b5e3f-9996-48a7-abde-c878dd2d71c2}</Project>
<Name>SharedDatabase</Name>

View File

@ -36,6 +36,7 @@
this.editButton = new System.Windows.Forms.Button();
this.closeButton = new System.Windows.Forms.Button();
this.deleteButton = new System.Windows.Forms.Button();
this.printButton = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@ -73,6 +74,7 @@
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.printButton);
this.splitContainer1.Panel2.Controls.Add(this.addButton);
this.splitContainer1.Panel2.Controls.Add(this.editButton);
this.splitContainer1.Panel2.Controls.Add(this.closeButton);
@ -141,6 +143,17 @@
this.deleteButton.UseVisualStyleBackColor = true;
this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click);
//
// printButton
//
this.printButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.printButton.Location = new System.Drawing.Point(23, 245);
this.printButton.Name = "printButton";
this.printButton.Size = new System.Drawing.Size(85, 40);
this.printButton.TabIndex = 6;
this.printButton.Text = "Print";
this.printButton.UseVisualStyleBackColor = true;
this.printButton.Click += new System.EventHandler(this.printButton_Click);
//
// OrderManagementDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -175,6 +188,7 @@
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button deleteButton;
private Common.Forms.ListViewEx listViewEx1;
private System.Windows.Forms.Button printButton;
}
}

View File

@ -69,6 +69,7 @@ namespace OrderManagement
Workflow,
Procedure,
Variant,
LaserMarking,
Pieces,
SNPrefix,
SNFirst,
@ -89,6 +90,7 @@ namespace OrderManagement
lv.Columns.Add(new ColumnHeader { Text = Strings.Workflow, Width = 150 });
lv.Columns.Add(new ColumnHeader { Text = Strings.Test_procedure, Width = 150 });
lv.Columns.Add(new ColumnHeader { Text = Strings.Variant_code, Width = 150 });
lv.Columns.Add(new ColumnHeader { Text = Strings.Laser_marking, Width = 150 });
lv.Columns.Add(new ColumnHeader { Text = Strings.Pieces_count, Width = 80 });
lv.Columns.Add(new ColumnHeader { Text = Strings.SN + " " + Strings.prefix, Width = 80 });
lv.Columns.Add(new ColumnHeader { Text = Strings.SN + " " + Strings.first, Width = 80 });
@ -108,6 +110,7 @@ namespace OrderManagement
lvi.SubItems.Add(o.Workflow);
lvi.SubItems.Add(o.TestProcedure);
lvi.SubItems.Add(o.VariantCode);
lvi.SubItems.Add(o.LaserMarking);
lvi.SubItems.Add(o.PiecesCount.ToString());
lvi.SubItems.Add(o.SNPrefix);
lvi.SubItems.Add(o.SNFirst.ToString(string.Format("D{0}", o.SNDigitsCount)));
@ -130,6 +133,7 @@ namespace OrderManagement
lvi.SubItems[i++].Text = o.Workflow;
lvi.SubItems[i++].Text = o.TestProcedure;
lvi.SubItems[i++].Text = o.VariantCode;
lvi.SubItems[i++].Text = o.LaserMarking;
lvi.SubItems[i++].Text = o.PiecesCount.ToString();
lvi.SubItems[i++].Text = o.SNPrefix;
lvi.SubItems[i++].Text = o.SNFirst.ToString(string.Format("D{0}", o.SNDigitsCount));
@ -202,47 +206,62 @@ namespace OrderManagement
private void listViewEx1_DoubleClick(object sender, EventArgs e)
{
editButton_Click(sender, e);
if (listViewEx1.SelectedItems.Count != 1 || !(listViewEx1.SelectedItems[0].Tag is OrderInfo)) return;
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
if (order.POState == (sbyte)OrderState.New)
{
editButton_Click(sender, e);
}
else
{
new OrderStateDlg(session, order).ShowDialog();
}
}
private void editButton_Click(object sender, EventArgs e)
{
if (listViewEx1.SelectedItems.Count == 1 && listViewEx1.SelectedItems[0].Tag is OrderInfo)
if (listViewEx1.SelectedItems.Count != 1 || !(listViewEx1.SelectedItems[0].Tag is OrderInfo)) return;
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
if (order.POState == (sbyte)OrderState.New)
{
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
if (order.POState == (sbyte)OrderState.New)
if (new EditOrderDlg(session, order, listOfOrders, true).ShowDialog() == DialogResult.OK)
{
if (new EditOrderDlg(session, order, listOfOrders, true).ShowDialog() == DialogResult.OK)
{
UpdateRow(listViewEx1.SelectedItems[0], order);
}
}
else
{
MessageBox.Show(Strings.You_can_only_edit_New_porduction_orders);
UpdateRow(listViewEx1.SelectedItems[0], order);
}
}
else
{
MessageBox.Show(Strings.You_can_only_edit_New_porduction_orders);
}
}
private void deleteButton_Click(object sender, EventArgs e)
{
if (listViewEx1.SelectedItems.Count == 1 && listViewEx1.SelectedItems[0].Tag is OrderInfo)
if (listViewEx1.SelectedItems.Count != 1 || !(listViewEx1.SelectedItems[0].Tag is OrderInfo)) return;
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
if (order.POState == (sbyte)OrderState.New)
{
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
if (order.POState == (sbyte)OrderState.New)
if (MessageBox.Show(Strings.Are_you_sure, Strings.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
if (MessageBox.Show(Strings.Are_you_sure, Strings.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
try
{
if (new EditOrderDlg(session, order, listOfOrders).ShowDialog() == DialogResult.OK)
{
UpdateRow(listViewEx1.SelectedItems[0], order);
}
session.Delete(order);
session.Flush();
listOfOrders.Remove(order);
listViewEx1.Items.Remove(listViewEx1.SelectedItems[0]);
}
catch (Exception exc)
{
MessageBox.Show(string.Format("Deleting an order failed\r\n{0}", exc.Message));
}
}
else
{
MessageBox.Show(Strings.You_can_only_delete_New_porduction_orders);
}
}
else
{
MessageBox.Show(Strings.You_can_only_delete_New_porduction_orders);
}
}
@ -272,5 +291,14 @@ namespace OrderManagement
listViewEx1.SetSortIcon(sortColumn, sortOrder);
listViewEx1.Sort();
}
private void printButton_Click(object sender, EventArgs e)
{
if (listViewEx1.SelectedItems.Count != 1 || !(listViewEx1.SelectedItems[0].Tag is OrderInfo)) return;
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
new OrderPrintDocument(order).Print();
}
}
}

View File

@ -0,0 +1,165 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.IO;
using Common;
using GenCode128;
using Gma.QrCodeNet.Encoding;
using SharedDatabase.Entities;
using OrderManagement.Resources;
namespace OrderManagement
{
public class OrderPrintDocument : Common.Printers.PrintersCommon
{
static QrEncoder encoder = new QrEncoder();
// Paper size
const bool IsLandscape = false;
const int PaperHeight = 1400;
const int PaperWidth = 900;
/// Texts
readonly Font font = new Font("Arial", 12, FontStyle.Bold);
const int Top = 100;
const int Column1left = 100;
const int Column2left = 300;
const int Spacing = 35;
/// Barcode
const bool IsQRCode = false;
const int BarcodeLeft = 600;
const int BarcodeTop = 100;
const int BarcodeWidth = 100;
const int BarcodeHeight = 50;
/// Data to print
OrderInfo order;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public OrderPrintDocument(OrderInfo order)
{
DocumentName = order.POName;
this.order = order;
/// Set print area size and margins (in dots using 100 dpi)
DefaultPageSettings.Landscape = IsLandscape;
}
/// <summary>
/// Override the default onbeginPrint method of the PrintDocument Object
/// </summary>
/// <param name=e></param>
/// <remarks></remarks>
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
base.OnBeginPrint(e);
}
/// <summary>
/// Override the default OnPrintPage method of the PrintDocument.
/// </summary>
/// <param name=e></param>
/// <remarks>This provides the print logic for our document</remarks>
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
/// Run base code
base.OnPrintPage(e);
string[] texts = new string[]
{
Strings.Order + " :",
order.POName,
Strings.Pieces_count + " :",
order.PiecesCount.ToString(),
Strings.First_serial_number + " :",
string.Format("{0}{1}{2}", (order.SNPrefix != null) ? order.SNPrefix : string.Empty,
order.SNDigitsCount != 0 ? order.SNFirst.ToString(string.Format("D{0}", order.SNDigitsCount)) : string.Empty,
(order.SNSuffix != null) ? order.SNSuffix : string.Empty),
Strings.Last_serial_number + " :",
string.Format("{0}{1}{2}", (order.SNPrefix != null) ? order.SNPrefix : string.Empty,
order.SNDigitsCount != 0 ? (order.SNFirst + order.PiecesCount - 1).ToString(string.Format("D{0}", order.SNDigitsCount)) : string.Empty,
(order.SNSuffix != null) ? order.SNSuffix : string.Empty),
Strings.First_radio_address + " :",
string.Format("{0}{1}{2}", (order.RAPrefix != null) ? order.RAPrefix : string.Empty,
order.RADigitsCount != 0 ? order.RAFirst.ToString(string.Format("D{0}", order.RADigitsCount)) : string.Empty,
(order.RASuffix != null) ? order.RASuffix : string.Empty),
Strings.Last_radio_address + " :",
string.Format("{0}{1}{2}", (order.RAPrefix != null) ? order.RAPrefix : string.Empty,
order.RADigitsCount != 0 ? (order.RAFirst + order.PiecesCount - 1).ToString(string.Format("D{0}", order.RADigitsCount)) : string.Empty,
(order.RASuffix != null) ? order.RASuffix : string.Empty),
Strings.Workflow + " :",
(order.Workflow != null) ? order.Workflow : string.Empty,
Strings.Test_procedure + " :",
(order.TestProcedure != null) ? order.TestProcedure : string.Empty,
Strings.Variant_code + " :",
(order.VariantCode != null) ? order.VariantCode : string.Empty,
Strings.Laser_marking + " :",
(order.LaserMarking != null) ? order.LaserMarking : string.Empty,
Strings.Remark + " :",
(order.Remark != null) ? order.Remark : string.Empty,
};
int lineTop = Top;
for (int i = 0; i < texts.Length; i += 2)
{
e.Graphics.DrawString(texts[i], font, Brushes.Black, new RectangleF(Column1left, lineTop, PaperWidth, PaperHeight));
e.Graphics.DrawString(texts[i + 1], font, Brushes.Black, new RectangleF(Column2left, lineTop, PaperWidth, PaperHeight));
lineTop += Spacing;
}
try
{
if (IsQRCode)
{
QrCode qrCode = encoder.Encode(order.POName);
DrawQR(e.Graphics, qrCode, BarcodeLeft, BarcodeTop, BarcodeWidth, BarcodeHeight);
}
else
{
Image img = Code128Rendering.MakeBarcodeImage(order.POName, 1, true);
#if VERTICAL_BARCODE
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
#endif
e.Graphics.DrawImage(img, BarcodeLeft, BarcodeTop, BarcodeWidth, BarcodeHeight);
}
}
catch (Exception)
{
}
}
public static void DrawQR(Graphics g, QrCode qrCode, float left, float top, float width, float height)
{
/// Assuming 100 dpi (printer)
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
float qrPixWidth = width / qrCode.Matrix.Width;
float qrPixHeight = height / qrCode.Matrix.Height;
for (int i = 0; i < qrCode.Matrix.Height; i++)
{
for (int j = 0; j < qrCode.Matrix.Width; j++)
{
if (qrCode.Matrix[j, i])
{
g.FillRectangle(Brushes.Black, new RectangleF(left + j * qrPixWidth,
top + i * qrPixHeight,
qrPixWidth,
qrPixHeight));
}
}
}
}
}
}

View File

@ -0,0 +1,95 @@
namespace OrderManagement
{
partial class OrderStateDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.orderLabel = new System.Windows.Forms.Label();
this.orderTextBox = new System.Windows.Forms.TextBox();
this.stateLabel = new System.Windows.Forms.Label();
this.stateTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// orderLabel
//
this.orderLabel.AutoSize = true;
this.orderLabel.Location = new System.Drawing.Point(28, 26);
this.orderLabel.Name = "orderLabel";
this.orderLabel.Size = new System.Drawing.Size(33, 13);
this.orderLabel.TabIndex = 0;
this.orderLabel.Text = "Order";
//
// orderTextBox
//
this.orderTextBox.Enabled = false;
this.orderTextBox.Location = new System.Drawing.Point(108, 23);
this.orderTextBox.Name = "orderTextBox";
this.orderTextBox.Size = new System.Drawing.Size(100, 20);
this.orderTextBox.TabIndex = 1;
//
// stateLabel
//
this.stateLabel.AutoSize = true;
this.stateLabel.Location = new System.Drawing.Point(28, 54);
this.stateLabel.Name = "stateLabel";
this.stateLabel.Size = new System.Drawing.Size(32, 13);
this.stateLabel.TabIndex = 2;
this.stateLabel.Text = "State";
//
// stateTextBox
//
this.stateTextBox.Enabled = false;
this.stateTextBox.Location = new System.Drawing.Point(108, 51);
this.stateTextBox.Name = "stateTextBox";
this.stateTextBox.Size = new System.Drawing.Size(100, 20);
this.stateTextBox.TabIndex = 3;
//
// OrderStateDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(479, 261);
this.Controls.Add(this.stateTextBox);
this.Controls.Add(this.stateLabel);
this.Controls.Add(this.orderTextBox);
this.Controls.Add(this.orderLabel);
this.Name = "OrderStateDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Order state";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label orderLabel;
private System.Windows.Forms.TextBox orderTextBox;
private System.Windows.Forms.Label stateLabel;
private System.Windows.Forms.TextBox stateTextBox;
}
}

View File

@ -0,0 +1,39 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Windows.Forms;
using NHibernate;
using SharedDatabase.Entities;
using OrderManagement.Resources;
namespace OrderManagement
{
public partial class OrderStateDlg : Form
{
ISession session;
OrderInfo order;
public OrderStateDlg()
{
InitializeComponent();
}
public OrderStateDlg(ISession session,OrderInfo order)
: this()
{
this.session = session;
this.order = order;
Localize();
orderTextBox.Text = order.POName;
stateTextBox.Text = order.POState.ToString();
}
void Localize()
{
orderLabel.Text = Strings.Order;
stateLabel.Text = Strings.State;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]

View File

@ -150,6 +150,24 @@ namespace OrderManagement.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to First radio address.
/// </summary>
internal static string First_radio_address {
get {
return ResourceManager.GetString("First_radio_address", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to First serial number.
/// </summary>
internal static string First_serial_number {
get {
return ResourceManager.GetString("First_serial_number", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid &apos;{0}&apos;.
/// </summary>
@ -168,6 +186,33 @@ namespace OrderManagement.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Laser marking.
/// </summary>
internal static string Laser_marking {
get {
return ResourceManager.GetString("Laser_marking", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Last radio address.
/// </summary>
internal static string Last_radio_address {
get {
return ResourceManager.GetString("Last_radio_address", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Last serial number.
/// </summary>
internal static string Last_serial_number {
get {
return ResourceManager.GetString("Last_serial_number", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to OK.
/// </summary>

View File

@ -228,4 +228,19 @@
<data name="You_can_only_delete_New_porduction_orders" xml:space="preserve">
<value>You can only delete 'New' porduction orders</value>
</data>
<data name="Laser_marking" xml:space="preserve">
<value>Laser marking</value>
</data>
<data name="First_radio_address" xml:space="preserve">
<value>First radio address</value>
</data>
<data name="First_serial_number" xml:space="preserve">
<value>First serial number</value>
</data>
<data name="Last_radio_address" xml:space="preserve">
<value>Last radio address</value>
</data>
<data name="Last_serial_number" xml:space="preserve">
<value>Last serial number</value>
</data>
</root>

View File

@ -14,21 +14,22 @@ namespace SharedDatabase.Entities
public virtual string Workflow { get; set; } /// 2
public virtual string TestProcedure { get; set; } /// 3
public virtual string VariantCode { get; set; } /// 4
public virtual int PiecesCount { get; set; } /// 5
public virtual string SNPrefix { get; set; } /// 6
public virtual int SNFirst { get; set; } /// 7
public virtual int SNDigitsCount { get; set; } /// 8
public virtual string SNSuffix { get; set; } /// 9
public virtual string RAPrefix { get; set; } /// 10
public virtual int RAFirst { get; set; } /// 11
public virtual int RADigitsCount { get; set; } /// 12
public virtual string RASuffix { get; set; } /// 13
public virtual string LaserMarking { get; set; } /// 5
public virtual int PiecesCount { get; set; } /// 6
public virtual string SNPrefix { get; set; } /// 7
public virtual int SNFirst { get; set; } /// 8
public virtual int SNDigitsCount { get; set; } /// 9
public virtual string SNSuffix { get; set; } /// 10
public virtual string RAPrefix { get; set; } /// 11
public virtual int RAFirst { get; set; } /// 12
public virtual int RADigitsCount { get; set; } /// 13
public virtual string RASuffix { get; set; } /// 14
public virtual int BaseNr1 { get; set; }
public virtual int BaseNr2 { get; set; }
public virtual int BaseNr3 { get; set; }
public virtual int BaseNr4 { get; set; }
public virtual int BaseNr5 { get; set; }
public virtual string Remark { get; set; } /// 14
public virtual string Remark { get; set; } /// 15
public OrderInfo()
{
@ -49,6 +50,7 @@ namespace SharedDatabase.Entities
Workflow = string.Empty;
TestProcedure = string.Empty;
VariantCode = string.Empty;
LaserMarking = string.Empty;
SNPrefix = string.Empty;
SNSuffix = string.Empty;
RAPrefix = string.Empty;
@ -56,39 +58,6 @@ namespace SharedDatabase.Entities
Remark = string.Empty;
}
/// <summary>
/// All members are copied except of ID (so that NHibernate works properly).
/// List of groups is empty.
/// </summary>
/// <param name="newOrderNr">New order ID string</param>
/// <param name="targetPiecesCount">-1 = the same number of pieces as the original order</param>
/// <returns></returns>
public virtual IParamsProvider Clone()
{
var newOrder = new OrderInfo();
newOrder.POName = string.Empty;
newOrder.POState = (sbyte)OrderState.New;
newOrder.Workflow = Workflow;
newOrder.TestProcedure = TestProcedure;
newOrder.VariantCode = VariantCode;
newOrder.PiecesCount = PiecesCount;
newOrder.SNPrefix = SNPrefix;
newOrder.SNFirst = SNFirst + PiecesCount;
newOrder.SNDigitsCount = SNDigitsCount;
newOrder.SNSuffix = SNSuffix;
newOrder.RAPrefix = RAPrefix;
newOrder.RAFirst = RAFirst + PiecesCount;
newOrder.RADigitsCount = RADigitsCount;
newOrder.RASuffix = RASuffix;
newOrder.BaseNr1 = BaseNr1;
newOrder.BaseNr2 = BaseNr2;
newOrder.BaseNr3 = BaseNr3;
newOrder.BaseNr4 = BaseNr4;
newOrder.BaseNr5 = BaseNr5;
newOrder.Remark = Remark;
return newOrder;
}
public virtual XmlSerializer GetSerializer() { return null; }
public virtual string ComponentName { get { return POName; } }
@ -100,6 +69,7 @@ namespace SharedDatabase.Entities
Strings.Workflow,
Strings.Test_procedure,
Strings.Variant_code,
Strings.Laser_marking,
Strings.Pieces_count,
Strings.Serial_nr + " " + Strings.prefix,
Strings.Serial_nr + " " + Strings.first,
@ -120,6 +90,9 @@ namespace SharedDatabase.Entities
switch (i)
{
case 1:
for (OrderState os = 0; os < OrderState.Count; os++) list.Add(os.ToString());
return list;
default:
return null;
}
@ -134,16 +107,17 @@ namespace SharedDatabase.Entities
case 2: return Workflow;
case 3: return TestProcedure;
case 4: return VariantCode;
case 5: return PiecesCount.ToString();
case 6: return SNPrefix;
case 7: return SNFirst.ToString();
case 8: return SNDigitsCount.ToString();
case 9: return SNSuffix;
case 10: return RAPrefix;
case 11: return RAFirst.ToString();
case 12: return RADigitsCount.ToString();
case 13: return RASuffix;
case 14: return Remark;
case 5: return LaserMarking;
case 6: return PiecesCount.ToString();
case 7: return SNPrefix;
case 8: return SNFirst.ToString();
case 9: return SNDigitsCount.ToString();
case 10: return SNSuffix;
case 11: return RAPrefix;
case 12: return RAFirst.ToString();
case 13: return RADigitsCount.ToString();
case 14: return RASuffix;
case 15: return Remark;
default:
return string.Format("order={0} pcs={1} wflow={2} proc={3} vaco={4} #1={5} #2={6} #3={7} #4={8} #5={9} remark={10}",
POName, PiecesCount, Workflow, TestProcedure, VariantCode,
@ -172,33 +146,36 @@ namespace SharedDatabase.Entities
VariantCode = str;
return CfgUpdateFlags.RestartRqrd;
case 5:
PiecesCount = int.Parse(str);
LaserMarking = str;
return CfgUpdateFlags.RestartRqrd;
case 6:
SNPrefix = str;
PiecesCount = int.Parse(str);
return CfgUpdateFlags.RestartRqrd;
case 7:
SNFirst = int.Parse(str);
SNPrefix = str;
return CfgUpdateFlags.RestartRqrd;
case 8:
SNDigitsCount = int.Parse(str);
SNFirst = int.Parse(str);
return CfgUpdateFlags.RestartRqrd;
case 9:
SNSuffix = str;
SNDigitsCount = int.Parse(str);
return CfgUpdateFlags.RestartRqrd;
case 10:
RAPrefix = str;
SNSuffix = str;
return CfgUpdateFlags.RestartRqrd;
case 11:
RAFirst = int.Parse(str);
RAPrefix = str;
return CfgUpdateFlags.RestartRqrd;
case 12:
RADigitsCount = int.Parse(str);
RAFirst = int.Parse(str);
return CfgUpdateFlags.RestartRqrd;
case 13:
RASuffix = str;
RADigitsCount = int.Parse(str);
return CfgUpdateFlags.RestartRqrd;
case 14:
RASuffix = str;
return CfgUpdateFlags.RestartRqrd;
case 15:
Remark = str;
return CfgUpdateFlags.RestartRqrd;
default:
@ -214,28 +191,43 @@ namespace SharedDatabase.Entities
switch (i)
{
case 0:
if (str.Length != 7)
{
message = string.Format("Order must have 7 digits");
return false;
}
else if (!int.TryParse(str, out idummy) || idummy <= 0)
{
message = string.Format("Order must be a positive integer number");
return false;
}
return true;
case 2:
case 3:
case 4:
case 5:
/// nonempty string
if (!string.IsNullOrEmpty(str)) return true;
message = string.Format(Strings._0_should_not_be_empty, ParamName(i));
return false;
case 5:
case 8:
case 12:
/// positive integers
if (int.TryParse(str, out idummy) && idummy > 0) return true;
case 1:
if (ParamValues(i).Contains(str)) return true;
break;
case 6:
case 9:
/// positive integers
if (int.TryParse(str, out idummy) && idummy > 0) return true;
break;
case 7:
case 10:
case 13:
case 11:
case 14:
case 15:
/// strings
return true;
case 7:
case 11:
case 8:
case 12:
case 13:
/// non-negative integer
if (int.TryParse(str, out idummy) && idummy >= 0) return true;
break;
@ -248,6 +240,45 @@ namespace SharedDatabase.Entities
return false;
}
public virtual void CopyContentTo(OrderInfo dest)
{
dest.POName = POName;
dest.POState = POState;
dest.Workflow = Workflow;
dest.TestProcedure = TestProcedure;
dest.VariantCode = VariantCode;
dest.LaserMarking = LaserMarking;
dest.PiecesCount = PiecesCount;
dest.SNPrefix = SNPrefix;
dest.SNFirst = SNFirst;
dest.SNDigitsCount = SNDigitsCount;
dest.SNSuffix = SNSuffix;
dest.RAPrefix = RAPrefix;
dest.RAFirst = RAFirst;
dest.RADigitsCount = RADigitsCount;
dest.RASuffix = RASuffix;
dest.BaseNr1 = BaseNr1;
dest.BaseNr2 = BaseNr2;
dest.BaseNr3 = BaseNr3;
dest.BaseNr4 = BaseNr4;
dest.BaseNr5 = BaseNr5;
dest.Remark = Remark;
}
/// <summary>
/// All members are copied except of ID (so that NHibernate works properly).
/// List of groups is empty.
/// </summary>
/// <param name="newOrderNr">New order ID string</param>
/// <param name="targetPiecesCount">-1 = the same number of pieces as the original order</param>
/// <returns></returns>
public virtual IParamsProvider Clone()
{
OrderInfo clone = new OrderInfo();
CopyContentTo(clone);
return clone;
}
public virtual bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
@ -259,5 +290,6 @@ namespace SharedDatabase.Entities
New = 0,
Active = 1,
Finished = 2,
Count
}
}

View File

@ -13,6 +13,7 @@ namespace SharedDatabase.Mappings
Map(x => x.Workflow);
Map(x => x.TestProcedure);
Map(x => x.VariantCode);
Map(x => x.LaserMarking);
Map(x => x.PiecesCount);
Map(x => x.SNFirst);
Map(x => x.SNPrefix);

View File

@ -312,6 +312,15 @@ namespace SharedDatabase.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Laser marking.
/// </summary>
internal static string Laser_marking {
get {
return ResourceManager.GetString("Laser_marking", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lower limit.
/// </summary>

View File

@ -411,4 +411,7 @@
<data name="SN" xml:space="preserve">
<value>S/N</value>
</data>
<data name="Laser_marking" xml:space="preserve">
<value>Laser marking</value>
</data>
</root>

View File

@ -610,12 +610,14 @@ namespace TBF.UI
if (procedureComboBox.Enabled)
{
if (ProceduresUpdated) ReloadProcedureComboBoxItems();
procedureGroupBox.BackColor = Color.Yellow;
procedureGroupBox.BackColor = Color.DarkBlue;
procedureGroupBox.ForeColor = Color.White;
procedureComboBox.Focus();
}
else
{
procedureGroupBox.BackColor = SystemColors.Control;
procedureGroupBox.ForeColor = SystemColors.ControlText;
}
IsShutdownDisabled = ((args.Flags & ButtonsEtc.ProcedureCmbBoxEn) == 0);
@ -817,7 +819,8 @@ namespace TBF.UI
foreach (var order in mySqlOrders)
{
procedureInfos.Add(new ProcedureInfo(src, 0, order.POName, signature, order.VariantCode, order.POName, order.Workflow));
procedureInfos.Add(new ProcedureInfo(src, 0, order.POName, signature, order.VariantCode,
order.POName, order.Workflow, order.LaserMarking));
}
}
}