Commit 6b9ef721 authored by solho's avatar solho

fix:補缺檔

parent a3c8d153
......@@ -25,6 +25,103 @@ namespace WebAPI.Controllers
response = new CommonResponseMsg();
connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
}
/// <summary>
/// 取得關帳最早日期
/// </summary>
/// <para ></param>
/// <returns></returns>
///
[Route("getSettleDateN")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage get_Settle_DateN(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))
{
;
String @wherecase1 = "", @wherecase2 = "";
SqlCommand cmd = new SqlCommand("", Conn);
String strsql = "";
strsql += @"
SELECT top 1 CONVERT(varchar(7),Settle_Date,126) Settle_Month,(
SELECT top 1 CONVERT(varchar(7),Settle_Date,126) Settle_Month 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
left join @
where 1=1 @wherecase1
order by Settle_Date
) as minSettle_Month 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 @wherecase2
";
if (obj_input["Permission_furtherSql"] != null)
{
JObject objPermission_furtherSql = JObject.Parse(obj_input["Permission_furtherSql"].ToString());
if (objPermission_furtherSql["firmID"] != null && !String.IsNullOrEmpty(objPermission_furtherSql["firmID"].ToString()))
{
@wherecase1 += " and b.ID in(@DSid)";
@wherecase2 += " and b.ID in(@DSid)";
@wherecase1 = @wherecase1.Replace("@DSid", objPermission_furtherSql["firmID"].ToString());
@wherecase2 = @wherecase2.Replace("@DSid", objPermission_furtherSql["firmID"].ToString());
//cmd.Parameters.Add("@DSid", objPermission_furtherSql["firmID"].ToString());
}
if (objPermission_furtherSql["option"] != null && !String.IsNullOrEmpty(objPermission_furtherSql["option"].ToString()))
{
if (objPermission_furtherSql["option"].ToString().Contains("2485762")) //內管 OPTION為 ALL
{
@wherecase1 = "";
@wherecase2 = "";
}
}
}
if (obj_input["Settle_Date"] != null)
{
@wherecase2 += " and Settle_Date between @Settle_Date and @Settle_Date ";
strsql += " and Settle_Date between @Settle_Date and @Settle_Date ";
cmd.Parameters.AddWithValue("@Settle_Date", obj_input["Settle_Date"].ToString());
}
if (obj_input["isClosed"] != null)
{
@wherecase2 += " and isClosed=@isClosed ";
cmd.Parameters.AddWithValue("@isClosed", (obj_input["isClosed"].ToString() == "1" ? true : false));
}
strsql = strsql.Replace("@wherecase1", @wherecase1).Replace("@wherecase2", @wherecase2);
strsql += " order by a.Settle_Date";
response.Code = "1";
cmd.CommandText = strsql;
DataTable dt = SqlToDt(cmd);
response.Msg = JsonConvert.SerializeObject(dt);
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
}
}
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;
}
/// <summary>
/// 取得關帳最早日期
/// </summary>
......
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": []
}
\ No newline at end of file
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