-
Notifications
You must be signed in to change notification settings - Fork 0
/
Contact.aspx.cs
153 lines (130 loc) · 4.54 KB
/
Contact.aspx.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Contact : Page
{
public DatoPersona datos = new DatoPersona();
protected void Page_Load(object sender, EventArgs e)
{
//MultiView1.ActiveViewIndex = 0;
GridView1.DataBind();
actualizarListas();
actualizarTextBox();
}
protected void MultiView1_ActiveViewChanged(object sender, EventArgs e)
{
if (MultiView1.ActiveViewIndex == 0)
{
txt_apellido.Enabled = true;
txt_nombre.Enabled = true;
txt_dni.Enabled = true;
txt_fecha.Enabled = true;
}
else if (MultiView1.ActiveViewIndex == 1)
{
txt_apellido.Enabled = true;
txt_nombre.Enabled = true;
txt_dni.Enabled = true;
txt_fecha.Enabled = true;
}
else if (MultiView1.ActiveViewIndex == 2)
{
txt_apellido.Enabled = false;
txt_nombre.Enabled = false;
txt_dni.Enabled = false;
txt_fecha.Enabled = false;
}
actualizarListas();
}
protected void actualizarListas()
{
DropDownList1.Items.Clear();
DropDownList2.Items.Clear();
datos.actualizar_tabla();
foreach (Row_Persona nodo in datos.tabla)
{
DropDownList1.Items.Add(nodo.id.ToString());
DropDownList2.Items.Add(nodo.id.ToString());
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
Row_Persona nodoAux = new Row_Persona();
nodoAux.apellido = txt_apellido.Text;
nodoAux.nombre = txt_nombre.Text;
nodoAux.dni = Convert.ToInt32(txt_dni.Text);
string dateAux2 = String.Format("{0: yyyy-MM-dd}", txt_fecha.Text);
// DateTime dateAux3 = Convert.ToDateTime(String.Format("{0:yyyy-mm-dd }", txt_fecha.Text));
// nodoAux.fecha = DateTime.ParseExact(dateAux2, "yyyy-MM-dd", null); ;
nodoAux.fecha = dateAux2;
datos.insertar_tabla(nodoAux);
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
Row_Persona nodoAux = new Row_Persona();
nodoAux.apellido = txt_apellido.Text;
nodoAux.nombre = txt_nombre.Text;
nodoAux.dni = Convert.ToInt32(txt_dni.Text);
nodoAux.fecha = String.Format("{0: yyyy-MM-dd}", txt_fecha.Text); //Convert.ToDateTime(String.Format("{0: yyyy-MM-dd}", txt_fecha.Text) ); // Convert.ToDateTime(String.Format("{0:d/M/yyyy HH:mm:ss}", txt_fecha.Text) );
nodoAux.id = Convert.ToInt32(DropDownList1.SelectedItem.Value);
datos.update_tabla(nodoAux);
GridView1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{
Row_Persona nodoAux = new Row_Persona();
nodoAux.id = Convert.ToInt32(DropDownList2.SelectedItem.Value);
datos.eliminar_tabla(nodoAux);
GridView1.DataBind();
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.Items[0].Selected == true)
{
MultiView1.ActiveViewIndex = 0;
}
else if (RadioButtonList1.Items[1].Selected == true)
{
MultiView1.ActiveViewIndex = 1;
}
else if (RadioButtonList1.Items[2].Selected == true)
{
MultiView1.ActiveViewIndex = 2;
}
GridView1.DataBind();
}
protected void actualizarTextBox()
{
if (RadioButtonList1.Items[0].Selected == true)
{
}
else if (RadioButtonList1.Items[1].Selected == true)
{
Row_Persona row = (Row_Persona)datos.tabla[DropDownList1.SelectedIndex];
txt_apellido.Text = row.apellido;
txt_nombre.Text = row.nombre;
txt_dni.Text = row.dni.ToString();
txt_fecha.Text = row.fecha;
}
else if (RadioButtonList1.Items[2].Selected == true)
{
Row_Persona row = (Row_Persona)datos.tabla[DropDownList2.SelectedIndex];
txt_apellido.Text = row.apellido;
txt_nombre.Text = row.nombre;
txt_dni.Text = row.dni.ToString();
txt_fecha.Text = row.fecha;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
actualizarTextBox();
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
actualizarTextBox();
}
}