main
forget_the_bright 1 year ago
parent 152523d6d9
commit 283b2e142e

@ -3,4 +3,16 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup> </startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

@ -33,11 +33,48 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MySql.Data"> <Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
<HintPath>D:\mes_db\NCA_MES_Models\CommonLibary\MySql.Data.dll</HintPath> <HintPath>..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.21.9.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.21.9\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.1.3.5\lib\net462\K4os.Compression.LZ4.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.5\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
</Reference>
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=8.0.33.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.33\lib\net462\MySql.Data.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.IO.Pipelines, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -71,6 +108,7 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -85,7 +123,9 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="SystemConfig.xml" /> <Content Include="SystemConfig.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

@ -25,7 +25,8 @@ namespace WindowsFormsApp1
/// 获取连接字符串 /// 获取连接字符串
/// </summary> /// </summary>
public static string connectionString = "server=10.164.1.169;port=3306;user=root;password=3687988; database=mesdb_nca;";//GetConnectionStringFromXml("./SystemConfig.xml"); public static string connectionString = GetConnectionStringFromXml("./SystemConfig.xml");
//"server=10.164.1.169;port=3306;user=root;password=3687988; database=mesdb_nca;";//GetConnectionStringFromXml("./SystemConfig.xml");
public static string DbName = getDbName();//"mesdb_nca"; public static string DbName = getDbName();//"mesdb_nca";
@ -43,16 +44,6 @@ namespace WindowsFormsApp1
return ""; return "";
} }
private MySqlConnection connection;
/// <summary>
/// DbHelperMySQL无参数构造函数
/// </summary>
private DbHelperMySQL(MySqlConnection connection)
{
this.connection = connection;
}
public static string GetConnectionStringFromXml(string xmlFilePath) public static string GetConnectionStringFromXml(string xmlFilePath)
{ {
try try
@ -74,6 +65,17 @@ namespace WindowsFormsApp1
} }
} }
private MySqlConnection connection;
/// <summary>
/// DbHelperMySQL无参数构造函数
/// </summary>
private DbHelperMySQL(MySqlConnection connection)
{
this.connection = connection;
}
#region 公用方法 #region 公用方法
/// <summary> /// <summary>
/// 获取表中最大的Id值 /// 获取表中最大的Id值

@ -35,6 +35,13 @@
this.namespace_name = new System.Windows.Forms.TextBox(); this.namespace_name = new System.Windows.Forms.TextBox();
this.lable2 = new System.Windows.Forms.Label(); this.lable2 = new System.Windows.Forms.Label();
this.txt_tablename = new System.Windows.Forms.ComboBox(); this.txt_tablename = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // button1
@ -50,7 +57,7 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(70, 120); this.label2.Location = new System.Drawing.Point(296, 16);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12); this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 4; this.label2.TabIndex = 4;
@ -76,7 +83,7 @@
// //
// namespace_name // namespace_name
// //
this.namespace_name.Location = new System.Drawing.Point(117, 155); this.namespace_name.Location = new System.Drawing.Point(131, 86);
this.namespace_name.Name = "namespace_name"; this.namespace_name.Name = "namespace_name";
this.namespace_name.Size = new System.Drawing.Size(218, 21); this.namespace_name.Size = new System.Drawing.Size(218, 21);
this.namespace_name.TabIndex = 70; this.namespace_name.TabIndex = 70;
@ -85,7 +92,7 @@
// lable2 // lable2
// //
this.lable2.AutoSize = true; this.lable2.AutoSize = true;
this.lable2.Location = new System.Drawing.Point(53, 160); this.lable2.Location = new System.Drawing.Point(67, 91);
this.lable2.Name = "lable2"; this.lable2.Name = "lable2";
this.lable2.Size = new System.Drawing.Size(59, 12); this.lable2.Size = new System.Drawing.Size(59, 12);
this.lable2.TabIndex = 71; this.lable2.TabIndex = 71;
@ -94,18 +101,91 @@
// txt_tablename // txt_tablename
// //
this.txt_tablename.FormattingEnabled = true; this.txt_tablename.FormattingEnabled = true;
this.txt_tablename.Location = new System.Drawing.Point(117, 116); this.txt_tablename.Location = new System.Drawing.Point(343, 12);
this.txt_tablename.Name = "txt_tablename"; this.txt_tablename.Name = "txt_tablename";
this.txt_tablename.Size = new System.Drawing.Size(218, 20); this.txt_tablename.Size = new System.Drawing.Size(218, 20);
this.txt_tablename.TabIndex = 72; this.txt_tablename.TabIndex = 72;
this.txt_tablename.Text = "请选择"; this.txt_tablename.Text = "请选择";
this.txt_tablename.TextUpdate += new System.EventHandler(this.orderId_TextUpdate); this.txt_tablename.TextUpdate += new System.EventHandler(this.orderId_TextUpdate);
// //
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("宋体", 11F);
this.textBox1.Location = new System.Drawing.Point(455, 425);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(335, 341);
this.textBox1.TabIndex = 73;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(142, 469);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(218, 21);
this.textBox2.TabIndex = 74;
this.textBox2.Text = "uiDataGridView1";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(70, 472);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 75;
this.label1.Text = "控件名称:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(69, 630);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 76;
this.button2.Text = "生成1";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(25, 405);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(827, 12);
this.label4.TabIndex = 77;
this.label4.Text = "-------------------------------------------------------------DataGridView生成------" +
"------------------------------------------------------";
//
// button3
//
this.button3.Location = new System.Drawing.Point(176, 630);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 78;
this.button3.Text = "生成2";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(285, 630);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 79;
this.button4.Text = "生成3";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(859, 778);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.label4);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.txt_tablename); this.Controls.Add(this.txt_tablename);
this.Controls.Add(this.lable2); this.Controls.Add(this.lable2);
this.Controls.Add(this.namespace_name); this.Controls.Add(this.namespace_name);
@ -130,6 +210,13 @@
private System.Windows.Forms.TextBox namespace_name; private System.Windows.Forms.TextBox namespace_name;
private System.Windows.Forms.Label lable2; private System.Windows.Forms.Label lable2;
private System.Windows.Forms.ComboBox txt_tablename; private System.Windows.Forms.ComboBox txt_tablename;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
} }
} }

@ -11,6 +11,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace WindowsFormsApp1 namespace WindowsFormsApp1
{ {
@ -103,6 +104,160 @@ namespace WindowsFormsApp1
} }
private void button2_Click(object sender, EventArgs e)
{
string tbname = txt_tablename.Text.Trim();//要生成的表名
if (tbname.Equals("请选择") || tbname.Equals(""))
{
MessageBox.Show("请选择表");
return;
};
var dt = GetDbTableInfo(tbname);
string uidatagridview = textBox2.Text.Trim();
textBox1.Text = "";
textBox1.Text += $"DataTable data = DbHelperMySQL.Query(\"select * from {tbname}\");\n";
textBox1.Text += "this."+ uidatagridview + ".DataSource = new BindingSource {DataSource = data};\n";
for (int i = 0; i < dt.Rows.Count; i++)
{
var Name = dt.Rows[i]["Name"].ToString();
textBox1.Text += $"var {Name}Column = {uidatagridview}.Columns[\"{Name}\"];\n";
}
for (int i = 0; i < dt.Rows.Count; i++)
{
var Name = dt.Rows[i]["Name"].ToString();
var IsNullable = dt.Rows[i]["COMMENT"].ToString();
textBox1.Text += $"{Name}Column.HeaderText = \"{IsNullable}\";\n";
}
textBox1.Text += $" {uidatagridview}.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;\n";
textBox1.Text += $" {uidatagridview}.AutoGenerateColumns = true;\n";
// textBox1.Text += $" {uidatagridview}.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;\n";
}
private void button3_Click(object sender, EventArgs e)
{
string tbname = txt_tablename.Text.Trim();//要生成的表名
if (tbname.Equals("请选择") || tbname.Equals(""))
{
MessageBox.Show("请选择表");
return;
};
var dt = GetDbTableInfo(tbname);
string uidatagridview = textBox2.Text.Trim();
textBox1.Text = "";
textBox1.Text += $" string sql = $\"SELECT column_name, column_comment from information_schema.COLUMNS where table_name = '{tbname}' ORDER BY ORDINAL_POSITION; \";\r\n" +
$" DataTable dt = DbHelperMySQL.Query(sql);\n";
textBox1.Text += "List<DataGridViewColumn> cols = new List<DataGridViewColumn>();\n";
textBox1.Text += "for (int i = 0; i < dt.Rows.Count; i++){\n" +
" DataGridViewTextBoxColumn temp = new DataGridViewTextBoxColumn();\n" +
"temp.Name = dt.Rows[i][0].ToString();\n" +
"temp.HeaderText = dt.Rows[i][1].ToString();\n" +
"cols.Add(temp);" +
"}\n";
textBox1.Text += "DataGridViewButtonColumn editBtn = new DataGridViewButtonColumn();\r\n" +
"editBtn.HeaderText = \"编辑\";\r\n" +
"editBtn.Name = \"edit\";\r\n" +
"editBtn.UseColumnTextForButtonValue = true;\r\n" +
"editBtn.Frozen = true;\n";
textBox1.Text += " DataGridViewButtonColumn addBtn = new DataGridViewButtonColumn();\r\n" +
"addBtn.HeaderText = \"修改\";\r\n" +
"addBtn.Name = \"editgd\";\r\n" +
"addBtn.Text = \"editgd\";\r\n" +
"addBtn.UseColumnTextForButtonValue = true;\r\n" +
"addBtn.Frozen = true;\n ";
textBox1.Text += "cols.Add(editBtn);\n cols.Add(addBtn);\n";
textBox1.Text += "if (cols.Last().Frozen)\r\n" +
"{\r\n " +
$"this.{uidatagridview}.RightToLeft = RightToLeft.Yes;\r\n" +
"cols.Reverse();\r\n" +
"}\r\n" +
$"this.{uidatagridview}.Columns.AddRange(cols.ToArray());\r\n\r\n" +
$"if (this.{uidatagridview}.Columns.Count > 0)\r\n" +
$"this.{uidatagridview}.FirstDisplayedScrollingColumnIndex = this.{uidatagridview}.Columns.Count - 2;\n";
textBox1.Text += $" {uidatagridview}.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;\n";
textBox1.Text += $"DataTable data = DbHelperMySQL.Query(\"select * from {tbname}\");\n";
textBox1.Text += $"this.{uidatagridview}.Rows.AddRange(data.AsEnumerable().Select(row => {{\r\n" +
"DataGridViewRow dataGridViewRow = new DataGridViewRow();\r\n " +
"DataGridViewButtonCell addCell = new DataGridViewButtonCell();\r\n" +
"addCell.Value = \"新增\";\r\n " +
"dataGridViewRow.Cells.Add(addCell);\r\n " +
"DataGridViewButtonCell editCell = new DataGridViewButtonCell();\r\n" +
"editCell.Value = \"修改\";\r\n " +
"dataGridViewRow.Cells.Add(editCell);\r\n " +
"foreach (var item in row.ItemArray.Reverse())\r\n " +
"{\r\n" +
"DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();\r\n" +
"cell.Value = item;\r\n " +
"dataGridViewRow.Cells.Add(cell);\r\n" +
"}\r\n" +
"dataGridViewRow.Height = 40;\r\n" +
"return dataGridViewRow;\r\n" +
"}).ToArray());";
}
private void button4_Click(object sender, EventArgs e)
{
string tbname = txt_tablename.Text.Trim();//要生成的表名
if (tbname.Equals("请选择") || tbname.Equals(""))
{
MessageBox.Show("请选择表");
return;
};
var dt = GetDbTableInfo(tbname);
string uidatagridview = textBox2.Text.Trim();
textBox1.Text = "";
textBox1.Text += "List<DataGridViewColumn> cols = new List<DataGridViewColumn>();\n";
for (int i = 0; i < dt.Rows.Count; i++)
{
var Name = dt.Rows[i]["Name"].ToString();
var IsNullable = dt.Rows[i]["COMMENT"].ToString();
textBox1.Text += $"DataGridViewTextBoxColumn {Name}Cloumn = new DataGridViewTextBoxColumn();\n";
textBox1.Text += $"{Name}Cloumn.Name = \"{Name}\";" +
$"{Name}Cloumn.HeaderText =\"{IsNullable}\";" +
$"cols.Add({Name}Cloumn);\n";
}
textBox1.Text += "DataGridViewButtonColumn editBtn = new DataGridViewButtonColumn();\r\n" +
"editBtn.HeaderText = \"编辑\";\r\n" +
"editBtn.Name = \"edit\";\r\n" +
"editBtn.UseColumnTextForButtonValue = true;\r\n" +
"editBtn.Frozen = true;\n";
textBox1.Text += " DataGridViewButtonColumn addBtn = new DataGridViewButtonColumn();\r\n" +
"addBtn.HeaderText = \"修改\";\r\n" +
"addBtn.Name = \"editgd\";\r\n" +
"addBtn.Text = \"editgd\";\r\n" +
"addBtn.UseColumnTextForButtonValue = true;\r\n" +
"addBtn.Frozen = true;\n ";
textBox1.Text += "cols.Add(editBtn);\n cols.Add(addBtn);\n";
textBox1.Text += "if (cols.Last().Frozen)\r\n" +
"{\r\n " +
$"this.{uidatagridview}.RightToLeft = RightToLeft.Yes;\r\n" +
"cols.Reverse();\r\n" +
"}\r\n" +
$"this.{uidatagridview}.Columns.AddRange(cols.ToArray());\r\n\r\n" +
$"if (this.{uidatagridview}.Columns.Count > 0)\r\n" +
$"this.{uidatagridview}.FirstDisplayedScrollingColumnIndex = this.{uidatagridview}.Columns.Count - 2;\n";
textBox1.Text += $" {uidatagridview}.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader;\n";
textBox1.Text += $"DataTable data = DbHelperMySQL.Query(\"select * from {tbname}\");\n";
textBox1.Text += $"this.{uidatagridview}.Rows.AddRange(data.AsEnumerable().Select(row => {{\r\n" +
"DataGridViewRow dataGridViewRow = new DataGridViewRow();\r\n " +
"DataGridViewButtonCell addCell = new DataGridViewButtonCell();\r\n" +
"addCell.Value = \"新增\";\r\n " +
"dataGridViewRow.Cells.Add(addCell);\r\n " +
"DataGridViewButtonCell editCell = new DataGridViewButtonCell();\r\n" +
"editCell.Value = \"修改\";\r\n " +
"dataGridViewRow.Cells.Add(editCell);\r\n " +
"foreach (var item in row.ItemArray.Reverse())\r\n " +
"{\r\n" +
"DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();\r\n" +
"cell.Value = item;\r\n " +
"dataGridViewRow.Cells.Add(cell);\r\n" +
"}\r\n" +
"dataGridViewRow.Height = 40;\r\n" +
"return dataGridViewRow;\r\n" +
"}).ToArray());";
}
//订单下拉模糊搜索 //订单下拉模糊搜索
private void orderId_TextUpdate(object sender, EventArgs e) //不要用TextChanged private void orderId_TextUpdate(object sender, EventArgs e) //不要用TextChanged
{ {
@ -124,10 +279,7 @@ namespace WindowsFormsApp1
/// <param name="tabname"></param> /// <param name="tabname"></param>
public static DataTable GetDbTableInfo(string tabname) public static DataTable GetDbTableInfo(string tabname)
{ {
string str = string.Format(@"SELECT COLUMN_NAME AS Name, COLUMN_TYPE AS Type,COLUMN_COMMENT AS COMMENT string str = $"SELECT COLUMN_NAME AS Name, COLUMN_TYPE AS Type,COLUMN_COMMENT AS COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{tabname}' ORDER BY ORDINAL_POSITION;";
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '{0}';", tabname);
var dt = DbHelperMySQL.Query(str); var dt = DbHelperMySQL.Query(str);
return dt; return dt;
} }
@ -135,7 +287,7 @@ WHERE TABLE_NAME = '{0}';", tabname);
public static List<string> GetTableName(string tableName) public static List<string> GetTableName(string tableName)
{ {
string sql = $"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{DbHelperMySQL.DbName}' AND TABLE_NAME LIKE '{tableName}%' limit 10;"; string sql = $"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{DbHelperMySQL.DbName}' AND TABLE_NAME LIKE '{tableName}%' limit 20;";
var dt = DbHelperMySQL.Query(sql); var dt = DbHelperMySQL.Query(sql);
//查询数据库表中所有已录入人员 //查询数据库表中所有已录入人员
List<string> sList = new List<string>(); //存放数据库查询结果 List<string> sList = new List<string>(); //存放数据库查询结果

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<SystemConfig> <SystemConfig>
<config name ="DataBaseType" ivalue="MYSQL" remark ="系统数据库类型"> </config> <config name ="DataBaseType" ivalue="MYSQL" remark ="系统数据库类型"> </config>
<config name ="ConnString" ivalue ="server=10.164.1.169;port=3306;user=root;password=3687988; database=mesdb_nca;" remark ="数据库连接字符串"> </config> <config name ="ConnString" ivalue ="server=10.40.18.18;port=3306;user=root;password=root_password; database=mesdb_nca;" remark ="数据库连接字符串"> </config>
<config name ="SystemParameter_tbname" ivalue="SYS_SystemParameter" remark ="系统初始参数表"> </config> <config name ="SystemParameter_tbname" ivalue="SYS_SystemParameter" remark ="系统初始参数表"> </config>
</SystemConfig> </SystemConfig>

Loading…
Cancel
Save