Imports System.Net
Imports System.Web.Http
Namespace Controllers
Public Class extDashboardController : Inherits ApiController
'สถานะใบสั่งซื้อ
<HttpGet>
<Route("api/extDashboard/GetPOStatus_dashBoard")>
Public Function GetPOStatus_dashBoard() As IHttpActionResult
Dim strSQL0 =
<Suparuck>
DECLARE @budgetYear VARCHAR(max);
SET @budgetYear = (
SELECT TOP (1) BUDGET.year
FROM BDG_TYPE
INNER JOIN BUDGET ON BDG_TYPE.BDGCODE = BUDGET.type
WHERE BUDGET.BudgetOpen = 'O'
);
--SELECT @budgetYear;
IF @budgetYear IS NOT NULL
BEGIN
SELECT TblPOStatus.StatusCode,
TblPOStatus.StatusName,
FORMAT(COUNT(MS_PO.PO_NO), 'N0') AS Items,
FORMAT(SUM(TOTAL_COST), 'N2') AS Total
FROM MS_PO
INNER JOIN TblPOStatus ON TblPOStatus.StatusCode = MS_PO.STATUS
GROUP BY TblPOStatus.StatusCode,
TblPOStatus.StatusName,
LEFT(PO_NO, 2)
HAVING LEFT(PO_NO, 2) = RIGHT(@budgetYear, 2)
ORDER BY TblPOStatus.StatusCode;
END
--ELSE
--BEGIN
-- SELECT TblPOStatus.StatusCode,
-- TblPOStatus.StatusName,
-- COUNT(MS_PO.PO_NO) AS Items,
-- LEFT(PO_NO, 2) AS BudgetYear,
-- SUM(TOTAL_COST) AS Total
-- FROM MS_PO
-- INNER JOIN TblPOStatus ON TblPOStatus.StatusCode = MS_PO.STATUS
-- GROUP BY TblPOStatus.StatusCode,
-- TblPOStatus.StatusName,
-- LEFT(PO_NO, 2)
-- HAVING LEFT(PO_NO, 2) = RIGHT(@budgetYear, 2)
-- ORDER BY TblPOStatus.StatusCode;
--END
</Suparuck>
Dim dt = Sexy_DatabaseVB.DbHelper.Query(strSQL0.Value)
If dt.Rows.Count = 0 Then 'ไม่ได้เปิดงบประมาณ BUDGET.BudgetOpen
'TODO
End If
Return Ok(dt.AsEnumerable().ToList())
End Function
' มูลค่ายาและเวชภัณฑ์คงคลัง ณ คลังยาย่อย
<HttpGet>
<Route("api/extDashboard/SubStockValue_dashBoard")>
Public Function GetSubStockValue_dashBoard() As IHttpActionResult
Dim strSQL0 =
<Suparuck>
SELECT DEPT_ID.DEPT_NAME, FORMAT(SUM(TOTAL_VALUE), 'N2') AS TotalAmount
FROM SUBSTOCK INNER JOIN DEPT_ID
ON DEPT_ID.DEPT_ID = SUBSTOCK.DEPT_ID AND TOTAL_VALUE IS NOT NULL
GROUP BY DEPT_NAME ORDER BY SUM(TOTAL_VALUE) DESC
</Suparuck>
Dim dt = Sexy_DatabaseVB.DbHelper.Query(strSQL0.Value)
'If dt.Rows.Count = 0 Then 'ไม่ได้เปิดงบประมาณ BUDGET.BudgetOpen
' 'TODO
'End If
Return Ok(dt.AsEnumerable().ToList())
End Function
End Class
End Namespace