protected void btnUpdate_Click(object sender, EventArgs e) { EncriptarDatos(); try { string sql; SqlDataReader reader; SqlConnection conexion = new SqlConnection(get_connectionString()); conexion.Open(); sql = "UPDATE [dbo].[Directivo] SET [Nombre] = '" + TxtNom.Text + "',[ApePaterno] = '" + TxtApeP.Text + "',[ApeMaterno] = '" + TxtApeM.Text + "' ,[cveEstado] = " + DDEstado.SelectedValue.ToString() + ",[cveMunicipio] = " + DDMunicipio.SelectedValue.ToString() + ",[cveLocalidad] =" + DDLocalidad.SelectedValue.ToString() + " 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 = ""; GVDirectivoEdoMunLoc.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].[Directivo] 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 = ""; GVDirectivoEdoMunLoc.DataBind(); } catch (Exception x) { Response.Write(x.ToString()); } }