private void ShowDataUpdate(TableType lottotype, DataTable tblCsvFile) //顯示資料更新結果 { CGLDataSet DataSet00 = new CGLDataSet(lottotype); #region Show in Web(html) string strCurrentDirectory = System.IO.Directory.GetCurrentDirectory(); string strHtmlDirectory = System.IO.Path.Combine(strCurrentDirectory, "html"); string strFileName = string.Format("update_{0}.html", DataSet00.ID); //StuGLSearch stuSearch00 = new StuGLSearch(); new CGLFunc().FileExist(strHtmlDirectory, strFileName); //if (System.IO.File.Exists(System.IO.Path.Combine(strHtmlDirectory, strFileName))) //{ // System.IO.File.Delete(System.IO.Path.Combine(strHtmlDirectory, strFileName)); //} //System.IO.File.Create(System.IO.Path.Combine(strHtmlDirectory, strFileName)); StringBuilder stringbuilder = new StringBuilder(); stringbuilder.AppendLine("<!DOCTYPE html>"); stringbuilder.AppendLine("<html lang = 'zh-tw' xmlns = 'http://www.w3.org/1999/xhtml' >"); stringbuilder.AppendLine("<head>"); stringbuilder.AppendLine(string.Format("<title>{0}資料更新</title>", DataSet00.LottoDescription)); stringbuilder.AppendLine("<meta charset = 'utf-8' />"); stringbuilder.AppendLine("<link rel = 'stylesheet' href = '../css/glmain.css' />"); stringbuilder.AppendLine("</head>"); stringbuilder.AppendLine("<body>"); stringbuilder.AppendLine("<table>"); stringbuilder.AppendLine(string.Format("<caption>{0} 資料更新</caption>", DataSet00.LottoDescription)); stringbuilder.AppendLine("<thead>"); stringbuilder.AppendLine("<tr>"); foreach (DataColumn dcColumn in tblCsvFile.Columns) { stringbuilder.AppendLine(string.Format("<th id='{0}' class='{0}' >", dcColumn.ColumnName)); stringbuilder.AppendLine(new CGLFunc().ConvertFieldNameID(dcColumn.ColumnName, 1)); stringbuilder.AppendLine("</th>"); } stringbuilder.AppendLine("</tr>"); stringbuilder.AppendLine("</thead>"); stringbuilder.AppendLine("<tbody>"); foreach (DataRow drRow in tblCsvFile.Rows) { stringbuilder.AppendLine("<tr>"); for (int intcolumn = 0; intcolumn < tblCsvFile.Columns.Count; intcolumn++) { stringbuilder.AppendLine("<td>"); stringbuilder.AppendLine(new CGLFunc().ConvertNameID(drRow[intcolumn].ToString(), 1)); stringbuilder.AppendLine("</td>"); } stringbuilder.AppendLine("</tr>"); } stringbuilder.AppendLine("</tbody>"); stringbuilder.AppendLine("</table>"); stringbuilder.AppendLine("</body>"); stringbuilder.AppendLine("</html>"); System.IO.File.WriteAllText(System.IO.Path.Combine(strHtmlDirectory, strFileName), stringbuilder.ToString(), Encoding.UTF8); Process.Start(System.IO.Path.Combine(strHtmlDirectory, strFileName)); #endregion }
public void ShowLastNumbers() //顯示末期資料 { CGLDataSet GLdataSet00 = new CGLDataSet(TableType.LottoBig); #region Set LottoType dictionary Dictionary <int, TableType> lottoType = new Dictionary <int, TableType>(); Dictionary <int, RoutedEventHandler> dicRoutedEventHandler = new Dictionary <int, RoutedEventHandler>(); lottoType.Add(0, TableType.LottoBig); dicRoutedEventHandler.Add(0, new RoutedEventHandler(BtnShowAllBig_Click)); lottoType.Add(1, TableType.Lotto539); dicRoutedEventHandler.Add(1, new RoutedEventHandler(BtnShowAll539_Click)); lottoType.Add(2, TableType.LottoDafu); dicRoutedEventHandler.Add(2, new RoutedEventHandler(BtnShowAllDafu_Click)); lottoType.Add(3, TableType.LottoWeli); dicRoutedEventHandler.Add(3, new RoutedEventHandler(BtnShowAllWeli_Click)); lottoType.Add(4, TableType.LottoSix); dicRoutedEventHandler.Add(4, new RoutedEventHandler(BtnShowAllSix_Click)); #endregion //string[] strLastNumbers = new string[6]; for (int i = 1; i <= 5; i++) { #region Set Label GLdataSet00 = new CGLDataSet(lottoType[i - 1]); StackPanel wp001 = new StackPanel() { Height = 32, VerticalAlignment = VerticalAlignment.Top, Orientation = System.Windows.Controls.Orientation.Horizontal }; System.Windows.Controls.Button btnShowAll = new System.Windows.Controls.Button() { Content = "全顯", Foreground = Brushes.Blue, BorderThickness = new Thickness(0.0), Margin = new Thickness(1, 1, 1, 1) }; btnShowAll.Click += dicRoutedEventHandler[i - 1]; wp001.Children.Add(btnShowAll); System.Windows.Controls.Label lbl001 = new System.Windows.Controls.Label() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right, Width = 75, Content = GLdataSet00.LottoDescription + ":" }; wp001.Children.Add(lbl001); Label lbl002 = new Label() { HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch, Width = 90 }; #endregion try { //if (oleConnect.State != ConnectionState.Connecting) oleConnect.Open(); StuGLData stuData00 = new StuGLData() { LottoType = lottoType[i - 1], DataBaseType = DatabaseType.Data, StrSELECT = " TOP 1 * ", StrFROM = "tblData", StrWHERE = string.Format("[{0}] > 0 ", "lngL1"), StrORDER = string.Format("[{0}] DESC ; ", "lngDateSN") }; DataTable endData = stuData00.GetSourceData(stuData00); #region Set Last Nums foreach (DataRow datarow00 in endData.Rows) { lbl002.Content = string.Format("{0}", datarow00["lngDateSN"]); wp001.Children.Add(lbl002); for (int Number00 = 1; Number00 <= GLdataSet00.CountNumber; Number00++) { Image pic001 = new Image() { Source = new BitmapImage( new Uri("pack://siteoforigin:,,,/Resources/N" + string.Format("{0:D2}", datarow00["lngL" + Number00.ToString()]) + ".png", UriKind.Absolute)) }; wp001.Children.Add(pic001); } if (GLdataSet00.SCountNumber > 0) { Image picspe = new Image() { Source = new BitmapImage( new Uri("pack://siteoforigin:,,,/Resources/spe.gif", UriKind.Absolute) ) }; wp001.Children.Add(picspe); Image pic001 = new Image() { Source = new BitmapImage( new Uri("pack://siteoforigin:,,,/Resources/N" + string.Format("{0:D2}", datarow00["lngS1"]) + ".png", UriKind.Absolute)) }; wp001.Children.Add(pic001); } } #endregion } catch (Exception e) { if (e.Source != null) { System.Windows.MessageBox.Show(string.Format("ShowLastNumbers:{0}", e.Message), "Error", MessageBoxButton.OK); } //throw; } spMain.Children.Add(wp001); } }