Exemplo n.º 1
0
 private void Button_export_Click(object sender, EventArgs e)
 {
     if (SurveyHelper.ActiveSurvey.survey_name != null)
     {
         SurveyHelper.ExportTableToCSV();
     }
 }
Exemplo n.º 2
0
        private async void Upload_btn_Click(object sender, System.EventArgs e)
        {
            var result = await FilePicker.PickAsync(new PickOptions
            {
                PickerTitle = "Select a .csv file"
            });

            if (result != null)
            {
                if (SQLiteHelper.CheckTableExistance(result.FileName))
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);

                    alert.SetTitle("Survey already exists");
                    alert.SetMessage("This survey has been uploaded before.\nDo you want to continue?\nNote: This will not overwrite the existing file.");
                    alert.SetPositiveButton("Yes", async(senderAlert, args) =>
                    {
                        // Read contents of CSV file into byte stream
                        var stream = await result.OpenReadAsync();
                        // creates a new database table for the survey but the
                        SurveyHelper.LoadSurveyFromCSV(result.FileName, stream, out string message);

                        textview_status.Text = message;
                    });
                    alert.SetNegativeButton("No", (senderAlert, args) =>
                    {
                        return;
                    });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
                else
                {
                    // Read contents of CSV file into byte stream
                    var stream = await result.OpenReadAsync();

                    SurveyHelper.LoadSurveyFromCSV(result.FileName, stream, out string message);

                    textview_status.Text = message;
                }
            }
        }