protected void BtnBuscar_Click(object sender, EventArgs e) { DataTable DtBuscar; string consultaRegistros = "ObtenerRegistros"; int TipoUsuario = Convert.ToInt32(Session["TipoUsuario"]); string NonbreAsesor = Convert.ToString(Session["Nombres"]); if (TipoUsuario != 3) { NonbreAsesor = "0"; } using (SqlConnection connex = new SqlConnection(strConnection)) { SqlCommand comm = new SqlCommand(consultaRegistros, connex); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@Backoffice", SqlDbType.VarChar); comm.Parameters.Add("@OBJECT_ID", SqlDbType.VarChar); comm.Parameters.Add("@Proyeccion", SqlDbType.VarChar); comm.Parameters["@Backoffice"].Value = DropBuscarBackoffice.SelectedValue == "(Seleccionar)" ? NonbreAsesor : DropBuscarBackoffice.SelectedValue.Trim(); comm.Parameters["@OBJECT_ID"].Value = TxtOrdenDeServicio.Text == "" ? "0" : TxtOrdenDeServicio.Text; comm.Parameters["@Proyeccion"].Value = DropProyeccion.SelectedValue == "(Seleccionar)" ? "0" : DropProyeccion.SelectedValue.Trim(); SqlDataAdapter adapter = new SqlDataAdapter(comm); connex.Open(); comm.ExecuteNonQuery(); DtBuscar = new DataTable(); adapter.Fill(DtBuscar); DataInforme.DataSource = DtBuscar; DataInforme.DataBind(); } }
public void ObetnerOrdenes() { int TipoUsuario = Convert.ToInt32(Session["TipoUsuario"]); string NonbreAsesor = Convert.ToString(Session["Nombres"]); if (TipoUsuario != 3) { NonbreAsesor = "0"; } DataTable DataMarshal; using (SqlCommand CmdObtenerOrdenes = new SqlCommand("ObtenerOrdenes")) { using (SqlConnection connex = new SqlConnection(strConnection)) { CmdObtenerOrdenes.Connection = connex; CmdObtenerOrdenes.CommandType = CommandType.StoredProcedure; CmdObtenerOrdenes.Parameters.AddWithValue("@NombreAsesor", NonbreAsesor); SqlDataAdapter adapter = new SqlDataAdapter(CmdObtenerOrdenes); connex.Open(); CmdObtenerOrdenes.ExecuteNonQuery(); DataMarshal = new DataTable(); adapter.Fill(DataMarshal); DataInforme.DataSource = DataMarshal; DataInforme.DataBind(); } } }
protected void BtnGuardar_Click(object sender, EventArgs e) { try { DataTable DtDatos; string consultaPersona = "GardarComentario"; using (SqlConnection connex = new SqlConnection(strConnection)) { SqlCommand comm = new SqlCommand(consultaPersona, connex); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@IdComentario", SqlDbType.VarChar); comm.Parameters.Add("@Responsable", SqlDbType.VarChar); comm.Parameters.Add("@DatalleResponsable", SqlDbType.VarChar); comm.Parameters.Add("@Depatamento", SqlDbType.VarChar); comm.Parameters.Add("@Ciudad", SqlDbType.VarChar); comm.Parameters.Add("@Comentario", SqlDbType.VarChar); comm.Parameters.Add("@Localidad", SqlDbType.VarChar); comm.Parameters.Add("@Barrio", SqlDbType.VarChar); comm.Parameters.Add("@Direccion", SqlDbType.VarChar); comm.Parameters["@IdComentario"].Value = LabNumeroOrden.Text; comm.Parameters["@Responsable"].Value = DropResponsable.SelectedItem.ToString(); comm.Parameters["@DatalleResponsable"].Value = DropDetalleResponsable.SelectedItem.ToString(); comm.Parameters["@Depatamento"].Value = DropDepartamento.SelectedItem.ToString(); comm.Parameters["@Ciudad"].Value = DropCiudad.SelectedItem.ToString(); comm.Parameters["@Comentario"].Value = TxtComentario.Text == "" ? "Sin Comentario" : TxtComentario.Text; comm.Parameters["@Localidad"].Value = TxtLocalidad.Text; comm.Parameters["@Barrio"].Value = TxtBarrio.Text; comm.Parameters["@Direccion"].Value = TxtDireccion.Text; SqlDataAdapter adapter = new SqlDataAdapter(comm); connex.Open(); comm.ExecuteNonQuery(); DtDatos = new DataTable(); adapter.Fill(DtDatos); DataInforme.DataSource = DtDatos; DataInforme.DataBind(); } //ObetnerOrdenes(); Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "showContent('success','Actualización guardada exitosamente.');", true); LabNumeroOrden.Text = ""; TxtComentario.Text = ""; TxtLocalidad.Text = ""; TxtBarrio.Text = ""; TxtDireccion.Text = ""; } catch (Exception ex) { // throw ex; Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "showContent('error','" + ex.Message + "');", true); } }
//Paginador protected void DataInforme_PageIndexChanging(object sender, GridViewPageEventArgs e) { DataInforme.PageIndex = e.NewPageIndex; DataInforme.DataBind(); }