/
Proveedores.cs
282 lines (249 loc) · 12.1 KB
/
Proveedores.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Promowork
{
public partial class Proveedores : Form
{
public Proveedores()
{
InitializeComponent();
}
private void proveedoresBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
if ((dNINIFProveedorTextBox.Text.Trim().Length == 0 || desProveedorTextBox.Text.Trim().Length == 0) && proveedoresDataGridView.RowCount != 0)
{
MessageBox.Show("El DNI/NIF y la Descripción no pueden estar vacios.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
else
{
try
{
this.Validate();
this.proveedoresBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.promowork_dataDataSet);
}
catch (DBConcurrencyException)
{
MessageBox.Show("No se Pudo Salvar la Información. El Registro fue modificado por otro Usuario.", "Error");
this.proveedoresTableAdapter.Fill(promowork_dataDataSet.Proveedores, VariablesGlobales.nIdEmpresaActual);
}
catch (SqlException ex)
{
if (ErroresSQLServer.ManipulaErrorSQL(ex, this.Text))
{
this.proveedoresTableAdapter.Fill(promowork_dataDataSet.Proveedores, VariablesGlobales.nIdEmpresaActual);
}
}
}
}
private void Proveedores_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'promowork_dataDataSet.CuentasBancos' table. You can move, or remove it, as needed.
this.cuentasBancosTableAdapter.Fill(this.promowork_dataDataSet.CuentasBancos, VariablesGlobales.nIdEmpresaActual);
cuentasBancosBindingSource.Filter = "CtaEmpresa=true";
// TODO: This line of code loads data into the 'promowork_dataDataSet.Provincias1' table. You can move, or remove it, as needed.
this.provincias1TableAdapter.Fill(this.promowork_dataDataSet.Provincias1);
// TODO: This line of code loads data into the 'promowork_dataDataSet.Poblaciones1' table. You can move, or remove it, as needed.
this.poblaciones1TableAdapter.Fill(this.promowork_dataDataSet.Poblaciones1);
// TODO: This line of code loads data into the 'promowork_dataDataSet.Poblaciones' table. You can move, or remove it, as needed.
this.poblacionesTableAdapter.Fill(this.promowork_dataDataSet.Poblaciones);
// TODO: This line of code loads data into the 'promowork_dataDataSet.Provincias' table. You can move, or remove it, as needed.
this.provinciasTableAdapter.Fill(this.promowork_dataDataSet.Provincias);
// TODO: This line of code loads data into the 'promowork_dataDataSet.FormasPago' table. You can move, or remove it, as needed.
this.formasPagoTableAdapter.Fill(this.promowork_dataDataSet.FormasPago);
// TODO: This line of code loads data into the 'promowork_dataDataSet.Participantes' table. You can move, or remove it, as needed.
this.participantesTableAdapter.Fill(this.promowork_dataDataSet.Participantes);
// TODO: This line of code loads data into the 'promowork_dataDataSet.ComprasCab' table. You can move, or remove it, as needed.
this.empresasActualTableAdapter.FillByEmpresa(promowork_dataDataSet.EmpresasActual, VariablesGlobales.nIdEmpresaActual);
this.proveedoresTableAdapter.Fill(promowork_dataDataSet.Proveedores, VariablesGlobales.nIdEmpresaActual);
}
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
toolStripTextBox1.Text = "";
proveedoresBindingSource.Filter = null;
proveedoresBindingSource.MoveLast();
proveedoresDataGridView.CurrentRow.Cells["IdEmpresa"].Value = VariablesGlobales.nIdEmpresaActual;
activoProveedorCheckBox.CheckState = CheckState.Checked;
if (Convert.IsDBNull(promowork_dataDataSet.Tables["EmpresasActual"].Rows[0]["ProvEmpresa"]))
{
numProveedorTextBox.Text = "1";
promowork_dataDataSet.Tables["EmpresasActual"].Rows[0]["ProvEmpresa"] = 1;
}
else
{
numProveedorTextBox.Text = Convert.ToString(promowork_dataDataSet.Tables["EmpresasActual"].Rows[0]["ProvEmpresa"]);
promowork_dataDataSet.Tables["EmpresasActual"].Rows[0]["ProvEmpresa"] = Convert.ToInt32(promowork_dataDataSet.Tables["EmpresasActual"].Rows[0]["ProvEmpresa"]) + 1;
}
this.Validate();
this.empresasActualBindingSource.EndEdit();
empresasActualTableAdapter.Update(promowork_dataDataSet.EmpresasActual);
numProveedorTextBox.Focus();
}
private void button1_Click(object sender, EventArgs e)
{
TiposProveedores frm = new TiposProveedores();
frm.ShowDialog();
this.participantesTableAdapter.Fill(this.promowork_dataDataSet.Participantes);
}
private void button2_Click(object sender, EventArgs e)
{
FormasPago frm = new FormasPago();
frm.ShowDialog();
this.formasPagoTableAdapter.Fill(this.promowork_dataDataSet.FormasPago);
}
private void button3_Click(object sender, EventArgs e)
{
Poblaciones frm = new Poblaciones();
frm.ShowDialog();
provinciasTableAdapter.Fill(promowork_dataDataSet.Provincias);
poblacionesTableAdapter.Fill(promowork_dataDataSet.Poblaciones);
proveedoresDataGridView_CellEnter(null, null);
}
private void button4_Click(object sender, EventArgs e)
{
Poblaciones frm = new Poblaciones();
frm.ShowDialog();
provincias1TableAdapter.Fill(promowork_dataDataSet.Provincias1);
poblaciones1TableAdapter.Fill(promowork_dataDataSet.Poblaciones1);
proveedoresDataGridView_CellEnter(null, null);
}
private void proveedoresDataGridView_CellEnter(object sender, DataGridViewCellEventArgs e)
{
DataRowView RowActual = (DataRowView)proveedoresBindingSource.Current;
object nIdPoblacion = RowActual["IdPoblacion"];
if (!Convert.IsDBNull(nIdPoblacion))
{
DataRow FilaSel = promowork_dataDataSet.Poblaciones.FindByIdPoblacion(Convert.ToInt32(nIdPoblacion));
int nIdProvincia = Convert.ToInt32(FilaSel["IdProvincia"]);
if (Convert.ToInt32(comboBox1.SelectedValue) != nIdProvincia)
{
comboBox1.SelectedValue = nIdProvincia;
this.poblacionesProvinciasTableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias, nIdProvincia);
}
comboBox2.SelectedValue = Convert.ToInt32(nIdPoblacion);
}
else
{
textBox1.Text = "";
comboBox1.SelectedValue = -1;
}
// ///////////////////////////
object nIdPobFiscal = RowActual["IdPobFiscal"];
if (!Convert.IsDBNull(nIdPobFiscal))
{
DataRow FilaSel = promowork_dataDataSet.Poblaciones1.FindByIdPoblacion(Convert.ToInt32(nIdPobFiscal));
int nIdProvincia = Convert.ToInt32(FilaSel["IdProvincia"]);
if (Convert.ToInt32(comboBox4.SelectedValue) != nIdProvincia)
{
comboBox4.SelectedValue = nIdProvincia;
this.poblacionesProvincias1TableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias1, nIdProvincia);
}
comboBox3.SelectedValue = Convert.ToInt32(nIdPobFiscal);
}
else
{
textBox2.Text = "";
comboBox4.SelectedValue = -1;
}
}
private void textBox1_Validated(object sender, EventArgs e)
{
if (textBox1.Text.Length != 0)
{
DataRow[] FilaSel;
FilaSel = promowork_dataDataSet.Tables["Poblaciones"].Select("postal= " + textBox1.Text);
if (FilaSel.Count() != 0)
{
int nIdProvincia = Convert.ToInt32(FilaSel[0]["IdProvincia"]);
int nIdPoblacion = Convert.ToInt32(FilaSel[0]["IdPoblacion"]);
comboBox1.SelectedValue = nIdProvincia;
this.poblacionesProvinciasTableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias, nIdProvincia);
comboBox2.SelectedValue = nIdPoblacion;
dirFiscalClienteTextBox.Focus();
}
else
{
textBox1.Text = "";
comboBox1.SelectedValue = -1;
comboBox2.SelectedValue = -1;
}
}
}
private void textBox2_Validated(object sender, EventArgs e)
{
if (textBox2.Text.Length != 0)
{
DataRow[] FilaSel;
FilaSel = promowork_dataDataSet.Tables["Poblaciones1"].Select("postal= " + textBox2.Text);
if (FilaSel.Count() != 0)
{
int nIdProvincia = Convert.ToInt32(FilaSel[0]["IdProvincia"]);
int nIdPoblacion = Convert.ToInt32(FilaSel[0]["IdPoblacion"]);
comboBox4.SelectedValue = nIdProvincia;
this.poblacionesProvincias1TableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias1, nIdProvincia);
comboBox3.SelectedValue = nIdPoblacion;
telProveedorTextBox.Focus();
}
else
{
textBox2.Text = "";
comboBox4.SelectedValue = -1;
comboBox3.SelectedValue = -1;
}
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
this.poblacionesProvinciasTableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias, Convert.ToInt32(comboBox1.SelectedValue));
}
catch
{
}
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
this.poblacionesProvincias1TableAdapter.FillByProvincia(promowork_dataDataSet.PoblacionesProvincias1, Convert.ToInt32(comboBox4.SelectedValue));
}
catch
{
}
}
private void button5_Click(object sender, EventArgs e)
{
BancosCuentas frm = new BancosCuentas();
frm.ShowDialog();
this.cuentasBancosTableAdapter.Fill(this.promowork_dataDataSet.CuentasBancos, VariablesGlobales.nIdEmpresaActual);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
toolStripTextBox1.Text = "";
proveedoresBindingSource.Filter = null;
}
private void toolStripTextBox1_KeyUp(object sender, KeyEventArgs e)
{
proveedoresBindingSource.Filter = "DesProveedor like '%" + toolStripTextBox1.Text + "%'";
}
internal void LoadFiltro(int nIdProveedor)
{
proveedoresBindingSource.Filter = "IdProveedor="+Convert.ToString(nIdProveedor);
}
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Confirma que desea Eliminar?.", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.proveedoresBindingSource.RemoveCurrent();
}
}
}
}