diff --git a/SolarPower/Controllers/StationReportController.cs b/SolarPower/Controllers/StationReportController.cs index 3febd9a..42716e6 100644 --- a/SolarPower/Controllers/StationReportController.cs +++ b/SolarPower/Controllers/StationReportController.cs @@ -133,9 +133,21 @@ namespace SolarPower.Controllers ApiResult apiResult = new ApiResult(); try { - var a = await stationReportRepository.Gettablebody(post); - apiResult.Code = "0000"; - apiResult.Data = a; + + var checkinv = stationReportRepository.Findhaveinv(post); + var getinvsql = checkinv.Result[0] as IDictionary; + if (getinvsql["mySelect"] == null) + { + apiResult.Code = "9985"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + } + else + { + var a = await stationReportRepository.Gettablebody(post); + apiResult.Code = "0000"; + apiResult.Data = a; + } + } catch (Exception exception) { @@ -741,7 +753,8 @@ namespace SolarPower.Controllers Userid = postObject.Userid }; var k = stationReportRepository.Findhaveinv(select_Table); - if(k.Result[0].values == null) + var getinvsql = k.Result[0] as IDictionary; + if (getinvsql["mySelect"] == null) { return ""; } diff --git a/SolarPower/Models/ErrorCode.cs b/SolarPower/Models/ErrorCode.cs index d88f4d7..bb221c5 100644 --- a/SolarPower/Models/ErrorCode.cs +++ b/SolarPower/Models/ErrorCode.cs @@ -20,6 +20,7 @@ namespace SolarPower.Models { "0002","請先刪除相關逆變器"}, { "0003","請先刪除相關設備"}, { "0004","請先移除相關逆變器綁定"}, + { "9985","該電站尚無逆變器資料"}, { "9986", "該帳號已被註冊,請重新輸入"}, { "9987", "查無該運維作業記錄檔案"}, { "9988", "查無該資料紀錄"}, diff --git a/SolarPower/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 1dc76a4..a8b8f94 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -742,14 +742,19 @@ var url = "/StationReport/GetForm"; $.post(url, send_data, function (rel) { if (rel.code != "0000") { - toast_error(rel.msg); + if (rel.code == "9985") { + toast_warning(rel.msg); + } else { + toast_error(rel.msg); + } + $('#TableBody').empty(); + $('#totbody').empty(); return; } var sta = ""; $('#TableBody').empty(); $('#totbody').empty(); $('#tothead').empty(); - if (form == 0) {//日報表 var thour = 0; var tpr = 0; @@ -934,7 +939,6 @@ haveinvertName = []; } $('.overflow-auto').show(); - nowform = form; }, 'json'); }