Пример #1
0
        /// <summary>
        /// Constructs a new Entity of Rating from a line from the datafiles.
        /// Should only be used when creating objects from files!
        /// </summary>
        /// <param name="line"></param>
        public Rating(string[] r)
        {
            ds = new DataSearch();
            Student s;

            try
            {
                s = ds.GetByID <Student>(Guid.Parse(r[1]));
            }
            catch (DuplicateDataException)
            {
                s = new Student();
            }
            Course c;

            try
            {
                c = ds.GetByID <Course>(Guid.Parse(r[2]));
            }
            catch (DuplicateDataException)
            {
                c = new Course();
            }
            Init(Guid.Parse(r[0]), s, c, EnumTranslator.stringToSemester[r[3]],
                 Int32.Parse(r[4]), Int32.Parse(r[5]), Int32.Parse(r[6]), Int32.Parse(r[7]),
                 Int32.Parse(r[8]), Int32.Parse(r[9]), Int32.Parse(r[10]), r[11], Int32.Parse(r[12]),
                 Boolean.Parse(r[13]), DateTime.Parse(r[14]));
        }
        /// <summary>
        /// Constructs a new Entity of Lecturer from a line from the datafiles.
        /// Should only be used when creating objects from files!
        /// </summary>
        /// <param name="line"></param>
        public Lecturer(string[] line)
        {
            DataSearch ds = new DataSearch();
            University u;

            try
            {
                u = ds.GetByID <University>(Guid.Parse(line[2]));
            }
            catch (DuplicateDataException)
            {
                u = new University();
            }
            Major m;

            try
            {
                m = ds.GetByID <Major>(Guid.Parse(line[3]));
            }
            catch (DuplicateDataException)
            {
                m = new Major();
            }
            Init(Guid.Parse(line[0]), line[1], u, m);
        }
Пример #3
0
        /// <summary>
        /// Constructs a new Entity of Course from a line from the datafiles.
        /// Should only be used when creating objects from files!
        /// </summary>
        /// <param name="line"></param>
        public Course(string[] line)
        {
            DataSearch ds = new DataSearch();

            University u;
            try
            {
                u = ds.GetByID<University>(Guid.Parse(line[2]));
            }
            catch (DuplicateDataException)
            {
                u = new University();
            }
            Lecturer l;
            try
            {
                l = ds.GetByID<Lecturer>(Guid.Parse(line[3]));
            }
            catch (DuplicateDataException)
            {
                l = new Lecturer();
            }
            Major m;
            try
            {
                m = ds.GetByID<Major>(Guid.Parse(line[5]));
            }
            catch (DuplicateDataException)
            {
                m = new Major();
            }
            Init(Guid.Parse(line[0]), line[1], u,
                l, EnumTranslator.stringToSemester[line[4]], m);
        }
Пример #4
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            DB db = new DB();

            String username = textBoxUsername.Text;
            String password = textBoxPassword.Text;

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `username`= @usn and `password` = @pass", db.GetConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;

            adapter.SelectCommand = command;

            adapter.Fill(table);

            //check if the user exists or not.
            if (table.Rows.Count > 0)
            {
                MessageBox.Show("You are logged on!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoginStatus.isLogged = true;
                object[]   values = table.Rows[0].ItemArray;
                DataSearch ds     = new DataSearch();
                University uni    = ds.GetByID <University>(Guid.Parse(values[4].ToString()));

                LoginStatus.CurrentUser = new Student(username, password, uni, values[5].ToString());

                LogenOn?.Invoke(this, new EventArgs());

                this.Close();
            }
            else
            {
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username To Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Password To Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Wrong Username Or Password", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Constructs a new Entity of Student from a line from the datafiles.
        /// Should only be used when creating objects from files!
        /// </summary>
        /// <param name="line"></param>
        public Student(string[] r)
        {
            DataSearch ds = new DataSearch();
            University u;

            try
            {
                u = ds.GetByID <University>(Guid.Parse(r[3]));
            }
            catch (DuplicateDataException)
            {
                u = new University();
            }
            Init(Guid.Parse(r[0]), r[1], r[2], u, r[5]);
        }
Пример #6
0
        /// <summary>
        /// Constructs a new Entity of Major from a line from the datafiles.
        /// Should only be used when creating objects from files!
        /// </summary>
        /// <param name="line"></param>
        public Major(string[] line)
        {
            DataSearch ds = new DataSearch();
            University u;

            try
            {
                u = ds.GetByID <University>(Guid.Parse(line[2]));
            }
            catch (DuplicateDataException)
            {
                u = new University();
            }
            Init(Guid.Parse(line[0]), line[1], u);;
        }