Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
code
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
solho
code
Commits
a13468c6
Commit
a13468c6
authored
Oct 13, 2021
by
solho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:新增客戶相關 Controller
parent
dda327c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
WebAPI/Controllers/CustomerController.cs
WebAPI/Controllers/CustomerController.cs
+68
-0
No files found.
WebAPI/Controllers/CustomerController.cs
0 → 100644
View file @
a13468c6
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Configuration
;
using
System.Data
;
using
System.Data.SqlClient
;
using
System.Net
;
using
System.Net.Http
;
using
System.Web
;
using
System.Web.Http
;
using
WebAPI.Models
;
using
static
WebAPI
.
Tool
.
Common
;
namespace
WebAPI.Controllers
{
public
class
CustomerController
:
ApiController
{
HttpResponseMessage
result
;
CommonResponseMsg
response
;
String
connString
;
public
CustomerController
()
{
result
=
new
HttpResponseMessage
(
HttpStatusCode
.
OK
);
response
=
new
CommonResponseMsg
();
connString
=
ConfigurationManager
.
ConnectionStrings
[
"eflow_cur"
].
ConnectionString
;
}
[
Route
(
"Get_CustomerList"
)]
[
CorsHandle
]
[
HttpPost
]
public
HttpResponseMessage
Get_CustomerList
(
ParamModel
param
)
{
if
(
param
!=
null
&&
param
.
Input
!=
null
&&
!
string
.
IsNullOrWhiteSpace
((
param
.
Input
.
ToString
())))
{
string
input
=
param
.
Input
.
ToString
();
try
{
using
(
SqlConnection
Conn
=
new
SqlConnection
(
connString
))
{
SqlCommand
cmd
=
new
SqlCommand
(
""
,
Conn
)
{
CommandText
=
@"
select customer_name from c_customer a
where a.is_enabled=1 "
};
DataTable
dt
=
SqlToDt
(
cmd
);
response
.
Msg
=
JsonConvert
.
SerializeObject
(
dt
);
response
.
Code
=
"1"
;
}
}
catch
(
Exception
e
)
{
response
.
Code
=
"0"
;
response
.
Msg
=
"Exception:"
+
e
.
StackTrace
;
}
}
else
{
response
.
Code
=
"0"
;
response
.
Msg
=
"no input or format error"
;
}
result
.
Content
=
new
StringContent
(
JsonConvert
.
SerializeObject
(
response
),
System
.
Text
.
Encoding
.
UTF8
,
"application/json"
);
return
result
;
}
}
}
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