Browse Source

Update

master
nelson.kai 2 years ago
parent
commit
0da614bc46
  1. 121
      Form1.Designer.cs
  2. 107
      Form1.cs
  3. 24
      Form1.resx
  4. 60
      ProgressForm.Designer.cs
  5. 25
      ProgressForm.cs
  6. 120
      ProgressForm.resx
  7. 72
      ShowForm.Designer.cs
  8. 20
      ShowForm.cs
  9. 120
      ShowForm.resx
  10. 273
      UpgradeLog.htm
  11. 206
      Utility/MySQLUtilityClass.cs
  12. 207
      Utility/OracleUtilityClass.cs
  13. 204
      Utility/PostgreSQLUtilityClass.cs

121
Form1.Designer.cs

@ -55,14 +55,6 @@ namespace ExportDataToFile
this.txtSourcePWD = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.dgvExportList = new System.Windows.Forms.DataGridView();
this.clExport = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.clCancel = new System.Windows.Forms.DataGridViewButtonColumn();
this.clShow = new System.Windows.Forms.DataGridViewButtonColumn();
this.clSourceTable = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.clTargetTable = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.clTableDel = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.clWhere = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.clMappingData = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.label11 = new System.Windows.Forms.Label();
this.dgvColumnMapping = new System.Windows.Forms.DataGridView();
this.clExpColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
@ -97,7 +89,7 @@ namespace ExportDataToFile
this.txtTargetID.Name = "txtTargetID";
this.txtTargetID.Size = new System.Drawing.Size(135, 29);
this.txtTargetID.TabIndex = 11;
this.txtTargetID.Text = "origtek";
this.txtTargetID.Text = "postgres";
//
// label7
//
@ -116,7 +108,7 @@ namespace ExportDataToFile
this.txtTargetDBName.Name = "txtTargetDBName";
this.txtTargetDBName.Size = new System.Drawing.Size(135, 29);
this.txtTargetDBName.TabIndex = 10;
this.txtTargetDBName.Text = "origtekpdb";
this.txtTargetDBName.Text = "EURO";
//
// label8
//
@ -135,7 +127,7 @@ namespace ExportDataToFile
this.txtTargetIP.Name = "txtTargetIP";
this.txtTargetIP.Size = new System.Drawing.Size(135, 29);
this.txtTargetIP.TabIndex = 8;
this.txtTargetIP.Text = "192.168.1.76";
this.txtTargetIP.Text = "localhost";
//
// label9
//
@ -180,7 +172,7 @@ namespace ExportDataToFile
this.txtSourceID.Name = "txtSourceID";
this.txtSourceID.Size = new System.Drawing.Size(135, 29);
this.txtSourceID.TabIndex = 5;
this.txtSourceID.Text = "origtek";
this.txtSourceID.Text = "sa";
//
// label4
//
@ -199,7 +191,7 @@ namespace ExportDataToFile
this.txtSourceDBName.Name = "txtSourceDBName";
this.txtSourceDBName.Size = new System.Drawing.Size(135, 29);
this.txtSourceDBName.TabIndex = 4;
this.txtSourceDBName.Text = "origtekpdb";
this.txtSourceDBName.Text = "EURO_Data";
//
// label3
//
@ -218,7 +210,7 @@ namespace ExportDataToFile
this.txtSourceIP.Name = "txtSourceIP";
this.txtSourceIP.Size = new System.Drawing.Size(135, 29);
this.txtSourceIP.TabIndex = 2;
this.txtSourceIP.Text = "192.168.1.76";
this.txtSourceIP.Text = "localhost";
//
// label2
//
@ -298,7 +290,7 @@ namespace ExportDataToFile
this.txtTargetPWD.PasswordChar = '*';
this.txtTargetPWD.Size = new System.Drawing.Size(135, 29);
this.txtTargetPWD.TabIndex = 12;
this.txtTargetPWD.Text = "!QAZ2wsx";
this.txtTargetPWD.Text = "i\'mnelson";
//
// label6
//
@ -329,7 +321,7 @@ namespace ExportDataToFile
this.txtSourcePWD.PasswordChar = '*';
this.txtSourcePWD.Size = new System.Drawing.Size(135, 29);
this.txtSourcePWD.TabIndex = 6;
this.txtSourcePWD.Text = "!QAZ2wsx";
this.txtSourcePWD.Text = "i\'mnelson";
//
// label5
//
@ -350,15 +342,6 @@ namespace ExportDataToFile
this.dgvExportList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.dgvExportList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvExportList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.clExport,
this.clCancel,
this.clShow,
this.clSourceTable,
this.clTargetTable,
this.clTableDel,
this.clWhere,
this.clMappingData});
this.dgvExportList.Location = new System.Drawing.Point(18, 125);
this.dgvExportList.Name = "dgvExportList";
this.dgvExportList.RowTemplate.Height = 25;
@ -367,76 +350,6 @@ namespace ExportDataToFile
this.dgvExportList.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvExportList_CellClick);
this.dgvExportList.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvExportList_CellContentClick);
//
// clExport
//
this.clExport.FalseValue = "false";
this.clExport.Frozen = true;
this.clExport.HeaderText = "匯出";
this.clExport.IndeterminateValue = "false";
this.clExport.Name = "clExport";
this.clExport.ReadOnly = true;
this.clExport.TrueValue = "true";
this.clExport.Width = 55;
//
// clCancel
//
this.clCancel.Frozen = true;
this.clCancel.HeaderText = "清除";
this.clCancel.Name = "clCancel";
this.clCancel.Text = "...";
this.clCancel.Width = 55;
//
// clShow
//
this.clShow.Frozen = true;
this.clShow.HeaderText = "顯示來源";
this.clShow.Name = "clShow";
this.clShow.Text = "...";
this.clShow.Width = 80;
//
// clSourceTable
//
this.clSourceTable.DataPropertyName = "TableName";
this.clSourceTable.Frozen = true;
this.clSourceTable.HeaderText = "來源資料表名稱";
this.clSourceTable.Name = "clSourceTable";
this.clSourceTable.ReadOnly = true;
this.clSourceTable.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.clSourceTable.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.clSourceTable.Width = 300;
//
// clTargetTable
//
this.clTargetTable.Frozen = true;
this.clTargetTable.HeaderText = "目標資料表名稱";
this.clTargetTable.Name = "clTargetTable";
this.clTargetTable.ReadOnly = true;
this.clTargetTable.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.clTargetTable.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.clTargetTable.Width = 300;
//
// clTableDel
//
this.clTableDel.Frozen = true;
this.clTableDel.HeaderText = "清除目標資料表內容";
this.clTableDel.Name = "clTableDel";
this.clTableDel.Width = 180;
//
// clWhere
//
this.clWhere.Frozen = true;
this.clWhere.HeaderText = "過濾條件";
this.clWhere.Name = "clWhere";
this.clWhere.Visible = false;
this.clWhere.Width = 200;
//
// clMappingData
//
this.clMappingData.Frozen = true;
this.clMappingData.HeaderText = "欄位對應";
this.clMappingData.Name = "clMappingData";
this.clMappingData.Visible = false;
//
// label11
//
this.label11.AutoSize = true;
@ -757,11 +670,6 @@ namespace ExportDataToFile
private System.Windows.Forms.ComboBox cbTargetTable;
private System.Windows.Forms.Button btnMapping;
private System.Windows.Forms.SaveFileDialog sfPath;
private System.Windows.Forms.DataGridViewCheckBoxColumn clExpColumn;
private System.Windows.Forms.DataGridViewButtonColumn clClean;
private System.Windows.Forms.DataGridViewTextBoxColumn clSourceColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn clType;
private System.Windows.Forms.DataGridViewComboBoxColumn clTargetColumn;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox txtMaxCount;
private System.Windows.Forms.Label label16;
@ -772,14 +680,11 @@ namespace ExportDataToFile
private System.Windows.Forms.Button btnImportXML;
private System.Windows.Forms.OpenFileDialog ofPath;
private System.Windows.Forms.Button btnClean;
private System.Windows.Forms.DataGridViewCheckBoxColumn clExport;
private System.Windows.Forms.DataGridViewButtonColumn clCancel;
private System.Windows.Forms.DataGridViewButtonColumn clShow;
private System.Windows.Forms.DataGridViewTextBoxColumn clSourceTable;
private System.Windows.Forms.DataGridViewTextBoxColumn clTargetTable;
private System.Windows.Forms.DataGridViewCheckBoxColumn clTableDel;
private System.Windows.Forms.DataGridViewTextBoxColumn clWhere;
private System.Windows.Forms.DataGridViewTextBoxColumn clMappingData;
private System.Windows.Forms.DataGridViewCheckBoxColumn clExpColumn;
private System.Windows.Forms.DataGridViewButtonColumn clClean;
private System.Windows.Forms.DataGridViewTextBoxColumn clSourceColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn clType;
private System.Windows.Forms.DataGridViewComboBoxColumn clTargetColumn;
}
}

107
Form1.cs

@ -46,7 +46,8 @@ namespace ExportDataToFile
private void Form1_Load(object sender, EventArgs e)
{
dgvExportList.Columns["clSourceTable"].DataPropertyName = "TableName";
ResetDataGridView();
}
private void btnSourceConnTest_Click(object sender, EventArgs e)
@ -600,15 +601,9 @@ namespace ExportDataToFile
txtTargetPWD.Text = "";
cbTargetTable.SelectedIndex = -1;
cbTargetTable.Enabled = false;
//sqlMSSourceConn.Close();
//sqlMSTargetConn.Close();
//sqlPsgSourceConn.Close();
//sqlPsgTargetConn.Close();
//sqlMySourceConn.Close();
//sqlMyTargetConn.Close();
//sqlOraSourceConn.Close();
//sqlOraTargetConn.Close();
dgvExportList.DataSource = null;
dgvColumnMapping.DataSource = null;
ResetDataGridView(); //重建DataGridView欄位
sqlMSSourceConn = null;
sqlMSTargetConn = null;
@ -2586,7 +2581,99 @@ namespace ExportDataToFile
}
}
private void ResetDataGridView()
{
#region dgvExportList
dgvExportList.Columns.Clear();
//匯出
DataGridViewCheckBoxColumn clExport = new DataGridViewCheckBoxColumn();
clExport.HeaderText = "匯出";
clExport.Name = "clExport";
clExport.Width = 50;
//清除
DataGridViewButtonColumn clCancel = new DataGridViewButtonColumn();
clCancel.HeaderText = "清除";
clCancel.Name = "clCancel";
clCancel.Width = 50;
//顯示來源
DataGridViewButtonColumn clShow = new DataGridViewButtonColumn();
clShow.HeaderText = "顯示來源";
clShow.Name = "clShow";
//來源資料表名稱
DataGridViewTextBoxColumn clSourceTable = new DataGridViewTextBoxColumn();
clSourceTable.HeaderText = "來源資料表名稱";
clSourceTable.Name = "clSourceTable";
clSourceTable.DataPropertyName = "TableName";
clSourceTable.Width = 200;
//目標資料表名稱
DataGridViewTextBoxColumn clTargetTable = new DataGridViewTextBoxColumn();
clTargetTable.HeaderText = "目標資料表名稱";
clTargetTable.Name = "clTargetTable";
clTargetTable.Width = 200;
//清除目標資料表內容
DataGridViewCheckBoxColumn clTableDel = new DataGridViewCheckBoxColumn();
clTableDel.HeaderText = "清除目標資料表內容";
clTableDel.Name = "clTableDel";
clTableDel.Width = 200;
//過濾條件
DataGridViewTextBoxColumn clWhere = new DataGridViewTextBoxColumn();
clWhere.HeaderText = "過濾條件";
clWhere.Name = "clWhere";
clWhere.Visible = false;
//欄位對應
DataGridViewTextBoxColumn clMappingData = new DataGridViewTextBoxColumn();
clMappingData.HeaderText = "欄位對應";
clMappingData.Name = "clMappingData";
clMappingData.Visible = false;
dgvExportList.Columns.Add(clExport);
dgvExportList.Columns.Add(clCancel);
dgvExportList.Columns.Add(clShow);
dgvExportList.Columns.Add(clSourceTable);
dgvExportList.Columns.Add(clTargetTable);
dgvExportList.Columns.Add(clTableDel);
dgvExportList.Columns.Add(clWhere);
dgvExportList.Columns.Add(clMappingData);
#endregion
#region dgvColumnMapping
//匯出
dgvColumnMapping.Columns.Clear();
DataGridViewCheckBoxColumn clExpColumn = new DataGridViewCheckBoxColumn();
clExpColumn.HeaderText = "匯出";
clExpColumn.Name = "clExpColumn";
clExpColumn.Width = 50;
//清除
DataGridViewButtonColumn clClean = new DataGridViewButtonColumn();
clClean.HeaderText = "清除";
clClean.Name = "clClean";
clClean.Width = 50;
//來源欄位
DataGridViewTextBoxColumn clSourceColumn = new DataGridViewTextBoxColumn();
clSourceColumn.HeaderText = "來源欄位";
clSourceColumn.Name = "clSourceColumn";
clSourceColumn.DataPropertyName = "COLUMN_NAME";
clSourceColumn.Width = 100;
//型態
DataGridViewTextBoxColumn clType = new DataGridViewTextBoxColumn();
clType.HeaderText = "型態";
clType.Name = "clType";
clType.DataPropertyName = "DATA_TYPE";
clType.Width = 100;
//目標欄位
DataGridViewComboBoxColumn clTargetColumn = new DataGridViewComboBoxColumn();
clTargetColumn.HeaderText = "目標欄位";
clTargetColumn.Name = "clTargetColumn";
clTargetColumn.Width = 100;
dgvColumnMapping.Columns.Add(clExpColumn);
dgvColumnMapping.Columns.Add(clClean);
dgvColumnMapping.Columns.Add(clSourceColumn);
dgvColumnMapping.Columns.Add(clType);
dgvColumnMapping.Columns.Add(clTargetColumn);
#endregion
}
#endregion
}
}

24
Form1.resx

@ -117,30 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="clExport.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clCancel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clShow.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clSourceTable.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clTargetTable.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clTableDel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clWhere.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clMappingData.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="clExpColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

60
ProgressForm.Designer.cs

@ -0,0 +1,60 @@

namespace ExportDataToFile
{
partial class ProgressForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pbExport = new System.Windows.Forms.ProgressBar();
this.SuspendLayout();
//
// pbExport
//
this.pbExport.Location = new System.Drawing.Point(12, 12);
this.pbExport.Name = "pbExport";
this.pbExport.Size = new System.Drawing.Size(297, 23);
this.pbExport.TabIndex = 1;
//
// ProgressForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(320, 44);
this.ControlBox = false;
this.Controls.Add(this.pbExport);
this.Name = "ProgressForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "匯出進度表";
this.ResumeLayout(false);
}
#endregion
public System.Windows.Forms.ProgressBar pbExport;
}
}

25
ProgressForm.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ExportDataToFile
{
public partial class ProgressForm : Form
{
public ProgressForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
pbExport.Value += 1;
}
}
}

120
ProgressForm.resx

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

72
ShowForm.Designer.cs

@ -0,0 +1,72 @@

namespace ExportDataToFile
{
partial class ShowForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgvShowResult = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dgvShowResult)).BeginInit();
this.SuspendLayout();
//
// dgvShowResult
//
this.dgvShowResult.AllowUserToAddRows = false;
this.dgvShowResult.AllowUserToDeleteRows = false;
this.dgvShowResult.AllowUserToOrderColumns = true;
this.dgvShowResult.AllowUserToResizeRows = false;
this.dgvShowResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvShowResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvShowResult.Location = new System.Drawing.Point(12, 12);
this.dgvShowResult.Name = "dgvShowResult";
this.dgvShowResult.RowTemplate.Height = 24;
this.dgvShowResult.Size = new System.Drawing.Size(1271, 600);
this.dgvShowResult.TabIndex = 0;
//
// ShowForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1295, 624);
this.Controls.Add(this.dgvShowResult);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ShowForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "顯示資料";
((System.ComponentModel.ISupportInitialize)(this.dgvShowResult)).EndInit();
this.ResumeLayout(false);
}
#endregion
public System.Windows.Forms.DataGridView dgvShowResult;
}
}

20
ShowForm.cs

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ExportDataToFile
{
public partial class ShowForm : Form
{
public ShowForm()
{
InitializeComponent();
}
}
}

120
ShowForm.resx

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

273
UpgradeLog.htm

@ -0,0 +1,273 @@
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html xmlns:msxsl="urn:schemas-microsoft-com:xslt"><head><meta content="en-us" http-equiv="Content-Language" /><meta content="text/html; charset=utf-16" http-equiv="Content-Type" /><title _locID="ConversionReport0">
移轉報告
</title><style>
/* Body style, for the entire document */
body
{
background: #F3F3F4;
color: #1E1E1F;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
padding: 0;
margin: 0;
}
/* Header1 style, used for the main title */
h1
{
padding: 10px 0px 10px 10px;
font-size: 21pt;
background-color: #E2E2E2;
border-bottom: 1px #C1C1C2 solid;
color: #201F20;
margin: 0;
font-weight: normal;
}
/* Header2 style, used for "Overview" and other sections */
h2
{
font-size: 18pt;
font-weight: normal;
padding: 15px 0 5px 0;
margin: 0;
}
/* Header3 style, used for sub-sections, such as project name */
h3
{
font-weight: normal;
font-size: 15pt;
margin: 0;
padding: 15px 0 5px 0;
background-color: transparent;
}
/* Color all hyperlinks one color */
a
{
color: #1382CE;
}
/* Table styles */
table
{
border-spacing: 0 0;
border-collapse: collapse;
font-size: 10pt;
}
table th
{
background: #E7E7E8;
text-align: left;
text-decoration: none;
font-weight: normal;
padding: 3px 6px 3px 6px;
}
table td
{
vertical-align: top;
padding: 3px 6px 5px 5px;
margin: 0px;
border: 1px solid #E7E7E8;
background: #F7F7F8;
}
/* Local link is a style for hyperlinks that link to file:/// content, there are lots so color them as 'normal' text until the user mouse overs */
.localLink
{
color: #1E1E1F;
background: #EEEEED;
text-decoration: none;
}
.localLink:hover
{
color: #1382CE;
background: #FFFF99;
text-decoration: none;
}
/* Center text, used in the over views cells that contain message level counts */
.textCentered
{
text-align: center;
}
/* The message cells in message tables should take up all avaliable space */
.messageCell
{
width: 100%;
}
/* Padding around the content after the h1 */
#content
{
padding: 0px 12px 12px 12px;
}
/* The overview table expands to width, with a max width of 97% */
#overview table
{
width: auto;
max-width: 75%;
}
/* The messages tables are always 97% width */
#messages table
{
width: 97%;
}
/* All Icons */
.IconSuccessEncoded, .IconInfoEncoded, .IconWarningEncoded, .IconErrorEncoded
{
min-width:18px;
min-height:18px;
background-repeat:no-repeat;
background-position:center;
}
/* Success icon encoded */
.IconSuccessEncoded
{
/* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */
/* [---XsltValidateInternal-Base64EncodedImage:IconSuccess#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABcElEQVR4Xq2TsUsCURzHv15g8ZJcBWlyiYYgCIWcb9DFRRwMW5TA2c0/QEFwFkxxUQdxVlBwCYWOi6IhWgQhBLHJUCkhLr/BW8S7gvrAg+N+v8/v+x68Z8MGy+XSCyABQAXgBgHGALoASkIIDWSLeLBetdHryMjd5IxQPWT4rn1c/P7+xxp72Cs9m5SZ0Bq2vPnbPFafK2zDvmNHypdC0BPkLlQhxJsCAhQoZwdZU5mwxh720qGo8MzTxTTKZDPCx2HoVzp6lz0Q9tKhyx0kGs8Ny+TkWRKk8lCROwEduhyg9l/6lunOPSfmH3NUH6uQ0KHLAe7JYvJjevm+DAMGJHToKtigE+vwvIidxLamb8IBY9e+C5LiXREkfho3TSd06HJA13/oh6T51MTsfQbHrsMynQ5dDihFjiK8JJAU9AKIWTp76dCVN7HWHrajmUEGvyF9nkbAE6gLIS7kTUyuf2gscLoJrElZo/Mvj+nPz/kLTmfnEwP3tB0AAAAASUVORK5CYII=);
}
/* Information icon encoded */
.IconInfoEncoded
{
/* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */
/* [---XsltValidateInternal-Base64EncodedImage:IconInformation#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHElEQVR4Xs2TsUoDQRRF7wwoziokjZUKadInhdhukR9YP8DMX1hYW+QvdsXa/QHBbcXC7W0CamWTQnclFutceIQJwwaWNLlwm5k5d94M76mmaeCrrmsLYOocY12FcxZFUeozCqKqqgYA8uevv1H6VuPxcwlfk5N92KHBxfFeCSAxxswlYAW/Xr989x/mv9gkhtyMDhcAxgzRsp7flj8B/HF1RsMXq+NZMkopaHe7lbKxQUEIGbKsYNoGn969060hZBkQex/W8oRQwsQaW2o3Ago2SVcJUzAgY3N0lTCZZm+zPS8HB51gMmS1DEYyOz9acKO1D8JWTlafKIMxdhvlfdyT94Vv5h7P8Ky7nQzACmhvKq3zk3PjW9asz9D/1oigecsioooAAAAASUVORK5CYII=);
}
/* Warning icon encoded */
.IconWarningEncoded
{
/* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */
/* [---XsltValidateInternal-Base64EncodedImage:IconWarning#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAx0lEQVR4XpWSMQ7CMAxFf4xAyBMLCxMrO8dhaBcuwdCJS3RJBw7SA/QGTCxdWJgiQYWKXJWKIXHIlyw5lqr34tQgEOdcBsCOx5yZK3hCCKdYXneQkh4pEfqzLfu+wVDSyyzFoJjfz9NB+pAF+eizx2Vruts0k15mPgvS6GYvpVtQhB61IB/dk6AF6fS4Ben0uIX5odtFe8Q/eW1KvFeH4e8khT6+gm5B+t3juyDt7n0jpe+CANTd+oTUjN/U3yVaABnSUjFz/gFq44JaVSCXeQAAAABJRU5ErkJggg==);
}
/* Error icon encoded */
.IconErrorEncoded
{
/* Note: Do not delete the comment below. It is used to verify the correctness of the encoded image resource below before the product is released */
/* [---XsltValidateInternal-Base64EncodedImage:IconError#Begin#background-image: url(data:image/png;base64,#Separator#);#End#] */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABQElEQVR4XqWTvUoEQRCE6wYPZUA80AfwAQz23uCMjA7MDRQEIzPBVEyNTQUFIw00vcQTTMzuAh/AxEQQT8HF/3G/oGGnEUGuoNnd6qoZuqltyKEsyzVJq5I6rnUp6SjGeGhESikzzlc1eL7opfuVbrqbU1Zw9NCgtQMaZpY0eNnaaL2fHusvTK5vKu7sjSS1Y4y3QUA6K3e3Mau5UFDyMP7tYF9o8cAHZv68vipoIJg971PZIZ5HiwdvYGGvFVFHmGmZ2MxwmQYPXubPl9Up0tfoMQGetXd6mRbvhBw+boZ6WF7Mbv1+GsHRk0fQmPAH1GfmZirbCfDJ61tw3Px8/8pZsPAG4jlVhcPgZ7adwNWBB68lkRQWFiTgFlbnLY3DGGM7izIJIyT/jjIvEJw6fdJTc6krDzh6aMwMP9bvDH4ADSsa9uSWVJkAAAAASUVORK5CYII=);
}
</style><script type="text/javascript" language="javascript">
// Startup
// Hook up the the loaded event for the document/window, to linkify the document content
var startupFunction = function() { linkifyElement("messages"); };
if(window.attachEvent)
{
window.attachEvent('onload', startupFunction);
}
else if (window.addEventListener)
{
window.addEventListener('load', startupFunction, false);
}
else
{
document.addEventListener('load', startupFunction, false);
}
// Toggles the visibility of table rows with the specified name
function toggleTableRowsByName(name)
{
var allRows = document.getElementsByTagName('tr');
for (i=0; i < allRows.length; i++)
{
var currentName = allRows[i].getAttribute('name');
if(!!currentName && currentName.indexOf(name) == 0)
{
var isVisible = allRows[i].style.display == '';
isVisible ? allRows[i].style.display = 'none' : allRows[i].style.display = '';
}
}
}
function scrollToFirstVisibleRow(name)
{
var allRows = document.getElementsByTagName('tr');
for (i=0; i < allRows.length; i++)
{
var currentName = allRows[i].getAttribute('name');
var isVisible = allRows[i].style.display == '';
if(!!currentName && currentName.indexOf(name) == 0 && isVisible)
{
allRows[i].scrollIntoView(true);
return true;
}
}
return false;
}
// Linkifies the specified text content, replaces candidate links with html links
function linkify(text)
{
if(!text || 0 === text.length)
{
return text;
}
// Find http, https and ftp links and replace them with hyper links
var urlLink = /(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\/\\\+&%\$#\=~;\{\}])*/gi;
return text.replace(urlLink, '<a href="$&">$&</a>') ;
}
// Linkifies the specified element by ID
function linkifyElement(id)
{
var element = document.getElementById(id);
if(!!element)
{
element.innerHTML = linkify(element.innerHTML);
}
}
function ToggleMessageVisibility(projectName)
{
if(!projectName || 0 === projectName.length)
{
return;
}
toggleTableRowsByName("MessageRowClass" + projectName);
toggleTableRowsByName('MessageRowHeaderShow' + projectName);
toggleTableRowsByName('MessageRowHeaderHide' + projectName);
}
function ScrollToFirstVisibleMessage(projectName)
{
if(!projectName || 0 === projectName.length)
{
return;
}
// First try the 'Show messages' row
if(!scrollToFirstVisibleRow('MessageRowHeaderShow' + projectName))
{
// Failed to find a visible row for 'Show messages', try an actual message row
scrollToFirstVisibleRow('MessageRowClass' + projectName);
}
}
</script></head><body><h1 _locID="ConversionReport">
移轉報告 - </h1><div id="content"><h2 _locID="OverviewTitle">概觀</h2><div id="overview"><table><tr><th></th><th _locID="ProjectTableHeader">專案</th><th _locID="PathTableHeader">路徑</th><th _locID="ErrorsTableHeader">錯誤</th><th _locID="WarningsTableHeader">警告</th><th _locID="MessagesTableHeader">訊息</th></tr><tr><td class="IconErrorEncoded" /><td><strong><a href="#ExportProject">ExportProject</a></strong></td><td>..\ExportProject\ExportProject.vdproj</td><td class="textCentered"><a href="#ExportProjectError">1</a></td><td class="textCentered"><a>0</a></td><td class="textCentered"><a href="#">0</a></td></tr><tr><td class="IconSuccessEncoded" /><td><strong><a href="#Solution"><span _locID="OverviewSolutionSpan">方案</span></a></strong></td><td>ExportDataToFile.sln</td><td class="textCentered"><a>0</a></td><td class="textCentered"><a>0</a></td><td class="textCentered"><a href="#" onclick="ScrollToFirstVisibleMessage('Solution'); return false;">1</a></td></tr></table></div><h2 _locID="SolutionAndProjectsTitle">方案和專案</h2><div id="messages"><a name="ExportProject" /><h3>ExportProject</h3><table><tr id="ExportProjectHeaderRow"><th></th><th class="messageCell" _locID="MessageTableHeader">訊息</th></tr><tr name="ErrorRowClassExportProject"><td class="IconErrorEncoded"><a name="ExportProjectError" /></td><td class="messageCell"><strong>..\ExportProject\ExportProject.vdproj:
</strong><span>找不到這種專案類型的基礎應用程式。請嘗試這個連結以取得其他資訊: 54435603-dbb4-11d2-8724-00a0c9a8b90c</span></td></tr></table><a name="Solution" /><h3 _locID="ProjectDisplayNameHeader">方案</h3><table><tr id="SolutionHeaderRow"><th></th><th class="messageCell" _locID="MessageTableHeader">訊息</th></tr><tr name="MessageRowHeaderShowSolution"><td class="IconInfoEncoded" /><td class="messageCell"><a _locID="ShowAdditionalMessages" href="#" name="SolutionMessage" onclick="ToggleMessageVisibility('Solution'); return false;">
顯示 1 其他訊息
</a></td></tr><tr name="MessageRowClassSolution" style="display: none"><td class="IconInfoEncoded"><a name="SolutionMessage" /></td><td class="messageCell"><strong>ExportDataToFile.sln:
</strong><span>這個方案檔不需要移轉。</span></td></tr><tr style="display: none" name="MessageRowHeaderHideSolution"><td class="IconInfoEncoded" /><td class="messageCell"><a _locID="HideAdditionalMessages" href="#" name="SolutionMessage" onclick="ToggleMessageVisibility('Solution'); return false;">
隱藏 1 其他訊息
</a></td></tr></table></div></div></body></html>

206
Utility/MySQLUtilityClass.cs

@ -0,0 +1,206 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using MySqlConnector;
namespace ManagementSystem.Utility
{
public static class MySQLUtility
{
#region 取得指定Table資料
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList , string strWhere, string strOrderBy, MySqlConnection sqlConn)
{
DataSet dsData = new DataSet();
string strCommand = "";
try
{
string strColumns = "";
foreach (string strColumn in strColumnList) //取得欄位陣列
{
if (strColumns != "")
{
strColumns += "," + strColumn.Trim();
}
else
{
strColumns = strColumn;
}
}
if (intTopCount > 0)
{
strCommand = string.Format("Select {1} From {2} Limit {0}", intTopCount.ToString(), strColumns, strTableName);
}
else
{
strCommand = string.Format("Select {0} From {1} ", strColumns, strTableName);
}
if (strWhere != "") //設定過濾條件
{
strCommand += " Where " + strWhere;
}
if (strOrderBy != "") //取得排序欄位
{
strCommand += " Order By " + strOrderBy;
}
using (MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(strCommand, sqlConn))
{
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
throw ex;
}
}
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, string strWhere, MySqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount, strColumnList, strWhere, "", sqlConn);
}
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, MySqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount, strColumnList,"","", sqlConn);
}
public static DataTable GetTable(string strTableName, int intTopCount, MySqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount,new string[] {"*"}, "", "", sqlConn);
}
public static DataTable GetTable(string strTableName, MySqlConnection sqlConn)
{
return GetTable(strTableName, 0, new string[] { "*" }, "", "", sqlConn);
}
#endregion
#region MyQL命令相關程式集
public static MySqlConnection GetConn(string strIP, string strDBName, string strID, string strPWD, string strPort)
{
try
{
string strConnectionString = "server=" + strIP + ";port=" + strPort + ";database=" + strDBName + ";user id=" + strID + ";password=" + strPWD + ";charset=utf8;";
MySqlConnection sqlConn = new MySqlConnection(strConnectionString);
sqlConn.ConnectionString = strConnectionString;
sqlConn.Open();
return sqlConn;
}
catch (Exception ex)
{
ErrorHandler.WriteErrorLog("MySQLUtilityClass.cs", ex);
return null;
}
}
public static DataTable GetSQLResult(string strSQL, MySqlConnection sqlConn)
{
DataSet dsData = new DataSet();
try
{
using (MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(strSQL, sqlConn))
{
if (sqlConn == null)
return null;
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch(Exception ex)
{
return null;
throw ex;
}
}
public static bool IsExist(string strSQL, MySqlConnection sqlConn)
{
try
{
DataTable dtResult = GetSQLResult(strSQL, sqlConn);
if (dtResult.Rows.Count > 0)
{ return true; }
else
{ return false; }
}
catch (Exception ex)
{
throw ex;
}
}
public static bool RunSQLNonReturn(string strSQL, MySqlConnection sqlConn)
{
try
{
MySqlCommand sqlCmd = new MySqlCommand(strSQL, sqlConn);
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlCmd.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
return false;
}
}
public static string GetSQLCount(string strSQL, MySqlConnection sqlConn)
{
string strCount = "";
DataTable dtTemp = GetSQLResult(strSQL, sqlConn);
strCount = dtTemp.Rows.Count.ToString();
//回傳查詢結果
if(strCount == "")
{ return "0"; }
else
{ return strCount; }
}
#endregion
}
}

207
Utility/OracleUtilityClass.cs

@ -0,0 +1,207 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using Oracle.ManagedDataAccess.Client;
namespace ManagementSystem.Utility
{
public static class OracleUtility
{
#region 取得指定Table資料
public static DataTable GetTable(string strTableName,int intTopCount, string[] strColumnList , string strWhere, string strOrderBy, OracleConnection sqlConn)
{
DataSet dsData = new DataSet();
string strCommand = "";
try
{
string strColumns = "";
foreach (string strColumn in strColumnList) //取得欄位陣列
{
if (strColumns != "")
{
strColumns += "," + strColumn.Trim();
}
else
{
strColumns = strColumn;
}
}
if (intTopCount > 0)
{
strCommand = string.Format("Select {1} From {2} FETCH FIRST {0} ROWS ONLY", intTopCount.ToString(), strColumns, strTableName);
}
else
{
strCommand = string.Format("Select {0} From {1} ", strColumns, strTableName);
}
if (strWhere != "") //設定過濾條件
{
strCommand += " Where " + strWhere;
}
if (strOrderBy != "") //取得排序欄位
{
strCommand += " Order By " + strOrderBy;
}
using (OracleDataAdapter sqlAdapter = new OracleDataAdapter(strCommand, sqlConn))
{
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
throw ex;
}
}
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, string strWhere, OracleConnection sqlConn)
{
return GetTable(strTableName, intTopCount ,strColumnList, strWhere, "", sqlConn);
}
public static DataTable GetTable(string strTableName,int intTopCount, string[] strColumnList, OracleConnection sqlConn)
{
return GetTable(strTableName, intTopCount, strColumnList,"","", sqlConn);
}
public static DataTable GetTable(string strTableName,int intTopCount, OracleConnection sqlConn)
{
return GetTable(strTableName, intTopCount, new string[] {"*"}, "", "", sqlConn);
}
public static DataTable GetTable(string strTableName, OracleConnection sqlConn)
{
return GetTable(strTableName, 0, new string[] { "*" }, "", "", sqlConn);
}
#endregion
#region Oracle命令相關程式集
public static OracleConnection GetConn(string strIP, string strDBName, string strID, string strPWD, string strPort)
{
try
{
string strConnectionString = "Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = " + strIP + ")(PORT = " + strPort + ")))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = " + strDBName + "))); User Id = " + strID + "; Password = " + strPWD + ";";
OracleConnection sqlConn = new OracleConnection(strConnectionString);
sqlConn.ConnectionString = strConnectionString;
sqlConn.Open();
return sqlConn;
}
catch (Exception ex)
{
ErrorHandler.WriteErrorLog("OracleSQLUtilityClass.GetConn", ex);
return null;
}
}
public static DataTable GetSQLResult(string strSQL, OracleConnection sqlConn)
{
DataSet dsData = new DataSet();
try
{
using (OracleDataAdapter sqlAdapter = new OracleDataAdapter(strSQL, sqlConn))
{
if (sqlConn == null)
return null;
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch(Exception ex)
{
ErrorHandler.WriteErrorLog("OracleSQLUtilityClass.GetSQLResult", ex);
throw ex;
}
}
public static bool IsExist(string strSQL, OracleConnection sqlConn)
{
try
{
DataTable dtResult = GetSQLResult(strSQL, sqlConn);
if (dtResult.Rows.Count > 0)
{ return true; }
else
{ return false; }
}
catch (Exception ex)
{
throw ex;
}
}
public static bool RunSQLNonReturn(string strSQL, OracleConnection sqlConn)
{
try
{
OracleCommand sqlCmd = new OracleCommand(strSQL, sqlConn);
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlCmd.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
ErrorHandler.WriteErrorLog("OracleSQLUtilityClass.RunSQLNonReturn", ex);
return false;
}
}
public static string GetSQLCount(string strSQL, OracleConnection sqlConn)
{
string strCount = "";
DataTable dtTemp = GetSQLResult(strSQL, sqlConn);
strCount = dtTemp.Rows.Count.ToString();
//回傳查詢結果
if(strCount == "")
{ return "0"; }
else
{ return strCount; }
}
#endregion
}
}

204
Utility/PostgreSQLUtilityClass.cs

@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data;
//using System.Data.Sql;
//using System.Data.SqlClient;
using System.Configuration;
using Npgsql;
namespace ManagementSystem.Utility
{
public static class PostgreSQLUtility
{
#region 取得指定Table資料
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, string strWhere, string strOrderBy, NpgsqlConnection sqlConn)
{
DataSet dsData = new DataSet();
try
{
string strColumns = "";
string strCommand = "";
foreach (string strColumn in strColumnList) //取得欄位陣列
{
if (strColumns != "")
{
strColumns += "," + strColumn.Trim();
}
else
{
strColumns = strColumn;
}
}
if (intTopCount > 0)
{
strCommand = string.Format("Select {1} From \"{2}\" LIMIT {0}", intTopCount.ToString(), strColumns, strTableName);
}
else
{
strCommand = string.Format("Select {0} From \"{1}\" ", strColumns, strTableName);
}
if (strWhere != "") //設定過濾條件
{
strCommand += " Where " + strWhere;
}
if (strOrderBy != "") //取得排序欄位
{
strCommand += " Order By " + strOrderBy;
}
using (NpgsqlDataAdapter sqlAdapter = new NpgsqlDataAdapter(strCommand, sqlConn))
{
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
throw ex;
}
}
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, string strWhere, NpgsqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount, strColumnList, strWhere, "", sqlConn);
}
public static DataTable GetTable(string strTableName, int intTopCount, string[] strColumnList, NpgsqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount, strColumnList, "", "", sqlConn);
}
public static DataTable GetTable(string strTableName, int intTopCount, NpgsqlConnection sqlConn)
{
return GetTable(strTableName, intTopCount, new string[] { "*" }, "", "", sqlConn);
}
public static DataTable GetTable(string strTableName, NpgsqlConnection sqlConn)
{
return GetTable(strTableName, 0, new string[] { "*" }, "", "", sqlConn);
}
#endregion
#region MS-SQL命令相關程式集
public static NpgsqlConnection GetConn(string strIP, string strDBName, string strID, string strPWD, string strPort)
{
try
{
string strConnectionString = "Host=" + strIP + ";Port="+ strPort + ";Database=" + strDBName + ";Username=" + strID + ";Password=" + strPWD;
NpgsqlConnection sqlConn = new NpgsqlConnection(strConnectionString);
sqlConn.ConnectionString = strConnectionString;
sqlConn.Open();
return sqlConn;
}
catch (Exception ex)
{
ErrorHandler.WriteErrorLog("PostgreSQLUtilityClass.cs", ex);
return null;
}
}
public static DataTable GetSQLResult(string strSQL, NpgsqlConnection sqlConn)
{
DataSet dsData = new DataSet();
try
{
using (NpgsqlDataAdapter sqlAdapter = new NpgsqlDataAdapter(strSQL, sqlConn))
{
if (sqlConn == null)
return null;
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlAdapter.Fill(dsData, "Result");
}
if (dsData.Tables.Count != 0)
{
return dsData.Tables["Result"];
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
throw ex;
}
}
public static bool IsExist(string strSQL, NpgsqlConnection sqlConn)
{
try
{
DataTable dtResult = GetSQLResult(strSQL, sqlConn);
if (dtResult.Rows.Count > 0)
{ return true; }
else
{ return false; }
}
catch (Exception ex)
{
throw ex;
}
}
public static bool RunSQLNonReturn(string strSQL, NpgsqlConnection sqlConn)
{
try
{
NpgsqlCommand sqlCmd = new NpgsqlCommand(strSQL, sqlConn);
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
{
sqlConn.Open();
}
sqlCmd.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
return false;
}
}
public static string GetSQLCount(string strSQL, NpgsqlConnection sqlConn)
{
string strCount = "";
DataTable dtTemp = GetSQLResult(strSQL, sqlConn);
strCount = dtTemp.Rows.Count.ToString();
//回傳查詢結果
if (strCount == "")
{ return "0"; }
else
{ return strCount; }
}
#endregion
}
}
Loading…
Cancel
Save