124 lines
3.5 KiB
C#
124 lines
3.5 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UI.Shared
|
|
{
|
|
public partial class PrintOrderForm : Form
|
|
{
|
|
public string PurchaseOrder;
|
|
public string Tester;
|
|
public bool OnlyGoodResults;
|
|
public bool OnlyLastResult;
|
|
|
|
public PrintOrderForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.Icon = Properties.Resources.TBF_icon;
|
|
}
|
|
|
|
private void PrintOrderForm_Load(object sender, EventArgs e)
|
|
{
|
|
Localize();
|
|
|
|
TBF.LocalSettings ls = Program.LocalSettings;
|
|
Left = (ls.PrintOrderLeft != 0) ? ls.PrintOrderLeft : 200;
|
|
Top = (ls.PrintOrderTop != 0) ? ls.PrintOrderTop : 100;
|
|
|
|
onlyGoodCheckBox.Checked = OnlyGoodResults = Program.LocalSettings.PrintOrderOnlyGoodResult;
|
|
onlyLastCheckBox.Checked = OnlyLastResult = Program.LocalSettings.PrintOrderOnlyLastResult;
|
|
|
|
PrepareOrderCombo(purchaseOrderComboBox);
|
|
PrepareTesterCombo(testerComboBox);
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Print_watermeter_results;
|
|
purchaseOrderGroupBox.Text = Strings.Purchase_order;
|
|
testerGroupBox.Text = Strings.Tester;
|
|
onlyGoodCheckBox.Text = Strings.Print_only_good_results;
|
|
onlyLastCheckBox.Text = Strings.Print_only_the_last_measurement;
|
|
printButton.Text = Strings.PrintBtnText;
|
|
cancelButton.Text = Strings.CancelBtnText;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
|
|
/// </summary>
|
|
/// <param name="orderComboBox">Puchase order ComboBox</param>
|
|
void PrepareOrderCombo(ComboBox orderComboBox)
|
|
{
|
|
for (int i = 0; i < Program.LocalSettings.PurchaseOrderHistoryCount; i++)
|
|
{
|
|
orderComboBox.Items.Add(Program.LocalSettings.PurchaseOrderHistory[i]);
|
|
}
|
|
if (orderComboBox.Items.Count > 0)
|
|
{
|
|
orderComboBox.Text = orderComboBox.Items[0].ToString();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
|
|
/// </summary>
|
|
/// <param name="orderComboBox">Puchase order ComboBox</param>
|
|
void PrepareTesterCombo(ComboBox testerComboBox)
|
|
{
|
|
for (int i = 0; i < Program.LocalSettings.TesterHistoryCount; i++)
|
|
{
|
|
testerComboBox.Items.Add(Program.LocalSettings.TesterHistory[i]);
|
|
}
|
|
if (testerComboBox.Items.Count > 0)
|
|
{
|
|
testerComboBox.Text = testerComboBox.Items[0].ToString();
|
|
}
|
|
}
|
|
|
|
private void printButton_Click(object sender, EventArgs e)
|
|
{
|
|
PurchaseOrder = purchaseOrderComboBox.Text;
|
|
Tester = testerComboBox.Text;
|
|
|
|
Program.LocalSettings.PrintOrderOnlyGoodResult = OnlyGoodResults = onlyGoodCheckBox.Checked;
|
|
Program.LocalSettings.PrintOrderOnlyLastResult = OnlyLastResult = onlyLastCheckBox.Checked;
|
|
|
|
Program.LocalSettings.PrintOrderLeft = Location.X;
|
|
Program.LocalSettings.PrintOrderTop = Location.Y;
|
|
bool b1 = Program.LocalSettings.UpdateHistory(testerComboBox.Text,
|
|
ref Program.LocalSettings.TesterHistory);
|
|
bool b2 = Program.LocalSettings.UpdateHistory(purchaseOrderComboBox.Text,
|
|
ref Program.LocalSettings.PurchaseOrderHistory
|
|
#if FUZHOU_150 || FUZHOU_300
|
|
, 20
|
|
#endif
|
|
);
|
|
if (!b1 && !b2)
|
|
{
|
|
Program.LocalSettings.Save();
|
|
}
|
|
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
PurchaseOrder = string.Empty;
|
|
Tester = string.Empty;
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
}
|
|
}
|