OrderManagement: 1.POName max. 10 digits 2.Modifications by others checked 3.DB updates are transactions 4.Order state refreshed each 5 s 5.version displayed in wnd title, ver. 3.0.13
This commit is contained in:
parent
10b17c250c
commit
f23fc0d4c4
@ -1,20 +1,23 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using SharedDatabase;
|
||||
using SharedDatabase.Entities;
|
||||
using OrderManagement.Resources;
|
||||
using NHibernate;
|
||||
|
||||
namespace OrderManagement
|
||||
{
|
||||
public partial class EditOrderDlg : Form
|
||||
{
|
||||
ISession session;
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(EditOrderDlg));
|
||||
|
||||
ISessionFactory sessionFactory;
|
||||
OrderInfo oriOrder;
|
||||
IList<OrderInfo> listOfOrders;
|
||||
bool isEnablePredefinedOrders;
|
||||
@ -22,11 +25,11 @@ namespace OrderManagement
|
||||
|
||||
EditParametersCtrl editParametersCtrl;
|
||||
|
||||
public EditOrderDlg(ISession session, OrderInfo order, IList<OrderInfo> listOfOrders, bool isEnablePredefinedOrders = false, bool editMode = false)
|
||||
public EditOrderDlg(ISessionFactory sessionFactory, OrderInfo order, IList<OrderInfo> listOfOrders, bool isEnablePredefinedOrders = false, bool editMode = false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.session = session;
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.oriOrder = order;
|
||||
this.listOfOrders = listOfOrders;
|
||||
this.isEnablePredefinedOrders = isEnablePredefinedOrders;
|
||||
@ -51,9 +54,10 @@ namespace OrderManagement
|
||||
{
|
||||
OrderInfo modifiedOrder = editParametersCtrl.ParamsProvider as OrderInfo;
|
||||
|
||||
int modifiedOrderNr;
|
||||
if (!isEnablePredefinedOrders &&
|
||||
(!int.TryParse(modifiedOrder.POName, out modifiedOrderNr) || modifiedOrderNr <= OrderManagementDlg.MaxPredefinedOrderNr))
|
||||
long modifiedOrderNr;
|
||||
if (!long.TryParse(modifiedOrder.POName, out modifiedOrderNr) ||
|
||||
modifiedOrderNr <= 0 ||
|
||||
(!isEnablePredefinedOrders && modifiedOrderNr <= OrderManagementDlg.MaxPredefinedOrderNr))
|
||||
{
|
||||
MessageBox.Show(string.Format(Strings.Order_number_must_be_larger_then_0, OrderManagementDlg.MaxPredefinedOrderNr));
|
||||
return;
|
||||
@ -72,10 +76,55 @@ namespace OrderManagement
|
||||
return;
|
||||
}
|
||||
|
||||
modifiedOrder.CopyContentTo(oriOrder);
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
if (Save(oriOrder))
|
||||
ITransaction transaction = null;
|
||||
bool oriOrdermodified = false;
|
||||
bool saved = false;
|
||||
try
|
||||
{
|
||||
ISession session = sessionFactory.OpenSession();
|
||||
transaction = session.BeginTransaction();
|
||||
|
||||
var list = (oriOrder.Id != 0)
|
||||
? session.QueryOver<OrderInfo>().Where(x => x.Id == oriOrder.Id).List()
|
||||
: new List<OrderInfo> { oriOrder };
|
||||
|
||||
if (list.Count != 1)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
else if (list[0].Equals(oriOrder, true))
|
||||
{
|
||||
modifiedOrder.CopyContentTo(list[0], true);
|
||||
session.SaveOrUpdate(list[0]);
|
||||
transaction.Commit();
|
||||
session.Flush();
|
||||
list[0].CopyContentTo(oriOrder, false);
|
||||
saved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
list[0].CopyContentTo(oriOrder, false);
|
||||
transaction.Rollback();
|
||||
oriOrdermodified = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (transaction != null) transaction.Rollback();
|
||||
log.ErrorFormat("Saving an order failed: {1}", exc.Message);
|
||||
}
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
if (saved)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else if (oriOrdermodified)
|
||||
{
|
||||
MessageBox.Show("Original order was modified by someone else,\r\ntry to adit this order once again");
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
@ -87,34 +136,6 @@ namespace OrderManagement
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the new or modified order to the database
|
||||
/// </summary>
|
||||
/// <returns>true when successful</returns>
|
||||
bool Save(OrderInfo order)
|
||||
{
|
||||
ITransaction transaction = session.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
session.SaveOrUpdate(order);
|
||||
transaction.Commit();
|
||||
session.Flush();
|
||||
Cursor.Current = Cursors.Default;
|
||||
return true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
transaction.Rollback();
|
||||
MessageBox.Show(string.Format("{0}{1}{2}", Strings.Saving_order_failed, Environment.NewLine, exc.Message),
|
||||
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
Cursor.Current = Cursors.Default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
@ -130,7 +151,7 @@ namespace OrderManagement
|
||||
/// <returns>false = OK, true = conflict (MessageBox appears before returning true)</returns>
|
||||
bool IsConflict(OrderInfo order, IList<OrderInfo> listOfOrders, OrderInfo orderToIgnore)
|
||||
{
|
||||
if (order.POName[0] == '3')
|
||||
if (order.POName.Length == 7 && order.POName[0] == '3')
|
||||
{
|
||||
if (MessageBox.Show(string.Format("{0}\r\n{1}", Strings.It_is_not_recommended_that_orders_start_with_3,
|
||||
Strings.Abort_creating_an_order_QM),
|
||||
|
||||
@ -17,9 +17,9 @@ namespace OrderManagement
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(OrderManagementDlg));
|
||||
|
||||
public const int MaxPredefinedOrderNr = 1000;
|
||||
public const long MaxPredefinedOrderNr = 1000;
|
||||
|
||||
ISession session;
|
||||
ISessionFactory sessionFactory;
|
||||
IList<OrderInfo> listOfOrders;
|
||||
IList<Process> listOfWorkflows;
|
||||
|
||||
@ -46,10 +46,10 @@ namespace OrderManagement
|
||||
Text = string.Format("{0} v.{1}", Program.ProgramName, Program.Version); ;
|
||||
}
|
||||
|
||||
public OrderManagementDlg(ISession session, IList<OrderInfo> listOfOrders, IList<Process> listOfWorkflows)
|
||||
public OrderManagementDlg(ISessionFactory sessionFactory, IList<OrderInfo> listOfOrders, IList<Process> listOfWorkflows)
|
||||
: this()
|
||||
{
|
||||
this.session = session;
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.listOfOrders = listOfOrders;
|
||||
this.listOfWorkflows = listOfWorkflows;
|
||||
}
|
||||
@ -78,7 +78,14 @@ namespace OrderManagement
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = string.Format("{0} ver.{1}", Strings.Order_Management, Program.Version);
|
||||
settingsToolStripMenuItem.Text = Strings.Settings;
|
||||
closeButton.Text = Strings.Close;
|
||||
addButton.Text = Strings.Add;
|
||||
editButton.Text = Strings.Edit;
|
||||
copyButton.Text = Strings.Copy;
|
||||
deleteButton.Text = Strings.Delete;
|
||||
printButton.Text = Strings.Print;
|
||||
}
|
||||
|
||||
enum Clmn
|
||||
@ -232,7 +239,7 @@ namespace OrderManagement
|
||||
///
|
||||
var order = new OrderInfo(candidatePOName);
|
||||
|
||||
if (new EditOrderDlg(session, order, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders).ShowDialog()
|
||||
if (new EditOrderDlg(sessionFactory, order, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders).ShowDialog()
|
||||
== DialogResult.OK)
|
||||
{
|
||||
listOfOrders.Add(order);
|
||||
@ -251,7 +258,14 @@ namespace OrderManagement
|
||||
}
|
||||
else
|
||||
{
|
||||
new OrderStateDlg(session, order).ShowDialog();
|
||||
try
|
||||
{
|
||||
new OrderStateDlg(order, sessionFactory).ShowDialog();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.ErrorFormat("Failed to read order {0} when creating OrderStateDlg: {1)", order.POName, exc.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +276,7 @@ namespace OrderManagement
|
||||
OrderInfo order = listViewEx1.SelectedItems[0].Tag as OrderInfo;
|
||||
if (order.POState == (sbyte)OrderState.New)
|
||||
{
|
||||
if (new EditOrderDlg(session, order, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders, true).ShowDialog()
|
||||
if (new EditOrderDlg(sessionFactory, order, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders, true).ShowDialog()
|
||||
== DialogResult.OK)
|
||||
{
|
||||
UpdateRow(listViewEx1.SelectedItems[0], order);
|
||||
@ -297,31 +311,31 @@ namespace OrderManagement
|
||||
///
|
||||
/// Create and edit the order
|
||||
///
|
||||
OrderInfo newOrder = oriOrder.Clone() as OrderInfo;
|
||||
newOrder.POName = candidatePOName;
|
||||
newOrder.POState = (sbyte)OrderState.New;
|
||||
newOrder.SNFirst = oriOrder.SNFirst + oriOrder.PiecesCount; /// TODO
|
||||
newOrder.RAFirst = oriOrder.RAFirst + oriOrder.PiecesCount; /// TODO
|
||||
newOrder.BaseNr1 = 0;
|
||||
newOrder.BaseNr2 = 0;
|
||||
newOrder.BaseNr3 = 0;
|
||||
newOrder.BaseNr4 = 0;
|
||||
newOrder.BaseNr5 = 0;
|
||||
newOrder.CurrentPcsCount = 0;
|
||||
newOrder.CurrentSN = 0;
|
||||
newOrder.CurrentRA = 0;
|
||||
newOrder.CurrentNr1 = 0;
|
||||
newOrder.CurrentNr2 = 0;
|
||||
newOrder.CurrentNr3 = 0;
|
||||
newOrder.CurrentNr4 = 0;
|
||||
newOrder.CurrentNr5 = 0;
|
||||
newOrder.Remark = string.Format("Copy of order {0}", oriOrder.POName);
|
||||
OrderInfo copiedOrder = oriOrder.Clone() as OrderInfo;
|
||||
copiedOrder.POName = candidatePOName;
|
||||
copiedOrder.POState = (sbyte)OrderState.New;
|
||||
copiedOrder.SNFirst = oriOrder.SNFirst + oriOrder.PiecesCount; /// TODO
|
||||
copiedOrder.RAFirst = oriOrder.RAFirst + oriOrder.PiecesCount; /// TODO
|
||||
copiedOrder.BaseNr1 = 0;
|
||||
copiedOrder.BaseNr2 = 0;
|
||||
copiedOrder.BaseNr3 = 0;
|
||||
copiedOrder.BaseNr4 = 0;
|
||||
copiedOrder.BaseNr5 = 0;
|
||||
copiedOrder.CurrentPcsCount = 0;
|
||||
copiedOrder.CurrentSN = 0;
|
||||
copiedOrder.CurrentRA = 0;
|
||||
copiedOrder.CurrentNr1 = 0;
|
||||
copiedOrder.CurrentNr2 = 0;
|
||||
copiedOrder.CurrentNr3 = 0;
|
||||
copiedOrder.CurrentNr4 = 0;
|
||||
copiedOrder.CurrentNr5 = 0;
|
||||
copiedOrder.Remark = string.Format("Copy of order {0}", oriOrder.POName);
|
||||
|
||||
if (new EditOrderDlg(session, newOrder, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders).ShowDialog()
|
||||
if (new EditOrderDlg(sessionFactory, copiedOrder, listOfOrders, Program.LocalSettings.IsShowPredefinedOrders).ShowDialog()
|
||||
== DialogResult.OK)
|
||||
{
|
||||
listOfOrders.Add(newOrder);
|
||||
AddRow(listViewEx1, newOrder);
|
||||
listOfOrders.Add(copiedOrder);
|
||||
AddRow(listViewEx1, copiedOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,10 +350,29 @@ namespace OrderManagement
|
||||
{
|
||||
try
|
||||
{
|
||||
session.Delete(order);
|
||||
session.Flush();
|
||||
listOfOrders.Remove(order);
|
||||
listViewEx1.Items.Remove(listViewEx1.SelectedItems[0]);
|
||||
ISession session = sessionFactory.OpenSession();
|
||||
var list = session.QueryOver<OrderInfo>().Where(x => x.Id == order.Id).List();
|
||||
if (list.Count == 1)
|
||||
{
|
||||
if (list[0].POState == (sbyte)OrderState.New)
|
||||
{
|
||||
session.Delete(list[0]);
|
||||
session.Flush();
|
||||
listOfOrders.Remove(order);
|
||||
listViewEx1.Items.Remove(listViewEx1.SelectedItems[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Strings.You_can_only_delete_New_porduction_orders);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listOfOrders.Remove(order);
|
||||
listViewEx1.Items.Remove(listViewEx1.SelectedItems[0]);
|
||||
MessageBox.Show(Strings.Order_was_already_deleted);
|
||||
}
|
||||
session.Close();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
16
OrderManagement/OrderStateDlg.Designer.cs
generated
16
OrderManagement/OrderStateDlg.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.currentSnLabel = new System.Windows.Forms.Label();
|
||||
this.currentRATextBox = new System.Windows.Forms.TextBox();
|
||||
this.currentRALabel = new System.Windows.Forms.Label();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// orderLabel
|
||||
@ -144,11 +145,23 @@
|
||||
this.currentRALabel.TabIndex = 10;
|
||||
this.currentRALabel.Text = "Last assigned radio address";
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.Location = new System.Drawing.Point(364, 23);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(85, 43);
|
||||
this.closeButton.TabIndex = 12;
|
||||
this.closeButton.Text = "Close";
|
||||
this.closeButton.UseVisualStyleBackColor = true;
|
||||
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
|
||||
//
|
||||
// OrderStateDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(479, 219);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.closeButton);
|
||||
this.Controls.Add(this.currentRATextBox);
|
||||
this.Controls.Add(this.currentRALabel);
|
||||
this.Controls.Add(this.currentSnTextBox);
|
||||
@ -166,7 +179,7 @@
|
||||
this.Name = "OrderStateDlg";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Order state";
|
||||
this.Text = "Order State";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -186,5 +199,6 @@
|
||||
private System.Windows.Forms.Label currentSnLabel;
|
||||
private System.Windows.Forms.TextBox currentRATextBox;
|
||||
private System.Windows.Forms.Label currentRALabel;
|
||||
private System.Windows.Forms.Button closeButton;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
@ -11,35 +11,81 @@ namespace OrderManagement
|
||||
{
|
||||
public partial class OrderStateDlg : Form
|
||||
{
|
||||
ISession session;
|
||||
OrderInfo order;
|
||||
ISessionFactory sessionFactory;
|
||||
int orderId;
|
||||
Timer timer;
|
||||
|
||||
public OrderStateDlg()
|
||||
private OrderStateDlg()
|
||||
{
|
||||
InitializeComponent();
|
||||
Localize();
|
||||
}
|
||||
|
||||
public OrderStateDlg(ISession session,OrderInfo order)
|
||||
public OrderStateDlg(OrderInfo order, ISessionFactory sessionFactory)
|
||||
: this()
|
||||
{
|
||||
this.session = session;
|
||||
this.order = order;
|
||||
Localize();
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.orderId = order.Id;
|
||||
|
||||
orderTextBox.Text = order.POName;
|
||||
stateTextBox.Text = ((OrderState)order.POState).ToString();
|
||||
targetPcsCountTextBox.Text = order.PiecesCount.ToString();
|
||||
producedPcsCountTextBox.Text = order.CurrentPcsCount.ToString();
|
||||
currentSnTextBox.Text = (order.SNPrefix != null ? order.SNPrefix : string.Empty) + order.CurrentSN.ToString(string.Format("D{0}", order.SNDigitsCount))
|
||||
+ (order.SNSuffix != null ? order.SNSuffix : string.Empty);
|
||||
currentRATextBox.Text = (order.RAPrefix != null ? order.RAPrefix : string.Empty) + order.CurrentRA.ToString(SharedDatabase.Const.RAFormat)
|
||||
+ (order.RASuffix != null ? order.RASuffix : string.Empty);
|
||||
/// Update UI when this form is loaded
|
||||
timer_Tick(null, null);
|
||||
|
||||
/// Timer for regular 5 second ticks
|
||||
timer = new System.Windows.Forms.Timer();
|
||||
timer.Interval = 5000; // ms
|
||||
timer.Tick += new EventHandler(timer_Tick);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
void timer_Tick(object sender, EventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = sessionFactory.OpenSession();
|
||||
var list = session.QueryOver<OrderInfo>().Where(x => x.Id == orderId).List();
|
||||
session.Close();
|
||||
|
||||
if (list.Count == 1) UpdateUI(list[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
stateTextBox.Text = "---";
|
||||
targetPcsCountTextBox.Text = "---";
|
||||
producedPcsCountTextBox.Text = "---";
|
||||
currentSnTextBox.Text = "---";
|
||||
currentRATextBox.Text = "---";
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateUI(OrderInfo o)
|
||||
{
|
||||
orderTextBox.Text = o.POName;
|
||||
stateTextBox.Text = ((OrderState)o.POState).ToString();
|
||||
targetPcsCountTextBox.Text = o.PiecesCount.ToString();
|
||||
producedPcsCountTextBox.Text = o.CurrentPcsCount.ToString();
|
||||
currentSnTextBox.Text = (o.SNPrefix != null ? o.SNPrefix : string.Empty)
|
||||
+ o.CurrentSN.ToString(string.Format("D{0}", o.SNDigitsCount))
|
||||
+ (o.SNSuffix != null ? o.SNSuffix : string.Empty);
|
||||
currentRATextBox.Text = (o.RAPrefix != null ? o.RAPrefix : string.Empty)
|
||||
+ o.CurrentRA.ToString(SharedDatabase.Const.RAFormat)
|
||||
+ (o.RASuffix != null ? o.RASuffix : string.Empty);
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.Order_State;
|
||||
orderLabel.Text = Strings.Order;
|
||||
stateLabel.Text = Strings.State;
|
||||
targetPcsCountLabel.Text = Strings.Target_quantity;
|
||||
producedPcsCountLabel.Text = Strings.Produced_quantity;
|
||||
currentSnLabel.Text = Strings.Last_assigned_serial_number;
|
||||
currentRALabel.Text = Strings.Last_assigned_radio_address;
|
||||
closeButton.Text = Strings.Close;
|
||||
}
|
||||
|
||||
private void closeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using Common;
|
||||
@ -169,19 +171,27 @@ namespace OrderManagement
|
||||
}
|
||||
}
|
||||
|
||||
ISession session;
|
||||
ISessionFactory sessionFactory;
|
||||
IList<OrderInfo> listOfOrders = null;
|
||||
IList<Process> listOfWorkflows = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
session = SharedDatabase.TracingDB.CreateSession(LocalSettings.TracingDBConnString);
|
||||
listOfOrders = session.QueryOver<OrderInfo>()
|
||||
.List();
|
||||
sessionFactory = Fluently.Configure()
|
||||
.Database(MySQLConfiguration.Standard.ConnectionString(LocalSettings.TracingDBConnString))
|
||||
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SharedDatabase.Entities.Process>())
|
||||
.ExposeConfiguration(BuildSchema).BuildSessionFactory();
|
||||
|
||||
ISession session = sessionFactory.OpenSession();
|
||||
|
||||
listOfOrders = session.QueryOver<OrderInfo>().List();
|
||||
|
||||
listOfWorkflows = session.QueryOver<Process>()
|
||||
.Where(x => x.ReleaseStatus != ReleaseStatus.Deactivated)
|
||||
.List();
|
||||
session.Close();
|
||||
break;
|
||||
}
|
||||
catch (Exception exc)
|
||||
@ -207,7 +217,7 @@ namespace OrderManagement
|
||||
|
||||
try
|
||||
{
|
||||
OrderManagementDlg dlg = new OrderManagementDlg(session, listOfOrders, listOfWorkflows);
|
||||
OrderManagementDlg dlg = new OrderManagementDlg(sessionFactory, listOfOrders, listOfWorkflows);
|
||||
Application.Run(dlg);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -224,6 +234,12 @@ namespace OrderManagement
|
||||
}
|
||||
}
|
||||
|
||||
public static void BuildSchema(NHibernate.Cfg.Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new NHibernate.Tool.hbm2ddl.SchemaExport(config).SetOutputFile("db_schema");
|
||||
}
|
||||
|
||||
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OrderManagement")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021-2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -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("3.0.11.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.11.0")]
|
||||
[assembly: AssemblyVersion("3.0.13.0")]
|
||||
[assembly: AssemblyFileVersion("3.0.13.0")]
|
||||
|
||||
117
OrderManagement/Resources/Strings.Designer.cs
generated
117
OrderManagement/Resources/Strings.Designer.cs
generated
@ -69,6 +69,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add.
|
||||
/// </summary>
|
||||
internal static string Add {
|
||||
get {
|
||||
return ResourceManager.GetString("Add", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Are you sure ?.
|
||||
/// </summary>
|
||||
@ -87,6 +96,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close.
|
||||
/// </summary>
|
||||
internal static string Close {
|
||||
get {
|
||||
return ResourceManager.GetString("Close", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close it please using 'Task manager'.
|
||||
/// </summary>
|
||||
@ -114,6 +132,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Copy.
|
||||
/// </summary>
|
||||
internal static string Copy {
|
||||
get {
|
||||
return ResourceManager.GetString("Copy", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Database.
|
||||
/// </summary>
|
||||
@ -132,6 +159,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
internal static string Delete {
|
||||
get {
|
||||
return ResourceManager.GetString("Delete", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to digits count.
|
||||
/// </summary>
|
||||
@ -141,6 +177,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit.
|
||||
/// </summary>
|
||||
internal static string Edit {
|
||||
get {
|
||||
return ResourceManager.GetString("Edit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Error.
|
||||
/// </summary>
|
||||
@ -213,6 +258,24 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Last assigned radio address.
|
||||
/// </summary>
|
||||
internal static string Last_assigned_radio_address {
|
||||
get {
|
||||
return ResourceManager.GetString("Last_assigned_radio_address", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Last assigned serial number.
|
||||
/// </summary>
|
||||
internal static string Last_assigned_serial_number {
|
||||
get {
|
||||
return ResourceManager.GetString("Last_assigned_serial_number", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Last radio address.
|
||||
/// </summary>
|
||||
@ -267,6 +330,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Order Management.
|
||||
/// </summary>
|
||||
internal static string Order_Management {
|
||||
get {
|
||||
return ResourceManager.GetString("Order_Management", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Order number must be larger then {0}.
|
||||
/// </summary>
|
||||
@ -276,6 +348,24 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Order State.
|
||||
/// </summary>
|
||||
internal static string Order_State {
|
||||
get {
|
||||
return ResourceManager.GetString("Order_State", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Order was already deleted.
|
||||
/// </summary>
|
||||
internal static string Order_was_already_deleted {
|
||||
get {
|
||||
return ResourceManager.GetString("Order_was_already_deleted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Order with the same ID already exists.
|
||||
/// </summary>
|
||||
@ -321,6 +411,24 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Print.
|
||||
/// </summary>
|
||||
internal static string Print {
|
||||
get {
|
||||
return ResourceManager.GetString("Print", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Produced quantity.
|
||||
/// </summary>
|
||||
internal static string Produced_quantity {
|
||||
get {
|
||||
return ResourceManager.GetString("Produced_quantity", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Producton order properties.
|
||||
/// </summary>
|
||||
@ -438,6 +546,15 @@ namespace OrderManagement.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Target quantity.
|
||||
/// </summary>
|
||||
internal static string Target_quantity {
|
||||
get {
|
||||
return ResourceManager.GetString("Target_quantity", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Test procedure.
|
||||
/// </summary>
|
||||
|
||||
@ -276,4 +276,43 @@
|
||||
<data name="Year_of_calibration" xml:space="preserve">
|
||||
<value>Year of calibration</value>
|
||||
</data>
|
||||
<data name="Order_was_already_deleted" xml:space="preserve">
|
||||
<value>Order was already deleted</value>
|
||||
</data>
|
||||
<data name="Close" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
<data name="Last_assigned_radio_address" xml:space="preserve">
|
||||
<value>Last assigned radio address</value>
|
||||
</data>
|
||||
<data name="Last_assigned_serial_number" xml:space="preserve">
|
||||
<value>Last assigned serial number</value>
|
||||
</data>
|
||||
<data name="Order_State" xml:space="preserve">
|
||||
<value>Order State</value>
|
||||
</data>
|
||||
<data name="Produced_quantity" xml:space="preserve">
|
||||
<value>Produced quantity</value>
|
||||
</data>
|
||||
<data name="Target_quantity" xml:space="preserve">
|
||||
<value>Target quantity</value>
|
||||
</data>
|
||||
<data name="Add" xml:space="preserve">
|
||||
<value>Add</value>
|
||||
</data>
|
||||
<data name="Copy" xml:space="preserve">
|
||||
<value>Copy</value>
|
||||
</data>
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="Edit" xml:space="preserve">
|
||||
<value>Edit</value>
|
||||
</data>
|
||||
<data name="Order_Management" xml:space="preserve">
|
||||
<value>Order Management</value>
|
||||
</data>
|
||||
<data name="Print" xml:space="preserve">
|
||||
<value>Print</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -186,18 +186,19 @@ namespace SharedDatabase.Entities
|
||||
{
|
||||
message = string.Empty;
|
||||
int idummy;
|
||||
long ldummy;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0: /// POName
|
||||
if (str.Length != 7)
|
||||
if (str.Length < 1 || str.Length > 10)
|
||||
{
|
||||
message = string.Format("Order must have 7 digits");
|
||||
message = string.Format("Order must have up to 10 digits");
|
||||
return false;
|
||||
}
|
||||
else if (!int.TryParse(str, out idummy) || idummy <= 0)
|
||||
else if (!long.TryParse(str, out ldummy) || ldummy <= 0)
|
||||
{
|
||||
message = string.Format("Order must be a positive integer number");
|
||||
message = string.Format("Order must be a positive integer number up to 9999999999");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -249,7 +250,12 @@ namespace SharedDatabase.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void CopyContentTo(OrderInfo dest)
|
||||
/// <summary>
|
||||
/// Copy content of one entity to another entity (except of Id)
|
||||
/// </summary>
|
||||
/// <param name="dest">Entity to copy to</param>
|
||||
/// <param name="visibleOnly">true = do not copy invisible members</param>
|
||||
public virtual void CopyContentTo(OrderInfo dest, bool visibleOnly = false)
|
||||
{
|
||||
dest.POName = POName;
|
||||
dest.POState = POState;
|
||||
@ -271,19 +277,72 @@ namespace SharedDatabase.Entities
|
||||
dest.RAFirst = RAFirst;
|
||||
dest.RASuffix = RASuffix;
|
||||
dest.Remark = Remark;
|
||||
dest.BaseNr1 = BaseNr1;
|
||||
dest.BaseNr2 = BaseNr2;
|
||||
dest.BaseNr3 = BaseNr3;
|
||||
dest.BaseNr4 = BaseNr4;
|
||||
dest.BaseNr5 = BaseNr5;
|
||||
dest.CurrentPcsCount = CurrentPcsCount;
|
||||
dest.CurrentSN = CurrentSN;
|
||||
dest.CurrentRA = CurrentRA;
|
||||
dest.CurrentNr1 = CurrentNr1;
|
||||
dest.CurrentNr2 = CurrentNr2;
|
||||
dest.CurrentNr3 = CurrentNr3;
|
||||
dest.CurrentNr4 = CurrentNr4;
|
||||
dest.CurrentNr5 = CurrentNr5;
|
||||
|
||||
if (!visibleOnly)
|
||||
{
|
||||
dest.BaseNr1 = BaseNr1;
|
||||
dest.BaseNr2 = BaseNr2;
|
||||
dest.BaseNr3 = BaseNr3;
|
||||
dest.BaseNr4 = BaseNr4;
|
||||
dest.BaseNr5 = BaseNr5;
|
||||
dest.CurrentPcsCount = CurrentPcsCount;
|
||||
dest.CurrentSN = CurrentSN;
|
||||
dest.CurrentRA = CurrentRA;
|
||||
dest.CurrentNr1 = CurrentNr1;
|
||||
dest.CurrentNr2 = CurrentNr2;
|
||||
dest.CurrentNr3 = CurrentNr3;
|
||||
dest.CurrentNr4 = CurrentNr4;
|
||||
dest.CurrentNr5 = CurrentNr5;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare content of two entities (except of Id)
|
||||
/// </summary>
|
||||
/// <param name="dest">Entity to compare with</param>
|
||||
/// <param name="visibleOnly">true = do not compare invisible members</param>
|
||||
/// <returns>true = two entities are equal (except of Id)</returns>
|
||||
public virtual bool Equals(OrderInfo dest, bool visibleOnly = false)
|
||||
{
|
||||
if (dest.POName != POName) return false;
|
||||
if (dest.POState != POState) return false;
|
||||
if (dest.Workflow != Workflow) return false;
|
||||
if (dest.TestProcedure != TestProcedure) return false;
|
||||
if (dest.VariantCode != VariantCode) return false;
|
||||
if (dest.VacoDescription != VacoDescription) return false;
|
||||
if (dest.MadeInText != MadeInText) return false;
|
||||
if (dest.Year != Year) return false;
|
||||
if (dest.ModuleParam != ModuleParam) return false;
|
||||
if (dest.LaserMarking != LaserMarking) return false;
|
||||
if (dest.Packing != Packing) return false;
|
||||
if (dest.PiecesCount != PiecesCount) return false;
|
||||
if (dest.SNPrefix != SNPrefix) return false;
|
||||
if (dest.SNFirst != SNFirst) return false;
|
||||
if (dest.SNDigitsCount != SNDigitsCount) return false;
|
||||
if (dest.SNSuffix != SNSuffix) return false;
|
||||
if (dest.RAPrefix != RAPrefix) return false;
|
||||
if (dest.RAFirst != RAFirst) return false;
|
||||
if (dest.RASuffix != RASuffix) return false;
|
||||
if (dest.Remark != Remark) return false;
|
||||
|
||||
if (!visibleOnly)
|
||||
{
|
||||
if (dest.BaseNr1 != BaseNr1) return false;
|
||||
if (dest.BaseNr2 != BaseNr2) return false;
|
||||
if (dest.BaseNr3 != BaseNr3) return false;
|
||||
if (dest.BaseNr4 != BaseNr4) return false;
|
||||
if (dest.BaseNr5 != BaseNr5) return false;
|
||||
if (dest.CurrentPcsCount != CurrentPcsCount) return false;
|
||||
if (dest.CurrentSN != CurrentSN) return false;
|
||||
if (dest.CurrentRA != CurrentRA) return false;
|
||||
if (dest.CurrentNr1 != CurrentNr1) return false;
|
||||
if (dest.CurrentNr2 != CurrentNr2) return false;
|
||||
if (dest.CurrentNr3 != CurrentNr3) return false;
|
||||
if (dest.CurrentNr4 != CurrentNr4) return false;
|
||||
if (dest.CurrentNr5 != CurrentNr5) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -5,7 +5,6 @@ using FluentNHibernate.Cfg;
|
||||
using FluentNHibernate.Cfg.Db;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using NHibernate.Tool.hbm2ddl;
|
||||
using log4net;
|
||||
using SharedDatabase.Entities;
|
||||
|
||||
@ -77,14 +76,14 @@ namespace SharedDatabase
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).SetOutputFile("db_schema");
|
||||
new NHibernate.Tool.hbm2ddl.SchemaExport(config).SetOutputFile("db_schema");
|
||||
}
|
||||
|
||||
static void BuildSchemaCreate(Configuration config)
|
||||
{
|
||||
/// This NHibernate tool takes a configuration (with mapping info in)
|
||||
/// and exports a database schema from it
|
||||
new SchemaExport(config).Create(true, true);
|
||||
new NHibernate.Tool.hbm2ddl.SchemaExport(config).Create(true, true);
|
||||
}
|
||||
|
||||
/// Create a NHibernate session for the given database
|
||||
|
||||
Loading…
Reference in New Issue
Block a user