Ejemplo n.º 1
0
        /// <summary></summary>
        /// <param name="Id">The id.</param>
        /// <returns>The <see cref="CrewMemberModel"/>.</returns>
        public CrewMemberModel GetCrewById(int Id)
        {
            CrewMemberModel crewMemberModel = null;

                string query = string.Format("select * from CrewMember where id = {0}", Id);
                OracleCommand command = new OracleCommand(query, DatabaseSettings.Connection);
                try
                {
                    OracleDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        CrewMemberModel.JobEnum job;
                        CrewMemberModel.JobEnum.TryParse(reader[2].ToString(), true, out job);
                        crewMemberModel = new CrewMemberModel(Convert.ToInt32(reader[0]), reader[1].ToString(), job, Convert.ToDateTime(reader[3]), Convert.ToString(reader[4]));
                        return crewMemberModel;
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

            return crewMemberModel;
        }
Ejemplo n.º 2
0
        /// <summary></summary>
        /// <returns>The <see cref="List"/>.</returns>
        public List<CrewMemberModel> GetAvailableCrewMembers()
        {
            List<CrewMemberModel> crewMembers = new List<CrewMemberModel>();
            CrewMemberModel crewMember = null;

                string query = "select cm.* from crewmember cm where cm.id not in (select crewmemberid from crewmember_ship)";
                OracleCommand command = new OracleCommand(query, DatabaseSettings.Connection);

                    OracleDataReader reader = command.ExecuteReader();

                    command.ExecuteNonQuery();
                    while (reader.Read())
                    {

                        int id = Convert.ToInt32(reader[0]);
                        string name = reader[1].ToString();
                        DateTime birthday = Convert.ToDateTime(reader[2]);
                        string username  = Convert.ToString(reader[4]);
                        CrewMemberModel.JobEnum job;
                        CrewMemberModel.JobEnum.TryParse(reader[3].ToString(), true, out job);

                        crewMember = new CrewMemberModel(id, name, job, birthday, username);
                        crewMembers.Add(crewMember);
                    }

                return crewMembers;
        }
Ejemplo n.º 3
0
        /// <summary></summary>
        /// <param name="user">The user.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public static bool LoginUser(CrewMemberModel user)
        {
            if (user != null)
            {
                LogedInUser = user;
                return true;
            }

            return false;
        }
Ejemplo n.º 4
0
 /// <summary></summary>
 /// <returns>The <see cref="bool"/>.</returns>
 public static bool LogOut()
 {
     LogedInUser = null;
     return true;
 }
Ejemplo n.º 5
0
 /// <summary></summary>
 public static void Initialize()
 {
     LogedInUser = null;
 }