Form1.cs
3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using BarcodeScannerClient;
//using HttpUtils;
using MoyaAdminLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace Cloakroom
{
public partial class Form1 : Form
{
private string cloakroomLabel = "narikkalappu.lbx";
//private int number = 1;
public Form1()
{
InitializeComponent();
Properties.Settings.Default.Reload();
}
private void settingsToolStripButton_Click(object sender, EventArgs e)
{
Settings frm = new Settings();
frm.ShowDialog();
}
private void Form1_Load(object sender, EventArgs e)
{
numberNumericUpDown.Value = Properties.Settings.Default.CodeNumber;
}
private void submitButton_Click(object sender, EventArgs e)
{
LuggageHold luggage = new LuggageHold();
luggage.luggageCode = numberNumericUpDown.Value.ToString();
luggage.description = luggaageDescriptionTextBox.Text;
luggage.date = DateTime.Now;
ListViewItem lvi = new ListViewItem(luggage.date.ToString("d.M.yyyy HH:mm"));
lvi.SubItems.Add(luggage.description);
lvi.SubItems.Add(luggage.luggageCode);
//luggagesListView.Items.Add(lvi);
if (printLabel((int)numberNumericUpDown.Value, luggage.description))
{
addMessageToListView("Luggage submitted.Code " + numberNumericUpDown.Value.ToString() + ", Description: '" + luggaageDescriptionTextBox.Text + "'");
numberNumericUpDown.Value += 1;
Properties.Settings.Default.CodeNumber = (int)numberNumericUpDown.Value;
Properties.Settings.Default.Save();
}
}
private bool printLabel(int number, string desc)
{
if (!File.Exists(cloakroomLabel))
{
MessageBox.Show("Cannot find print template");
return false;
}
bpac.DocumentClass doc = null;
try
{
doc = new bpac.DocumentClass();
}
catch (Exception ex)
{
MessageBox.Show("Could not print luggage label. LuggageCode: " + number.ToString());
Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
return false;
}
//doc.SetPrinter(Objects.Conf.BoxLabelPrinter, false);
if (doc != null)
{
//doc.Open(Path.Combine(Properties.Settings.Default.dd, cloakroomLabel));
doc.Open(cloakroomLabel);
doc.GetObject("Code").Text = number.ToString();
doc.GetObject("Desc").Text = desc;
doc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
doc.PrintOut(2, bpac.PrintOptionConstants.bpoDefault);
doc.EndPrint();
doc.Close();
return true;
}
return false;
}
private void addMessageToListView(string p)
{
ListViewItem lvi = new ListViewItem(DateTime.Now.ToString("d.M.yyyy HH:mm"));
lvi.SubItems.Add(p);
messageListView.Items.Insert(0, lvi);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
}
}
}