Exemplo n.º 1
0
        private void btnLoadData_Click(object sender, EventArgs e)
        {
            if (txtPath.Text.Contains("Matches.csv"))
            {
                //Show wait cursor
                Cursor = Cursors.WaitCursor;
                if (!(txtPath.Text == null))
                {
                    //Open db connection
                    dbh.OpenConnectionToDB();
                    DataTable importData = GetDataFromCsv();
                    if (importData != null)
                    {
                        //Call save import data from db handler
                        dbh.SaveImportDataToDatabase(importData);

                        MessageBox.Show("Import Games Completed");
                        //Show normal cursor
                        Cursor = Cursors.Default;
                    }
                    dbh.CloseConnectionToDB();
                }
            }

            if (txtPath.Text.Contains("Teams.csv"))
            {
                //Show wait cursor
                Cursor = Cursors.WaitCursor;
                if (!(txtPath.Text == null))
                {
                    //Open db connection
                    dbh.OpenConnectionToDB();
                    DataTable importData = GetDataFromCsv();
                    if (importData != null)
                    {
                        //Call save import data from db handler
                        dbh.SaveImportDataToDatabase(importData, "Teams");

                        MessageBox.Show("Import Teams Completed");
                        //Show normal cursor
                        Cursor = Cursors.Default;
                    }
                    dbh.CloseConnectionToDB();
                }
            }

            if (txtPath.Text == "")
            {
                MessageHandler.ShowMessage("No filename selected.");
            }
        }