Commit 13e575a9 authored by solho's avatar solho

關帳流程設定開關帳功能

parent aa921c3a
...@@ -111,7 +111,122 @@ namespace WebAPI.Controllers ...@@ -111,7 +111,122 @@ namespace WebAPI.Controllers
return result; return result;
} }
public DataTable get_Esn_todos_SettleData( String gWadeID, bool is_enabled) [Route("getesntodosSettle")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage get_esn_todos_Settle(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);
String strsql = "", Permission_furtherSql = obj_input["Permission_furtherSql"].ToString();
strsql += String.Format(@"select a.id, Settle_Date ,isClosed ,Emp_DS ,a.update_time from [esn_todos_Settle] a
left join [evw_qResult_EmpDS] b on a.DSNum=b.Emp_DSNum
left join [evw_qResult_Dept] c on a.DeptNum=c.targetID
left join [evw_qResult_EmpItem] d on a.ItemNum=d.Emp_ItemNum
where 1=1 ");
JObject objPermission_furtherSql = JObject.Parse(obj_input["Permission_furtherSql"].ToString());
if (obj_input["Settle_Date"]!=null)
{
strsql += " and Settle_Date between @Settle_Date and @Settle_Date ";
cmd.Parameters.Add("@Settle_Date", obj_input["Settle_Date"].ToString());
}
if (obj_input["isClosed"] != null )
{
strsql += " and isClosed=@isClosed ";
cmd.Parameters.Add("@isClosed", (obj_input["isClosed"].ToString()=="1"?true:false));
}
if (objPermission_furtherSql["firmID"] != null )
{
strsql += " and b.ID in(@DSid)";
strsql= strsql.Replace("@DSid", objPermission_furtherSql["firmID"].ToString());
//cmd.Parameters.Add("@DSid", objPermission_furtherSql["firmID"].ToString());
}
if (objPermission_furtherSql["deptID"] != null )
{
//strsql += " and DeptNum in(@DeptNum)";
//cmd.Parameters.Add("@DeptNum", objPermission_furtherSql["deptID"].ToString());
}
if (objPermission_furtherSql["workGroupID"] != null )
{
//strsql += " and ItemNum in(@ItemNum)";
//cmd.Parameters.Add("@ItemNum", objPermission_furtherSql["workGroupID"].ToString());
}
cmd.CommandText = strsql;
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("updateesntodosSettle")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage update_esn_todos_Settle(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);
String strsql = "" ;
strsql += String.Format(@"update [esn_todos_Settle] set isClosed=@isClosed , update_user_id=@gUserID_wade ,update_time=GETDATE()
where id in(@ids) ");
cmd.Parameters.AddWithValue("@gUserID_wade", obj_input["gUserID_wade"].ToString());
cmd.Parameters.AddWithValue("@isClosed", obj_input["isClosed"].ToString()=="1"?true:false);
JArray idsar =JArray.Parse( obj_input["ids"].ToString());
if (idsar.Count>0)
{
string t= String.Join(",", obj_input["ids"]);
strsql=strsql.Replace("@ids", t);
}
cmd.CommandText = strsql;
DataTable dt = SqlToDt(cmd);
response.Msg = "設定完成";
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;
}
public DataTable get_esn_todos_Settle_config( String gWadeID, bool is_enabled)
{ {
DataTable dt=null; DataTable dt=null;
try try
...@@ -140,10 +255,10 @@ namespace WebAPI.Controllers ...@@ -140,10 +255,10 @@ namespace WebAPI.Controllers
} }
[Route("UpdateEsntodosSettle")] [Route("insertEsntodosSettle")]
[CorsHandle] [CorsHandle]
[HttpPost] [HttpPost]
public HttpResponseMessage Update_Esn_todos_Settle(ParamModel param) public HttpResponseMessage insert_Esn_todos_Settle(ParamModel param)
{ {
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString()))) if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{ {
...@@ -154,7 +269,7 @@ namespace WebAPI.Controllers ...@@ -154,7 +269,7 @@ namespace WebAPI.Controllers
using (SqlConnection Conn = new SqlConnection(connString)) using (SqlConnection Conn = new SqlConnection(connString))
{ {
SqlCommand cmd = new SqlCommand("",Conn); SqlCommand cmd = new SqlCommand("",Conn);
DataTable dtL1 = get_Esn_todos_SettleData(obj_input["gWadeID"].ToString(), true); DataTable dtL1 = get_esn_todos_Settle_config(obj_input["gWadeID"].ToString(), true);
String strsql="" ,wherecase ; String strsql="" ,wherecase ;
DataRow drL1; DataRow drL1;
if (dtL1 != null) if (dtL1 != null)
......
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