示例#1
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Test not selected.", "Export", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if ((fileName == "") || (fileName == null))
            {
                MessageBox.Show("File name not set.", "Export test", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (showSaveDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            int testId = (int)dataGridView1.SelectedRows[0].Cells[0].Value;

            ImEx imEx = new ImEx();

            if (((Connection)connectionComboBox.SelectedItem).DbType == Connection.Type.Sql)
            {
                imEx.InitSQLConnection(((Connection)connectionComboBox.SelectedItem).ServerName,
                                       ((Connection)connectionComboBox.SelectedItem).DbName,
                                       ((Connection)connectionComboBox.SelectedItem).UserName,
                                       ((Connection)connectionComboBox.SelectedItem).Password);
            }
            else
            {
                imEx.InitAccessConnection(((Connection)connectionComboBox.SelectedItem).FileName);
            }
            ProcessingForm pc = new ProcessingForm();

            pc.Show();
            pc.Caption   = "Export test";
            pc.Operation = "Exporting...";
            pc.StartSomeProcess();
            imEx.theadFilePath = fileName;
            imEx.theadTestId   = testId;
            Thread t = new Thread(new ThreadStart(imEx.ExportTestOnNewTheader));

            t.Start();
            while (t.ThreadState != ThreadState.Stopped)
            {
                pc.ReDrowProgress();
            }
            pc.Close();
            pc.Dispose();
            MessageBox.Show("Test is exported.", "Export test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            DialogResult = DialogResult.OK;
        }
示例#2
0
 private void impotrFromTypedTextFile_Click(object sender, EventArgs e)
 {
     if (showOpenDialog("Gmat test files(*.txt)|*.txt|All files (*.*)|*.*") == DialogResult.OK)
     {
         ImEx imEx = new ImEx();
         if (((Connection)connectionComboBox.SelectedItem).DbType == Connection.Type.Sql)
         {
             imEx.InitSQLConnection(((Connection)connectionComboBox.SelectedItem).ServerName,
                                    ((Connection)connectionComboBox.SelectedItem).DbName,
                                    ((Connection)connectionComboBox.SelectedItem).UserName,
                                    ((Connection)connectionComboBox.SelectedItem).Password);
         }
         else
         {
             imEx.InitAccessConnection(((Connection)connectionComboBox.SelectedItem).DbName);
         }
         try
         {
             ProcessingForm pc = new ProcessingForm();
             pc.Show();
             pc.Caption   = "Import test";
             pc.Operation = "Importing...";
             pc.StartSomeProcess();
             imEx.theadFilePath = textBoxFileName.Text;
             Thread t = new Thread(new ThreadStart(imEx.ImportTestOnNewTheader));
             t.Start();
             while (t.ThreadState != ThreadState.Stopped)
             {
                 pc.ReDrowProgress();
             }
             pc.Close();
             pc.Dispose();
             MessageBox.Show("Test is imported.", "Import test", MessageBoxButtons.OK, MessageBoxIcon.Information);
             DialogResult = DialogResult.OK;
         }
         catch
         {
             MessageBox.Show("File isn't GmatClubTest file.", "Import test", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
             textBoxFileName.Text = "";
         }
     }
 }
示例#3
0
        private void importButton_Click(object sender, EventArgs e)
        {
            if ((fileName == "") || (fileName == null))
            {
                MessageBox.Show("File name not specified.", "Import test", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (showOpenDialog("Gmat test files(*.gtf)|*.gtf|All files (*.*)|*.*") != DialogResult.OK)
                {
                    return;
                }
            }

            ImEx imEx = new ImEx();

            if (((Connection)connectionComboBox.SelectedItem).DbType == Connection.Type.Sql)
            {
                imEx.InitSQLConnection(((Connection)connectionComboBox.SelectedItem).ServerName,
                                       ((Connection)connectionComboBox.SelectedItem).DbName,
                                       ((Connection)connectionComboBox.SelectedItem).UserName,
                                       ((Connection)connectionComboBox.SelectedItem).Password);
            }
            else
            {
                imEx.InitAccessConnection(((Connection)connectionComboBox.SelectedItem).FileName);
            }
            bool isUpdate = false;

            for (int i = 0; i < dataset1.Tests.Count; ++i)
            {
                if (dataset1.Tests[i].GUID == fileDataset.Tests[0].GUID)
                {
                    if (
                        MessageBox.Show(
                            "Test ' " + dataset1.Tests[i].Name + "' version " + dataset1.Tests[i].Version +
                            " is alredy exist in databese. Updete test to version " + fileDataset.Tests[0].Version,
                            "Import test", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        imEx.DeleteOldTest(dataset1.Tests[i].Id);
                        ProcessingForm pc = new ProcessingForm();
                        pc.Show();
                        pc.Caption   = "Import test";
                        pc.Operation = "Importing...";
                        pc.StartSomeProcess();
                        imEx.theadFilePath = fileName;
                        Thread t = new Thread(new ThreadStart(imEx.ImportTestOnNewTheader));
                        t.Start();
                        while (t.ThreadState != ThreadState.Stopped)
                        {
                            pc.ReDrowProgress();
                        }
                        pc.Close();
                        pc.Dispose();
                    }
                    isUpdate = true;
                    break;
                }
            }
            if (!isUpdate)
            {
                ProcessingForm pc = new ProcessingForm();
                pc.Show();
                pc.Caption   = "Import test";
                pc.Operation = "Importing...";
                pc.StartSomeProcess();
                imEx.theadFilePath = fileName;
                Thread t = new Thread(new ThreadStart(imEx.ImportTestOnNewTheader));
                t.Start();
                while (t.ThreadState != ThreadState.Stopped)
                {
                    pc.ReDrowProgress();
                }
                pc.Close();
                pc.Dispose();
            }
            MessageBox.Show("Test is imported.", "Import test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ((Connection)connectionComboBox.SelectedItem).Refresh();
            DialogResult = DialogResult.OK;
        }