Commit 51d7ec15 authored by tr's avatar tr

1、表开发工具优化:适配所有表的说明维护需要;表名增加回车加载表信息和Alt+F8快捷键支持

parent db8f153d
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<appSettings> <appSettings>
<add key="UpdateTime" value="2021-07-29 14:12:41.660" /> <add key="UpdateTime" value="2021-07-29 18:01:08.283" />
</appSettings> </appSettings>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
......
使用说明: 使用说明:
1、配置说明:可设置默认数据库路径和默认导出路径 1、配置说明:可设置默认数据库路径和默认导出路径
2、操作说明:支持右键増行/删行,以及按键Insert与Delete 2、操作说明:支持右键増行/删行,以及按键Insert与Delete
3、导出文件:以表名命名,即每表导出一个相应类型文件。默认导出路径为temp,可自定义。 3、导出文件:以表名命名,相同类型多次导出则覆盖前面文件。默认导出路径为temp,可自定义。
4、暂存与恢复:暂存时,每表每天只暂存一个文件。暂存路径根目录save文件夹。 4、暂存与恢复:暂存界面录入信息,可通过恢复暂存恢复。按表名暂存,每表每日只暂存一个文件。暂存路径为根目录save文件夹。
5、数据库设置:快速设置数据库链接并记录历史设置。程序启动时读取配置文件的默认数据库链接。 5、数据库设置:快速设置数据库链接并记录历史设置。程序启动时读取配置文件的默认数据库链接。
6、加载表信息:表创建后,可以输入表名,通过该按钮加载相应信息。使用该功能时,有几点需要注意: 6、加载表信息:输入表名后:回车、点击工具栏-加载表信息、Alt+F8选择相似,都可以加载相关列信息
a.加载信息后,通过导出SQL按钮,会更新数据库的描述信息,除描述信息之外的任何修改不会更新到数据库。 7、注意事项:
b.由于类型是下拉选择框,对于非本工具创建的表,存在类型风险,即无法找到匹配的下拉项。 a.当表首次创建时,通过导出文件->生成SQL,会自动创建并记录描述信息
b.当表已存在时,通过导出文件->生成SQL,仅会更新描述信息
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
this.dgvData = new System.Windows.Forms.DataGridView(); this.dgvData = new System.Windows.Forms.DataGridView();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.Column4 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.Column7 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
...@@ -252,23 +252,8 @@ ...@@ -252,23 +252,8 @@
// //
this.Column2.DataPropertyName = "ColumnType"; this.Column2.DataPropertyName = "ColumnType";
this.Column2.HeaderText = "类型"; this.Column2.HeaderText = "类型";
this.Column2.Items.AddRange(new object[] {
"",
"INT",
"VARCHAR(50)",
"DATETIME",
"IMAGE",
"BIT",
"VARCHAR(MAX)",
"UNIQUEIDENTIFIER",
"DECIMAL(19,6)",
"DECIMAL(18,2)",
"FLOAT",
"NVARCHAR(50)",
"NVARCHAR(MAX)"});
this.Column2.Name = "Column2"; this.Column2.Name = "Column2";
this.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.Column2.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.Column2.Width = 150; this.Column2.Width = 150;
// //
// Column3 // Column3
...@@ -325,13 +310,13 @@ ...@@ -325,13 +310,13 @@
// //
this.tableLayoutPanel1.ColumnCount = 8; this.tableLayoutPanel1.ColumnCount = 8;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 75F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5F));
this.tableLayoutPanel1.Controls.Add(this.dgvData, 0, 1); this.tableLayoutPanel1.Controls.Add(this.dgvData, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.label2, 2, 0); this.tableLayoutPanel1.Controls.Add(this.label2, 2, 0);
...@@ -360,7 +345,7 @@ ...@@ -360,7 +345,7 @@
// label2 // label2
// //
this.label2.Dock = System.Windows.Forms.DockStyle.Fill; this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
this.label2.Location = new System.Drawing.Point(236, 0); this.label2.Location = new System.Drawing.Point(391, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(69, 27); this.label2.Size = new System.Drawing.Size(69, 27);
this.label2.TabIndex = 3; this.label2.TabIndex = 3;
...@@ -372,15 +357,15 @@ ...@@ -372,15 +357,15 @@
this.tbTableName.Dock = System.Windows.Forms.DockStyle.Fill; this.tbTableName.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbTableName.Location = new System.Drawing.Point(78, 3); this.tbTableName.Location = new System.Drawing.Point(78, 3);
this.tbTableName.Name = "tbTableName"; this.tbTableName.Name = "tbTableName";
this.tbTableName.Size = new System.Drawing.Size(152, 23); this.tbTableName.Size = new System.Drawing.Size(307, 23);
this.tbTableName.TabIndex = 4; this.tbTableName.TabIndex = 4;
// //
// tbTableDescription // tbTableDescription
// //
this.tbTableDescription.Dock = System.Windows.Forms.DockStyle.Fill; this.tbTableDescription.Dock = System.Windows.Forms.DockStyle.Fill;
this.tbTableDescription.Location = new System.Drawing.Point(311, 3); this.tbTableDescription.Location = new System.Drawing.Point(466, 3);
this.tbTableDescription.Name = "tbTableDescription"; this.tbTableDescription.Name = "tbTableDescription";
this.tbTableDescription.Size = new System.Drawing.Size(152, 23); this.tbTableDescription.Size = new System.Drawing.Size(307, 23);
this.tbTableDescription.TabIndex = 5; this.tbTableDescription.TabIndex = 5;
// //
// wDBTableDevelopTools // wDBTableDevelopTools
...@@ -431,16 +416,16 @@ ...@@ -431,16 +416,16 @@
private System.Windows.Forms.ToolStripButton tsbDbLink; private System.Windows.Forms.ToolStripButton tsbDbLink;
private System.Windows.Forms.ToolStripTextBox tstbDbLink; private System.Windows.Forms.ToolStripTextBox tstbDbLink;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripButton tsbLoadTable;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripButton tsbSysSetting;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1; private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column6; private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
private System.Windows.Forms.DataGridViewComboBoxColumn Column2; private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column3; private System.Windows.Forms.DataGridViewCheckBoxColumn Column3;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column4; private System.Windows.Forms.DataGridViewCheckBoxColumn Column4;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column7; private System.Windows.Forms.DataGridViewCheckBoxColumn Column7;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5; private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripButton tsbLoadTable;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripButton tsbSysSetting;
} }
} }
\ No newline at end of file
...@@ -138,8 +138,10 @@ namespace Tools.UI ...@@ -138,8 +138,10 @@ namespace Tools.UI
//上下文菜单-事件 //上下文菜单-事件
this.tsmiAddRow.Click += TsmiAddRow_Click; this.tsmiAddRow.Click += TsmiAddRow_Click;
this.tsmiDelRow.Click += TsmiDelRow_Click; this.tsmiDelRow.Click += TsmiDelRow_Click;
//文本框-事件
this.tbTableName.KeyDown += TbTableName_KeyDown;
} }
private void BindBaseInfo() private void BindBaseInfo()
{ {
this.tbTableName.DataBindings.Clear(); this.tbTableName.DataBindings.Clear();
...@@ -263,16 +265,6 @@ namespace Tools.UI ...@@ -263,16 +265,6 @@ namespace Tools.UI
private void TsbLoadTable_Click(object sender, EventArgs e) private void TsbLoadTable_Click(object sender, EventArgs e)
{ {
if (this.TableName.Equals(""))
{
Utils.Tip("请输入表名!");
return;
}
if (!this.IsExistTable(this.TableName))
{
Utils.Tip("该表尚未创建!");
return;
}
//初始化表列信息 //初始化表列信息
this.InitTableColumnInfo(this.TableName); this.InitTableColumnInfo(this.TableName);
} }
...@@ -328,7 +320,7 @@ namespace Tools.UI ...@@ -328,7 +320,7 @@ namespace Tools.UI
} }
#endregion #endregion
#region 上下文-事件 #region 上下文菜单-事件
private void TsmiAddRow_Click(object sender, EventArgs e) private void TsmiAddRow_Click(object sender, EventArgs e)
{ {
...@@ -344,6 +336,47 @@ namespace Tools.UI ...@@ -344,6 +336,47 @@ namespace Tools.UI
} }
} }
#endregion
#region 文本框-事件
private void TbTableName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//初始化表列信息
this.InitTableColumnInfo(this.TableName);
}
else if (e.KeyData == (Keys.Alt | Keys.F8))
{
this.ShowMenuTips();
}
}
//提供Alt+F8的提示功能
ContextMenu _menu = new ContextMenu();
private void ShowMenuTips()
{
this._menu.MenuItems.Clear();
var sql = $"SELECT name FROM sys.tables WHERE name LIKE '{this.TableName}%' ORDER BY name";
var dt = this._db.GetDataTable(sql, "sys_tables", false);
if (dt.Rows.Count > 0)
{
var items = dt.Select().AsEnumerable().Select(r => new MenuItem(r["name"].ToString(), Item_Click));
this._menu.MenuItems.AddRange(items.ToArray());
this._menu.Show(this.tbTableName, new Point(0, this.tbTableName.Height));
}
else
{
Utils.Tip($"当前数据库中不存在,与'{this.TableName}%'相似的表!");
}
}
private void Item_Click(object sender, EventArgs e)
{
var item = sender as MenuItem;
this.tbTableName.Text = item.Text;
this.InitTableColumnInfo(item.Text);
}
#endregion #endregion
/// <summary> /// <summary>
...@@ -501,8 +534,20 @@ namespace Tools.UI ...@@ -501,8 +534,20 @@ namespace Tools.UI
/// <param name="tableName"></param> /// <param name="tableName"></param>
private void InitTableColumnInfo(string tableName) private void InitTableColumnInfo(string tableName)
{ {
//空值校验
if (string.IsNullOrEmpty(tableName))
{
Utils.Tip("请输入表名!");
return;
}
//清空当前表格 //清空当前表格
this._ds.Tables[infoTable].Rows.Clear(); this._ds.Tables[infoTable].Rows.Clear();
//是否存在
if (!this.IsExistTable(tableName))
{
Utils.Tip("该表尚未创建!");
return;
}
var sqlist = new List<TQuery> { var sqlist = new List<TQuery> {
//取表结构 //取表结构
...@@ -563,5 +608,6 @@ namespace Tools.UI ...@@ -563,5 +608,6 @@ namespace Tools.UI
#region 待开发:支持查询后修改指定列类型列名等 #region 待开发:支持查询后修改指定列类型列名等
#endregion #endregion
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment