Commit 6f49f14e authored by solho's avatar solho

feat:新增訂製版客戶列表 功能

parent 272c6c36
...@@ -24,7 +24,7 @@ namespace WebAPI.Controllers ...@@ -24,7 +24,7 @@ namespace WebAPI.Controllers
response = new CommonResponseMsg(); response = new CommonResponseMsg();
connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString; connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
} }
[Route("Get_CustomerList")] [Route("Get_CustomerListTP")]
[CorsHandle] [CorsHandle]
[HttpPost] [HttpPost]
public HttpResponseMessage Get_CustomerList(ParamModel param) public HttpResponseMessage Get_CustomerList(ParamModel param)
...@@ -34,15 +34,16 @@ namespace WebAPI.Controllers ...@@ -34,15 +34,16 @@ namespace WebAPI.Controllers
string input = param.Input.ToString(); string input = param.Input.ToString();
try try
{ {
JObject obj_input = JObject.Parse(input.ToString());
using (SqlConnection Conn = new SqlConnection(connString)) using (SqlConnection Conn = new SqlConnection(connString))
{ {
SqlCommand cmd = new SqlCommand("", Conn) SqlCommand cmd = new SqlCommand("", Conn)
{ {
CommandText = @" CommandText = @"select a.customer_name,a.customer_id,case when isnull(b.customer_id,'')!='' then 1 else 0 end isSelect from c_customer a
select customer_name,customer_id from c_customer a left join (select customer_id from essen_request_info a1 where a1.request_id=@request_id) b on a.customer_id=b.customer_id
where a.is_enabled=1 "
where a.is_enabled=1 "
}; };
cmd.Parameters.Add("@request_id", obj_input["request_id"].ToString());
DataTable dt = SqlToDt(cmd); DataTable dt = SqlToDt(cmd);
response.Msg = JsonConvert.SerializeObject(dt); response.Msg = JsonConvert.SerializeObject(dt);
response.Code = "1"; response.Code = "1";
...@@ -63,12 +64,11 @@ namespace WebAPI.Controllers ...@@ -63,12 +64,11 @@ namespace WebAPI.Controllers
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json"); result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result; return result;
} }
[Route("Update_CustomerListTP")] [Route("Update_CustomerListTP")]
[CorsHandle] [CorsHandle]
[HttpPost] [HttpPost]
public HttpResponseMessage Update_CustomerList(ParamModel param) public HttpResponseMessage Update_CustomerListTP(ParamModel param)
{ {
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString()))) if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{ {
...@@ -80,12 +80,13 @@ namespace WebAPI.Controllers ...@@ -80,12 +80,13 @@ namespace WebAPI.Controllers
{ {
SqlCommand cmd = new SqlCommand("", Conn) SqlCommand cmd = new SqlCommand("", Conn)
{ {
CommandText = @"MERGE INTO essen_request_info WITH(HOLDLOCK) as target USING(select * from essen_request_info a where a.request_id=@request_id ) as source (request_id,customer_id) CommandText = @"MERGE INTO essen_request_info WITH(HOLDLOCK) as target USING(
select @request_id as request_id, @customer_id as customer_id ) as source (request_id,customer_id)
on(target.request_id = source.request_id ) on(target.request_id = source.request_id )
WHEN MATCHED THEN UPDATE SET customer_id = @customer_id WHEN MATCHED THEN UPDATE SET customer_id = @customer_id
WHEN NOT MATCHED THEN INSERT(request_id,customer_id) WHEN NOT MATCHED THEN INSERT(request_id,customer_id)
VALUES(@request_id,@customer_id )" VALUES(@request_id,@customer_id );"
}; };
cmd.Parameters.AddWithValue("@customer_id", obj_input["customer_id"].ToString()); cmd.Parameters.AddWithValue("@customer_id", obj_input["customer_id"].ToString());
...@@ -110,11 +111,49 @@ namespace WebAPI.Controllers ...@@ -110,11 +111,49 @@ namespace WebAPI.Controllers
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json"); result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result; return result;
} }
[Route("Delete_CustomerListTP")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage Delete_CustomerListTP(ParamModel param)
{
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
JObject obj_input = JObject.Parse(input.ToString());
try
{
using (SqlConnection Conn = new SqlConnection(connString))
{
SqlCommand cmd = new SqlCommand("", Conn)
{
CommandText = @"delete from essen_request_info where request_id=@request_id;"
};
cmd.Parameters.AddWithValue("@request_id", obj_input["request_id"].ToString());
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;
}
[Route("Update_CustomerList")] [Route("Update_CustomerList")]
[CorsHandle] [CorsHandle]
[HttpPost] [HttpPost]
public HttpResponseMessage Update_CustomerList2(ParamModel param) public HttpResponseMessage Update_CustomerList(ParamModel param)
{ {
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString()))) if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{ {
......
...@@ -415,6 +415,7 @@ namespace WebAPI.Controllers ...@@ -415,6 +415,7 @@ namespace WebAPI.Controllers
{ {
CommandText = sqlstr CommandText = sqlstr
}; };
cmd.CommandTimeout = 600;
cmd.Parameters.AddWithValue("@Start_YM", obj_input["Start_YM"].ToString()); cmd.Parameters.AddWithValue("@Start_YM", obj_input["Start_YM"].ToString());
cmd.Parameters.AddWithValue("@End_YM", obj_input["End_YM"].ToString()); cmd.Parameters.AddWithValue("@End_YM", obj_input["End_YM"].ToString());
cmd.Parameters.AddWithValue("@RptType", obj_input["RptType"].ToString()); cmd.Parameters.AddWithValue("@RptType", obj_input["RptType"].ToString());
...@@ -422,15 +423,10 @@ namespace WebAPI.Controllers ...@@ -422,15 +423,10 @@ namespace WebAPI.Controllers
cmd.Parameters.AddWithValue("@DisplayType", obj_input["DisplayType"].ToString()); cmd.Parameters.AddWithValue("@DisplayType", obj_input["DisplayType"].ToString());
cmd.Parameters.AddWithValue("@DataMode", obj_input["DataMode"].ToString()); cmd.Parameters.AddWithValue("@DataMode", obj_input["DataMode"].ToString());
DataTable dt = SqlToDt(cmd); DataTable dt = SqlToDt(cmd);
DataRow dr;
for (int i = 0; i < dt.Rows.Count; i++)
{
dr = dt.Rows[i];
}
response.Code = "1";
string JSONString = string.Empty; string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(dt); JSONString = JsonConvert.SerializeObject(dt);
response.Msg = JSONString; response.Msg = JSONString;
response.Code = "1";
} }
} }
catch (Exception e) catch (Exception e)
......
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