Пример #1
0
        public static async Task <Employee> GetEmployee(int id)
        {
            string sql = "SELECT * FROM Employee WHERE Id = @id";

            SqlCeCommand command = new SqlCeCommand(sql, con);

            command.Parameters.Add("@id", id);

            await con.OpenAsync();

            SqlCeDataReader result = (SqlCeDataReader)await command.ExecuteReaderAsync();

            Employee employee = new Employee();

            while (await result.ReadAsync())
            {
                employee.Id           = result.GetInt32(0);
                employee.Name         = result.GetString(1);
                employee.Email        = result.GetString(2);
                employee.Salary       = result.GetDecimal(3);
                employee.Gender       = result.GetString(4);
                employee.ContractType = result.GetString(5);
                //employee.RegisterDate = result.GetDateTime(6);
            }

            con.Close();

            return(employee);
        }
        public async Task <IDataReader> ExecuteReaderAsync(string querry)
        {
            SqlCeCommand command = new SqlCeCommand(querry, dbConnection);
            DbDataReader reader  = await command.ExecuteReaderAsync();

            return(reader);
        }
Пример #3
0
        /// <summary>
        /// Gets the member id of the associated name
        /// </summary>
        private async Task <int> GetMemberID(string memberName)
        {
            int memberID = 0;

            using (SqlCeConnection connection = new SqlCeConnection(connectionFilePath))
            {
                await connection.OpenAsync();

                // TODO: Establish unique item

                string query = "SELECT ID FROM Members WHERE NAME='" + memberName + "'";

                SqlCeCommand command = new SqlCeCommand();
                command.Connection  = connection;
                command.CommandText = query;

                DbDataReader reader = await command.ExecuteReaderAsync();

                try
                {
                    while (reader.Read())
                    {
                        memberID = reader.GetInt32(0);
                    }
                }
                finally
                {
                    reader.Close();
                }

                connection.Close();
            }

            return(memberID);
        }
        public async Task <IList <LogEntity> > GetAllAsync()
        {
            var Logs        = new List <LogEntity>();
            var _connection = new SqlCeConnection(Globals.DbConnectionString);

            _connection.Open();
            var sql = "SELECT * FROM LogEntities";

            SqlCeCommand selectCommand;

            using (selectCommand = new SqlCeCommand(sql, _connection))
            {
                using (var reader = await selectCommand.ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        var log = new LogEntity();


                        DateTime?CreatedDate = null;
                        DateTime CreatedDate2;
                        DateTime?ModifiedDate = null;
                        DateTime ModifiedDate2;

                        var s = DateTime.TryParse(reader["CreatedDateTime"].ToString(), out CreatedDate2);
                        if (s)
                        {
                            CreatedDate         = CreatedDate2;
                            log.CreatedDateTime = CreatedDate;
                        }

                        var s2 = DateTime.TryParse(reader["ModifiedDateTime"].ToString(), out ModifiedDate2);
                        if (s2)
                        {
                            ModifiedDate         = ModifiedDate2;
                            log.ModifiedDateTime = ModifiedDate;
                        }


                        log.Id        = Convert.ToInt64(reader["Id"].ToString());
                        log.Date      = Convert.ToDateTime(reader["Date"].ToString());
                        log.Level     = reader["Level"].ToString();
                        log.Thread    = reader["Thread"].ToString();
                        log.Message   = reader["Message"].ToString();
                        log.Exception = reader["Exception"].ToString();


                        Logs.Add(log);
                    }
                }
                return(Logs);
            }
        }
Пример #5
0
        /// <summary>
        /// Gets the ticket id of the associated seat parameters
        /// </summary>
        private async Task <int> GetTicketID(int section, int row, int seat)
        {
            int ticketID = 0;

            using (SqlCeConnection connection = new SqlCeConnection(connectionFilePath))
            {
                await connection.OpenAsync();

                // TODO: Establish unique item

                string query = "SELECT ID FROM Tickets WHERE T_SECTION=" + section
                               + " AND T_ROW=" + row
                               + " AND T_SEAT=" + seat;

                SqlCeCommand command = new SqlCeCommand();
                command.Connection  = connection;
                command.CommandText = query;

                DbDataReader reader = await command.ExecuteReaderAsync();

                try
                {
                    while (reader.Read())
                    {
                        ticketID = reader.GetInt32(0);
                    }
                }
                finally
                {
                    reader.Close();
                }

                connection.Close();
            }

            return(ticketID);
        }