Exemplo n.º 1
0
 public Requisition(int RequisitionID, Project ReqProject, DMLUser User, DateTime ReqDate)
 {
     this.RequisitionID = RequisitionID;
     this.ReqProject    = ReqProject;
     this.User          = User;
     this.ReqDate       = ReqDate;
 }
Exemplo n.º 2
0
 public Delivery(int DeliveryID, Project DelProject, DMLUser User, DateTime DelDate)
 {
     this.DeliveryID = DeliveryID;
     this.DelProject = DelProject;
     this.User       = User;
     this.DelDate    = DelDate;
 }
Exemplo n.º 3
0
        private bool checkStudent(DMLUser tmpUser)
        {
            if (!Helpers.verifySGBDConnection(cn))
            {
                throw new Exception("Cannot connect to database.");
            }
            bool       result  = false;
            SqlCommand cmdType = new SqlCommand("SELECT * FROM DML.Student WHERE NumMec=@nummec");

            cmdType.Parameters.Clear();
            cmdType.Parameters.AddWithValue("@nummec", tmpUser.NumMec);
            cmdType.Connection = cn;
            SqlDataReader typeData = cmdType.ExecuteReader();

            if (typeData.HasRows)
            {
                typeData.Read();
                user = new Student(
                    tmpUser.NumMec,
                    tmpUser.FirstName,
                    tmpUser.LastName,
                    tmpUser.Email,
                    tmpUser.PathToImage,
                    typeData["Course"].ToString()
                    );
                result = true;
            }
            cn.Close();
            return(result);
        }
Exemplo n.º 4
0
        public HomeWindow(DMLUser user)
        {
            InitializeComponent();

            this.User = user;

            // Set user name label and image
            user_name.Content = _user.FirstName + " " + _user.LastName;
            if (!String.IsNullOrEmpty(_user.PathToImage))
            {
                // Try to load image
                try
                {
                    profile_image.Source = new BitmapImage(new Uri(_user.PathToImage, UriKind.Absolute));
                }
                catch (Exception exc)
                {
                }
            }

            // Show home page
            Home page = new Home(_user.NumMec);

            frame.Navigate(page);
        }
Exemplo n.º 5
0
 public void addWorker(DMLUser worker)
 {
     if (worker == null)
     {
         throw new Exception("Trying to add invalid user to project!");
     }
     _workers.Add(worker);
 }
Exemplo n.º 6
0
        private bool checkLogin()
        {
            if (String.IsNullOrEmpty(email_box.Text) || String.IsNullOrEmpty(password_box.Password))
            {
                throw new Exception("You must enter both fields to log in!");
            }
            bool          result = false;
            SqlCommand    cmd;
            SqlDataReader userData;
            DMLUser       tmpUser;

            try {
                cn = Helpers.getSGBDConnection();
                if (!Helpers.verifySGBDConnection(cn))
                {
                    throw new Exception("Cannot connect to database");
                }
                cmd = new SqlCommand("SELECT * FROM DML.CHECK_LOGIN (@email, @password)", cn);
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@email", email_box.Text);
                cmd.Parameters.AddWithValue("@password", password_box.Password);
                userData = cmd.ExecuteReader();
                if (userData.HasRows)
                {
                    userData.Read();
                    tmpUser = new DMLUser(
                        int.Parse(userData["NumMec"].ToString()),
                        userData["FirstName"].ToString(),
                        userData["LastName"].ToString(),
                        userData["Email"].ToString(),
                        userData["PathToImage"].ToString()
                        );

                    cn.Close();

                    // Check if it is professor, student or staff
                    if (checkProfessor(tmpUser))
                    {
                        result = true;
                    }
                    if (!result && checkStudent(tmpUser))
                    {
                        result = true;
                    }
                }
                else if (!checkStaff())
                {
                    throw new Exception("User and/or password are incorrect!");
                }
                result = true;
            } catch (SqlException e) {
                throw e;
            } finally {
                cn.Close();
            }

            return(result);
        }
Exemplo n.º 7
0
 public bool removeWorker(DMLUser worker)
 {
     if (_workers.Contains(worker))
     {
         _workers.Remove(worker);
         return(true);
     }
     return(false);
 }
Exemplo n.º 8
0
 private void project_members_listbox_MouseDoubleClick(object sender, RoutedEventArgs e)
 {
     // Go to selected member's page
     if (project_members.SelectedItem != null)
     {
         DMLUser    user   = project_members.SelectedItem as DMLUser;
         HomeWindow window = (HomeWindow)Window.GetWindow(this);
         window.goToUserPage(user);
     }
 }
Exemplo n.º 9
0
 public bool hasWorker(DMLUser user)
 {
     foreach (DMLUser worker in _workers)
     {
         if (worker.NumMec == user.NumMec)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 10
0
        public UserPage(DMLUser User)
        {
            InitializeComponent();
            this.User        = User;
            RequisitionsData = new ObservableCollection <Requisition>();
            // Set user's infos
            user_name.Text  = _user.FirstName + ' ' + _user.LastName;
            user_email.Text = _user.Email;
            user_nmec.Text  = _user.NumMec.ToString();
            if (!String.IsNullOrEmpty(_user.PathToImage))
            {
                // Try to load image
                try {
                    user_image.Source = new BitmapImage(new Uri(_user.PathToImage, UriKind.Absolute));
                } catch (Exception e)
                {
                }
            }

            // Change label text based on user type (student or professor)
            if (typeof(Professor).IsInstanceOfType(this.User))
            {
                course_area.Content   = "Scientific Area";
                user_course_area.Text = ((Professor)_user).ScientificArea;
            }
            else
            {
                course_area.Content   = "Course";
                user_course_area.Text = ((Student)_user).Course;
            }
            try
            {
                // Load user's requisitions
                loadRequisitions();
            }
            catch (SqlException exc)
            {
                Helpers.ShowCustomDialogBox(exc);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            user_last_requisitions_list.ItemsSource = RequisitionsData;
        }
Exemplo n.º 11
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     user  = null;
     staff = null;
     try
     {
         // Check for valid credentials
         bool logged = checkLogin();
         if (logged)
         {
             // Go to user's window, based on it's class (user or staff)
             if (user != null)
             {
                 HomeWindow home = new HomeWindow(user);
                 home.Show();
             }
             else if (staff != null)
             {
                 StaffWindow staffHome = new StaffWindow(staff);
                 staffHome.Show();
             }
             Window.GetWindow(this).Hide();
         }
         else
         {
             MessageBox.Show("User or password wrong !");
         }
     }
     catch (SqlException exc)
     {
         Helpers.ShowCustomDialogBox(exc);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
        public void goToUserPage(DMLUser user)
        {
            UserPage page = new UserPage(user);

            frame.Navigate(page);
        }