-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsulta_clientes.cs
232 lines (194 loc) · 7.9 KB
/
consulta_clientes.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MundoMusical.XBASE;
using MundoMusical.DB;
using MundoMusical.CUSTOM_CONTROLS;
using MundoMusical.XML_SCHEMA_WRITER;
using MundoMusical.CONSULTAS.CLIENTES.CLIENTES_GENERAL;
using MundoMusical.CONSULTAS.CLIENTES.CLIENTES_VENTAS;
namespace MundoMusical.CONSULTAS.CLIENTES
{
public partial class consulta_clientes : baseConsultas
{
private dbop db;
private enum modegrid {CONSULTA_CLIENTES, CONSULTA_CLIENTES_VENTA};
private string gridmode;
private dgvtoxml_dataset schemacommit;
private frmrptclientes_general reportegeneral;
private frmrptclientes_ventas reporteclientesventas;
public consulta_clientes(consultas_central central)
{
InitializeComponent();
this.initialsets();
this.db = new dbop();
this.FormClosed += (a,b) => { central.Close(); };
}
private void initialsets()
{
this.dtpfechanacimiento.Format = DateTimePickerFormat.Short;
this.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
behaviorDefinitions.txtOnlyNumbers(ref this.txtidcliente);
behaviorDefinitions.txtOnlyNumbers(ref this.txtcp);
behaviorDefinitions.txtOnlyNumbers(ref this.txttelefono);
this.txtidcliente.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txtcp.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txtcurp.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txtnombreapellido.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txtrfc.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txttelefono.GotFocus += (sender, args) => { this.loadall(); this.cleartxt(); };
this.txtidcliente.KeyUp += (sender, args) => {
if (this.txtidcliente.Text != string.Empty) {
this.db.getclientesdgvconsultas(ref this.dgv, this.txtidcliente.Text.Trim(), "idcliente");
}
else
{
this.loadall();
}
};
this.txtnombreapellido.KeyUp += (sender, args) => {
if(this.txtnombreapellido.Text != string.Empty)
{
this.db.getclientesdgvconsultas(ref this.dgv, this.txtnombreapellido.Text, "nombreapellido");
}
else
{
this.loadall();
}
};
this.dtpfechanacimiento.ValueChanged += (sender, args) =>
{
this.db.getclientesdgvconsultas(ref this.dgv, this.dtpfechanacimiento.Text.Trim(), "fechanacimiento");
};
this.dtpfechanacimiento.KeyUp += (sender, args) =>
{
this.db.getclientesdgvconsultas(ref this.dgv, this.dtpfechanacimiento.Text.Trim(), "fechanacimiento");
};
this.txttelefono.KeyUp += (sender, args) =>
{
if(this.txttelefono.Text.Trim() == string.Empty)
{
this.loadall();
}
else
{
this.db.getclientesdgvconsultas(ref this.dgv, this.txttelefono.Text.Trim(), "telefono");
}
};
this.txtcp.KeyUp += (sender, args) =>
{
if(this.txtcp.Text.Trim() == string.Empty)
{
this.loadall();
}
else
{
this.db.getclientesdgvconsultas(ref this.dgv, this.txtcp.Text.Trim(), "codigopostal");
}
};
this.txtcurp.KeyUp += (sender, args) => {
if(this.txtcurp.Text.Trim() == string.Empty)
{
this.loadall();
}
else
{
this.db.getclientesdgvconsultas(ref this.dgv, this.txtcurp.Text.Trim(), "curp");
}
};
this.txtrfc.KeyUp += (sender, args) => {
if(this.txtrfc.Text.Trim() == string.Empty)
{
this.loadall();
}
else
{
this.db.getclientesdgvconsultas(ref this.dgv, this.txtrfc.Text.Trim(), "rfc");
}
};
}
private void showventas()
{
if(this.dgv.RowCount == 0)
{
genericDefinitions.dangerInfo("No hay clientes en tabla");
}
else
{
this.gridmode = modegrid.CONSULTA_CLIENTES_VENTA.ToString();
string[] envio = new string[this.dgv.RowCount];
for(int x = 0; x< this.dgv.RowCount; ++x)
{
envio[x] = this.dgv.Rows[x].Cells[0].Value.ToString();
}
this.db.getclientesventasdgvconsultas(ref this.dgv, envio);
}
}
private void cleartxt()
{
this.txtcp.Text = "";
this.txtcurp.Text = "";
this.txtidcliente.Text = "";
this.txtnombreapellido.Text = "";
this.txtrfc.Text = "";
this.txttelefono.Text = "";
}
private void consulta_clientes_Load(object sender, EventArgs e)
{
this.loadall();
}
private void loadall()
{
this.gridmode = modegrid.CONSULTA_CLIENTES.ToString();
this.db.getclientesdgvconsultas(ref this.dgv);
}
private void btnverventas_Click(object sender, EventArgs e)
{
this.showventas();
}
private void btnverventas2_Click(object sender, EventArgs e)
{
this.showventas();
}
private void btnprint_Click(object sender, EventArgs e)
{
this.reporting();
}
private void reporting()
{
if(this.dgv.RowCount == 0)
{
genericDefinitions.dangerInfo("No hay registros para imprimir.");
this.txtidcliente.Focus();
}
else
{
switch (this.gridmode)
{
case ("CONSULTA_CLIENTES"):
{
this.schemacommit = new dgvtoxml_dataset(this.dgv, this.Name+"_"+this.gridmode);
this.schemacommit.create();
this.reportegeneral = new frmrptclientes_general(this.schemacommit.getdatatable());
this.reportegeneral.ShowDialog();
break;
}
case ("CONSULTA_CLIENTES_VENTA"):
{
this.schemacommit = new dgvtoxml_dataset(this.dgv, this.Name + "_" + this.gridmode);
this.schemacommit.create();
this.reporteclientesventas = new frmrptclientes_ventas(this.schemacommit.getdatatable());
this.reporteclientesventas.ShowDialog();
break;
}
}
}
}
}
}