Exemplo n.º 1
0
 private void GetResponse(int responseID)
 {
     try
     {
         response = ResponsesDB.GetResponse(responseID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
Exemplo n.º 2
0
 private int GetLastResponseID(int respondentID)
 {
     try
     {
         return(ResponsesDB.GetLastResponseID(respondentID));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
         return(0);
     }
 }
Exemplo n.º 3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (ResponsesDB.DeleteResponse(Convert.ToInt32(txtResponseID.Text)))
     {
         MessageBox.Show("Response has been deleted.", "DELETED!");
     }
     else
     {
         MessageBox.Show("Response could not be deleted.", "ERROR!");
         return;
     }
 }
Exemplo n.º 4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                this.PutRespondent(respondent);
                try
                {
                    if (!RespondentsDB.AddRespondent(respondent))
                    {
                        MessageBox.Show("This email already exists. Submitting new answers.",
                                        "Database Message");
                        this.DialogResult = DialogResult.OK;

                        int respondentID = RespondentsDB.GetRespondentID(respondent.EmailAddress);
                        PutResponse(response, respondentID);
                        if (!ResponsesDB.AddResponse(response))
                        {
                            MessageBox.Show("There was some database error.", "ERROR!");
                        }
                        else
                        {
                            MessageBox.Show("Responses submitted! Thank you!", "YAY!");
                            this.DialogResult = DialogResult.OK;
                            ClearDataForm();
                        }
                    }
                    else
                    {
                        int respondentID = GetLastRespondentID();
                        PutResponse(response, respondentID);
                        if (!ResponsesDB.AddResponse(response))
                        {
                            MessageBox.Show("There was some database error.", "ERROR!");
                        }
                        else
                        {
                            MessageBox.Show("Responses submitted! Thank you!", "YAY!");
                            this.DialogResult = DialogResult.OK;
                            ClearDataForm();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
        }