Example #1
0
 // Constructor
 public Message(int chatid, User author, DateTime date, string content)
 {
     ChatID = chatid;
     Author = author;
     Content = content;
     Date = date;
     AuthorID = author.UserID;
 }
 public Form_MainAdmin(User loggedinasuser)
 {
     InitializeComponent();
     adminhandler = new AdminHandler();
     lbl_Name.Text = loggedinasuser.Name;
     RefreshScreen();
     ignoreWarnings = false;
 }
        // Constructor
        public Form_Meeting(User client, User volunteer)
        {
            InitializeComponent();

            currentuser = client;
            targetuser = volunteer;

            lbl_VolunName.Text = targetuser.Name;
        }
 public Form_MainVolunteer(User loggedinasuser)
 {
     InitializeComponent();
     currentuser = loggedinasuser as Volunteer;
     lbl_UserName.Text = currentuser.Name;
     volunteerhandler = new VolunteerHandler();
     RefreshInterface();
     timer_Refresh.Start();
 }
 public int GetChatID(User currentuser, User otheruser)
 {
     int chatid = -1;
     if(CheckIfChatted(currentuser, otheruser, out chatid))
     {
         return chatid;
     }
     System.Windows.Forms.MessageBox.Show("Er bestaat geen chat tussen de gebruikers");
     return -1;
 }
 // Methods
 public bool StartChat(User currentuser, User otheruser)
 {
     int chatid;
     if(!CheckIfChatted(currentuser, otheruser, out chatid))
     {
         return DatabaseHandler.StartChat(currentuser, otheruser);
     }
     System.Windows.Forms.MessageBox.Show("Gebruikers hebben al een gesprek");
     return false;
 }
        public Form_MainClient(User loggedinasuser)
        {
            InitializeComponent();
            currentuser = loggedinasuser;
            lbl_UserName.Text = currentuser.Name;
            clienthandler = new ClientHandler(currentuser as Client);
            RefreshInterface();

            timer_Refresh.Start();
        }
        // Constructor
        public Form_Chat(User currentuser, User otheruser)
        {
            InitializeComponent();

            chathandler = new ChatHandler();
            currentUser = currentuser;
            otherUser = otheruser;
            snd = new SoundPlayer(Properties.Resources.Notification);
            currentchat = OpenChat(currentUser, otherUser);
            Timer_Refresh.Start();
        }
 public bool DeleteUser(User user)
 {
     try
     {
         DatabaseHandler.DeleteUser(user);
         return true;
     }
     catch
     {
         return false;
     }
 }
 public List<Question> GetQuestionsByAuthor(User author)
 {
     Synchronize();
     try
     {
         return questions.FindAll(x => x.Auteur == author.UserID);
     }
     catch (NullReferenceException ex)
     {
         return null;
     }
 }
 public bool AddUser(User user)
 {
     try
     {
         DatabaseHandler.AddUser(user);
         return true;
     }
     catch (NullReferenceException ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
         return false;
     }
 }
        // Constructor
        public Form_QuestionDetails(Question questiontoshow, Client currentuser, Review reviewtoshow)
        {
            InitializeComponent();

            this.currentuser = currentuser;
            currentreview = reviewtoshow;
            this.currentreview = reviewtoshow;
            clienthandler = new ClientHandler(this.currentuser as Client);
            currentquestion = questiontoshow;
            RefreshInterface();
            this.ActiveControl = lbl_Info1;
            isChanged = false;
        }
Example #13
0
 public Chat OpenChat(User currentuser, User otheruser)
 {
     int chatid = -1;
     if (chathandler.CheckIfChatted(currentuser, otheruser, out chatid))
     {
         // They already have a chat
         return chathandler.GetChat(chatid);
     }
     else
     {
         // They do not yet have a chat
         chathandler.StartChat(currentuser, otheruser);
         chathandler.CheckIfChatted(currentuser, otheruser, out chatid);
         return chathandler.GetChat(chatid);
     }
 }
        public static bool CheckIfHaveChat(User someuser, User anotheruser, out int chatid)
        {
            chatid = -1;
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT GESPREKID FROM TGESPREK WHERE USERID1 = " + someuser.UserID
                    + " AND USERID2 = " + anotheruser.UserID
                    + " OR USERID2 = " + someuser.UserID
                    + " AND USERID1 = " + anotheruser.UserID;
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        chatid = dr.GetInt32(0);
                        return true;
                    }
                }
                return false;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return false;
            }
            finally
            {
                Disconnect();
            }
        }
        public static void AddUser(User newuser)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                    "Insert into TUSER(NAAM, GEBOORTEDATUM, GESLACHT, WOONPLAATS, ADRES, EMAIL, WACHTWOORD, TYPE) VALUES (:NewNAAM, :NewGEBOORTEDATUM, :NewGESLACHT, :NewWOONPLAATS, :NewADRES, :NewEMAIL, :NewWACHTWOORD, :NewTYPE)";

                cmd.Parameters.Add("NewNAAM", OracleDbType.Varchar2).Value = newuser.Name;
                cmd.Parameters.Add("NewGEBOORTEDATUM", OracleDbType.Date).Value = newuser.DateOfBirth;
                cmd.Parameters.Add("NewGESLACHT", OracleDbType.Varchar2).Value = newuser.Gender; ;
                cmd.Parameters.Add("NewWOONPLAATS", OracleDbType.Varchar2).Value = newuser.City; ;
                cmd.Parameters.Add("NewADRES", OracleDbType.Varchar2).Value = newuser.Adress; ;
                cmd.Parameters.Add("NewEMAIL", OracleDbType.Varchar2).Value = newuser.Email; ;
                cmd.Parameters.Add("NewWACHTWOORD", OracleDbType.Varchar2).Value = newuser.Password;
                if (newuser is Client)
                    cmd.Parameters.Add("NewTYPE", OracleDbType.Varchar2).Value = "CLIENT";
                if (newuser is Volunteer)
                    cmd.Parameters.Add("NewTYPE", OracleDbType.Varchar2).Value = "VOLUNTEER";
                if (newuser is Admin)
                    cmd.Parameters.Add("NewTYPE", OracleDbType.Varchar2).Value = "ADMIN";
                cmd.ExecuteNonQuery();

                if(newuser is Volunteer)
                {
                    ExtendVolunteer(GetUserID(newuser.Email));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Disconnect();
            }
        }
 public bool CheckIfChatted(User currentuser, User otheruser, out int gesprekid)
 {
     return DatabaseHandler.CheckIfHaveChat(currentuser, otheruser, out gesprekid);
 }
        public static bool StartChat(User someuser, User anotheruser)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                    "Insert into TGESPREK(USERID1, USERID2) VALUES (:NewUser1, :NewUser2)";

                cmd.Parameters.Add("NewUser1", OracleDbType.Int32).Value = someuser.UserID;
                cmd.Parameters.Add("NewUser2", OracleDbType.Int32).Value = anotheruser.UserID;
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }
Example #18
0
 public bool SendMessage(int chatid, User author, string content)
 {
     return chathandler.SendMessage(new Message(chatid, currentUser, DateTime.Now, content));
 }
        public static bool DeleteUser(User usertodelete)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TUSER WHERE USERID = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TAFSPRAAK WHERE VOLUNTEER = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TAFSPRAAK WHERE CLIENT = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TCLIENT WHERE CLIENTID = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TQUESTION WHERE AUTEUR = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TREVIEW WHERE CLIENT = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TREVIEW WHERE VOLUNTEER = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TROOSTER WHERE VOLUNTEERID = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "DELETE FROM TVOLUNTEER WHERE VOLUNTEERID = :deleteIDvalue";

                cmd.Parameters.Add("deleteIDvalue", OracleDbType.Varchar2).Value = usertodelete.UserID;
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return true;

            }
        }