Commit 8544537f authored by solho's avatar solho

取得權限資料邏輯調整

parent 96045529
......@@ -62,7 +62,19 @@ namespace WebAPI.Controllers
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 (obj_input["Settle_Date"] != null)
{
@wherecase2 += " and Settle_Date between @Settle_Date and @Settle_Date ";
......@@ -74,15 +86,7 @@ namespace WebAPI.Controllers
@wherecase2 += " and isClosed=@isClosed ";
cmd.Parameters.AddWithValue("@isClosed", (obj_input["isClosed"].ToString() == "1" ? true : false));
}
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());
}
strsql = strsql.Replace("@wherecase1", @wherecase1).Replace("@wherecase2", @wherecase2);
strsql += " order by a.Settle_Date";
response.Code = "1";
......@@ -127,30 +131,19 @@ namespace WebAPI.Controllers
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,b.id as DStargetid from [esn_todos_Settle] a
String strsql = "" ;
strsql += String.Format(@"select a.id, Settle_Date ,isClosed ,Emp_DS ,a.update_time,b.id as DStargetid,b.Emp_DSNum from [esn_todos_Settle] a
inner 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 && !String.IsNullOrEmpty(obj_input["Settle_Date"].ToString()) )
{
strsql += " and Settle_Date between @Settle_Date_begin and @Settle_Date_end ";
DateTime Settle_Date = Convert.ToDateTime(obj_input["Settle_Date"].ToString());
cmd.Parameters.AddWithValue("@Settle_Date_begin", Settle_Date );
cmd.Parameters.AddWithValue("@Settle_Date_end", Settle_Date.AddMonths(1).AddDays(-1) );
}
if (obj_input["isClosed"] != null )
if (obj_input["Permission_furtherSql"] != null)
{
strsql += " and isClosed=@isClosed ";
cmd.Parameters.AddWithValue("@isClosed", (obj_input["isClosed"].ToString()=="1"?true:false));
}
JObject objPermission_furtherSql = JObject.Parse(obj_input["Permission_furtherSql"].ToString());
if (objPermission_furtherSql["firmID"] != null && !String.IsNullOrEmpty(objPermission_furtherSql["firmID"].ToString()))
{
strsql += " and b.ID in(@DSid)";
strsql= strsql.Replace("@DSid", objPermission_furtherSql["firmID"].ToString());
strsql = strsql.Replace("@DSid", objPermission_furtherSql["firmID"].ToString());
//cmd.Parameters.Add("@DSid", objPermission_furtherSql["firmID"].ToString());
}
if (objPermission_furtherSql["deptID"] != null && !String.IsNullOrEmpty(objPermission_furtherSql["deptID"].ToString()))
......@@ -163,6 +156,19 @@ namespace WebAPI.Controllers
//strsql += " and ItemNum in(@ItemNum)";
//cmd.Parameters.Add("@ItemNum", objPermission_furtherSql["workGroupID"].ToString());
}
}
if (obj_input["Settle_Date"]!=null && !String.IsNullOrEmpty(obj_input["Settle_Date"].ToString()) )
{
strsql += " and Settle_Date between @Settle_Date_begin and @Settle_Date_end ";
DateTime Settle_Date = Convert.ToDateTime(obj_input["Settle_Date"].ToString());
cmd.Parameters.AddWithValue("@Settle_Date_begin", Settle_Date );
cmd.Parameters.AddWithValue("@Settle_Date_end", Settle_Date.AddMonths(1).AddDays(-1) );
}
if (obj_input["isClosed"] != null )
{
strsql += " and isClosed=@isClosed ";
cmd.Parameters.AddWithValue("@isClosed", (obj_input["isClosed"].ToString()=="1"?true:false));
}
cmd.CommandText = strsql;
DataTable dt = SqlToDt(cmd);
response.Msg = JsonConvert.SerializeObject(dt);
......
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