Ejemplo n.º 1
0
        public void insertar(TOOrden o)
        {
            String     query   = "insert into Orden values(@nom, @fec, @est, @ide);";
            string     conn    = Properties.Settings.Default.Conn;
            SqlCommand command = new SqlCommand(query, new SqlConnection(conn));

            try
            {
                command.Parameters.AddWithValue("@nom", o.Nombre_Usuario);
                command.Parameters.AddWithValue("@fec", o.Fecha);
                command.Parameters.AddWithValue("@est", o.Estado);
                command.Parameters.AddWithValue("@ide", o.Identificador);
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                command.ExecuteNonQuery();
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { if (command.Connection.State == ConnectionState.Open)
                      {
                          command.Connection.Close();
                      }
            }
        }
Ejemplo n.º 2
0
        public BLOrden consultarOrden(int codigo_Orden)
        {
            TOOrden toOrden = daoOrden.buscarOrden(codigo_Orden);
            BLOrden ordenBl = new BLOrden(toOrden.Codigo_Orden, toOrden.Fecha_Hora, toOrden.Cedula, toOrden.Estado_Pedido, toOrden.Costo_Total);

            return(ordenBl);
        }
Ejemplo n.º 3
0
        public void actualizar(TOOrden o)
        {
            string     query   = "update Orden set Nombre_Usuario = @nom, Fecha = @fec, Estado = @est where Identificacion = @ide";
            string     conn    = Properties.Settings.Default.Conn;
            SqlCommand command = new SqlCommand(query, new SqlConnection(conn));

            try
            {
                command.Parameters.AddWithValue("@nom", o.Nombre_Usuario);
                command.Parameters.AddWithValue("@fec", o.Fecha);
                command.Parameters.AddWithValue("@est", o.Estado);
                command.Parameters.AddWithValue("@ide", o.Identificador);
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                command.ExecuteNonQuery();
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { if (command.Connection.State == ConnectionState.Open)
                      {
                          command.Connection.Close();
                      }
            }
        }
Ejemplo n.º 4
0
        public void Buscar()
        {
            TOOrden o = dao.Buscar(this.Identificador);

            this.nombreUsuario = o.Nombre_Usuario;
            this.Fecha         = o.Fecha;
            this.Estado        = o.Estado;
        }
        public BLOrden Buscar(int identificador)
        {
            TOOrden o = dao.Buscar(identificador);

            //this.nombreUsuario = o.Nombre_Usuario;
            //this.Fecha = o.Fecha;
            //this.Estado = o.Estado;
            return(new BLOrden(o.Nombre_Usuario, o.Fecha, o.Estado, identificador));
        }
Ejemplo n.º 6
0
        public void cambiarEstado(int orden, String nuevoEstado)
        {
            TOOrden toOrden = new TOOrden();

            toOrden.Estado        = nuevoEstado;
            toOrden.Identificador = orden;

            DaoOrden dao = new DaoOrden();

            dao.actualizar(toOrden);
        }
Ejemplo n.º 7
0
        public LinkedList <TOOrden> listaOrdenes()
        {
            string               query   = "select * from Orden";
            string               conn    = Properties.Settings.Default.Conn;
            SqlCommand           command = new SqlCommand(query, new SqlConnection(conn));
            LinkedList <TOOrden> list    = new LinkedList <TOOrden>();
            TOOrden              o;
            SqlDataReader        data;

            try
            {
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                data = command.ExecuteReader();
                if (data.HasRows)
                {
                    while (data.Read())
                    {
                        string   nombre        = data["Nombre_Usuario"].ToString();
                        String   fecha         = data["Fecha"].ToString();
                        string   stado         = data["Estado"].ToString();
                        int      identificador = Int32.Parse(data["Identificador"].ToString());
                        DateTime fecha1        = DateTime.Now;
                        DateTime fecha2        = DateTime.Parse(fecha.ToString());
                        //DateTime fecha2 = new DateTime(fecha);
                        //DateInterval res
                        // long res = DateAndTime.DateDiff(DateInterval.Minute,fecha2,fecha1);
                        o = new TOOrden(nombre, fecha, stado, identificador);
                        //o = new TOOrden(nombre, fecha, stado, identificador);

                        list.AddLast(o);
                    }
                }
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            return(list);
        }
Ejemplo n.º 8
0
        public TOOrden buscarOrden(int Codigo_orden)
        {
            TOOrden toOrden = new TOOrden();

            establecerConexion();

            //try
            //{
            sentencia.Transaction = transa;
            sentencia.Connection  = conexion;


            sentencia.CommandText = "SELECT Codigo_orden, [Fecha/Hora_pedido] , Cedula, Estado_pedido, Costo_total FROM Orden WHERE Codigo_orden=@codigo_Orden;";
            sentencia.Parameters.AddWithValue("@codigo_Orden", Codigo_orden.ToString());


            using (SqlDataReader reader = sentencia.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        toOrden.Codigo_Orden = int.Parse(reader["Codigo_orden"].ToString());
                        //toOrden.Fecha_Hora = Convert.ToDateTime(reader["Fecha/Hora_pedido"].ToString());
                        toOrden.Cedula        = reader["Cedula"].ToString();
                        toOrden.Estado_Pedido = reader["Estado_pedido"].ToString();
                        toOrden.Costo_Total   = double.Parse(reader["Costo_total"].ToString());
                    }
                }
                else
                {
                    toOrden.Codigo_Orden  = 0;
                    toOrden.Cedula        = "";
                    toOrden.Estado_Pedido = "";
                    toOrden.Costo_Total   = 0;
                }
            }



            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.ToString());

            conexion.Close();
            return(toOrden);
        }
Ejemplo n.º 9
0
        public int insertar(TOOrden o)
        {
            String     query   = "Insert INTO Orden(Nombre_Usuario, Estado) values(@nom, @est);";
            string     conn    = Properties.Settings.Default.Conn;
            SqlCommand command = new SqlCommand(query, new SqlConnection(conn));

            try
            {
                command.Parameters.AddWithValue("@nom", o.Nombre_Usuario);
                // command.Parameters.AddWithValue("@fec", o.Fecha);
                command.Parameters.AddWithValue("@est", o.Estado);
                //command.Parameters.AddWithValue("@ide", o.Identificador);
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                command.ExecuteNonQuery();

                query   = "SELECT IDENT_CURRENT('Orden')";
                conn    = Properties.Settings.Default.Conn;
                command = new SqlCommand(query, new SqlConnection(conn));

                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                Object a          = command.ExecuteScalar();
                String b          = a.ToString();
                int    secuencial = int.Parse(b);
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
                return(secuencial);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { if (command.Connection.State == ConnectionState.Open)
                      {
                          command.Connection.Close();
                      }
            }
        }
Ejemplo n.º 10
0
        public LinkedList <TOOrden> listaOrdenes()
        {
            string               query   = "select * from Orden";
            string               conn    = Properties.Settings.Default.Conn;
            SqlCommand           command = new SqlCommand(query, new SqlConnection(conn));
            LinkedList <TOOrden> list    = new LinkedList <TOOrden>();
            TOOrden              o;
            SqlDataReader        data;

            try
            {
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                data = command.ExecuteReader();
                if (data.HasRows)
                {
                    while (data.Read())
                    {
                        string   nombre        = data.GetValue(0).ToString();
                        DateTime fecha         = DateTime.Parse(data.GetValue(1).ToString());
                        string   stado         = data.GetValue(2).ToString();
                        int      identificador = Int32.Parse(data.GetValue(3).ToString());
                        o = new TOOrden(nombre, fecha, stado, identificador);
                        list.AddLast(o);
                    }
                }
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            } catch (Exception e) {
                throw e;
            } finally {
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            return(list);
        }
Ejemplo n.º 11
0
        public TOOrden Buscar(int identificador)
        {
            string     query   = "select * from Orden where Identificador = @ide";
            string     conn    = Properties.Settings.Default.Conn;
            SqlCommand command = new SqlCommand(query, new SqlConnection(conn));
            TOOrden    o;

            try
            {
                command.Parameters.AddWithValue("@ide", identificador);
                if (command.Connection.State == ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                SqlDataReader data   = command.ExecuteReader();
                string        nombre = data.GetValue(0).ToString();
                String        fecha  = data.GetValue(1).ToString();
                //DateTimeOffset f = new DateTimeOffset(fecha);
                string estado = data.GetValue(2).ToString();
                int    ident  = Int32.Parse(data.GetValue(3).ToString());
                o = new TOOrden(nombre, fecha, estado, ident);
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally { if (command.Connection.State == ConnectionState.Open)
                      {
                          command.Connection.Close();
                      }
            }
            return(o);
        }
Ejemplo n.º 12
0
        public void actualizar()
        {
            TOOrden o = new TOOrden(this.nombreUsuario, this.Fecha, this.Estado, this.Identificador);

            dao.actualizar(o);
        }
Ejemplo n.º 13
0
        public void insertar()
        {
            TOOrden o = new TOOrden(this.nombreUsuario, this.Fecha, this.Estado, this.Identificador);

            dao.insertar(o);
        }
        public void actualizar(string Estado, int Identificador)
        {
            TOOrden o = new TOOrden(Estado, Identificador);

            dao.actualizar(o);
        }
        public int insertar(string nombreUsuario, String Fecha, string Estado, int Identificador)
        {
            TOOrden o = new TOOrden(nombreUsuario, Fecha, Estado, Identificador);

            return(dao.insertar(o));
        }