-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form2.cs
452 lines (419 loc) · 19.9 KB
/
Form2.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
using MySql.Data.MySqlClient;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Proyecto_09
{
public class Form2 : Form
{
private IContainer components = null;
private Label label10;
private Label label9;
private Label label8;
private Button buttonExit;
private Label label1;
private Label label2;
private Label label3;
private TextBox textBox1;
private TextBox textBox2;
private TextBox textBox3;
private TextBox textBox5;
private MonthCalendar monthCalendar1;
private Button buttonSave;
private Label label4;
private TextBox textBox6;
private RadioButton radioButton1;
private RadioButton radioButton2;
private RadioButton radioButton3;
private RadioButton radioButton4;
public Form2()
{
this.InitializeComponent();
}
private void buttonExit_Click(object sender, EventArgs e)
{
base.Close();
}
private void buttonSave_Click(object sender, EventArgs e)
{
string nombreEquipo = this.textBox1.Text;
string marca = this.textBox2.Text;
string id = this.textBox6.Text;
string modelo = this.textBox3.Text;
string area = this.radiobutton().ToString();
string fabricante = this.textBox5.Text;
string[] str = new string[5];
int year = this.monthCalendar1.SelectionStart.Year;
str[0] = year.ToString();
str[1] = "/";
year = this.monthCalendar1.SelectionStart.Month;
str[2] = year.ToString();
str[3] = "/";
year = this.monthCalendar1.SelectionStart.Day;
str[4] = year.ToString();
string fecha = string.Concat(str);
if (this.validacionCampos())
{
string query = string.Concat(new string[] { "INSERT INTO hvequipo (id, marca, nombre_equipo, especificaciones, area, fabricante, fecha) VALUES ('", id, "', '", marca, "', '", nombreEquipo, "', '", modelo, "', '", area, "', '", fabricante, "', '", fecha, "')" });
MySqlConnection conexionDB = Conectar.Conecta();
conexionDB.Open();
try
{
(new MySqlCommand(query, conexionDB)).ExecuteNonQuery();
MessageBox.Show("La hoja de vida del equipo se agrego correctamente");
this.limpiarCampos();
}
catch (Exception exception)
{
Exception ex = exception;
MessageBox.Show(string.Concat("Error al agregar la hoja de vida del equipo: ", ex.Message));
}
conexionDB.Close();
}
}
protected override void Dispose(bool disposing)
{
if ((!disposing ? false : this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.buttonExit = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
this.buttonSave = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.textBox6 = new System.Windows.Forms.TextBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// label10
//
this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label10.Location = new System.Drawing.Point(45, 135);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(154, 16);
this.label10.TabIndex = 7;
this.label10.Text = "Modelo y Especificaciones";
//
// label9
//
this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(45, 62);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(41, 16);
this.label9.TabIndex = 6;
this.label9.Text = "Marca";
//
// label8
//
this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(45, 100);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(114, 16);
this.label8.TabIndex = 5;
this.label8.Text = "Nombre Del Equipo";
//
// buttonExit
//
this.buttonExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonExit.FlatAppearance.BorderSize = 0;
this.buttonExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonExit.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonExit.Location = new System.Drawing.Point(581, 12);
this.buttonExit.Name = "buttonExit";
this.buttonExit.Size = new System.Drawing.Size(75, 23);
this.buttonExit.TabIndex = 4;
this.buttonExit.Text = "X";
this.buttonExit.UseVisualStyleBackColor = true;
this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(45, 216);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(94, 16);
this.label1.TabIndex = 8;
this.label1.Text = "Area del Equipo";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(45, 250);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(67, 16);
this.label2.TabIndex = 9;
this.label2.Text = "Fabricante";
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(45, 292);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(125, 16);
this.label3.TabIndex = 10;
this.label3.Text = "Fecha de Adquisición";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.Location = new System.Drawing.Point(247, 97);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(224, 24);
this.textBox1.TabIndex = 11;
//
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox2.Location = new System.Drawing.Point(247, 59);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 24);
this.textBox2.TabIndex = 12;
//
// textBox3
//
this.textBox3.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox3.Location = new System.Drawing.Point(247, 132);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(224, 57);
this.textBox3.TabIndex = 13;
//
// textBox5
//
this.textBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox5.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox5.Location = new System.Drawing.Point(247, 247);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 24);
this.textBox5.TabIndex = 15;
//
// monthCalendar1
//
this.monthCalendar1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.monthCalendar1.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.monthCalendar1.Location = new System.Drawing.Point(247, 279);
this.monthCalendar1.Name = "monthCalendar1";
this.monthCalendar1.TabIndex = 16;
this.monthCalendar1.DateChanged += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateChanged);
//
// buttonSave
//
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonSave.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonSave.Location = new System.Drawing.Point(569, 418);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 17;
this.buttonSave.Text = "Guardar";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(45, 21);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(78, 16);
this.label4.TabIndex = 18;
this.label4.Text = "Identificador";
this.label4.Click += new System.EventHandler(this.label4_Click);
//
// textBox6
//
this.textBox6.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox6.Location = new System.Drawing.Point(247, 18);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(100, 24);
this.textBox6.TabIndex = 19;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton1.Location = new System.Drawing.Point(247, 216);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(108, 20);
this.radioButton1.TabIndex = 20;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Administrativo";
this.radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton2.Location = new System.Drawing.Point(358, 216);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(77, 20);
this.radioButton2.TabIndex = 21;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Industrial";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton3.Location = new System.Drawing.Point(439, 216);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(75, 20);
this.radioButton3.TabIndex = 22;
this.radioButton3.TabStop = true;
this.radioButton3.Text = "Finanzas";
this.radioButton3.UseVisualStyleBackColor = true;
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Font = new System.Drawing.Font("Neo Sans", 9.749999F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButton4.Location = new System.Drawing.Point(513, 216);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(124, 20);
this.radioButton4.TabIndex = 23;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "Servicio al Cliente";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.Visible = false;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(668, 606);
this.Controls.Add(this.radioButton4);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.label4);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.monthCalendar1);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.buttonExit);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
this.PerformLayout();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void limpiarCampos()
{
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
this.textBox5.Text = "";
this.textBox6.Text = "";
}
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
}
private int radiobutton()
{
int num;
if (this.radioButton1.Checked)
{
num = 1;
}
else if (this.radioButton2.Checked)
{
num = 2;
}
else if (!this.radioButton3.Checked)
{
num = (!this.radioButton4.Checked ? 0 : 4);
}
else
{
num = 3;
}
return num;
}
private bool validacionCampos()
{
bool flag;
if ((this.textBox1.Text == "" || this.textBox2.Text == "" || this.textBox3.Text == "" || this.textBox5.Text == "" || this.textBox6.Text == "" ? false : this.radiobutton() != 0))
{
flag = true;
}
else
{
MessageBox.Show("Debe llenar todos los campos para poder agregar la hoja de vida del equipo");
flag = false;
}
return flag;
}
}
}