示例#1
0
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            this.pnlNuevo.Visible = true;

            int idGrupoVal = int.Parse(this.GridView1.Rows[e.NewEditIndex].Cells[0].Text);

            Session["idGrupoValidacion"] = idGrupoVal;
            this.lstBoxSelectedProv.DataBind();

            int[] idValidaciones = new PNegocio.Administrador.ValidacionXML().getValFactByIdGrpVal(idGrupoVal);

            string nombre = HttpUtility.HtmlDecode(this.GridView1.Rows[e.NewEditIndex].Cells[1].Text);

            this.txtNombreGrupo.Text = nombre.Trim();

            this.chbListValidaciones.DataBind();
            foreach (ListItem item in this.chbListValidaciones.Items)
            {
                for (int i = 0; i < idValidaciones.Length; i++)
                {
                    if (int.Parse(item.Value) == idValidaciones[i])
                    {
                        item.Selected = true;
                    }
                }
            }
            e.Cancel = true;
            this.btnEliminar.Visible = true;
        }
示例#2
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            List <int> idValidaciones = new List <int>();

            foreach (ListItem validacion in this.chbListValidaciones.Items)
            {
                if (validacion.Selected)
                {
                    idValidaciones.Add(int.Parse(validacion.Value));
                }
            }

            List <int> idProveedores = new List <int>();

            foreach (ListItem proveedor in this.lstBoxSelectedProv.Items)
            {
                idProveedores.Add(int.Parse(proveedor.Value));
            }

            int idGrupoValidacion = 0;

            if (Session["idGrupoValidacion"] != null)
            { //Cuando si tiene un numero, entonces la operación va a hacer para guardar cambios
                idGrupoValidacion = int.Parse(Session["idGrupoValidacion"].ToString());
            }

            string mensajeJS = "";

            if (idValidaciones.Count != 0)
            {
                if (this.txtNombreGrupo.Text.Trim().Length != 0)
                {
                    if (idProveedores.Count != 0)
                    {
                        string res = new PNegocio.Administrador.ValidacionXML().guardarNuevoGrupoValidacion(idGrupoValidacion, this.txtNombreGrupo.Text, idValidaciones, idProveedores, int.Parse(Session["idPants"].ToString()));
                        if (res == "correcto")
                        {
                            this.GridView1.DataBind();
                            this.GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
                            this.pnlNuevo.Visible = false;
                            Session.Remove("idGrupoValidacion");

                            mensajeJS = "Proceso realizado satisfactoriamente";
                        }
                        else
                        {
                            mensajeJS = "Error. Error al intentar guardar el grupo de validación.";
                        }
                    }
                    else
                    {
                        mensajeJS = "Advertencia. Debe de seleccionar proveedores para agregar al grupo de validación";
                    }
                }
                else
                {
                    mensajeJS = "Advertencia. Debe de escribir el nombre para el grupo de validación";
                }
            }
            else
            {
                mensajeJS = "Elija alguna validación para este grupo";
            }
            if (mensajeJS.Length != 0)
            {
                this.lblDialog.Text = mensajeJS;
                //Session["textoDialogo"] = mensajeJS;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "mostrarDialog()", true);
                //string script = @"<script type='text/javascript'>alert('" + mensajeJS + "');</script>";
                //ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
            }
            if (this.GridView1.Rows.Count != 0)
            {
                this.lblSinRegistros.Visible = false;
            }
        }