public Form_Answer(Volunteer user, Question question)
        {
            InitializeComponent();

            currentquestion = question;
            currentuser = user;
        }
 public bool DeleteVolunteer(Volunteer volunteer)
 {
     if (userhandler.DeleteUser(volunteer))
         return true;
     else
         return false;
 }
 // Constructors
 public Appointment(Client client, Volunteer volunteer,DateTime date, string location)
 {
     this.client = client;
     this.volunteer = volunteer;
     this.date = date;
     this.location = location;
 }
 // Constructor
 public Review(DateTime date, Client client,Volunteer targetuser,int rating, string content)
 {
     Rating = rating;
     Targetuser = targetuser;
     Client = client;
     Content = content;
     Date = date;
 }
 public Form_AcceptQuestion(Volunteer user, Question question)
 {
     InitializeComponent();
     volunteerhandler = new VolunteerHandler();
     currentquestion = question;
     currentuser = user;
     RefreshInterface();
 }
 public Form_MainVolunteer(User loggedinasuser)
 {
     InitializeComponent();
     currentuser = loggedinasuser as Volunteer;
     lbl_UserName.Text = currentuser.Name;
     volunteerhandler = new VolunteerHandler();
     RefreshInterface();
     timer_Refresh.Start();
 }
        // Constructor
        public Form_Profile(Volunteer volun, bool canedit)
        {
            InitializeComponent();
            volunteer = volun;

            canEdit = canedit;
            hasPicture = false;
            isChanged = false;
            InitializeInterface();
        }
        private string DownloadPhoto(Volunteer volun)
        {
            try
            {
                // Create a new WebClient instance.
                string serverpath = volun.PathToPhoto;
                int postslash = volun.PathToPhoto.LastIndexOf('/') + 1;
                int length = volun.PathToPhoto.Length;
                string tempfilename = volun.PathToPhoto.Substring(postslash, length - postslash);

                WebClient myWebClient = new WebClient();
                myWebClient.Credentials = new NetworkCredential("i259530", "temppass1");
                myWebClient.DownloadFile(serverpath, tempfilename);
                return tempfilename;
            }
            catch
            {
                return string.Empty;
            }
        }
Exemple #9
0
 public Volunteer ExtendVolunteer(Volunteer volunteer)
 {
     return(userhandler.ExtendVolunteer(volunteer));
 }
Exemple #10
0
 public List <Review> GetMyReviews(Volunteer volun)
 {
     return(DatabaseHandler.GetMyReviews(volun));
 }
 public Volunteer ExtendVolunteer(Volunteer volun)
 {
     return(DatabaseHandler.GetVolunteerDetails(volun));
 }
 public bool UpdateVolunteer(Volunteer volun)
 {
     return DatabaseHandler.UpdateVolunteer(volun);
 }
 // TODO: NOT CORRECT
 public bool AddMeeting(Client client, Volunteer volunteer, DateTime date, string location)
 {
     Appointment meeting = new Appointment(client, volunteer, date, location);
     return false; ;
 }
 public List<Appointment> GetMyAppointments(Volunteer volun)
 {
     return DatabaseHandler.GetMyAppointments(volun);
 }
        public static List<Appointment> GetMyAppointments(Volunteer volun)
        {
            List<Appointment> returnlist = new List<Appointment>();
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT CLIENT, DATUMTIJD, LOCATIE FROM TAFSPRAAK WHERE VOLUNTEER = :newUSERID";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("newUSERID", OracleDbType.Varchar2).Value = volun.UserID;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var clientid = dr.GetInt32(0);
                    var datetime = dr.GetString(1);
                    var location = dr.GetString(2);

                    returnlist.Add(new Appointment(GetUserNoConnect(clientid) as Client, volun as Volunteer, Convert.ToDateTime(datetime), location));
                }
                return returnlist;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return returnlist;
            }
            finally
            {
                Disconnect();
            }
        }
        public static List<Review> GetAllReviews()
        {
            List<Review> returnlist = new List<Review>();
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT R.REVIEWID, R.RATING, R.TEKST, R.DATUM, C.USERID, C.NAAM, C.GEBOORTEDATUM, C.GESLACHT, C.WOONPLAATS, C.ADRES, C.EMAIL, C.WACHTWOORD, C.TYPE, "
               + "V.USERID, V.NAAM, V.GEBOORTEDATUM, V.GESLACHT, V.WOONPLAATS, V.ADRES, V.EMAIL, V.WACHTWOORD, V.TYPE FROM TUSER V, TUSER C, TREVIEW R WHERE V.USERID = R.VOLUNTEER AND C.USERID = R.CLIENT";
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var id = dr.GetInt32(0);
                    var rating = dr.GetInt32(1);
                    var content = dr.GetString(2);
                    var date = dr.GetDateTime(3);

                    var clientid = dr.GetInt32(4);
                    var clientname = dr.GetString(5);
                    var clientdob = dr.GetDateTime(6);
                    var clientgender = dr.GetString(7);
                    var clientcity = dr.GetString(8);
                    var clientaddress = dr.GetString(9);
                    var clientemail = dr.GetString(10);
                    var clientpassword = dr.GetString(11);
                    var clientype = dr.GetString(12);

                    var volunid = dr.GetInt32(13);
                    var volunname = dr.GetString(14);
                    var volundob = dr.GetDateTime(15);
                    var volungender = dr.GetString(16);
                    var voluncity = dr.GetString(17);
                    var volunaddress = dr.GetString(18);
                    var volunemail = dr.GetString(19);
                    var volunpassword = dr.GetString(20);
                    var voluntype = dr.GetString(21);

                    Client someclient = new Client(clientname, clientdob, clientgender, clientcity, clientaddress, clientemail, clientpassword);
                    someclient.UserID = clientid;
                    Volunteer somevolun = new Volunteer(volunname, volundob, volungender, voluncity, volunaddress, volunemail, volunpassword, false, "", "", "");
                    somevolun.UserID = volunid;

                    returnlist.Add(new Review(date, someclient, somevolun, rating, content));

                    returnlist[returnlist.Count - 1].ReviewID = id;
                }

                return returnlist;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
            finally
            {
                Disconnect();
            }
        }
        public static bool UpdateVolunteer(Volunteer volun)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "UPDATE TVOLUNTEER SET RIJBEWIJS = :newRIJBEWIJS, BIOGRAFIE = :newBIOGRAFIE, VOG = :newVOG, FOTO = :newFOTO WHERE USERID = " + volun.UserID;

                if(volun.DrivingLicense)
                    cmd.Parameters.Add("newRIJBEWIJS", OracleDbType.Varchar2).Value = "JA";
                else
                    cmd.Parameters.Add("newRIJBEWIJS", OracleDbType.Varchar2).Value = "NEE";

                cmd.Parameters.Add("newBIOGRAFIE", OracleDbType.Varchar2).Value = volun.Biogragphy;
                cmd.Parameters.Add("newVOG", OracleDbType.Varchar2).Value = volun.PathToVOG;
                cmd.Parameters.Add("newFOTO", OracleDbType.Varchar2).Value = volun.PathToPhoto;
                cmd.ExecuteNonQuery();

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "UPDATE TROOSTER SET MAANDAG = :newMAANDAG, DINSDAG = :newDINSDAG, WOENSDAG = :newWOENSDAG, DONDERDAG = :newDONDERDAG, VRIJDAG = :newVRIJDAG, ZATERDAG = :newZATERDAG, ZONDAG = :newZONDAG WHERE USERID = " + volun.UserID;

                cmd.Parameters.Add("newMAANDAG", OracleDbType.Varchar2).Value = volun.Schedule.Monday;
                cmd.Parameters.Add("newDINSDAG", OracleDbType.Varchar2).Value = volun.Schedule.Tuesday;
                cmd.Parameters.Add("newWOENSDAG", OracleDbType.Varchar2).Value = volun.Schedule.Wednesday;
                cmd.Parameters.Add("newDONDERDAG", OracleDbType.Varchar2).Value = volun.Schedule.Thursday;
                cmd.Parameters.Add("newVRIJDAG", OracleDbType.Varchar2).Value = volun.Schedule.Friday;
                cmd.Parameters.Add("newZATERDAG", OracleDbType.Varchar2).Value = volun.Schedule.Saturday;
                cmd.Parameters.Add("newZONDAG", OracleDbType.Varchar2).Value = volun.Schedule.Sunday;

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }
 public bool AddVolunteer(Volunteer newvolunteer)
 {
     return false;
 }
Exemple #19
0
 public bool AddVolunteer(Volunteer newvolunteer)
 {
     return(false);
 }
Exemple #20
0
        // TODO: NOT CORRECT
        public bool AddMeeting(Client client, Volunteer volunteer, DateTime date, string location)
        {
            Appointment meeting = new Appointment(client, volunteer, date, location);

            return(false);;
        }
 public bool UpdateVolunteer(Volunteer volun)
 {
     return(DatabaseHandler.UpdateVolunteer(volun));
 }
 public bool UpdateVolunteer(Volunteer volunteer)
 {
     return userhandler.UpdateVolunteer(volunteer);
 }
        public static List<Review> GetMyReviews(Volunteer volun)
        {
            List<Review> returnlist = new List<Review>();
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT CLIENT, DATUM, RATING, TEKST FROM TREVIEW WHERE VOLUNTEER = :newUSERID";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("newUSERID", OracleDbType.Varchar2).Value = volun.UserID;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var clientid = dr.GetInt32(0);
                    var datetime = dr.GetDateTime(1);
                    var rating = dr.GetInt32(2);
                    var content = dr.GetString(3);

                    returnlist.Add(new Review(datetime, GetUserNoConnect(clientid) as Client, volun , rating, content));
                }
                return returnlist;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return returnlist;
            }
            finally
            {
                Disconnect();
            }
        }
 private void btn_profile_Click(object sender, EventArgs e)
 {
     currentuser = volunteerhandler.ExtendVolunteer(currentuser);
     Form_Profile profiledialog = new Form_Profile(currentuser, true);
     timer_Refresh.Stop();
     profiledialog.ShowDialog();
     timer_Refresh.Start();
 }
 public List<Review> GetMyReviews(Volunteer volun)
 {
     return DatabaseHandler.GetMyReviews(volun);
 }
 public Volunteer ExtendVolunteer(Volunteer volun)
 {
     return DatabaseHandler.GetVolunteerDetails(volun);
 }
 public Volunteer ExtendVolunteer(Volunteer volunteer)
 {
     return userhandler.ExtendVolunteer(volunteer);
 }
Exemple #28
0
 public bool UpdateVolunteer(Volunteer volunteer)
 {
     return(userhandler.UpdateVolunteer(volunteer));
 }
        private bool UploadPhoto(Volunteer volun)
        {
            try
            {
                // Create a new WebClient instance.
                if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    string fileName = openFileDialog.FileName;
                    string filetype = fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'));
                    string tempcopy = "IMG" + volun.UserID + filetype;
                    string destination = uriString + @"/" + tempcopy;
                    if (hasPicture)
                        File.Delete(imgpath);
                    File.Copy(fileName, tempcopy);

                    WebClient myWebClient = new WebClient();
                    myWebClient.Credentials = new NetworkCredential("i259530", "temppass1");
                    byte[] responseArray = myWebClient.UploadFile(destination, tempcopy);

                    DatabaseHandler.UpdatePhoto(destination, volun.UserID);
                    File.Delete(tempcopy);

                    volun.PathToPhoto = destination;
                    return true;
                }
                return false;
            }
            catch
            {
                MessageBox.Show("Upload Failed.");
                return false;
            }
        }
Exemple #30
0
 public List <Appointment> GetMyAppointments(Volunteer volun)
 {
     return(DatabaseHandler.GetMyAppointments(volun));
 }
        public static User GetUser(int ids)
        {
            User toadd = null;
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT USERID, NAAM, GEBOORTEDATUM, GESLACHT, WOONPLAATS, ADRES, EMAIL, WACHTWOORD, TYPE FROM TUSER WHERE USERID = " + ids; // QUERY
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                Disconnect();
                return null;
            }

            try
            {
                while (dr.Read())
                {
                    // Read from DB
                    var id = dr.GetInt32(0);
                    var name = dr.GetString(1);
                    var dateOfBirth = dr.GetDateTime(2);
                    var gender = dr.GetString(3);
                    var city = dr.GetString(4);
                    var adress = dr.GetString(5);
                    var email = dr.GetString(6);
                    var password = dr.GetString(7);

                    var type = dr.GetString(8);

                    switch (type)
                    {
                        case "CLIENT":
                            Client newClient = new Client(name, dateOfBirth, gender, city, adress, email, password);
                            toadd = newClient;
                            toadd.UserID = id;
                            break;
                        case "VOLUNTEER":
                            toadd = null;
                            Volunteer newUser = new Volunteer(name, dateOfBirth, gender, city, adress, email, password, false, "Niet Opgegeven", "ONBEKEND", "ONBEKEND");
                            toadd = newUser;
                            toadd.UserID = id;
                            break;
                        case "ADMIN":
                            Admin newAdmin = new Admin(name, dateOfBirth, gender, city, adress, email, password);
                            toadd = newAdmin;
                            toadd.UserID = id;
                            break;
                        default:
                            toadd = null;
                            break;
                    }

                }
                Disconnect();
                return toadd;
            }
            catch (InvalidCastException ex)
            {
                Disconnect();
                MessageBox.Show(ex.ToString());
                return null;
            }
        }
        private bool DownloadVOG(Volunteer volun)
        {
            try
            {
                // Create a new WebClient instance.
                string serverpath = volun.PathToVOG;
                string tempfilename = "VOG" + volun.UserID + ".pdf";

                WebClient myWebClient = new WebClient();
                myWebClient.Credentials = new NetworkCredential("i259530", "temppass1");
                myWebClient.DownloadFile(serverpath, tempfilename);

                if (DialogResult.OK == saveFileDialog.ShowDialog())
                {
                    string newfilename = saveFileDialog.FileName;
                    File.Copy(tempfilename, newfilename);
                }
                File.Delete(tempfilename);
                return true;
            }
            catch
            {
                MessageBox.Show("Download Failed.");
                return false;
            }
        }
        public static Volunteer GetVolunteerDetails(Volunteer volun)
        {
            Volunteer toget = volun;
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT V.BIOGRAFIE, V.FOTO, V.VOG, V.RIJBEWIJS, R.MAANDAG, R.DINSDAG, R.WOENSDAG, R.DONDERDAG, R.VRIJDAG, R.ZATERDAG, R.ZONDAG FROM TVOLUNTEER V, TROOSTER R WHERE V.USERID = " + toget.UserID + " AND R.USERID = " + toget.UserID;
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    // Read from DB
                    var bio = SafeReadString(dr, 0);
                    var photo = SafeReadString(dr, 1);
                    var vog = SafeReadString(dr, 2);
                    var license = SafeReadString(dr, 3);
                    var monday = SafeReadString(dr, 4);
                    var tuesday = SafeReadString(dr, 5);
                    var wednesday = SafeReadString(dr, 6);
                    var thursday = SafeReadString(dr, 7);
                    var friday = SafeReadString(dr, 8);
                    var saturday = SafeReadString(dr, 9);
                    var sunday = SafeReadString(dr, 10);

                    // Fill
                    toget.Biogragphy = bio;
                    toget.PathToPhoto = photo;
                    toget.PathToVOG = vog;
                    toget.Schedule.Monday = monday;
                    toget.Schedule.Tuesday = tuesday;
                    toget.Schedule.Wednesday = wednesday;
                    toget.Schedule.Thursday = thursday;
                    toget.Schedule.Friday = friday;
                    toget.Schedule.Saturday = saturday;
                    toget.Schedule.Sunday = sunday;
                    if (license == "JA")
                        toget.DrivingLicense = true;
                    else
                        toget.DrivingLicense = false;

                }

                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT ROUND(SUM(RATING)/COUNT(RATING)*2, 1) FROM TREVIEW WHERE VOLUNTEER = " + toget.UserID;
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    // Read from DB
                    var rating = SafeReadDecimal(dr, 0);

                    // Fill
                    toget.Rating = rating;
                }
                return toget;
            }
            catch (InvalidCastException ex)
            {
                MessageBox.Show(ex.ToString());
                return null;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Checks and preocesses all form data.
        /// </summary>
        /// <returns>The volunteer or client if succesfull, otherwise null</returns>
        private User CheckAndReadEverything()
        {
            string email, password, name, gender, city, address;
            DateTime dateofbirth;

            // E-Mail
            email = tbox_Email.Text;
            if(!email.Contains('@'))
            {
                MessageBox.Show("Er is geen valide email ingevuld");
                return null;
            }
            // Password
            password = tbox_Password.Text;
            if(password.Length < 5)
            {
                MessageBox.Show("Lengte van wachtwoord moet minimaal 5 tekens zijn");
                return null;
            }
            // Name
            name = tbox_Name.Text;
            // TODO: Add checks?
            // Gender
            if(cbox_Gender.Text == "Man")
            {
                gender = "M";
            }
            else
            {
                gender = "V";
            }
            // City
            city = tbox_City.Text;
            // Address
            address = tbox_Address.Text;
            // Date of Birth
            dateofbirth = dtp_DateOfBirth.Value;
            if(rbtn_Volunteer.Checked)
            {
                if (vogpending)
                {
                    Volunteer newVolunteer = new Volunteer(name, dateofbirth, gender, city, address, email, password, false, "", vogpath, "");
                    return newVolunteer;
                }
                else
                {
                    MessageBox.Show("Upload eerst je VOG");
                    return null;
                }
            }
            else
            {
                Client newClient = new Client(name, dateofbirth, gender, city, address, email, password);
                return newClient;
            }
        }