Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
c7248812
Commit
c7248812
authored
Dec 15, 2023
by
陈航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
类生成工具添加生成前端列名功能
parent
d22ff3e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
21 deletions
+69
-21
wAutoClass.Designer.cs
Tools/UI/wAutoClass.Designer.cs
+15
-1
wAutoClass.cs
Tools/UI/wAutoClass.cs
+54
-20
No files found.
Tools/UI/wAutoClass.Designer.cs
View file @
c7248812
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
this
.
lsbTableInfo
=
new
System
.
Windows
.
Forms
.
ListBox
();
this
.
lsbTableInfo
=
new
System
.
Windows
.
Forms
.
ListBox
();
this
.
txtSearch
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtSearch
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtResult
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtResult
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
chkFrontendcolumn
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
toolStrip1
.
SuspendLayout
();
this
.
toolStrip1
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
splitContainer1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
splitContainer1
)).
BeginInit
();
this
.
splitContainer1
.
Panel1
.
SuspendLayout
();
this
.
splitContainer1
.
Panel1
.
SuspendLayout
();
...
@@ -138,14 +139,26 @@
...
@@ -138,14 +139,26 @@
this
.
txtResult
.
Size
=
new
System
.
Drawing
.
Size
(
448
,
370
);
this
.
txtResult
.
Size
=
new
System
.
Drawing
.
Size
(
448
,
370
);
this
.
txtResult
.
TabIndex
=
0
;
this
.
txtResult
.
TabIndex
=
0
;
//
//
// chkFrontendcolumn
//
this
.
chkFrontendcolumn
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
chkFrontendcolumn
.
AutoSize
=
true
;
this
.
chkFrontendcolumn
.
Location
=
new
System
.
Drawing
.
Point
(
518
,
4
);
this
.
chkFrontendcolumn
.
Name
=
"chkFrontendcolumn"
;
this
.
chkFrontendcolumn
.
Size
=
new
System
.
Drawing
.
Size
(
99
,
21
);
this
.
chkFrontendcolumn
.
TabIndex
=
8
;
this
.
chkFrontendcolumn
.
Text
=
"生成前端列名"
;
this
.
chkFrontendcolumn
.
UseVisualStyleBackColor
=
true
;
this
.
chkFrontendcolumn
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
chkFrontendcolumn_CheckedChanged
);
//
// wAutoClass
// wAutoClass
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
621
,
395
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
621
,
395
);
this
.
Controls
.
Add
(
this
.
chkFrontendcolumn
);
this
.
Controls
.
Add
(
this
.
splitContainer1
);
this
.
Controls
.
Add
(
this
.
splitContainer1
);
this
.
Controls
.
Add
(
this
.
toolStrip1
);
this
.
Controls
.
Add
(
this
.
toolStrip1
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
3
,
4
,
3
,
4
);
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
3
,
4
,
3
,
4
);
this
.
Name
=
"wAutoClass"
;
this
.
Name
=
"wAutoClass"
;
...
@@ -172,5 +185,6 @@
...
@@ -172,5 +185,6 @@
private
System
.
Windows
.
Forms
.
TextBox
txtResult
;
private
System
.
Windows
.
Forms
.
TextBox
txtResult
;
private
System
.
Windows
.
Forms
.
ToolStripButton
tsbRefresh
;
private
System
.
Windows
.
Forms
.
ToolStripButton
tsbRefresh
;
private
System
.
Windows
.
Forms
.
ListBox
lsbTableInfo
;
private
System
.
Windows
.
Forms
.
ListBox
lsbTableInfo
;
private
System
.
Windows
.
Forms
.
CheckBox
chkFrontendcolumn
;
}
}
}
}
\ No newline at end of file
Tools/UI/wAutoClass.cs
View file @
c7248812
...
@@ -91,6 +91,32 @@ namespace Tools.UI
...
@@ -91,6 +91,32 @@ namespace Tools.UI
}
}
private
void
lsbTableInfo_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
lsbTableInfo_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
GenerateEntity
();
}
private
string
GetCsharpTypeNameBySqlType
(
string
nSqlTypeName
)
{
switch
(
nSqlTypeName
)
{
case
"image"
:
return
"Image"
;
case
"int"
:
return
"int"
;
case
"datetime"
:
return
"DateTime"
;
case
"bit"
:
return
"bool"
;
case
"varchar"
:
return
"string"
;
case
"char"
:
return
"char"
;
default
:
return
"string"
;
}
}
private
void
chkFrontendcolumn_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
GenerateEntity
();
}
/// <summary>
/// 生成所需实体或前端列名
/// </summary>
private
void
GenerateEntity
()
{
{
string
strTableName
=
lsbTableInfo
.
SelectedItem
.
ToString
();
string
strTableName
=
lsbTableInfo
.
SelectedItem
.
ToString
();
...
@@ -107,40 +133,48 @@ ORDER BY b.column_id;
...
@@ -107,40 +133,48 @@ ORDER BY b.column_id;
DataTable
dataTable
=
this
.
_db
.
GetDataTable
(
sb
.
ToString
(),
"结果列表"
);
DataTable
dataTable
=
this
.
_db
.
GetDataTable
(
sb
.
ToString
(),
"结果列表"
);
sb
.
Clear
();
sb
.
Clear
();
sb
.
Append
(
$@"
//生成前端列名
if
(
chkFrontendcolumn
.
Checked
)
{
sb
.
Append
(
$@"
Colums:
[
"
);
foreach
(
DataRow
row
in
dataTable
.
Rows
)
{
sb
.
Append
(
$@"
{{
label
:
'
{
row
[
"Description"
]}
'
,
value
:
'
{
row
[
"name"
]}
'
,
show_overflow_tooltip
:
true
}}
,"
);
}
txtResult
.
Text
=
sb
.
ToString
().
Substring
(
0
,
sb
.
ToString
().
Length
-
1
)
+
@"
]"
;
}
else
//生成实体类
{
sb
.
Append
(
$@"
/// <summary>
/// <summary>
///
{
strTableName
}
///
{
strTableName
}
/// </summary>
/// </summary>
public class
{
strTableName
}
public class
{
strTableName
}
{{
{{
");
");
foreach
(
DataRow
row
in
dataTable
.
Rows
)
foreach
(
DataRow
row
in
dataTable
.
Rows
)
{
{
sb
.
Append
(
$@"
sb
.
Append
(
$@"
/// <summary>
/// <summary>
///
{
row
[
"Description"
]}
///
{
row
[
"Description"
]}
/// </summary>
/// </summary>
public
{
GetCsharpTypeNameBySqlType
(
row
[
"TypeName"
].
ToString
())}
{
row
[
"name"
]}
{{
get
;
set
;
}}
public
{
GetCsharpTypeNameBySqlType
(
row
[
"TypeName"
].
ToString
())}
{
row
[
"name"
]}
{{
get
;
set
;
}}
"
);
"
);
}
}
sb
.
Append
(
$@"
sb
.
Append
(
$@"
}}
}}
"
);
"
);
txtResult
.
Text
=
sb
.
ToString
();
txtResult
.
Text
=
sb
.
ToString
();
}
private
string
GetCsharpTypeNameBySqlType
(
string
nSqlTypeName
)
{
switch
(
nSqlTypeName
)
{
case
"image"
:
return
"Image"
;
case
"int"
:
return
"int"
;
case
"datetime"
:
return
"DateTime"
;
case
"bit"
:
return
"bool"
;
case
"varchar"
:
return
"string"
;
case
"char"
:
return
"char"
;
default
:
return
"string"
;
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment