Escolar Documentos
Profissional Documentos
Cultura Documentos
TABLAS
Aplicación
Solución
onselectedindexchanged="ddl_cursos_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td class="style5">
<asp:Label ID="Label11" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label2" runat="server" Text="Código
Curso" Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txt_curso"
runat="server"></asp:TextBox>
</td>
<td class="style5">
<asp:Button ID="Button3" runat="server"
onclick="Button3_Click"
Text="Guardar" Font-Bold="True" />
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label3" runat="server"
Text="Seleccione Profesor"
Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:DropDownList ID="ddl_profesor" runat="server"
AutoPostBack="True"
onselectedindexchanged="ddl_profesor_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label4" runat="server" Text="Código
Profesor" Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txt_profesor"
runat="server"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label5" runat="server" Text="Turno" Font-
Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:DropDownList ID="ddl_turno" runat="server">
<asp:ListItem>Mañana</asp:ListItem>
<asp:ListItem>Tarde</asp:ListItem>
<asp:ListItem>Noche</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label6" runat="server" Text="Horario"
Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:DropDownList ID="ddl_horario" runat="server">
<asp:ListItem>L-M-V- 08:00-10:00</asp:ListItem>
<asp:ListItem>M-J-08:00-10:00</asp:ListItem>
<asp:ListItem>L-M-V-15:00-17:00</asp:ListItem>
<asp:ListItem>M-J-15:00-17:00</asp:ListItem>
<asp:ListItem>L-M-V-18:00-20:00</asp:ListItem>
<asp:ListItem>M-J-18:00-20:00</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style3">
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label7" runat="server" Text="Seleccione
Alumno" Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:DropDownList ID="ddl_alumnos" runat="server"
Height="16px" Width="156px"
AutoPostBack="True"
onselectedindexchanged="ddl_alumnos_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label8" runat="server" Text="Código
Alumno" Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txt_codal" runat="server"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label12" runat="server" Font-Bold="True"
Text="Nombres"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txt_nomal" runat="server"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label9" runat="server" Text="Apellidos"
Font-Bold="True"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txt_apal" runat="server"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Button ID="Button1" runat="server" Text="Agregar"
onclick="Button1_Click" Font-Bold="True" />
</td>
<td class="style3">
<asp:Button ID="Button5" runat="server"
onclick="Button5_Click"
Text="Nuevo Alumno" Font-Bold="True" />
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="lbl_mensaje" runat="server"
Text="Label"></asp:Label>
</td>
<td class="style3">
</td>
<td class="style5">
</td>
</tr>
</table>
<table style="width:109%;" bgcolor="#FFFF80">
<tr>
<td>
<asp:ListBox ID="lst_codal" runat="server" Font-
Bold="True" Width="100px"></asp:ListBox>
</td>
<td class="style1" bgcolor="#FFFF80">
<asp:ListBox ID="lst_nomal" runat="server" Font-
Bold="True" Width="200px"></asp:ListBox>
</td>
<td class="style1" bgcolor="#FFFF80">
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lbl_mensaje_detalle" runat="server"
Text="Label"></asp:Label>
</td>
<td>
</td>
</tr>
</table>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/reporte_matricula.aspx">Ir al
Reporte</asp:HyperLink>
</form>
</body>
</html>
c)Código de la Clase
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace PROY_MATRICULA
{
public partial class matricula : System.Web.UI.Page
{
private string connectionString =
("server=.;database=WEBMATRICULA;uid=sa;pwd=123");
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
cargar_cursos();
cargar_profesor();
cargar_alumnos();
}
try
{
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem newItem = new ListItem();
newItem.Text = reader["nomcur"].ToString();
newItem.Value = reader["idcur"].ToString();
ddl_cursos.Items.Add(newItem);
}
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error leyendo lista de empresas.
";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
txt_curso.Text = reader["idcur"].ToString();
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error obteniendo empresa. ";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
txt_profesor.Text = reader["idprof"].ToString();
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error obteniendo empresa. ";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
try
{
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem newItem = new ListItem();
newItem.Text = reader["nomprof"].ToString();
newItem.Value = reader["idprof"].ToString();
ddl_profesor.Items.Add(newItem);
}
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error leyendo lista de empresas.
";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
try
{
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem newItem = new ListItem();
newItem.Text = reader["apal"].ToString();
newItem.Value = reader["idal"].ToString();
ddl_alumnos.Items.Add(newItem);
}
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error leyendo lista de empresas.
";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
txt_codal.Text = reader["idal"].ToString();
txt_nomal.Text = reader["nomal"].ToString();
txt_apal.Text = reader["apal"].ToString();
reader.Close();
}
catch (Exception err)
{
//lblResultado.Text = "Error obteniendo empresa. ";
//lblResultado.Text += err.Message;
}
finally
{
con.Close();
}
}
cmd.Parameters.AddWithValue("@idcur", txt_curso.Text);
cmd.Parameters.AddWithValue("@idprof", txt_profesor.Text);
cmd.Parameters.AddWithValue("@turno",
ddl_turno.SelectedValue);
cmd.Parameters.AddWithValue("@horario",
ddl_horario.SelectedValue);
int added = 0;
try
{
con.Open();
added = cmd.ExecuteNonQuery();
lbl_mensaje.Text = added.ToString() + " registro
insertado.";
}
catch (Exception err)
{
lbl_mensaje.Text = "Error insertando matricula. ";
lbl_mensaje.Text += err.Message;
}
finally
{
con.Close();
}
if (added > 0)
{
//Rellenar_Empresa();
}
int i, n;
n = lst_codal.Items.Count;
string sql_dmatricula = null;
int idmat=calcular_idmat();
txt_idmat.Text = idmat.ToString();
cmd1.Parameters.AddWithValue("@idmat", txt_idmat.Text);
cmd1.Parameters.AddWithValue("@idal", idal);
cmd1.Parameters.AddWithValue("@nomal", nomal);
int added1 = 0;
try
{
con1.Open();
added = cmd1.ExecuteNonQuery();
lbl_mensaje_detalle.Text = added.ToString() + "
registro de alumno insertado.";
}
catch (Exception err)
{
lbl_mensaje_detalle.Text = "Error insertando alumno
en dmatricula. ";
lbl_mensaje_detalle.Text += err.Message;
}
finally
{
con1.Close();
}
if (added1 > 0)
{
//Rellenar_Empresa();
}
}
}
Ejecución