protected void btnInsert_Click(object sender, EventArgs e) { //GETTING DATA string nom, apem, apep, tele, correo; nom = Encriptar(TxtNom.Text); apem = Encriptar(TxtApeM.Text); apep = Encriptar(TxtApeP.Text); tele = Encriptar(TxtTel.Text); correo = Encriptar(TxtCorreo.Text); try { string sql; SqlDataReader reader; SqlConnection conexion = new SqlConnection(get_connectionString()); conexion.Open(); sql = "INSERT INTO [dbo].[Maestro] ([Nomina],[Nombre],[ApePaterno],[ApeMaterno],[Telefono],[Correo],[cveEstado],[cveMunicipio],[cveLocalidad]) VALUES ('" + TxtNomi.Text + "','" + nom + "','" + apep + "','" + apem + "','" + tele + "','" + correo + "'," + DDEstado.SelectedValue.ToString() + "," + DDMunicipio.SelectedValue.ToString() + "," + DDLocalidad.SelectedValue.ToString() + ")"; SqlCommand miComando = new SqlCommand(); miComando.CommandText = sql; miComando.Connection = conexion; reader = miComando.ExecuteReader(); TxtNomi.Text = ""; TxtNom.Text = ""; TxtApeP.Text = ""; TxtApeM.Text = ""; TxtTel.Text = ""; TxtCorreo.Text = ""; GVMaestrosEdoMunLoc.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].[Maestro] WHERE ([Nomina]='" + TxtNomi.Text + "')"; SqlCommand miComando = new SqlCommand(); miComando.CommandText = sql; miComando.Connection = conexion; reader = miComando.ExecuteReader(); TxtNomi.Text = ""; TxtNom.Text = ""; TxtApeP.Text = ""; TxtApeM.Text = ""; TxtTel.Text = ""; TxtCorreo.Text = ""; GVMaestrosEdoMunLoc.DataBind(); } catch (Exception x) { Response.Write(x.ToString()); } }