diff --git a/SolarPower/Controllers/LoginController.cs b/SolarPower/Controllers/LoginController.cs index 39c7b61..e4b5df8 100644 --- a/SolarPower/Controllers/LoginController.cs +++ b/SolarPower/Controllers/LoginController.cs @@ -86,6 +86,7 @@ namespace SolarPower.Controllers } HttpContext.Session.SetString("MyAccount", edFunction.AESEncrypt(user.Account)); //將帳號透過AES加密 + HttpContext.Session.SetString("CompanyId", edFunction.AESEncrypt(user.CompanyId.ToString())); //將公司id透過AES加密 return RedirectToAction("Index", "User"); diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index cd93cba..77eaf36 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -1,4 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +using SolarPower.Models; +using SolarPower.Models.User; +using SolarPower.Repository.Interface; + using System; using System.Collections.Generic; using System.Linq; @@ -6,16 +13,54 @@ using System.Threading.Tasks; namespace SolarPower.Controllers { - public class PowerStationController : Controller + public class PowerStationController : MyBaseController { + private readonly IUserRepository userRepository; + + public PowerStationController(IUserRepository userRepository) : base() + { + this.userRepository = userRepository; + } public IActionResult Index() { return View(); } + public IActionResult Add() + { + return View("~/Views/PowerStation/PowerStationAdd.cshtml"); + } + public IActionResult Edit() { return View("~/Views/PowerStation/PowerStationEdit.cshtml"); } + + /// + /// 取得下拉式公司選單,須為Deleted: 0 + /// + /// + [HttpGet] + public async Task>> GetUserSelectOptionListAsync() + { + ApiResult> apiResult = new ApiResult>(); + try + { + EDFunction edFunction = new EDFunction(); + var companyId= Convert.ToInt32(edFunction.AESDecrypt(HttpContext.Session.GetString("CompanyId"))); //將公司id透過AES解密 + var userSelectItemLists = await userRepository.GetUserSelectOptionListAsync(companyId); + + apiResult.Code = "0000"; + apiResult.Data = userSelectItemLists; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } } } diff --git a/SolarPower/Models/User.cs b/SolarPower/Models/User.cs index 5bfba2b..78477d7 100644 --- a/SolarPower/Models/User.cs +++ b/SolarPower/Models/User.cs @@ -130,4 +130,11 @@ namespace SolarPower.Models.User public string Phone { get; set; } //手機 } + public class UserSelectItemList + { + public string Text { get; set; } + public string Value { get; set; } + } + + } diff --git a/SolarPower/Repository/Implement/UserRepository.cs b/SolarPower/Repository/Implement/UserRepository.cs index 0761ef2..973648a 100644 --- a/SolarPower/Repository/Implement/UserRepository.cs +++ b/SolarPower/Repository/Implement/UserRepository.cs @@ -277,5 +277,33 @@ namespace SolarPower.Repository.Implement return result; } } + + + /// + /// 透過公司,查詢使用者列表,0為全部公司的所有人 + /// + /// + /// + public async Task> GetUserSelectOptionListAsync(int companyId) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = $"SELECT Id AS Value, Name AS Text FROM {tableName} WHERE Deleted = 0"; + if(companyId != 0) + { + sql+=@" AND CompanyId=@companyId"; + } + result = (await conn.QueryAsync(sql, new { companyId = companyId })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } } } diff --git a/SolarPower/Repository/Interface/IUserRepository.cs b/SolarPower/Repository/Interface/IUserRepository.cs index b44ef2f..8f0d930 100644 --- a/SolarPower/Repository/Interface/IUserRepository.cs +++ b/SolarPower/Repository/Interface/IUserRepository.cs @@ -67,5 +67,12 @@ namespace SolarPower.Repository.Interface /// /// Task> GetAllByFilterAsync(PostUserFilter filter); + + /// + /// 透過公司,查詢使用者列表,0為全部公司的所有人 + /// + /// + /// + Task> GetUserSelectOptionListAsync(int CompanyId); } } diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index acafc32..0597490 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -50,7 +50,7 @@
- + 新增電站 diff --git a/SolarPower/Views/PowerStation/PowerStationAdd.cshtml b/SolarPower/Views/PowerStation/PowerStationAdd.cshtml new file mode 100644 index 0000000..7155fc9 --- /dev/null +++ b/SolarPower/Views/PowerStation/PowerStationAdd.cshtml @@ -0,0 +1,163 @@ + +
+
+
+
+
+
+ +
+
+ +
+ +
電站基本資料
+ +
+
+
+
+ + +
+
+ + +
+
+

是否為代管:

+

+

+ + +
+

+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
逆變器
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
光電板
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+@section Scripts{ + + +} \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index 1cacd51..9a3d60b 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -81,4 +81,42 @@
- \ No newline at end of file + + +@section Scripts{ + + +} \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml index 4b3b997..f42db3a 100644 --- a/SolarPower/Views/PowerStation/_StationInfo.cshtml +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -16,60 +16,68 @@
-

電站代碼 

-

PEP-NTP001

+

電站代碼: 

+ +
-

電站名稱:

-

新竹巨城站

+

電站名稱:

+ +

是否為代管 :

- - + +

-

台電掛錶日 

-

2018-12-26

+

台電掛錶日 

+ +
-

預計回收年限:

-

20

+

預計回收年限:

+ +
-

資料建立:

-

蜘蛛人

+

資料建立: +

-

電廠發電容量 
(kW)

-

362.7

+

電廠發電容量 
(kW)

+ +
-

運維人員:

-

美國隊長
鋼鐵人

+

運維人員:

+
-

被代管公司 :

-

台達電

+

被代管公司 :

+ +
-

授電費率:

-

PM060MW2_305

+

授電費率:

+ +
-

座標:

-

25.0726625,
121.5725953

+

座標:

+ +
-

建立時間:

-

2018-10-01 12:00

+

建立時間:

@@ -78,13 +86,19 @@
逆變器
-

廠牌:AUO

+

廠牌:AUO

+ +
-

型號 :PM060MW2_305

+

型號 :PM060MW2_305

+ +
-

數量:400

+

數量:400

+ +
@@ -92,16 +106,24 @@
光電板
-

廠牌:ABLYTEK

+

廠牌:ABLYTEK

+ +
-

規格 :1640×992×40

+

規格 :1640×992×40

+ +
-

數量:1116

+

數量:1116

+ +
-

型號 :6MN6A295

+

型號 :6MN6A295

+ +
@@ -253,4 +275,4 @@ - \ No newline at end of file + diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 02c0d7d..c133257 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -31,6 +31,7 @@ + @@ -1153,6 +1154,10 @@ + + + + @*各頁面的JavaScript*@ @RenderSection("Scripts", required: false)