Example #1
0
        void BindData(string VbConsultar)
        {
            DataTable dtbl = new DataTable();

            Cnx.BaseDatos(Session["D[BX"].ToString(), Session["$VR"].ToString(), Session["V$U@"].ToString(), Session["P@$"].ToString());
            using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
            {
                string VbTxtSql = "EXEC SP_ConfiguracionV2_ 12,'" + VbConsultar + "','','','','',0,0,0,0,'01-01-1','02-01-1','03-01-1'";

                sqlCon.Open();
                SqlDataAdapter sqlDa = new SqlDataAdapter(VbTxtSql, sqlCon);
                sqlDa.Fill(dtbl);
            }
            if (dtbl.Rows.Count > 0)
            {
                GrdDatos.DataSource = dtbl;
                GrdDatos.DataBind();
            }
            else
            {
                dtbl.Rows.Add(dtbl.NewRow());
                GrdDatos.DataSource = dtbl;
                GrdDatos.DataBind();
                GrdDatos.Rows[0].Cells.Clear();
                GrdDatos.Rows[0].Cells.Add(new TableCell());
                GrdDatos.Rows[0].Cells[0].ColumnSpan      = dtbl.Columns.Count;
                GrdDatos.Rows[0].Cells[0].Text            = "No existen registros ..!";
                GrdDatos.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
            }
        }
Example #2
0
        protected void GrdDatos_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                string vble;
                vble = (GrdDatos.Rows[e.RowIndex].FindControl("TxtPos") as TextBox).Text.Trim();
                if (vble == String.Empty)
                {
                    //ScriptManager.RegisterClientScriptBlock(this.UpPanel, UpPanel.GetType(), "IdntificadorBloqueScript", "alert('Debe ingresar una posición')", true);
                    return;
                }
                string VbPosisicones = (GrdDatos.Rows[e.RowIndex].FindControl("TxtPos") as TextBox).Text.Trim() + (GrdDatos.Rows[e.RowIndex].FindControl("TxtPosSup") as TextBox).Text.Trim() +
                                       (GrdDatos.Rows[e.RowIndex].FindControl("TxtPosMaster") as TextBox).Text.Trim();

                Cnx.BaseDatos(Session["D[BX"].ToString(), Session["$VR"].ToString(), Session["V$U@"].ToString(), Session["P@$"].ToString());
                using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
                {
                    sqlCon.Open();
                    string     query  = "EXEC SP_ConfiguracionV2_ 5,@Posiciones,@Descr,@Ruta,@NomForm,'',@Nivel,@id,0,0,'01-01-01','02-01-01','03-01-01'";
                    SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
                    sqlCmd.Parameters.AddWithValue("@Posiciones", VbPosisicones);
                    sqlCmd.Parameters.AddWithValue("@Descr", (GrdDatos.Rows[e.RowIndex].FindControl("TxtIdDescr") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Nivel", (GrdDatos.Rows[e.RowIndex].FindControl("TxtNivel") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Ruta", (GrdDatos.Rows[e.RowIndex].FindControl("TxtRuta") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@NomForm", (GrdDatos.Rows[e.RowIndex].FindControl("TxtNomForm") as TextBox).Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@id", Convert.ToInt32(GrdDatos.DataKeys[e.RowIndex].Value.ToString()));
                    sqlCmd.ExecuteNonQuery();
                    GrdDatos.EditIndex = -1;
                    BindData(TxtBusqueda.Text);
                }
            }
            catch (Exception ex)
            {
                ClsConexion ClsUE = new ClsConexion();
                ClsUE.UpdateError(Session["C77U"].ToString(), "FrmMenu", "Update", "0", ex.Message, Session["77Version"].ToString(), Session["77Act"].ToString());
            }
        }
Example #3
0
 protected void GrdPerfilAsig_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     if ((int)Session["IdGrupoRP"] != 0)
     {
         Cnx.BaseDatos(Session["D[BX"].ToString(), Session["$VR"].ToString(), Session["V$U@"].ToString(), Session["P@$"].ToString());
         using (SqlConnection sqlCon = new SqlConnection(Cnx.GetConex()))
         {
             sqlCon.Open();
             string     query  = "DELETE FROM TblUsrPerfiles WHERE CodidUsrPerfil = @ID";
             SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
             sqlCmd.Parameters.AddWithValue("@ID", Convert.ToInt32(GrdPerfilAsig.DataKeys[e.RowIndex].Value.ToString()));
             sqlCmd.ExecuteNonQuery();
             ActivarControles();
             BindData(TxtBusqueda.Text, TxtBusqUsu.Text, "UPD");
         }
     }
 }