protected void btnInsert_Click1(object sender, EventArgs e) { string nom, apem, apep, tel, correo; nom = Encriptar(TxtNom.Text); apem = Encriptar(TxtApeM.Text); apep = Encriptar(TxtApeP.Text); tel = Encriptar(TxtTel.Text); correo = Encriptar(TxtCorreo.Text); try { string sql; SqlDataReader reader; SqlConnection conexion = new SqlConnection(get_connectionString()); conexion.Open(); sql = "INSERT INTO [dbo].[Alumno]([Matricula],[Nombre],[ApePaterno],[ApeMaterno],[Telefono],[Correo],[cveEstado],[cveMunicipio],[cveLocalidad]) VALUES ('" + TxtMat.Text + "','" + nom + "','" + apep + "','" + apem + "', '" + tel + "','" + correo + "'," + DDEstado.SelectedValue.ToString() + "," + DDMunicipio.SelectedValue.ToString() + "," + DDLocalidad.SelectedValue.ToString() + ")"; SqlCommand miComando = new SqlCommand(); miComando.CommandText = sql; miComando.Connection = conexion; reader = miComando.ExecuteReader(); TxtMat.Text = ""; TxtNom.Text = ""; TxtApeP.Text = ""; TxtApeM.Text = ""; TxtTel.Text = ""; TxtCorreo.Text = ""; GVAlumnosEdoMunLoc.DataBind(); } catch (Exception x) { Response.Write(x.ToString()); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { string sql; SqlDataReader reader; SqlConnection conexion = new SqlConnection(get_connectionString()); conexion.Open(); sql = "DELETE FROM [dbo].[Alumno] WHERE ([Matricula]='" + TxtMat.Text + "')"; SqlCommand miComando = new SqlCommand(); miComando.CommandText = sql; miComando.Connection = conexion; reader = miComando.ExecuteReader(); TxtMat.Text = ""; TxtNom.Text = ""; TxtApeP.Text = ""; TxtApeM.Text = ""; GVAlumnosEdoMunLoc.DataBind(); } catch (Exception x) { Response.Write(x.ToString()); } }