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
35866dfb
Commit
35866dfb
authored
Nov 13, 2020
by
罗显健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
帮助文件移到独立文件夹
parent
6ceca42b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
10 deletions
+54
-10
dbtools_help.txt
AppHome/config/help/dbtools_help.txt
+0
-0
syschecker_help.txt
AppHome/config/help/syschecker_help.txt
+0
-0
wEditBasic.cs
Tools/MyCommon/wEditBasic.cs
+2
-1
Utils.cs
Tools/MyUtils/Utils.cs
+45
-7
wMain.cs
Tools/wMain.cs
+7
-2
No files found.
AppHome/config/dbtools_help.txt
→
AppHome/config/
help/
dbtools_help.txt
View file @
35866dfb
File moved
AppHome/config/syschecker_help.txt
→
AppHome/config/
help/
syschecker_help.txt
View file @
35866dfb
File moved
Tools/MyCommon/wEditBasic.cs
View file @
35866dfb
...
...
@@ -50,7 +50,8 @@ namespace Tools.MyCommon
if
(!
this
.
_db
.
ConnectionTest
())
{
this
.
_db
=
null
;
throw
new
Exception
(
$"数据库链接无效!\r\n链接:
{
link
}
"
);
// throw new Exception($"数据库链接无效!\r\n链接:{link}"); // 给提示即可,否则无法操作下去,即使想改链接。
MessageBox
.
Show
(
$"数据库链接无效!\r\n链接:
{
link
}
"
);
}
}
/// <summary>
...
...
Tools/MyUtils/Utils.cs
View file @
35866dfb
...
...
@@ -71,7 +71,7 @@ namespace Tools.MyUtils
/// 提示框
/// </summary>
/// <param name="msg"></param>
public
static
void
Tip
(
string
msg
,
int
width
=
0
,
int
height
=
0
)
public
static
void
Tip
(
string
msg
,
int
width
=
0
,
int
height
=
0
)
{
new
wMsgBox
().
Show
(
msg
,
width
,
height
);
}
...
...
@@ -81,7 +81,7 @@ namespace Tools.MyUtils
/// <param name="txtFileName"></param>
public
static
void
ShowHelp
(
string
txtFileName
)
{
var
helpFileName
=
$@"
{
Utils
.
ConfigPath
}
\
{
txtFileName
}
.txt"
;
var
helpFileName
=
$@"
{
Utils
.
ConfigPath
}
\
help\
{
txtFileName
}
.txt"
;
if
(
File
.
Exists
(
helpFileName
))
{
using
(
var
sr
=
new
StreamReader
(
helpFileName
))
...
...
@@ -167,13 +167,15 @@ namespace Tools.MyUtils
public
static
DataRow
GetNewRow
(
this
DataTable
dt
)
{
var
result
=
dt
.
NewRow
();
//非空列默认赋值为0
//非空列默认赋值为0
..
foreach
(
DataColumn
c
in
dt
.
Columns
)
{
if
(
c
.
AllowDBNull
||
c
.
AutoIncrement
)
continue
;
//非空列处理:主键列根据列类型生成;非主键列统一用0初始化
result
[
c
.
ColumnName
]
=
dt
.
PrimaryKey
.
Contains
(
c
)
?
GetDefaultPrimaryKey
(
c
)
:
"0"
;
// 非空主键可以自动赋值,其他列用0 未考虑数据类型会直接报错
result
[
c
.
ColumnName
]
=
dt
.
PrimaryKey
.
Contains
(
c
)
?
GetDefaultPrimaryKey
(
c
)
:
GetDefaultColumnValue
(
c
);
result
.
EndEdit
();
}
//当有筛选条件时,默认赋值筛选字段
...
...
@@ -224,6 +226,42 @@ namespace Tools.MyUtils
return
result
;
}
private
static
object
GetDefaultColumnValue
(
DataColumn
c
)
{
object
result
=
"0"
;
var
typeName
=
c
.
DataType
.
Name
.
ToLower
();
if
(
typeName
.
Equals
(
"int32"
)
||
typeName
.
Equals
(
"int64"
))
{
var
obj
=
c
.
Table
.
Compute
(
$"Max(
{
c
.
ColumnName
}
)"
,
"1=1"
);
int
.
TryParse
(
obj
?.
ToString
(),
out
int
max
);
result
=
(
max
+
1
).
ToString
();
}
else
if
(
typeName
.
Equals
(
"guid"
))
{
result
=
Guid
.
NewGuid
().
ToString
();
}
else
if
(
typeName
.
Equals
(
"datetime"
))
{
result
=
DateTime
.
Now
;
}
else
{
result
=
$"
{
c
.
ColumnName
}
_
{
c
.
Table
.
Rows
.
Count
}
"
;
}
return
result
;
}
#
endregion
#
region
(
扩展
)
整型范围
...
...
@@ -316,7 +354,7 @@ namespace Tools.MyUtils
{
return
$"IF NOT EXISTS(SELECT 1 FROM sys.tables WHERE name = '
{
tableName
}
')\r\nBEGIN\r\nCREATE TABLE
{
tableName
}
\r\n("
;
}
public
static
string
GenSqlBody
(
DataTable
dt
,
string
tableName
,
string
tableDescription
,
out
List
<
string
>
descriptionList
)
public
static
string
GenSqlBody
(
DataTable
dt
,
string
tableName
,
string
tableDescription
,
out
List
<
string
>
descriptionList
)
{
//描述信息
descriptionList
=
new
List
<
string
>();
...
...
Tools/wMain.cs
View file @
35866dfb
...
...
@@ -54,8 +54,13 @@ namespace Tools
try
{
var
item
=
this
.
listView1
.
SelectedItems
[
0
];
var
w
=
Activator
.
CreateInstance
(
item
.
Tag
as
Type
)
as
Form
;
w
?.
ShowDialog
();
var
from
=
Activator
.
CreateInstance
(
item
.
Tag
as
Type
)
as
Form
;
if
(
from
!=
null
)
{
from
.
Text
=
item
.
Text
;
from
.
ShowDialog
();
from
.
Dispose
();
}
}
catch
(
Exception
ex
)
{
...
...
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