コード例 #1
0
        public Form_Answer(Volunteer user, Question question)
        {
            InitializeComponent();

            currentquestion = question;
            currentuser = user;
        }
コード例 #2
0
 public bool UpdateQuestion(Question questiontoupdate)
 {
     if (DatabaseHandler.UpdateQuestion(questiontoupdate))
         return true;
     else
         return false;
 }
コード例 #3
0
 public bool DeleteQuestion(Question question)
 {
     if (DatabaseHandler.DeleteQuestion(question.ID))
         return true;
     else
         return false;
 }
コード例 #4
0
 public bool AddQuestion(Question question)
 {
     if (DatabaseHandler.AddQuestion(question))
         return true;
     else
         return false;
 }
コード例 #5
0
 public Form_AcceptQuestion(Volunteer user, Question question)
 {
     InitializeComponent();
     volunteerhandler = new VolunteerHandler();
     currentquestion = question;
     currentuser = user;
     RefreshInterface();
 }
コード例 #6
0
 // Methods
 public bool AddQuestion(int auteur, string location, string content)
 {
     Question newQuestion = new Question(CurrentUser, auteur, location, content, DateTime.Now);
     if (questionhandler.AddQuestion(newQuestion))
     {
         return true;
     }
     return false;
 }
コード例 #7
0
        // 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;
        }
コード例 #8
0
 // Properties
 // Methods
 public bool DeleteQuestion(Question helprequest)
 {
     return questionhandler.DeleteQuestion(helprequest);
 }
コード例 #9
0
 // Methods
 public bool AnswerQuestion(Question question, string answer)
 {
     questions.QuestionList.Find(x => x.Auteur == question.Auteur).Answer = answer;
     return true;
 }
コード例 #10
0
 public bool UpdateQuestion(Question questiontoupdate)
 {
     if (questions.UpdateQuestion(questiontoupdate))
         return true;
     else
         return false;
 }
コード例 #11
0
 // Methods
 public bool AnswerQuestion(Question question, string answer)
 {
     questions.QuestionList.Find(x => x.Auteur == question.Auteur).Answer = answer;
     return(true);
 }
コード例 #12
0
 // Constructor
 public Form_Review(Question question)
 {
     InitializeComponent();
     currentquestion = question;
 }
コード例 #13
0
        public static bool AddQuestion(Question newquestion)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                    "Insert into TQUESTION(AUTEUR, VRAAG, BIJZONDERHEID, LOCATIE, AFSTAND, VERVOER, DATUM, OPGELOST) VALUES (:NewAUTEUR, :NewVRAAG, :NewBIJZONDERHEID, :NewLOCATIE, :NewAFSTAND, :NewVERVOER, :NewDATUM, :NewOPGELOST)";

                cmd.Parameters.Add("NewAUTEUR", OracleDbType.Int32).Value = newquestion.Auteur;
                cmd.Parameters.Add("NewVRAAG", OracleDbType.Varchar2).Value = newquestion.Content;
                cmd.Parameters.Add("NewBIJZONDERHEID", OracleDbType.Varchar2).Value = newquestion.Discrepancy;
                cmd.Parameters.Add("NewLOCATIE", OracleDbType.Varchar2).Value = newquestion.Location;
                cmd.Parameters.Add("NewAFSTAND", OracleDbType.Varchar2).Value = newquestion.Distance;
                cmd.Parameters.Add("NewVERVOER", OracleDbType.Varchar2).Value = newquestion.Transport;
                cmd.Parameters.Add("NewDATUM", OracleDbType.Varchar2).Value = newquestion.Date.ToString("dd-MMM-yy");
                cmd.Parameters.Add("NewOPGELOST", OracleDbType.Varchar2).Value = newquestion.Solved;

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }
コード例 #14
0
        public static List<Question> GetAllQuestions()
        {
            List<Question> questionlist = new List<Question>();
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText = "SELECT QUESTIONID, AUTEUR, VRAAG , BIJZONDERHEID, LOCATIE, AFSTAND , VERVOER , DATUM , OPGELOST, ANTWOORD, VOLUNTEERID FROM TQUESTION"; // 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 questionid = dr.GetInt32(0);
                    var auteur = dr.GetInt32(1);
                    var vraag = SafeReadString(dr, 2);
                    var bijzonderheid = SafeReadString(dr, 3);
                    var locatie = SafeReadString(dr, 4);
                    var afstand = SafeReadString(dr, 5);
                    var vervoer = SafeReadString(dr, 6);
                    DateTime datum = dr.GetDateTime(7);
                    var opgelost = SafeReadString(dr, 8);
                    var antwoord = SafeReadString(dr, 9);
                    int volunteerid = SafeReadInt(dr, (10));

                    Question toadd;
                    toadd = new Question(null, auteur, locatie, vervoer, afstand, bijzonderheid, vraag, datum, opgelost);
                    toadd.ID = questionid;
                    toadd.Answer = antwoord;
                    toadd.VolunteerID = volunteerid;
                    questionlist.Add(toadd);
                }
                foreach (Question q in questionlist)
                {
                    q.Client = (Client)GetUser(q.Auteur);
                }

                foreach (Question q in questionlist)
                {
                    if (q.VolunteerID != -1)
                    {
                        q.Volunteer = (Volunteer)GetUser(q.VolunteerID);
                    }
                }
                return questionlist;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
コード例 #15
0
        public static bool UpdateQuestion(Question question)
        {
            try
            {
                Connect();
                cmd = new OracleCommand();
                cmd.Connection = con;
                cmd.CommandText =
                   "UPDATE TQUESTION SET VRAAG = :newContent, BIJZONDERHEID =  :newDiscripancy, LOCATIE = :newLocation, AFSTAND = :newDistance, VERVOER = :newTransport, DATUM = :newDate, OPGELOST =:newSolved, ANTWOORD = :newAnswer, VOLUNTEERID = :newVolunteer WHERE QUESTIONID = :newIDvalue";

                cmd.Parameters.Add("newContent", OracleDbType.Varchar2).Value = question.Content;
                cmd.Parameters.Add("newDiscripancy", OracleDbType.Varchar2).Value = question.Discrepancy;
                cmd.Parameters.Add("newLocation", OracleDbType.Varchar2).Value = question.Location;
                cmd.Parameters.Add("newDistance", OracleDbType.Varchar2).Value = question.Distance;
                cmd.Parameters.Add("newTransport", OracleDbType.Varchar2).Value = question.Transport;
                cmd.Parameters.Add("newDate", OracleDbType.Date).Value = question.Date.ToString("dd-MMM-yy");
                cmd.Parameters.Add("newSolved", OracleDbType.Varchar2).Value = question.Solved;
                cmd.Parameters.Add("newAnswer", OracleDbType.Varchar2).Value = question.Answer;

                if (question.Volunteer == null)
                {
                    cmd.Parameters.Add("newVolunteer", OracleDbType.Int32).Value = null;
                }
                else
                {
                    cmd.Parameters.Add("newVolunteer", OracleDbType.Int32).Value = question.Volunteer.UserID;
                }
                cmd.Parameters.Add("newIDvalue", OracleDbType.Int32).Value = question.ID;

                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }