示例#1
0
        protected void btnRealizarDevolucion_Click(object sender, EventArgs e)
        {
            cSGPRDEVOLUCIONNegocios devolucion = new cSGPRDEVOLUCIONNegocios(Global.gCOD_APLICACION, "CA", 0, "0");
            devolucion.FEC_DEVOLUCION = DateTime.Now;
            Label lblIdentifiacion = (Label)_prestamoElegido.FindControl("lblIdentificacion");
            devolucion.CAR_USUARIOGIMNASIO = lblIdentifiacion.Text;

            Char[] delimiter = { '_' };
            string idPanel = _prestamoElegido.ID;
            string idPrestamo = idPanel.Split(delimiter)[1];

            devolucion.FK_IDPRESTAMO = int.Parse(idPrestamo);

            if (!ComprobarDevolucionValida(devolucion))
            {
                if (!Page.ClientScript.IsStartupScriptRegistered("DevolucionInvalida"))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "DevolucionInvalida",
                        "<script type=\"text/javascript\"> alert('Debe ingresar alguna cantidad a devolver para al menos uno de los implementos.'); </script>");
                }
                return;
            }

            devolucion.Insertar();

            AgregarImplementosDevueltos(devolucion);

            WrapperDetalle.Controls.Clear();
            _prestamoElegido = null;

            cSGPRIMPLEMENTOPORPRESTAMONegocios implementosTemp = new cSGPRIMPLEMENTOPORPRESTAMONegocios(Global.gCOD_APLICACION, "CA", 0, "0");
            implementosTemp.FK_IDPRESTAMO = int.Parse(idPrestamo);
            DataTable tablaImplementos = implementosTemp.SeleccionarTodos_Con_FK_IDPRESTAMO_FK();
            if (tablaImplementos.Rows.Count == 0)
            {
                cSGPRPRESTAMONegocios prestamos = new cSGPRPRESTAMONegocios(Global.gCOD_APLICACION, "CA", 0, "0");
                prestamos.ID_PRESTAMO = int.Parse(idPrestamo);
                prestamos.ESTADO = true;
                prestamos.Actualizar();
            }

            if (!Page.ClientScript.IsStartupScriptRegistered("DevolucionSatisfactoria"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "DevolucionSatisfactoria",
                    "<script type=\"text/javascript\"> __doPostBack(); alert('La devolución se realizó satisfactoriamente.'); </script>");
            }
        }