Ejemplo n.º 1
0
        /// <summary>
        /// Allows to register a new international ticket
        /// </summary>
        /// <param name="z">Object Type TiqueteInternacional</param>
        public void registrarTiqInt(TiqueteInternacional z)
        {
            validarTiqInter(z);
            TiquetesDAL x = new TiquetesDAL();

            x.registrarTiqInter(z);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// allows to validate that the data of a TiqueteInternacional are not null or incorrect.
        /// </summary>
        /// <param name="ti">Object type TiqueteInternacional</param>
        private void validarTiqInter(TiqueteInternacional ti)
        {
            DateTime fecha      = Convert.ToDateTime(ti.Fecha);
            int      numerodias = (fecha - DateTime.Now).Days;

            if (String.IsNullOrEmpty(ti.Fecha))
            {
                throw new Exception("Fecha de viaje Requerida");
            }
            if (numerodias < 6)
            {
                throw new Exception("El tiquete debe de poseer una semana de anticipación");
            }
            if (numerodias < 0)
            {
                throw new Exception("El tiquete debe de poseer una Fecha Vigente");
            }
            if (String.IsNullOrEmpty(ti.Asiento))
            {
                throw new Exception("Numero de asiento Requerido");
            }
            if (String.IsNullOrEmpty(ti.CodUnidad))
            {
                throw new Exception("Codigo de unidad Requerido");
            }
            if (String.IsNullOrEmpty(ti.FechaVenta))
            {
                throw new Exception("Fecha de Venta Requerida");
            }
            if (String.IsNullOrEmpty(ti.Horasalida))
            {
                throw new Exception("Hora de Salida Requerida");
            }
            if (String.IsNullOrEmpty(Convert.ToString(ti.Monto)))
            {
                throw new Exception("Monto Requerido");
            }
            if (String.IsNullOrEmpty(ti.NumPassport))
            {
                throw new Exception("Numero de Pasaporte Requerido");
            }
            if (ti.Monto < 0)
            {
                throw new Exception("El monto debe ser Positivo Requerido");
            }
            if (String.IsNullOrEmpty(ti.TerminalLLegada))
            {
                throw new Exception("Destino Requerido");
            }
            if (String.IsNullOrEmpty(ti.TerminalSalida))
            {
                throw new Exception("Terminal De Salida Requerida");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allows to register a new international ticket
        /// </summary>
        /// <param name="z">Object Type TiqueteInternacional</param>
        public void registrarTiqInter(TiqueteInternacional z)
        {
            string path = Path.GetFullPath("tiqInter.txt");//para agregar carpetas afuera agrego ..\\

            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine(z.ToString());
                    sw.Close();
                }
            }
            else
            {
                using (StreamWriter file = new StreamWriter(path, true))
                {
                    file.WriteLine(z.ToString()); //se agrega información al documento

                    file.Close();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allows to charge a list of all international tickets sold in a specific date to make an cash register
        /// </summary>
        /// <param name="info"> Object type CierreCaja to find the specific tickets</param>
        /// <returns>list of international tickets</returns>
        public List <TiqueteInternacional> cargarTiquetesInterArq(CierreCaja info)
        {
            List <TiqueteInternacional> mas = new List <TiqueteInternacional>();
            StreamReader lectura;
            StreamWriter escribir;
            string       cadena, empleado;
            bool         encontrado;

            encontrado = false;
            string[] campos    = new string[14];
            char[]   separador = { ',' };
            try
            {
                //lectura = File.OpenText(@"C:\Users\Usuario\Desktop\lol.txt");
                string path = Path.GetFullPath("tiqInter.txt");//para agregar carpetas afuera agrego ..\\
                lectura = File.OpenText(path);
                //escribir = File.CreateText(@"C:\Users\Usuario\Desktop\temp.txt");
                // String Nombre = dataTabla.CurrentRow.Cells[0].Value.ToString();
                cadena = lectura.ReadLine();
                while (cadena != null)
                {
                    campos = cadena.Split(separador);
                    if (campos[11].Equals(info.GSUsuario) && campos[12].Equals(info.GSFecha))
                    {
                        TiqueteInternacional p = new TiqueteInternacional();
                        p.NumTiquete      = Convert.ToInt32(campos[0]);
                        p.NumPassport     = campos[1];
                        p.Fecha           = campos[2];
                        p.Asiento         = campos[3];
                        p.CodUnidad       = campos[4];
                        p.Horasalida      = campos[5];
                        p.TerminalSalida  = campos[6];
                        p.TerminalLLegada = campos[7];
                        p.Equipaje        = Convert.ToBoolean(campos[8]);
                        p.NumEquipaje     = Convert.ToInt32(campos[9]);
                        p.Monto           = Convert.ToDouble(campos[10]);
                        p.Vendedor        = campos[11];
                        p.FechaVenta      = campos[12];
                        mas.Add(p);
                    }

                    /*
                     * else
                     * {
                     *  escribir.WriteLine(cadena);
                     * }
                     */
                    cadena = lectura.ReadLine();
                }

                lectura.Close();
                //escribir.Close();

                /*
                 * File.AppendAllText(@"C:\Users\Usuario\Desktop\temp.txt", "Your Text" + "\n");
                 * File.Delete(@"C:\Users\Usuario\Desktop\lol.txt");
                 * File.Move(@"C:\Users\Usuario\Desktop\temp.txt", @"C:\Users\Usuario\Desktop\lol.txt");
                 */
                return(mas);
            }
            catch (FileNotFoundException fe)
            {
            }
            catch (Exception be)
            {
            }
            return(mas);
        }