Beispiel #1
0
        public static string[] CrearMensaje(string OT, string NombreOT, string TipoMensaje, string Categoria, string Asunto, string Comentario, string Usuario, bool urgente, string idcategoria)
        {
            int             IDMensaje = 0;
            string          Mensaje   = "";
            Mail_Controller controlm  = new Mail_Controller();

            if ((Asunto != "Seleccionar") && (Comentario.Count() > 4) && (Categoria != "Seleccionar") && (TipoMensaje != "Seleccionar"))
            {
                IDMensaje = controlm.NuevoMensaje(OT, NombreOT, Asunto, Comentario, Usuario, Convert.ToInt32(idcategoria), Categoria, TipoMensaje);
                Mensaje   = "OK";
                if (IDMensaje != 0)
                {
                    if (urgente)
                    {
                        controlm.EnviarCorreo(OT, NombreOT, Asunto, Comentario, Usuario);
                    }
                }
                else
                {
                    Mensaje = "Ha ocurrido un error, vuelva a intentarlo";
                }
            }
            else
            {
                Mensaje = "El Mensaje debe tener Asunto y Comentario, estos deben ser mayor a 4 caracteres.";
            }

            return(new[] { IDMensaje.ToString(), Mensaje });
        }
Beispiel #2
0
        protected void btnRedactar_Click(object sender, EventArgs e)
        {
            int IDMensaje = 0;

            if (txtNOT.Text != "" && txtAsunto.Text != "" && lblNombreOT.Text != "")
            {
                IDMensaje = controlm.NuevoMensaje(txtNOT.Text, txtAsunto.Text, txtMensaje.Text, Session["Usuario"].ToString());
                if (IDMensaje != 0)
                {
                    bool respuesta = true;
                    int  contador  = arch.Count;
                    if (contador != 0)
                    {
                        foreach (Archivo i in arch)
                        {
                            respuesta = controlm.UpdateMailArchivo(i.IDArchivo, IDMensaje);
                        }
                        if (respuesta != true)
                        {
                            string popupScript = "<script language='JavaScript'> alert('Ha ocurrido un error al Adjuntar Archivo'); </script>";
                            Page.RegisterStartupScript("PopupScript", popupScript);
                        }
                        else
                        {
                            if (chkImportancia.Checked == true)
                            {
                                string popupScript = "<script language='JavaScript'> alert(' Mensaje Enviado Correctamente'); location.href='javascript:history.go(-" + volver + ")';  </script>";
                                Page.RegisterStartupScript("PopupScript", popupScript);
                            }
                            else
                            {
                                string popupScript = "<script language='JavaScript'> alert(' Mensaje Enviado Correctamente'); location.href='javascript:history.go(-" + volver + ")';  </script>";
                                Page.RegisterStartupScript("PopupScript", popupScript);
                            }
                        }
                    }
                    else
                    {
                        if (chkImportancia.Checked == true)
                        {
                            EnviarCorreo();
                            string popupScript = "<script language='JavaScript'> alert(' Mensaje Enviado Correctamente'); location.href='javascript:history.go(-" + volver + ")';  </script>";
                            Page.RegisterStartupScript("PopupScript", popupScript);
                        }
                        else
                        {
                            string popupScript = "<script language='JavaScript'> alert(' Mensaje Enviado Correctamente'); location.href='javascript:history.go(-" + volver + ")';  </script>";
                            Page.RegisterStartupScript("PopupScript", popupScript);
                        }
                    }
                }
                else
                {
                    string popupScript = "<script language='JavaScript'> alert('Ha ocurrido un error, vuelva a intentarlo');location.href='Mensajeria.aspx' </script>";
                    Page.RegisterStartupScript("PopupScript", popupScript);
                }
            }
            else
            {
                string popupScript = "<script language='JavaScript'> alert('¡Debe buscar una OT para crear mensaje!');</script>";
                Page.RegisterStartupScript("PopupScript", popupScript);
            }
        }