示例#1
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            SqlConnector sqlConnector = new SqlConnector(isAdd, backupCheckBox.Checked);

            if (sourceComboBox.SelectedIndex == 0)
            {
                List <GFModel> modelsGF = new List <GFModel>();

                try
                {
                    modelsGF = ImportGF.ParseHTML(inputFilePath);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid file");

                    return;
                }

                try
                {
                    sqlConnector.CreateGF(modelsGF);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error connecting to the Database");
                }
            }
            else if (sourceComboBox.SelectedIndex == 1)
            {
                List <MALModel> modelsMAL = new List <MALModel>();

                try
                {
                    modelsMAL = ImportMAL.ParseXML(inputFilePath);
                }
                catch (Exception)
                {
                    MessageBox.Show("Invalid file");

                    return;
                }

                try
                {
                    sqlConnector.CreateMAL(modelsMAL);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error connecting to the Database");
                }
            }
        }
示例#2
0
        private void SaveAsButton_Click(object sender, EventArgs e)
        {
            CheckOutputType();

            SaveFileDialog saveFile = new SaveFileDialog
            {
                Filter = $"{outputFileType} (*.{outputFileType})|*.{outputFileType}",
                Title  = $"Save as {outputFileType} File"
            };

            if (saveFile.ShowDialog() == DialogResult.OK)
            {
                outputFilePath = saveFile.FileName;

                if (sourceComboBox.SelectedIndex == 0)
                {
                    List <GFModel> modelsGF = new List <GFModel>();

                    try
                    {
                        modelsGF = ImportGF.ParseHTML(inputFilePath);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Invalid file");

                        return;
                    }

                    if (outputFileType == "txt")
                    {
                        ExportTXT exportTXT = new ExportTXT(modelsGF, outputFilePath);
                    }
                    else if (outputFileType == "csv")
                    {
                        ExportCSV exportCSV = new ExportCSV(modelsGF, outputFilePath);
                    }
                }
                else if (sourceComboBox.SelectedIndex == 1)
                {
                    List <MALModel> modelsMAL = new List <MALModel>();

                    try
                    {
                        modelsMAL = ImportMAL.ParseXML(inputFilePath);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Invalid file");

                        return;
                    }

                    if (outputFileType == "txt")
                    {
                        ExportTXT exportTXT = new ExportTXT(modelsMAL, outputFilePath);
                    }
                    else if (outputFileType == "csv")
                    {
                        ExportCSV exportCSV = new ExportCSV(modelsMAL, outputFilePath);
                    }
                }
            }
        }