示例#1
0
        protected void gvDatos1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int indice = Convert.ToInt32(e.CommandArgument);
            int cant   = Convert.ToInt32(((TextBox)gvDatos1.Rows[indice].Cells[7].Controls[1]).Text);

            if (e.CommandName == "autorizar")
            {
                libMov             = new BD_ALM_Movimientos();
                libMov.StrConexion = axVarSes.Lee <string>("strConexion");
                int cantdisp = libMov.ObtenerExistenciasItem(Convert.ToInt64(gvDatos1.Rows[indice].Cells[5].Text));
                if (cant <= cantdisp)
                {
                    if (libMov.autorizarSalida(Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text), Convert.ToInt32(gvDatos1.Rows[indice].Cells[2].Text), cant))
                    {
                        pnMensajeError.Visible = false;
                        Response.Redirect("ALM_PED_Autorizar.aspx");
                    }
                    else
                    {
                        pnMensajeError.Visible = true;
                        lblMensajeError.Text   = "No se pudo aprobar el pedido Nro. " + Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text) + ". " + libMov.Mensaje;;
                        pnMensajeOK.Visible    = false;
                    }
                }
                else
                {
                    pnMensajeError.Visible = true;
                    lblMensajeError.Text   = "No se pudo aprobar el pedido Nro. " + Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text) + ". No existen suficientes existencias en almacenes.";
                    pnMensajeOK.Visible    = false;
                }
            }
            if (e.CommandName == "modificar")
            {
                ((TextBox)gvDatos1.Rows[indice].Cells[7].Controls[1]).Enabled = true;
            }
            if (e.CommandName == "rechazar")
            {
                libMov             = new BD_ALM_Movimientos();
                libMov.StrConexion = axVarSes.Lee <string>("strConexion");
                if (libMov.RechazarSalida(Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text), Convert.ToInt32(gvDatos1.Rows[indice].Cells[2].Text), Convert.ToInt32(gvDatos1.Rows[indice].Cells[6].Text)))
                {
                    pnMensajeError.Visible = false;
                    Response.Redirect("ALM_PED_Autorizar.aspx");
                }
                else
                {
                    pnMensajeError.Visible = true;
                    lblMensajeOK.Text      = "No se pudo rechazar el pedido Nro. " + Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text) + libMov.Mensaje;
                    pnMensajeOK.Visible    = false;
                }
            }
        }
        protected void gvDatos1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int indice = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "eliminar")
            {
                libMov             = new BD_ALM_Movimientos();
                libMov.StrConexion = axVarSes.Lee <string>("strConexion");
                if (libMov.RechazarSalida(Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text), Convert.ToInt32(gvDatos1.Rows[indice].Cells[2].Text), Convert.ToInt32(gvDatos1.Rows[indice].Cells[5].Text)))
                {
                    pnMensajeError.Visible = false;
                    Response.Redirect("ALM_PED_Entregar1.aspx");
                }
                else
                {
                    pnMensajeError.Visible = true;
                    lblMensajeOK.Text      = "No se pudo eliminar el pedido Nro. " + Convert.ToInt64(gvDatos1.Rows[indice].Cells[0].Text) + libMov.Mensaje;
                    pnMensajeOK.Visible    = false;
                }
            }
        }