92 lines
3.0 KiB
C#
92 lines
3.0 KiB
C#
///
|
|
/// Copyright (c) 2021-2022 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
|
|
{
|
|
ISessionFactory sessionFactory;
|
|
int orderId;
|
|
Timer timer;
|
|
|
|
private OrderStateDlg()
|
|
{
|
|
InitializeComponent();
|
|
Localize();
|
|
}
|
|
|
|
public OrderStateDlg(OrderInfo order, ISessionFactory sessionFactory)
|
|
: this()
|
|
{
|
|
this.sessionFactory = sessionFactory;
|
|
this.orderId = order.Id;
|
|
|
|
/// 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();
|
|
}
|
|
}
|
|
}
|