Exemplo n.º 1
0
        /// <summary>
        /// Lee los datos del archivo txt, sino lanza un error controlado
        /// </summary>
        /// <returns></returns>
        public string Leer()
        {
            Texto  texto    = new Texto();
            string fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                              + "jornada.txt";
            string retorno = "";

            try
            {
                texto.Leer(fileName, out retorno);
            }
            catch (Exception e)
            {
                throw new ArchivosException("Error al leer Jornada.txt", e);
            }
            return(retorno);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Guarda en un archivo de texto el contenido del ticket creado en ejecucion
        /// </summary>
        /// <returns></returns>
        public bool HacerTicket()
        {
            bool retorno = false;

            Texto aux = new Texto();

            this.sb.AppendFormat("\n\n\n=========== Fecha: {0} ==========\n", DateTime.Now);
            this.sb.AppendFormat("=========== Precio total: {0} ===========", this.precioTotal);

            if (aux.Guardar(Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + @"\Ticket.txt", this.sb.ToString()))
            {
                retorno         = true;
                this.flagTicket = true;
            }

            return(retorno);
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Edit([Bind(Include = "TextoId,CursoId,FuncionarioId,Titulo,Conteudo")] Texto texto)
        {
            if (ModelState.IsValid)
            {
                db.Textos.Attach(texto);
                db.Entry(texto).Property(x => x.CursoId).IsModified  = true;
                db.Entry(texto).Property(x => x.Conteudo).IsModified = true;
                db.Entry(texto).Property(x => x.Titulo).IsModified   = true;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CursoId = new SelectList(db.Cursos, "CursoId", "Nome", texto.CursoId);
            // ViewBag.FuncionarioId = new SelectList(db.Funcionarios, "FuncionarioId", "Nome", texto.UserId);
            return(View(texto));
        }
Exemplo n.º 4
0
        private void btnTxt_Click(object sender, EventArgs e)
        {
            Texto          patente        = new Texto();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.ShowDialog();
            patente.Leer(openFileDialog.FileName, out this.cola);
            StringBuilder sb = new StringBuilder();

            foreach (Patente p in this.cola)
            {
                sb.AppendLine(p.ToString());
            }
            MessageBox.Show(sb.ToString());

            this.IniciarSimulacion();
        }
Exemplo n.º 5
0
        public static string Leer()
        {
            Texto  reader  = new Texto();
            string archivo = AppDomain.CurrentDomain.BaseDirectory + "texto.txt";
            string datos   = "";

            try
            {
                reader.Leer(archivo, out datos);
            }
            catch (Excepciones.ArchivosException)
            {
                datos = "No pudo leerse";
            }

            return(datos);
        }
Exemplo n.º 6
0
        static void Memento_Exemplo1()
        {
            var texto = new Texto();

            texto.EscreverTexto("Primeira linha do texto\n");
            texto.EscreverTexto("Segunda linha do texto\n");
            texto.EscreverTexto("Terceira linha do texto\n");
            texto.MostrarTexto();
            texto.DesfazerEscrita();
            texto.MostrarTexto();
            texto.DesfazerEscrita();
            texto.MostrarTexto();
            texto.DesfazerEscrita();
            texto.MostrarTexto();
            texto.DesfazerEscrita();
            texto.MostrarTexto();
        }
Exemplo n.º 7
0
        public static bool Guardar(Jornada jornada)
        {
            Texto  guardar = new Texto();
            string archivo = AppDomain.CurrentDomain.BaseDirectory + "texto.txt";
            bool   rtnVal;

            try
            {
                rtnVal = guardar.Guardar(archivo, jornada.ToString());
            }
            catch (Excepciones.ArchivosException)
            {
                rtnVal = false;
            }

            return(rtnVal);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Guardar de clase guardará los datos de la Jornada en un archivo de texto.
        /// </summary>
        /// <param name="jornada"></param>
        /// <returns></returns>
        public static bool Guardar(Jornada jornada)
        {
            bool retorno = false;

            Texto texto = new Texto();

            try
            {
                texto.Guardar("Jornada.txt", jornada.ToString());
                retorno = true;
            }
            catch (ArchivosException e)
            {
                throw new ArchivosException(e);
            }
            return(retorno);
        }
Exemplo n.º 9
0
        private void btnLeerTxt_Click(object sender, EventArgs e)
        {
            try
            {
                Texto texto = new Texto();

                if (texto.Leer(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + ".\\Ensamblados.txt", out string nombres))
                {
                    rtbArchivos.Text = nombres;
                }
            }

            catch (ArchivoException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Boton que guarda el informe  de productos
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnGuardarInforme_Click(object sender, EventArgs e)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         foreach (Producto item in alvaroFabrica.Listaproductos)
         {
             sb.Append(item.Informacion());
         }
         Texto.EscribirTexto(sb.ToString());
     }
     catch (Exception GuardarInforme)
     {
         MessageBox.Show(GuardarInforme.Message, "Error");
     }
     MessageBox.Show("Se guardo el informe exitosamente", "Exito");
 }
Exemplo n.º 11
0
        public static Usuario GerarEntidade(AtualizarUsuarioCommand command)
        {
            try
            {
                int                id         = command.Id;
                Texto              login      = new Texto(command.Login, "Login", 50);
                SenhaMedia         senha      = new SenhaMedia(command.Senha);
                EPrivilegioUsuario privilegio = command.Privilegio;

                Usuario usuario = new Usuario(id, login, senha, privilegio);
                return(usuario);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Imprime el reporte de las ventas totales
        /// </summary>
        private void ImprimirReporte()
        {
            try
            {
                Thread.Sleep(Convert.ToInt32(ConfigurationManager.AppSettings.Get("TiempoDelay")));

                /*pongo un delay, para simular que fue a la impresora, etc, pero como corre en un hilo secundario,
                 * se puede seguir manejando la app*/
                Texto texto = new Texto();
                texto.Guardar(string.Concat("Reporte", DateTime.Now.Ticks, ".txt"), VentasBussines.ObtenerTodasLasVentas());
                ActualizarInformacionReporte("El reporte se imprimio en la carpeta Archivos Guardados.");
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrio un error al intentar realizar el reporte", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Metodo estatico Guarda objeto Jornada en un archivo txt en el desktop de la pc
        /// </summary>
        /// <param name="jornada"></param>
        /// <returns></returns>
        public static bool Guardar(Jornada jornada)
        {
            try
            {
                //string ruta =  ".\\Archivo.txt";
                string ruta  = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\Archivo.txt";
                Texto  texto = new Texto();

                texto.Guardar(ruta, jornada.ToString());

                return(true);
            }
            catch (Exception ex)
            {
                throw new ArchivosException(ex);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Lee los datos desde el path indicado
        /// </summary>
        /// <returns></returns> retorna los datos en un string
        bool Leer()
        {
            bool   flag = false;
            string datos;

            try
            {
                Texto  text = new Texto();
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                flag = text.Leer(path + @"\ArchivoJornada", out datos);
            }
            catch (Exception error)
            {
                throw new ArchivosException("no se pudo guardar", error);
            }
            return(flag);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Guarda una jornada en un archivo de texto
        /// </summary>
        /// <param name="jornada"></param>
        /// <returns>True si puede guardar la jornada</returns>
        public static bool Guardar(Jornada jornada)
        {
            bool retorno = false;
            IArchivo <string> archivosTexto = new Texto();
            string            ruta          = AppDomain.CurrentDomain.BaseDirectory + "Jornada.txt";

            try
            {
                retorno = archivosTexto.Guardar(ruta, jornada.ToString());
            }
            catch (ArchivosException e)
            {
                throw e;
            }

            return(retorno);
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            string Texto;



            Console.Write("Digite Uma frase Qualquer: ");
            Texto = Console.ReadLine();

            Console.Write(Texto
                          .Replace("A", "4").Replace("a", "4")
                          .Replace("E", "3").Replace("e", "3")
                          .Replace("I", "1").Replace("i", "1")
                          .Replace("L", "1").Replace("l", "1")
                          .Replace("O", "0").Replace("o", "0")
                          .Replace("T", "7").Replace("t", "7")
                          .Replace("S", "5").Replace("s", "5"));
        }
Exemplo n.º 17
0
        //--------------------------------------------------------------------------------------------
        #region metodos
        /// <summary>
        /// Metodo estatico para guardar el contenido de la jornada en un archivo de texto
        /// </summary>
        /// <param name="jornada"></param>
        /// <returns></returns>
        public static bool Guardar(Jornada jornada)
        {
            Texto aux = new Texto();

            try
            {
                ////Al llamar a este metodo se guardara en el escritorio
                return(aux.Guardar(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Jornada.txt", jornada.ToString()));


                //Al llamar a este metodo se guardara en C:\...\Blanco.Leonardo.2doC.TP3\SalidaPorPantalla\bin\Debug
                //return aux.Guardar(AppDomain.CurrentDomain.BaseDirectory + "Jornada.txt", jornada.ToString());
            }
            catch (ArchivosException e)
            {
                throw e;
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Guarda los datos en un archivo en la ruta.
        /// </summary>
        /// <param name="jornada"></param>
        /// <returns>True en caso de que se haya guardado, caso contrario lanza excepción.</returns>
        public static bool Guardar(Jornada jornada)
        {
            try
            {
                string ruta = System.IO.Directory.GetCurrentDirectory() + @"\Archivos";
                System.IO.Directory.CreateDirectory(ruta);

                Texto txt = new Texto();

                txt.Guardar((ruta + @"\Jornada.txt"), jornada.ToString());

                return(true);
            }
            catch (Exception e)
            {
                throw new ArchivosException(e);
            }
        }
Exemplo n.º 19
0
        private void btnTxt_Click(object sender, EventArgs e)
        {
            try
            {
                Texto texto = new Texto();
                texto.Leer("patentes.txt", out this.cola);
                this.IniciarSimulacion();
            }

            /*catch (PatenteInvalidaException a)
             * {
             *  MessageBox.Show(a.Message);
             * }*/
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 20
0
        public void VerificarGuardarArchivoTexto_Fail()
        {
            //arrange
            Texto  txt            = new Texto();
            string datosGuardados = "Este archivo se genero al probar el metodo VerificarGuardarArchivoTexto_Fail() del proyecto TestUnitarioEntidades.";
            string archivo        = null;

            //act
            try
            {
                txt.Guardar(archivo, datosGuardados);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArchivosException));
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Le agrega al historial las paginas visitadas.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmHistorial_Load(object sender, EventArgs e)
        {
            Texto archivos = new Texto(frmHistorial.ARCHIVO_HISTORIAL);

            List <string> historial;

            if (archivos.leer(out historial))
            {
                foreach (string item in historial)
                {
                    this.lstHistorial.Items.Add(item);
                }
            }
            else
            {
                MessageBox.Show("No se guardo el historial.");
            }
        }
Exemplo n.º 22
0
        private void btnTxt_Click(object sender, EventArgs e)
        {
            Texto txt = new Texto();

            try
            {
                txt.Leer("patentes.txt", out this.cola);
            }
            catch (PatenteInvalidaException ex)
            {
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ext)
            {
                MessageBox.Show(ext.Message, "erro2", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.inicializarSimulacion();
        }
Exemplo n.º 23
0
        public void VerificarLeerArchivoTexto_Fail()
        {
            //arrange
            Texto  txt = new Texto();
            string datos;
            string pathArchivo = "ArchivoInexistente.txt";

            //act
            try
            {
                txt.Leer(pathArchivo, out datos);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArchivosException));
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Lee el archivo de objetos Jornada en formato txt
        /// </summary>
        /// <returns>Lo leido en el archivo, en forma de string</returns>
        public static string Leer()
        {
            string resultado;

            Texto aux = new Texto();

            try
            {
                aux.Leer("Jornada.txt", out resultado);
            }
            catch (Exception e)
            {
                throw new ArchivosException(e);
            }


            return(resultado);
        }
Exemplo n.º 25
0
        public void LanzaExcepcionDeArchivo()
        {
            //arrange
            string path   = "";
            string datos  = "";
            Texto  lector = new Texto();

            //act
            try
            {
                lector.Leer(path, out datos);
            }
            //assert
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArchivosException));
            }
        }
Exemplo n.º 26
0
        public async Task <ActionResult> ConcluirAprovacao(int id)
        {
            var texto = new Texto
            {
                TextoId  = id,
                Aprovado = true
            };

            if (ModelState.IsValid)
            {
                db.Textos.Attach(texto);
                db.Entry(texto).Property(x => x.Aprovado).IsModified = true;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemplo n.º 27
0
        /// <summary>
        /// Lee los datos de una jornada en un solo string para poder mostrarlo.
        /// </summary>
        /// <param name="datos">Cadena de caracteres que contendra los datos de la jornada.</param>
        /// <returns></returns>
        public static bool Leer(out string datos)
        {
            try
            {
                Texto txt = new Texto();
                txt.leer(FILE_NAME, out datos);

                return(true);
            }
            catch (ArchivosException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new ArchivosException(e);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Lee una Jornada guardada como archivo texto y lo retorna como string
        /// </summary>
        /// <returns></returns>
        public static string Leer()
        {
            Texto  t = new Texto();
            string datos = "", archivo = "Jornada.txt";

            try
            {
                if (t.Leer(archivo, out datos))
                {
                    return(datos);
                }
            }
            catch (ArchivosException e)
            {
                throw e;
            }

            return(datos);
        }
Exemplo n.º 29
0
 private void modificar_Click(object sender, EventArgs e)
 {
     if (tabla.Rows.Count != 0)
     {
         try
         {
             texto        = textoController.Seleccionar(tabla);
             titulo.Text  = texto.getTitulo();
             titulo.Text  = texto.getTitulo();
             tiempo.Text  = texto.getTiempo().ToString();
             cuento.Text  = texto.getTexto();
             modificacion = true;
         }
         catch (MySqlException ex)
         {
             MessageBox.Show(ex.Message + " Debe seleccionar un registro.");
         }
     }
 }
 public static void LogInOutlook(String mail, String password)
 {
     try
     {
         Click.On(Texto.ResultadoOutlook());
         Click.On(Button.BtnIniciarSesion());
         Enter.EnviarTexto(InputDate.InputMail(), mail);
         Click.On(Button.BtnSiguiente());
         Enter.EnviarTexto(InputDate.InputPassWord(), password);
         Click.On(Button.BtnSiguiente());
         XLog.Message("LogIn en Outlook, OK");
     }
     catch (System.Exception)
     {
         XLog.Message("LogIn en Outlook, KO");
         throw new System.Exception("Fallo LogIn en Outlook");
     }
     Driver.TaskPrint();
 }