using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SistemaIAN { public partial class Usuario : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; BindData(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string WClave = GridView1.Rows[e.RowIndex].Cells[0].Text; Response.Redirect("AEscribano.aspx?Clave=2"); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; BindData(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["lorenzom_SistemaIANConnectionString"].ConnectionString); //SqlCommand cmd = new SqlCommand(); //cmd.CommandText = "UPDATE ESCRIBANOS SET APELLIDO = @APELLIDO, NOMBRES = @NOMBRES, REGISTRO = @REGISTRO, CARNET = @CARNET, " + // "EMAIL = @EMAIL, DIRECCION = @DIRECCION, LOCALIDAD = @LOCALIDAD, PROVINCIA = @PROVINCIA, TELEFONOS = @TELEFONOS, " + // "MOVIL = @MOVIL WHERE ID_ESCRIBANO=@ID_ESCRIBANO"; //cmd.Parameters.Add("@ID_ESCRIBANO", SqlDbType.Int).Value = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[0].Text); //cmd.Parameters.Add("@APELLIDO", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text; //cmd.Parameters.Add("@NOMBRES", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text; //cmd.Parameters.Add("@REGISTRO", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text; //cmd.Parameters.Add("@CARNET", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text; //cmd.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text; //cmd.Parameters.Add("@DIRECCION", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text; //cmd.Parameters.Add("@LOCALIDAD", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text; //cmd.Parameters.Add("@PROVINCIA", SqlDbType.Int).Value = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].Cells[8].Controls[0])).Text); //cmd.Parameters.Add("@TELEFONOS", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[9].Controls[0])).Text; //cmd.Parameters.Add("@MOVIL", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[10].Controls[0])).Text; //cmd.Connection = con; //con.Open(); //cmd.ExecuteNonQuery(); //con.Close(); //GridView1.EditIndex = -1; //BindData(); } private void BindData() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["lorenzom_SistemaIANConnectionString"].ConnectionString); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM ESCRIBANOS", con); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } protected void Alta_Click(object sender, EventArgs e) { Response.Redirect("AEscribano.aspx?Clave=0"); } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; string WC = row.Cells[0].Text; Response.Redirect("AEscribano.aspx?Clave=" + WC); } protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { GridViewRow row = GridView1.Rows[e.NewSelectedIndex]; } } }