Commit 56e3218f authored by solho's avatar solho

關帳日期邏輯調整

parent 95806702
...@@ -26,7 +26,7 @@ namespace WebAPI.Controllers ...@@ -26,7 +26,7 @@ namespace WebAPI.Controllers
connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString; connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
} }
/// <summary> /// <summary>
/// 取得關帳最日期 /// 取得關帳最日期
/// </summary> /// </summary>
/// <para ></param> /// <para ></param>
/// <returns></returns> /// <returns></returns>
...@@ -45,32 +45,45 @@ namespace WebAPI.Controllers ...@@ -45,32 +45,45 @@ namespace WebAPI.Controllers
using (SqlConnection Conn = new SqlConnection(connString)) using (SqlConnection Conn = new SqlConnection(connString))
{ {
; ;
String @wherecase1="", @wherecase2="";
SqlCommand cmd = new SqlCommand("", Conn); SqlCommand cmd = new SqlCommand("", Conn);
String strsql = ""; String strsql = "";
strsql += @" strsql += @"
SELECT top 1 CONVERT(varchar(7),Settle_Date,126) Settle_Month from [esn_todos_Settle] a 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
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_EmpDS] b on a.DSNum=b.Emp_DSNum
left join [evw_qResult_Dept] c on a.DeptNum=c.targetID 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 [evw_qResult_EmpItem] d on a.ItemNum=d.Emp_ItemNum
where 1=1 where 1=1 @wherecase2
"; ";
JObject objPermission_furtherSql = JObject.Parse(obj_input["Permission_furtherSql"].ToString()); JObject objPermission_furtherSql = JObject.Parse(obj_input["Permission_furtherSql"].ToString());
if (obj_input["Settle_Date"] != null) 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 "; strsql += " and Settle_Date between @Settle_Date and @Settle_Date ";
cmd.Parameters.Add("@Settle_Date", obj_input["Settle_Date"].ToString()); cmd.Parameters.Add("@Settle_Date", obj_input["Settle_Date"].ToString());
} }
if (obj_input["isClosed"] != null) if (obj_input["isClosed"] != null)
{ {
strsql += " and isClosed=@isClosed "; @wherecase2 += " and isClosed=@isClosed ";
cmd.Parameters.Add("@isClosed", (obj_input["isClosed"].ToString() == "1" ? true : false)); cmd.Parameters.Add("@isClosed", (obj_input["isClosed"].ToString() == "1" ? true : false));
} }
if (objPermission_furtherSql["firmID"] != null) if (objPermission_furtherSql["firmID"] != null && !String.IsNullOrEmpty(objPermission_furtherSql["firmID"].ToString()))
{ {
strsql += " and b.ID in(@DSid)"; @wherecase1 += " and b.ID in(@DSid)";
strsql = strsql.Replace("@DSid", objPermission_furtherSql["firmID"].ToString()); @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()); //cmd.Parameters.Add("@DSid", objPermission_furtherSql["firmID"].ToString());
} }
strsql = strsql.Replace("@wherecase1", @wherecase1).Replace("@wherecase2", @wherecase2);
strsql += " order by a.Settle_Date"; strsql += " order by a.Settle_Date";
response.Code = "1"; response.Code = "1";
cmd.CommandText = strsql; cmd.CommandText = strsql;
......
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