-
Notifications
You must be signed in to change notification settings - Fork 1
/
printcbGui.cs
176 lines (148 loc) · 5.07 KB
/
printcbGui.cs
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using MundoMusical.CONFIGURACION_DE_IMPRESION;
using MundoMusical.CUSTOM_CONTROLS;
using MundoMusical.DB;
using MundoMusical.PRODUCT;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MundoMusical.LABELS
{
public partial class printcbGui : BaseForm
{
private dbop db;
private Thread thprint;
private printCbar xprint;
private List<int> codigos;
private seeproductsinternal buscaProducto;
public printcbGui()
{
InitializeComponent();
this.db = new dbop();
this.xprint = new printCbar();
this.myload();
}
public printcbGui(Central2 central)
{
InitializeComponent();
this.db = new dbop();
this.xprint = new printCbar();
this.myload();
this.FormClosed += (sender, args) => { central.etiquetas = null; };
}
private void printcbGui_Load(object sender, EventArgs e)
{
this.ActiveControl = this.txtcodigo;
}
private void rbtodas_CheckedChanged(object sender, EventArgs e)
{
if (this.rbtodas.Checked)
{
this.rbindividual.Checked = false;
}
}
private void rbindividual_CheckedChanged(object sender, EventArgs e)
{
if (this.rbindividual.Checked)
{
this.rbtodas.Checked = false;
}
}
private void loadCodigos()
{
this.codigos = this.db.getallProductId();
}
private void myload()
{
behaviorDefinitions.txtOnlyNumbers(ref this.txtcodigo);
this.txttotalprods.Text = this.db.getProductosCount().ToString() + " Codigos";
this.loadCodigos();
}
private void printSelected()
{
if (this.rbindividual.Checked || this.rbtodas.Checked)
{
this.thprint = new Thread(new ThreadStart(this.print)) { IsBackground = true };
this.thprint.Start();
}
else
{
genericDefinitions.dangerInfo("Seleccione una opcion!");
}
}
private void print()
{
this.Invoke(new MethodInvoker(delegate ()
{
int copies =(int) this.nup.Value;
if (this.rbindividual.Checked)
{
if (this.db.existproduct(int.Parse(this.txtcodigo.Text.Trim())))
{
this.xprint.setParams(int.Parse(this.txtcodigo.Text.Trim()));
this.xprint.print(copies);
}
else
{
genericDefinitions.error("Id producto Invalido!");
this.txtcodigo.Focus();
}
}
else if (this.rbtodas.Checked)
{
foreach (int obj in this.codigos)
{
this.xprint.setParams(obj);
this.xprint.print(copies);
}
}
this.nup.Value = 1;
this.txtcodigo.Text = "";
}));
}
private void baccept_Click(object sender, EventArgs e)
{
if (this.rbindividual.Checked && this.txtcodigo.Text.Trim() == "")
{
genericDefinitions.dangerInfo("Ingrese Un Codigo de Producto a Imprimir.");
this.txtcodigo.Focus();
return;
}
if (this.rbtodas.Checked)
{
this.loadCodigos();
if (genericDefinitions.yesno("¿Confirma la Impresion de " + (this.codigos.Count * this.nup.Value).ToString() + " Etiquetas?", "Security Process"))
{
if (!printerControl.printIsSafe(this.db.getprinteretiquetaname()))
{
using (printWarning pw = new printWarning())
{
pw.ShowDialog();
}
return;
}
}
else
{
return;
}
}
this.printSelected();
}
private void btncat_Click(object sender, EventArgs e)
{
this.myload();
}
private void btnBuscaproducto_Click(object sender, EventArgs e)
{
this.buscaProducto = new seeproductsinternal(this);
this.buscaProducto.ShowDialog();
}
}
}