Beispiel #1
0
        protected void btnEnviarImagen_Click(object sender, EventArgs e)
        {
            string numdoc = "";

            userName = "";
            numdoc   = txtNumeroDoc.Text.Trim();
            if (string.IsNullOrEmpty(numdoc))
            {
                lblErrorSi.Text  = "El Numero de Documento es Obligatorio.";
                lblErrorSi2.Text = "El Numero de Documento es Obligatorio.";
                txtNumeroDoc.Focus();
                return;
            }
            if (!file_upload.HasFile)
            {
                lblErrorSi.Text  = "No hay una Imagen Seleccionada.";
                lblErrorSi2.Text = "No hay una Imagen Seleccionada.";/*TRY MERGE WILL*/
                return;
            }
            Validation val   = new Validation();
            bool       isDoc = val.IsDocument(numdoc);

            if (!isDoc)
            {
                lblErrorSi.Text  = "El Dato Ingresado No es un Documento Valido.";
                lblErrorSi2.Text = "El Dato Ingresado No es un Documento Valido.";
                return;
            }

            BrInformacion brInformacion = new BrInformacion();

            string[] anwser = brInformacion.GetBYNunDoc(numdoc).Split('|');

            if (anwser.Length < 2)
            {
                lblErrorSi.Text  = "Aun no eres Socio.";
                lblErrorSi2.Text = "Aun no eres Socio.";
                return;
            }
            userName = anwser[0];
            string idMPayMdetail = anwser[1];

            if (!val.IsEntero(idMPayMdetail))
            {
                lblErrorSi.Text  = "Ocurrio un error de sistema.";
                lblErrorSi2.Text = "Ocurrio un error de sistema.";
                return;
            }
            if (!file_upload.HasFile)
            {
                lblErrorSi.Text  = "No hay una Imagen Seleccionada.";
                lblErrorSi2.Text = "No hay una Imagen Seleccionada.";
                return;
            }
            //si hay una archivo.

            string[] arraynombreArchivo2 = file_upload.FileName.Split('.');

            int indice = (arraynombreArchivo2.Length - 1);

            string extension = arraynombreArchivo2[indice];

            if (extension.ToLower() == "png" || extension.ToLower() == "jpg" || extension.ToLower() == "jpeg")
            {
                var idmem = LblIdMembership.Text.Trim();

                if (idmem != "")
                {
                    idMPayMdetail = idmem;
                }

                var    key           = DateTime.Now.ToString("yyyyMMddHHmmss");
                string nombreArchivo = $"login{key}__{idMPayMdetail}" + userName + "." + extension;

                if (val.IsEntero(idMPayMdetail))
                {
                    //var llave = Guid.NewGuid().ToString();

                    string ruta = "~/Resources/RecibosRegister/" + nombreArchivo;

                    //ComprimirImagen(file_upload.FileContent, ruta, "Jpeg", 40);
                    //GuardarImage(file_upload.FileContent, ruta, "compresionImagen.Jpeg", "jpg");

                    file_upload.SaveAs(Server.MapPath(ruta));
                }
                BrUser brUser       = new BrUser();
                bool   updateIdMent = false;


                if (idmem != "")
                {
                    if (val.IsEntero(idmem))
                    {
                        BrMembershipPayDetail brMembership = new BrMembershipPayDetail();
                        var response = brMembership.GetQuote(int.Parse(idmem), userName).Split('|');
                        var quote    = response[0];

                        //DateTime payDate = DateTime.Parse("2019-04-04 23:59:59");
                        //if (decimal.Parse(quote) == decimal.Parse("0"))
                        //{
                        //    lblErrorSi.Text = "Ocurrio un error.";
                        //    lblErrorSi2.Text = "Ocurrio un error.";
                        //    return;
                        //}
                        updateIdMent = brMembership.PutReceiptQuote(idmem, nombreArchivo);
                    }
                }
                else
                {
                    updateIdMent = brUser.PorVerificar(idMPayMdetail + "¬" + userName + "¬" + nombreArchivo);
                }

                if (!updateIdMent)
                {
                    lblErrorSi.Text  = "Usted ya no puede subir recibos.";
                    lblErrorSi2.Text = "Usted ya no puede subir recibos.";
                    return;
                }


                lblErrorSi.Text   = "El Recibo Fue Enviado Con exito, espere la confirmación que se le estará enviando a su correo, dentro de las proximas 24 horas";
                lblErrorSi2.Text  = "El Recibo Fue Enviado Con exito, espere la confirmación que se le estará enviando a su correo, dentro de las proximas 24 horas";
                txtNumeroDoc.Text = "";

                Email      oEmail    = new Email();
                MyMessages mm        = new MyMessages();
                var        emailUser = anwser[2].Trim();
                string     fname     = mm.ToCapitalize(anwser[3].Trim()).Trim();
                string     gender    = anwser[4].Trim();

                bool answer = oEmail.SendEmail(emailUser, "[Ribera del Rio - Inresorts, Registro en Proceso]", mm.MessageComprobandoImagen(fname, gender), true);
                answer = oEmail.SendEmail("*****@*****.**", "[Ribera del Rio - Inresorts, Registro en Proceso]", mm.MessageComprobandoImagen(fname, gender), true);

                string hex    = "#2981c5";
                Color  _color = ColorTranslator.FromHtml(hex);
                lblErrorSi2.ForeColor = _color;
                lblErrorSi.ForeColor  = _color;
                return;
            }
            lblErrorSi.Text  = "La Imagen No tiene el Formato Correcto.";
            lblErrorSi2.Text = "La Imagen No tiene el Formato Correcto.";
        }