|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Data;
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
using System.Data.SqlTypes;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
@ -53,6 +54,7 @@ namespace WindowsFormsApp1
|
|
|
|
return sb.ToString();
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//string constr = txt_constr.Text.Trim();//数据库链接字符串
|
|
|
|
//string constr = txt_constr.Text.Trim();//数据库链接字符串
|
|
|
@ -68,14 +70,16 @@ namespace WindowsFormsApp1
|
|
|
|
txt_ret.Text += "using System;\n" +
|
|
|
|
txt_ret.Text += "using System;\n" +
|
|
|
|
"using NCA_MES_Models.CommonUtils.DB.DBAttribute;\n\n";
|
|
|
|
"using NCA_MES_Models.CommonUtils.DB.DBAttribute;\n\n";
|
|
|
|
txt_ret.Text += "namespace "+ namespaceName + "{\n\n";
|
|
|
|
txt_ret.Text += "namespace "+ namespaceName + "{\n\n";
|
|
|
|
txt_ret.Text += "[TableName(\"" + tbname + "\")]" + "\n"+"public class " + GenerateClassName(tbname) + " {";
|
|
|
|
txt_ret.Text += "/// <summary>" + "\n" +
|
|
|
|
|
|
|
|
"/// " + GetTableComment(tbname) + "\n"+
|
|
|
|
|
|
|
|
"/// </summary>" + "\n" +
|
|
|
|
|
|
|
|
"[TableName(\"" + tbname + "\")]" + "\n"+
|
|
|
|
|
|
|
|
"public class " + GenerateClassName(tbname) + " {";
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var Name = dt.Rows[i]["Name"].ToString();
|
|
|
|
var Name = dt.Rows[i]["Name"].ToString();
|
|
|
|
var Type = dt.Rows[i]["Type"].ToString();
|
|
|
|
var Type = dt.Rows[i]["Type"].ToString();
|
|
|
|
var IsNullable = dt.Rows[i]["COMMENT"].ToString();
|
|
|
|
var IsNullable = dt.Rows[i]["COMMENT"].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Type type = DbTypeStr_To_CsharpType(Type);
|
|
|
|
Type type = DbTypeStr_To_CsharpType(Type);
|
|
|
|
//txt_ret.Text += @"/// <summary>" + "\n" + "///" + IsNullable + "\n" + " /// </summary>\n" +""+ " public " + type.Name +" "+ Name + " { get; set; }" + "\n";//不加注释版本
|
|
|
|
//txt_ret.Text += @"/// <summary>" + "\n" + "///" + IsNullable + "\n" + " /// </summary>\n" +""+ " public " + type.Name +" "+ Name + " { get; set; }" + "\n";//不加注释版本
|
|
|
|
txt_ret.Text += "\n\t" + @"/// <summary>" +
|
|
|
|
txt_ret.Text += "\n\t" + @"/// <summary>" +
|
|
|
@ -142,6 +146,15 @@ WHERE TABLE_NAME = '{0}';", tabname);
|
|
|
|
return sList;
|
|
|
|
return sList;
|
|
|
|
//return dt;
|
|
|
|
//return dt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetTableComment(string tableName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string sql = $"SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{DbHelperMySQL.DbName}' AND TABLE_NAME ='{tableName}';";
|
|
|
|
|
|
|
|
var dt = DbHelperMySQL.Query(sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(dt.Rows.Count<1) return tableName;
|
|
|
|
|
|
|
|
return dt.Rows[0]["TABLE_COMMENT"].ToString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static List<string> GetTableName()
|
|
|
|
public static List<string> GetTableName()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string sql = $"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{DbHelperMySQL.DbName}';";
|
|
|
|
string sql = $"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{DbHelperMySQL.DbName}';";
|
|
|
|