예제 #1
0
    protected void gvNotificaciones_SelectedIndexChanged(object sender, EventArgs e)
    {
        string strScript = "";

        Class.Notificaciones objNotificacion = new Class.Notificaciones();
        int intNumeroNotificaciones          = 0;

        try
        {
            // Marco la notificacion como leida:
            objNotificacion.IdNotificacion = Convert.ToInt32(this.gvNotificaciones.SelectedRow.Cells[0].Text);
            objNotificacion.IdUsuario      = Convert.ToInt32(Session["userIDInj"].ToString());
            objNotificacion.AltaNotificacionLeida();
            if (objNotificacion.ErrorNumber != 0)
            {
                strScript = "Error Notificaciones!AltaNotificacionLeida:\\n" + objNotificacion.ErrorMessage.Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
                return;
            }

            // Abro el popup de la notificación seleccionada:
            this.pnlMasterPopupNot.Visible = true;
            MPE.Show();
            //this.txtDepartamento.Text = this.gvNotificaciones.SelectedRow.Cells[2].Text.Replace(" ", "");
            //this.txtRol.Text = this.gvNotificaciones.SelectedRow.Cells[3].Text.Replace(" ", "");
            //this.txtUsuario.Text = this.gvNotificaciones.SelectedRow.Cells[4].Text.Replace(" ", "");
            //this.txtEsParaTodos.Text = this.gvNotificaciones.SelectedRow.Cells[5].Text.Replace(" ", "");
            this.txtMensaje.InnerHtml = this.gvNotificaciones.SelectedRow.Cells[6].Text.Replace(" ", "");

            // Actualizo el dataset:
            this.dstNotificaciones.DataBind();
            this.gvNotificaciones.DataBind();

            // Actualizo el contador de notificaciones:
            objNotificacion.IdUsuario        = Convert.ToInt32(Session["idUsuario"].ToString());
            intNumeroNotificaciones          = objNotificacion.ObtenerNumeroDeNotifcaciones();
            Session["NumeroNotificaciones"]  = intNumeroNotificaciones.ToString();
            this.lblCountNotificaciones.Text = intNumeroNotificaciones.ToString();
        }
        catch (Exception ex)
        {
            strScript = "Error: " + ex.Message.ToString().Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
        }
        finally
        {
            if (strScript != "")
            {
                strScript = "<script language='javascript'> alert('" + strScript + "');</script>";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "Error", strScript, false);
            }
        }
    }
예제 #2
0
    protected void btnNotificaciones_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        Class.Notificaciones objNotificacion = new Class.Notificaciones();
        string strScript = "";
        int    intNumeroNotificaciones = 0;

        this.pnlMasterPopupNot.Visible = false;
        try

        {
            this.pnlMasterPopupNot.Visible = false;
            if (this.pnlNotificaciones.Visible == true)
            {
                this.pnlNotificaciones.Visible = false;
            }
            else
            {
                this.pnlNotificaciones.Visible      = true;
                Session["NotificacionesPorMostrar"] = System.Configuration.ConfigurationManager.AppSettings["NotificacionesPorMostrar"].ToString();
                this.dstNotificaciones.DataBind();
                this.gvNotificaciones.DataBind();
            }
            objNotificacion.IdUsuario        = Convert.ToInt32(Session["idUsuario"].ToString());
            intNumeroNotificaciones          = objNotificacion.ObtenerNumeroDeNotifcaciones();
            Session["NumeroNotificaciones"]  = intNumeroNotificaciones.ToString();
            this.lblCountNotificaciones.Text = intNumeroNotificaciones.ToString();
        }
        catch (Exception ex)
        {
            strScript = "Error: " + ex.Message.ToString().Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
        }
        finally
        {
            objNotificacion = null;
            if (strScript != "")
            {
                strScript = "<script language='javascript'> alert('" + strScript + "');</script>";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "Error", strScript, false);
            }
        }
    }
    protected void btnEnviarNotificacion_Click(object sender, EventArgs e)
    {
        string strScript = "";

        Class.Notificaciones objNotificacion = new Class.Notificaciones();

        try
        {
            if (this.txtMensajeEdit.Text.Trim() == "")
            {
                if (this.hidEsEnEspanol.Value == "true")
                {
                    strScript = "No hay ningun mensaje para enviar";
                }
                else
                {
                    strScript = "There is no message to send";
                }
                return;
            }

            if (this.ddlDepartamento.SelectedItem.Text == "" && this.ddlRol.SelectedItem.Text == "" && this.ddlUser.SelectedItem.Text == "" && this.ddlEsParaTodos.SelectedItem.Text.ToUpper() == "NO")
            {
                if (this.hidEsEnEspanol.Value == "true")
                {
                    strScript = "No hay ningun destinatario seleccionado";
                }
                else
                {
                    strScript = "No selected recipients";
                }
                return;
            }



            if (this.ddlDepartamento.SelectedItem.Text != "")
            {
                objNotificacion.IdDepartamento = Convert.ToInt32(this.ddlDepartamento.SelectedItem.Value);
            }
            if (this.ddlRol.SelectedItem.Text != "")
            {
                objNotificacion.IdRol = Convert.ToInt32(this.ddlRol.SelectedItem.Value);
            }
            if (this.ddlUser.SelectedItem.Text != "")
            {
                objNotificacion.IdUsuario = Convert.ToInt32(this.ddlUser.SelectedItem.Value);
            }
            if (this.ddlEsParaTodos.SelectedItem.Text.ToUpper() == "NO")
            {
                objNotificacion.EsParaTodos = false;
            }
            else
            {
                objNotificacion.EsParaTodos = true;
            }

            objNotificacion.Mensaje = this.txtMensajeEdit.Text;
            objNotificacion.Mantenimiento(1);
            if (objNotificacion.ErrorNumber != 0)
            {
                if (this.hidEsEnEspanol.Value == "true")
                {
                    strScript = "Error Notificaciones!AltaNotificacionLeida:\\n" + objNotificacion.ErrorMessage.Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
                }
                else
                {
                    strScript = "Error Notificaciones!AltaNotificacionLeida:\\n" + objNotificacion.ErrorMessage.Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
                }
                return;
            }
            else
            {
                if (this.hidEsEnEspanol.Value == "true")
                {
                    strScript = "Notificacion enviada correctamente";
                }
                else
                {
                    strScript = "Notification sent correctly";
                }
            }


            // Actualizo el dataset:
            this.dstNotificaciones.DataBind();
            this.gvNotificacionesClient.DataBind();
            // Limpio valores:
            this.ddlDepartamento.Text = "";
            this.ddlEsParaTodos.Text  = "";
            this.ddlRol.Text          = "";
            this.ddlUser.Text         = "";
            this.txtMensajeEdit.Text  = "";
            this.ddlDepartamento.Focus();
        }
        catch (Exception ex)
        {
            strScript = "Error: " + ex.Message.ToString().Replace("'", "").Replace("\n", "\\n").Replace("\r", "\\n").Replace(Convert.ToString((char)10), "\\n").Replace(Convert.ToString((char)13), "\\n");
        }
        finally
        {
            if (strScript != "")
            {
                strScript = "<script language='javascript'> alert('" + strScript + "');</script>";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "Error", strScript, false);
            }
        }
    }