private void MainWindow_Load(object sender, EventArgs e) { bool internet = false; /*新建fp文件 用于存放选择的端口号*/ FileStream fport = new FileStream("fp", FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fport); sw.Close(); oneCard = new OneCard(); manage = new Manage(); lost = new Lost(); internet = InternetCheck.IsConnectInternet(); if (internet) { SLB_Internet.Text = "已接入互联网"; DataTable dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0); OparateMySQL.UpdateToMySQL(dt, 0); dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1); OparateMySQL.UpdateToMySQL(dt, 1); } else { SLB_Internet.Text = "未接入互联网"; } }
private void MainWindow_FormClosed(object sender, FormClosedEventArgs e) { if (SLB_Internet.Text.ToString() == "已接入互联网") { DataTable dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0); OparateMySQL.UpdateToMySQL(dt, 0); dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1); OparateMySQL.UpdateToMySQL(dt, 1); } }