28 Commits

Author SHA1 Message Date
d41ad3e4cc STAGE3 OK 2025-11-12 18:13:09 +08:00
ba6e641bac STAGE 2 OK 2025-11-12 17:51:42 +08:00
9969417bd8 優化 FollowerController.cs 的子查詢性能
問題:
Line 345 將家族成員 ID 載入內存(ToList)
- 如果家族有 100+ 成員,載入 100-400 bytes

優化:
移除 ToList(),改為使用 IQueryable 子查詢
- var ccList = cc.ToList(); // 移除
- 直接使用 cc 進行 Contains 查詢
- 生成 SQL: WHERE num IN (SELECT...) OR leader IN (SELECT...)

效果:
✓ 減少內存占用:100-400 bytes → 0
✓ 完全在數據庫執行
✓ SQL 優化器可以更好地優化查詢計劃

對比:
- 原始版本(載入內存):2 次查詢
- 優化版本(子查詢):1 次查詢(最佳)
2025-11-12 17:30:53 +08:00
eff3ad778b 優化 adminUserController.cs 的子查詢性能
問題:
Line 93 將所有會員的 admin_num 載入內存(ToList)
- 如果有 10,000 個會員,載入 10,000 個 int (40KB)

優化:
改為使用 IQueryable 子查詢,在數據庫層面執行
- var usedAdminNums = _db.members.Select(b => b.admin_num);  // 不 ToList()
- 生成 SQL: WHERE num NOT IN (SELECT admin_num FROM members)

效果:
✓ 減少內存占用:40KB → 0
✓ 減少查詢次數:2 次 → 1 次
✓ SQL 優化器可以更好地優化查詢計劃

對比原始代碼:
- 原始(嵌套 AsEnumerable):N+1 查詢問題,執行 51 次
- ToList 版本:載入 40KB,執行 2 次
- 當前版本:不載入內存,執行 1 次(最佳)
2025-11-12 17:27:35 +08:00
bc1f1422e9 加入 TODO 註解標記需優化的查詢
標記位置:
1. GetFollowerOrders (Line 402)
   - 建議加入分頁或日期範圍限制

2. GetActivityFollowers (Line 1048)
   - 建議在數據庫層面過濾未完成沖帳項目
   - 考慮加入 Take() 或分頁

目的:
方便日後追蹤並優化性能瓶頸
2025-11-12 17:21:53 +08:00
1698b51d19 優化 transfer_registerController.cs 中的 AsEnumerable 位置
問題:
之前將某些 AsEnumerable() 改為 ToList() 可能導致數據過載

優化:
1. GetFollowerOrders (Line 420)
   - 改回 AsEnumerable()
   - 原因:雖然有 f_num 限制,但信眾可能有大量訂單
   - AsEnumerable() 確保數據庫查詢先執行,只在需要內存計算時才轉換

2. GetActivityFollowers (Line 1057)
   - 改回 AsEnumerable()
   - 原因:activity_num 限制可能包含大量訂單(數千條)
   - AsEnumerable() 避免將所有數據載入內存

保持不變:
- Line 240:follower 查詢的 ToList() 保持不變
  原因:Where(f.num == x.f_num) 限制為單一記錄
  需要在內存中執行解密操作

技術原則:
- AsEnumerable() 應該在「數據庫查詢完成後、內存計算前」使用
- ToList() 只在「確定數據量小」或「必須立即執行」時使用
- 解密等無法在數據庫執行的操作必須在內存中進行
2025-11-12 17:20:36 +08:00
4e26dd648d 完成 Batch 3:修復 4 個 API Controller 的 AsEnumerable 問題
修復文件(共 17 處):

1. supplierController.cs (6 處)
   - 移除簡單查詢的 AsEnumerable() (2 處)
   - AsEnumerable() → AsQueryable() (GetList, GetKindList)
   - 優化分頁查詢模式(Count + ToPagedList.ToList())(2 處)
   - 修復 Split().Select().ToList() 類型問題

2. adminUserController.cs (4 處)
   - 移除簡單查詢的 AsEnumerable()
   - AsEnumerable() → AsQueryable() (GetList)
   - 優化分頁查詢模式
   - 重構複雜查詢:移除嵌套的 AsEnumerable()
     改為先 ToList() 再使用 Contains

3. orderdetailController.cs (3 處)
   - 移除 AsEnumerable(),改為在查詢末端使用 OrderBy
   - 優化分頁查詢模式
   - 修復 null-propagating operator:
     .FirstOrDefault()?.print_id → .Select(u => u.print_id).FirstOrDefault()

4. transfer_registerController.cs (6 處)
   - AsEnumerable() → ToList() (需要解密操作的情況)
   - 保留在必要時才轉換到內存操作
   - 確保數據庫查詢先執行

技術改進:
✓ 複雜嵌套查詢優化(adminUserController)
✓ 解密操作前置優化(transfer_registerController)
✓ Null-propagating operator 替換為安全的 Select
✓ 統一使用三元運算符處理分頁
✓ IEnumerable<int> → List<int> 避免類型轉換錯誤
2025-11-12 17:18:12 +08:00
e20b250944 修復 FilesSetController.cs 中的類型錯誤
問題:
1. CS1061: files_num 是 int 類型,不是 int?
   - 錯誤地使用了 HasValue 和 .Value
2. CS0019: Count 應該使用方法調用 Count()

修復:
- 第 93 行:移除 HasValue 和 .Value
  改為直接使用 ids.Contains(q.files_num)
- 第 94 行:Count 改為 Count()

根因分析:
在 Model.actItem_files 中,files_num 定義為 int 類型
而不是 Nullable<int>,因此不需要 nullable 處理。
2025-11-12 17:12:40 +08:00
e88821db4b 完成 Batch 2:修復 4 個 API Controller 的 AsEnumerable 問題
修復文件(共 21 處):

1. newsController.cs (7 處)
   - 移除簡單查詢的 AsEnumerable()
   - AsEnumerable() → AsQueryable() (GetList, GetKindList)
   - 優化分頁查詢模式(Count + ToPagedList.ToList())
   - 修復 Split().Select().ToList() 類型問題

2. FilesSetController.cs (5 處)
   - 移除簡單查詢的 AsEnumerable()
   - AsEnumerable() → AsQueryable() (GetList)
   - 優化分頁查詢模式
   - 修復 files_num nullable 字段處理
   - 修復 Split().Select().ToList() 類型問題

3. bedController.cs (5 處)
   - 移除簡單查詢的 AsEnumerable()
   - AsEnumerable() → AsQueryable() (companies, bed_order_detail)
   - 優化分頁查詢模式
   - 簡化查詢條件

4. bed_kindController.cs (4 處)
   - AsEnumerable() → AsQueryable() (bed_kind, bed_kind_detail)
   - 優化分頁查詢模式(兩處)
   - 優化 bedDt 查詢:移除 AsEnumerable(),改用 Where + ToList()
   - 修復 bed_kind_detail_id nullable 字段處理

技術改進:
✓ 所有查詢改為在數據庫執行
✓ 統一使用三元運算符處理分頁
✓ Count 在分頁前執行
✓ 正確處理 nullable 字段(HasValue + .Value)
✓ IEnumerable<int> → List<int> 避免類型轉換錯誤
2025-11-12 17:11:05 +08:00
3f63457c5a 修復 memberController.cs 中 nullable 字段的處理
問題:
1. CS1503: mem_num 是 int? 類型,不能直接用於 Contains(int)
2. CS0019: Count 應該使用方法調用 Count()

修復:
- 第 110 行:加入 HasValue 檢查和 .Value 取值
- 第 111 行:使用 Count() 方法而非 Count 屬性

技術說明:
在 LINQ to Entities 中處理 nullable 字段時,必須:
1. 使用 HasValue 檢查是否有值
2. 使用 .Value 取得實際值
3. 確保類型匹配以便正確生成 SQL 查詢

相關文件已正確處理:
✓ accountingController.cs (第 97 行)
✓ stockController.cs (第 92 行)
2025-11-12 17:04:03 +08:00
9a0d5ae700 修復 Batch 1 中 IEnumerable.Contains 的型別轉換問題
問題:
- Split().Select(int.Parse) 返回 IEnumerable<int>
- LINQ to Entities 中使用 Contains 需要具體集合類型

修復:
- 在所有 Split().Select() 後加 .ToList()
- 確保 EF 可以將 Contains 轉換為 SQL IN 子句

影響文件:
- memberController.cs (2 處)
- accountingController.cs (1 處)
- FollowerController.cs (1 處)
- stockController.cs (1 處)

技術說明:
LINQ to Entities 要求 Contains 的集合參數是具體化的集合(List/Array),
而不能是延遲執行的 IEnumerable,以便正確生成 SQL 查詢。
2025-11-12 17:01:49 +08:00
79b7dd114f 修復 Batch 1: FollowerController, memberController, accountingController, stockController
- FollowerController.cs: 8 處修復
- memberController.cs: 9 處修復
- accountingController.cs: 8 處修復
- stockController.cs: 8 處修復

總計 33 處,覆蓋會員、財務、庫存核心功能
2025-11-12 16:37:59 +08:00
cd05ad2305 phase 2 2025-11-12 16:20:51 +08:00
5ae262205c 更新查詢方式 2025-11-12 15:58:20 +08:00
6f5a2e65bd Merge branch 'main' of https://git.17888.com.tw/yiming/17168ERP
# Conflicts:
#	web/admin/guadan/create.aspx
2025-11-12 12:53:25 +08:00
22d283dbe6 增加JSON IGNORE設定 2025-11-12 12:50:13 +08:00
3b5d366863 修改URL錯誤 2025-11-07 10:26:49 +08:00
c0404b8e70 添加sql執行文件,執行該文件就可以正常使用掛單和神祖牌位模組 2025-11-06 09:25:45 +08:00
1a6731e4c6 Merge remote-tracking branch 'origin/hkj1003' 2025-11-05 13:18:03 +08:00
b776b411b4 上传资料库结构 2025-10-29 13:54:27 +08:00
e9f17a5037 神祖牌位管理模組,掛單模組前端URL添加HTTP_HOST 2025-10-29 13:48:20 +08:00
05ef2e28f3 UPDATE 2025-10-20 11:54:40 +08:00
90ef949ca4 Merge remote-tracking branch 'origin/hkj1003' 2025-10-19 22:02:28 +08:00
39c9dd29e1 Merge branch 'yiming1013' 2025-10-19 22:01:45 +08:00
a6aa35176c Merge branch 'main' of https://git.17888.com.tw/yiming/17168ERP 2025-10-19 22:00:45 +08:00
7d36d6b0a6 掛單調整 2025-10-14 13:44:23 +08:00
6fc82510cc 在掛單資料頁面,增加判斷掛單是否超時 2025-10-09 16:49:32 +08:00
4a36ce9c1c 挂单资料增加挂单单号查询,增加显示挂单单号 2025-10-03 16:41:34 +08:00
90 changed files with 5515 additions and 448 deletions

Binary file not shown.

View File

@@ -0,0 +1,176 @@
USE [17168erp_t2]
GO
/****** Object: Table [dbo].[AncestralTabletArea] Script Date: 2025/10/29 下午 01:32:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AncestralTabletArea](
[AreaId] [int] IDENTITY(1,1) NOT NULL,
[AreaName] [nvarchar](10) NOT NULL,
[AreaCode] [nvarchar](20) NOT NULL,
[ParentAreaId] [int] NULL,
[AreaType] [nvarchar](10) NULL,
[Price] [int] NULL,
[SortOrder] [int] NULL,
[IsDisabled] [bit] NOT NULL,
[Description] [nvarchar](200) NULL,
PRIMARY KEY CLUSTERED
(
[AreaId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[AncestralTabletPosition] Script Date: 2025/10/29 下午 01:32:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AncestralTabletPosition](
[PositionId] [int] IDENTITY(1,1) NOT NULL,
[AreaId] [int] NOT NULL,
[PositionCode] [nvarchar](20) NOT NULL,
[PositionName] [nvarchar](50) NULL,
[Price] [int] NULL,
[StatusCode] [nvarchar](20) NULL,
[Description] [nvarchar](200) NULL,
[RowNo] [int] NULL,
[ColumnNo] [int] NULL,
PRIMARY KEY CLUSTERED
(
[PositionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY],
CONSTRAINT [UQ_Position_Area_Code] UNIQUE NONCLUSTERED
(
[AreaId] ASC,
[PositionCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[AncestralTabletPositionRecord] Script Date: 2025/10/29 下午 01:32:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AncestralTabletPositionRecord](
[RecordId] [int] IDENTITY(1,1) NOT NULL,
[RegistrantCode] [nvarchar](20) NOT NULL,
[NPTitle] [nvarchar](30) NULL,
[NPStandDate] [date] NOT NULL,
[NPYangShang] [nvarchar](20) NULL,
[WPContent] [nvarchar](1000) NULL,
[CreatedAt] [datetime] NOT NULL,
[UpdatedAt] [datetime] NULL,
PRIMARY KEY CLUSTERED
(
[RecordId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[AncestralTabletRegistrant] Script Date: 2025/10/29 下午 01:32:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AncestralTabletRegistrant](
[RegistrantCode] [nvarchar](20) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Phone] [nvarchar](50) NULL,
[Address] [nvarchar](60) NULL,
[RegisterDate] [date] NOT NULL,
[Price] [int] NULL,
[PositionId] [int] NULL,
[StartDate] [date] NOT NULL,
[EndDate] [date] NULL,
[IsLongTerm] [bit] NOT NULL,
[IsActive] [bit] NOT NULL,
[CreatedAt] [datetime] NOT NULL,
[UpdatedAt] [datetime] NULL,
[IsEnd] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[RegistrantCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[AncestralTabletStatus] Script Date: 2025/10/29 下午 01:32:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AncestralTabletStatus](
[StatusCode] [nvarchar](20) NOT NULL,
[StatusName] [nvarchar](20) NOT NULL,
[StatusType] [nvarchar](20) NOT NULL,
PRIMARY KEY CLUSTERED
(
[StatusCode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AncestralTabletArea] ADD DEFAULT ((0)) FOR [IsDisabled]
GO
ALTER TABLE [dbo].[AncestralTabletPositionRecord] ADD DEFAULT (getdate()) FOR [CreatedAt]
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] ADD DEFAULT ((0)) FOR [IsLongTerm]
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] ADD DEFAULT ((1)) FOR [IsActive]
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] ADD DEFAULT (getdate()) FOR [CreatedAt]
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] ADD DEFAULT ((0)) FOR [IsEnd]
GO
ALTER TABLE [dbo].[AncestralTabletArea] WITH CHECK ADD CONSTRAINT [FK_AncestralTabletArea_Parent] FOREIGN KEY([ParentAreaId])
REFERENCES [dbo].[AncestralTabletArea] ([AreaId])
GO
ALTER TABLE [dbo].[AncestralTabletArea] CHECK CONSTRAINT [FK_AncestralTabletArea_Parent]
GO
ALTER TABLE [dbo].[AncestralTabletPosition] WITH CHECK ADD CONSTRAINT [FK_Position_Area] FOREIGN KEY([AreaId])
REFERENCES [dbo].[AncestralTabletArea] ([AreaId])
GO
ALTER TABLE [dbo].[AncestralTabletPosition] CHECK CONSTRAINT [FK_Position_Area]
GO
ALTER TABLE [dbo].[AncestralTabletPosition] WITH CHECK ADD CONSTRAINT [FK_Position_Status] FOREIGN KEY([StatusCode])
REFERENCES [dbo].[AncestralTabletStatus] ([StatusCode])
GO
ALTER TABLE [dbo].[AncestralTabletPosition] CHECK CONSTRAINT [FK_Position_Status]
GO
ALTER TABLE [dbo].[AncestralTabletPositionRecord] WITH CHECK ADD FOREIGN KEY([RegistrantCode])
REFERENCES [dbo].[AncestralTabletRegistrant] ([RegistrantCode])
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] WITH CHECK ADD CONSTRAINT [FK_Registrant_Position] FOREIGN KEY([PositionId])
REFERENCES [dbo].[AncestralTabletPosition] ([PositionId])
GO
ALTER TABLE [dbo].[AncestralTabletRegistrant] CHECK CONSTRAINT [FK_Registrant_Position]
GO
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'available', N'可用', N'Position')
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'maintenance', N'維護中', N'Position')
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'used', N'已使用', N'Position')
GO
-- 1. 如果不存在 OrderUuid 栏位,则新增
IF NOT EXISTS (
SELECT 1
FROM sys.columns
WHERE Name = N'OrderUuid'
AND Object_ID = Object_ID(N'dbo.GuaDanOrderGuest')
)
BEGIN
ALTER TABLE [dbo].[GuaDanOrderGuest]
ADD [OrderUuid] UNIQUEIDENTIFIER NULL;
END
GO
-- 2. 如果不存在 FK_GuaDanOrderGuest_Order 外键,则新增
IF NOT EXISTS (
SELECT 1
FROM sys.foreign_keys
WHERE Name = N'FK_GuaDanOrderGuest_Order'
AND parent_object_id = OBJECT_ID(N'dbo.GuaDanOrderGuest')
)
BEGIN
ALTER TABLE [dbo].[GuaDanOrderGuest]
ADD CONSTRAINT [FK_GuaDanOrderGuest_Order]
FOREIGN KEY ([OrderUuid]) REFERENCES [dbo].[GuaDanOrder] ([Uuid]);
END
GO

View File

@@ -0,0 +1,11 @@
資料字典:
USE [17168erp_t]
GO
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'available', N'可用', N'Position')
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'maintenance', N'維護中', N'Position')
INSERT [dbo].[AncestralTabletStatus] ([StatusCode], [StatusName], [StatusType]) VALUES (N'used', N'已使用', N'Position')
GO
代碼中會用到上面表中的狀態,所以必須在該表中插入上面的數據
AncestralTabletStatus_script.sql文件中的表是神祖牌位功能模組需要用到的表再運行之前需要先執行該文件
執行AncestralTabletStatus_script.sql後要把在item表中新增的URL權限添加到相應的管理員帳號

Binary file not shown.

12
review_report.txt Normal file
View File

@@ -0,0 +1,12 @@
═══════════════════════════════════════════════════════════════
🔍 AsEnumerable/AsQueryable/ToList 完整 REVIEW
═══════════════════════════════════════════════════════════════
檢查範圍Batch 1-3 所有已修改文件
檢查標準:
✅ 最佳選擇 - 性能和可讀性都最優
⚠️ 可優化 - 可以進一步優化
❌ 需修正 - 存在明顯問題
═══════════════════════════════════════════════════════════════

1
tyme4net/tyme4net Submodule

Submodule tyme4net/tyme4net added at 9ee8f71dac

View File

@@ -89,6 +89,11 @@ namespace Model
public virtual DbSet<RegionRoomBedStatus> RegionRoomBedStatus { get; set; }
public virtual DbSet<RegionType> RegionType { get; set; }
public virtual DbSet<Room> Room { get; set; }
public virtual DbSet<AncestralTabletArea> AncestralTabletArea { get; set; }
public virtual DbSet<AncestralTabletPosition> AncestralTabletPosition { get; set; }
public virtual DbSet<AncestralTabletPositionRecord> AncestralTabletPositionRecord { get; set; }
public virtual DbSet<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; }
public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; }
public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount)
{

View File

@@ -523,6 +523,139 @@ namespace Model
using System;
using System.Collections.Generic;
public partial class AncestralTabletArea
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AncestralTabletArea()
{
this.AncestralTabletArea1 = new HashSet<AncestralTabletArea>();
this.AncestralTabletPosition = new HashSet<AncestralTabletPosition>();
}
public int AreaId { get; set; }
public string AreaName { get; set; }
public string AreaCode { get; set; }
public Nullable<int> ParentAreaId { get; set; }
public string AreaType { get; set; }
public Nullable<int> Price { get; set; }
public Nullable<int> SortOrder { get; set; }
public bool IsDisabled { get; set; }
public string Description { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AncestralTabletArea> AncestralTabletArea1 { get; set; }
public virtual AncestralTabletArea AncestralTabletArea2 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AncestralTabletPosition> AncestralTabletPosition { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class AncestralTabletPosition
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AncestralTabletPosition()
{
this.AncestralTabletRegistrant = new HashSet<AncestralTabletRegistrant>();
}
public int PositionId { get; set; }
public int AreaId { get; set; }
public string PositionCode { get; set; }
public string PositionName { get; set; }
public Nullable<int> Price { get; set; }
public string StatusCode { get; set; }
public string Description { get; set; }
public Nullable<int> RowNo { get; set; }
public Nullable<int> ColumnNo { get; set; }
public virtual AncestralTabletArea AncestralTabletArea { get; set; }
public virtual AncestralTabletStatus AncestralTabletStatus { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class AncestralTabletPositionRecord
{
public int RecordId { get; set; }
public string RegistrantCode { get; set; }
public string NPTitle { get; set; }
public System.DateTime NPStandDate { get; set; }
public string NPYangShang { get; set; }
public string WPContent { get; set; }
public System.DateTime CreatedAt { get; set; }
public Nullable<System.DateTime> UpdatedAt { get; set; }
public virtual AncestralTabletRegistrant AncestralTabletRegistrant { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class AncestralTabletRegistrant
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AncestralTabletRegistrant()
{
this.AncestralTabletPositionRecord = new HashSet<AncestralTabletPositionRecord>();
}
public string RegistrantCode { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public System.DateTime RegisterDate { get; set; }
public Nullable<int> Price { get; set; }
public Nullable<int> PositionId { get; set; }
public System.DateTime StartDate { get; set; }
public Nullable<System.DateTime> EndDate { get; set; }
public bool IsLongTerm { get; set; }
public bool IsActive { get; set; }
public System.DateTime CreatedAt { get; set; }
public Nullable<System.DateTime> UpdatedAt { get; set; }
public bool IsEnd { get; set; }
public virtual AncestralTabletPosition AncestralTabletPosition { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AncestralTabletPositionRecord> AncestralTabletPositionRecord { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class AncestralTabletStatus
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AncestralTabletStatus()
{
this.AncestralTabletPosition = new HashSet<AncestralTabletPosition>();
}
public string StatusCode { get; set; }
public string StatusName { get; set; }
public string StatusType { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AncestralTabletPosition> AncestralTabletPosition { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class appellation
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
@@ -857,6 +990,12 @@ namespace Model
public partial class GuaDanOrder
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public GuaDanOrder()
{
this.GuaDanOrderGuest = new HashSet<GuaDanOrderGuest>();
}
public Nullable<System.DateTime> StartDate { get; set; }
public Nullable<System.DateTime> EndDate { get; set; }
public Nullable<int> CreateUser { get; set; }
@@ -874,6 +1013,8 @@ namespace Model
public virtual admin admin { get; set; }
public virtual follower followers { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
}
}
namespace Model
@@ -898,6 +1039,7 @@ namespace Model
public Nullable<System.DateTime> CheckInAt { get; set; }
public Nullable<System.DateTime> CheckOutAt { get; set; }
public string StatusCode { get; set; }
public Nullable<System.Guid> OrderUuid { get; set; }
public virtual follower followers { get; set; }
public virtual RegionRoomBed RegionRoomBed { get; set; }
@@ -905,6 +1047,7 @@ namespace Model
public virtual RegionRoomBedStatus RegionRoomBedStatus { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<RegionAndRoomAndBedSchedule> RegionAndRoomAndBedSchedule { get; set; }
public virtual GuaDanOrder GuaDanOrder { get; set; }
}
}
namespace Model

View File

@@ -254,6 +254,74 @@
<Property Name="word" Type="nvarchar(max)" />
<Property Name="systems" Type="int" />
</EntityType>
<EntityType Name="AncestralTabletArea">
<Key>
<PropertyRef Name="AreaId" />
</Key>
<Property Name="AreaId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="AreaName" Type="nvarchar" MaxLength="10" Nullable="false" />
<Property Name="AreaCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="ParentAreaId" Type="int" />
<Property Name="AreaType" Type="nvarchar" MaxLength="10" />
<Property Name="Price" Type="int" />
<Property Name="SortOrder" Type="int" />
<Property Name="IsDisabled" Type="bit" Nullable="false" />
<Property Name="Description" Type="nvarchar" MaxLength="200" />
</EntityType>
<EntityType Name="AncestralTabletPosition">
<Key>
<PropertyRef Name="PositionId" />
</Key>
<Property Name="PositionId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="AreaId" Type="int" Nullable="false" />
<Property Name="PositionCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="PositionName" Type="nvarchar" MaxLength="50" />
<Property Name="Price" Type="int" />
<Property Name="StatusCode" Type="nvarchar" MaxLength="20" />
<Property Name="Description" Type="nvarchar" MaxLength="200" />
<Property Name="RowNo" Type="int" />
<Property Name="ColumnNo" Type="int" />
</EntityType>
<EntityType Name="AncestralTabletPositionRecord">
<Key>
<PropertyRef Name="RecordId" />
</Key>
<Property Name="RecordId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="RegistrantCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="NPTitle" Type="nvarchar" MaxLength="30" />
<Property Name="NPStandDate" Type="date" Nullable="false" />
<Property Name="NPYangShang" Type="nvarchar" MaxLength="20" />
<Property Name="WPContent" Type="nvarchar" MaxLength="1000" />
<Property Name="CreatedAt" Type="datetime" Nullable="false" />
<Property Name="UpdatedAt" Type="datetime" />
</EntityType>
<EntityType Name="AncestralTabletRegistrant">
<Key>
<PropertyRef Name="RegistrantCode" />
</Key>
<Property Name="RegistrantCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
<Property Name="Phone" Type="nvarchar" MaxLength="50" />
<Property Name="Address" Type="nvarchar" MaxLength="60" />
<Property Name="RegisterDate" Type="date" Nullable="false" />
<Property Name="Price" Type="int" />
<Property Name="PositionId" Type="int" />
<Property Name="StartDate" Type="date" Nullable="false" />
<Property Name="EndDate" Type="date" />
<Property Name="IsLongTerm" Type="bit" Nullable="false" />
<Property Name="IsActive" Type="bit" Nullable="false" />
<Property Name="CreatedAt" Type="datetime" Nullable="false" />
<Property Name="UpdatedAt" Type="datetime" />
<Property Name="IsEnd" Type="bit" Nullable="false" />
</EntityType>
<EntityType Name="AncestralTabletStatus">
<Key>
<PropertyRef Name="StatusCode" />
</Key>
<Property Name="StatusCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="StatusName" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="StatusType" Type="nvarchar" MaxLength="20" Nullable="false" />
</EntityType>
<EntityType Name="appellation">
<Key>
<PropertyRef Name="num" />
@@ -454,6 +522,7 @@
<Property Name="CheckInAt" Type="date" />
<Property Name="CheckOutAt" Type="date" />
<Property Name="StatusCode" Type="nvarchar" MaxLength="20" Nullable="false" />
<Property Name="OrderUuid" Type="uniqueidentifier" />
</EntityType>
<EntityType Name="GuadanTimeSetting">
<Key>
@@ -910,6 +979,18 @@
<Property Name="balance_act_item" Type="int" />
<Property Name="balance_pro_order_detail" Type="int" />
</EntityType>
<Association Name="FK__Ancestral__Regis__5A1A5A11">
<End Role="AncestralTabletRegistrant" Type="Self.AncestralTabletRegistrant" Multiplicity="1" />
<End Role="AncestralTabletPositionRecord" Type="Self.AncestralTabletPositionRecord" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletRegistrant">
<PropertyRef Name="RegistrantCode" />
</Principal>
<Dependent Role="AncestralTabletPositionRecord">
<PropertyRef Name="RegistrantCode" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_accounting_accounting_kind">
<End Role="accounting_kind" Type="Self.accounting_kind" Multiplicity="0..1" />
<End Role="accounting" Type="Self.accounting" Multiplicity="*" />
@@ -1178,6 +1259,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_AncestralTabletArea_Parent">
<End Role="AncestralTabletArea" Type="Self.AncestralTabletArea" Multiplicity="0..1" />
<End Role="AncestralTabletArea1" Type="Self.AncestralTabletArea" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletArea">
<PropertyRef Name="AreaId" />
</Principal>
<Dependent Role="AncestralTabletArea1">
<PropertyRef Name="ParentAreaId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" Type="Self.bed_kind" Multiplicity="0..1" />
<End Role="bed_kind_detail" Type="Self.bed_kind_detail" Multiplicity="*" />
@@ -1372,6 +1465,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_GuaDanOrderGuest_Order">
<End Role="GuaDanOrder" Type="Self.GuaDanOrder" Multiplicity="0..1" />
<End Role="GuaDanOrderGuest" Type="Self.GuaDanOrderGuest" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="GuaDanOrder">
<PropertyRef Name="Uuid" />
</Principal>
<Dependent Role="GuaDanOrderGuest">
<PropertyRef Name="OrderUuid" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_GuaDanOrderGuest_RoomUuid">
<End Role="Room" Type="Self.Room" Multiplicity="0..1" />
<End Role="GuaDanOrderGuest" Type="Self.GuaDanOrderGuest" Multiplicity="*" />
@@ -1506,6 +1611,30 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Position_Area">
<End Role="AncestralTabletArea" Type="Self.AncestralTabletArea" Multiplicity="1" />
<End Role="AncestralTabletPosition" Type="Self.AncestralTabletPosition" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletArea">
<PropertyRef Name="AreaId" />
</Principal>
<Dependent Role="AncestralTabletPosition">
<PropertyRef Name="AreaId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Position_Status">
<End Role="AncestralTabletStatus" Type="Self.AncestralTabletStatus" Multiplicity="0..1" />
<End Role="AncestralTabletPosition" Type="Self.AncestralTabletPosition" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletStatus">
<PropertyRef Name="StatusCode" />
</Principal>
<Dependent Role="AncestralTabletPosition">
<PropertyRef Name="StatusCode" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_activity">
<End Role="activity" Type="Self.activity" Multiplicity="0..1" />
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
@@ -1718,6 +1847,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Registrant_Position">
<End Role="AncestralTabletPosition" Type="Self.AncestralTabletPosition" Multiplicity="0..1" />
<End Role="AncestralTabletRegistrant" Type="Self.AncestralTabletRegistrant" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletPosition">
<PropertyRef Name="PositionId" />
</Principal>
<Dependent Role="AncestralTabletRegistrant">
<PropertyRef Name="PositionId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Room_Region">
<End Role="Region" Type="Self.Region" Multiplicity="1" />
<End Role="Room" Type="Self.Room" Multiplicity="*" />
@@ -1966,6 +2107,11 @@
<EntitySet Name="admin" EntityType="Self.admin" Schema="dbo" store:Type="Tables" />
<EntitySet Name="admin_group" EntityType="Self.admin_group" Schema="dbo" store:Type="Tables" />
<EntitySet Name="admin_log" EntityType="Self.admin_log" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletArea" EntityType="Self.AncestralTabletArea" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletPosition" EntityType="Self.AncestralTabletPosition" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletPositionRecord" EntityType="Self.AncestralTabletPositionRecord" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletRegistrant" EntityType="Self.AncestralTabletRegistrant" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletStatus" EntityType="Self.AncestralTabletStatus" Schema="dbo" store:Type="Tables" />
<EntitySet Name="appellation" EntityType="Self.appellation" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind" EntityType="Self.bed_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind_detail" EntityType="Self.bed_kind_detail" Schema="dbo" store:Type="Tables" />
@@ -2010,6 +2156,10 @@
<EntitySet Name="supplier" EntityType="Self.supplier" Schema="dbo" store:Type="Tables" />
<EntitySet Name="supplier_kind" EntityType="Self.supplier_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="transfer_register" EntityType="Self.transfer_register" Schema="dbo" store:Type="Tables" />
<AssociationSet Name="FK__Ancestral__Regis__5A1A5A11" Association="Self.FK__Ancestral__Regis__5A1A5A11">
<End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" />
<End Role="AncestralTabletPositionRecord" EntitySet="AncestralTabletPositionRecord" />
</AssociationSet>
<AssociationSet Name="FK_accounting_accounting_kind" Association="Self.FK_accounting_accounting_kind">
<End Role="accounting_kind" EntitySet="accounting_kind" />
<End Role="accounting" EntitySet="accounting" />
@@ -2094,6 +2244,10 @@
<End Role="admin_group" EntitySet="admin_group" />
<End Role="admin" EntitySet="admin" />
</AssociationSet>
<AssociationSet Name="FK_AncestralTabletArea_Parent" Association="Self.FK_AncestralTabletArea_Parent">
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" />
</AssociationSet>
<AssociationSet Name="FK_bed_kind_detail_bed_kind" Association="Self.FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" EntitySet="bed_kind" />
<End Role="bed_kind_detail" EntitySet="bed_kind_detail" />
@@ -2158,6 +2312,10 @@
<End Role="followers" EntitySet="followers" />
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
</AssociationSet>
<AssociationSet Name="FK_GuaDanOrderGuest_Order" Association="Self.FK_GuaDanOrderGuest_Order">
<End Role="GuaDanOrder" EntitySet="GuaDanOrder" />
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
</AssociationSet>
<AssociationSet Name="FK_GuaDanOrderGuest_RoomUuid" Association="Self.FK_GuaDanOrderGuest_RoomUuid">
<End Role="Room" EntitySet="Room" />
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
@@ -2202,6 +2360,14 @@
<End Role="news_kind" EntitySet="news_kind" />
<End Role="news" EntitySet="news" />
</AssociationSet>
<AssociationSet Name="FK_Position_Area" Association="Self.FK_Position_Area">
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
</AssociationSet>
<AssociationSet Name="FK_Position_Status" Association="Self.FK_Position_Status">
<End Role="AncestralTabletStatus" EntitySet="AncestralTabletStatus" />
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_activity" Association="Self.FK_pro_order_activity">
<End Role="activity" EntitySet="activity" />
<End Role="pro_order" EntitySet="pro_order" />
@@ -2270,6 +2436,10 @@
<End Role="RegionRoomBedStatus" EntitySet="RegionRoomBedStatus" />
<End Role="RegionRoomBed" EntitySet="RegionRoomBed" />
</AssociationSet>
<AssociationSet Name="FK_Registrant_Position" Association="Self.FK_Registrant_Position">
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
<End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" />
</AssociationSet>
<AssociationSet Name="FK_Room_Region" Association="Self.FK_Room_Region">
<End Role="Region" EntitySet="Region" />
<End Role="Room" EntitySet="Room" />
@@ -4348,6 +4518,35 @@
<End Role="RegionRoomBedStatus" EntitySet="RegionRoomBedStatus" />
<End Role="RegionRoomBed" EntitySet="RegionRoomBed" />
</AssociationSet>
<EntitySet Name="AncestralTabletArea" EntityType="Model.AncestralTabletArea" />
<EntitySet Name="AncestralTabletPosition" EntityType="Model.AncestralTabletPosition" />
<EntitySet Name="AncestralTabletPositionRecord" EntityType="Model.AncestralTabletPositionRecord" />
<EntitySet Name="AncestralTabletRegistrant" EntityType="Model.AncestralTabletRegistrant" />
<EntitySet Name="AncestralTabletStatus" EntityType="Model.AncestralTabletStatus" />
<AssociationSet Name="FK_AncestralTabletArea_Parent" Association="Model.FK_AncestralTabletArea_Parent">
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" />
</AssociationSet>
<AssociationSet Name="FK_Position_Area" Association="Model.FK_Position_Area">
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
</AssociationSet>
<AssociationSet Name="FK_Position_Status" Association="Model.FK_Position_Status">
<End Role="AncestralTabletStatus" EntitySet="AncestralTabletStatus" />
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
</AssociationSet>
<AssociationSet Name="FK_Registrant_Position" Association="Model.FK_Registrant_Position">
<End Role="AncestralTabletPosition" EntitySet="AncestralTabletPosition" />
<End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" />
</AssociationSet>
<AssociationSet Name="FK__Ancestral__Regis__5A1A5A11" Association="Model.FK__Ancestral__Regis__5A1A5A11">
<End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" />
<End Role="AncestralTabletPositionRecord" EntitySet="AncestralTabletPositionRecord" />
</AssociationSet>
<AssociationSet Name="FK_GuaDanOrderGuest_Order" Association="Model.FK_GuaDanOrderGuest_Order">
<End Role="GuaDanOrder" EntitySet="GuaDanOrder" />
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
</AssociationSet>
</EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" />
@@ -4641,6 +4840,7 @@
<Property Name="IsCancel" Type="Boolean" Nullable="false" />
<NavigationProperty Name="admin" Relationship="Model.FK_GuaDanOrder_Admin_CreateUser" FromRole="GuaDanOrder" ToRole="admin" />
<NavigationProperty Name="followers" Relationship="Model.FK_GuaDanOrder_Followers" FromRole="GuaDanOrder" ToRole="follower" />
<NavigationProperty Name="GuaDanOrderGuest" Relationship="Model.FK_GuaDanOrderGuest_Order" FromRole="GuaDanOrder" ToRole="GuaDanOrderGuest" />
</EntityType>
<EntityType Name="GuaDanOrderGuest">
<Key>
@@ -4660,6 +4860,8 @@
<NavigationProperty Name="Room" Relationship="Model.FK_GuaDanOrderGuest_RoomUuid" FromRole="GuaDanOrderGuest" ToRole="Room" />
<NavigationProperty Name="RegionRoomBedStatus" Relationship="Model.FK_GuaDanOrderGuest_StatusCode" FromRole="GuaDanOrderGuest" ToRole="RegionRoomBedStatus" />
<NavigationProperty Name="RegionAndRoomAndBedSchedule" Relationship="Model.FK_Schedule_GuaDanOrderGuest" FromRole="GuaDanOrderGuest" ToRole="RegionAndRoomAndBedSchedule" />
<Property Name="OrderUuid" Type="Guid" />
<NavigationProperty Name="GuaDanOrder" Relationship="Model.FK_GuaDanOrderGuest_Order" FromRole="GuaDanOrderGuest" ToRole="GuaDanOrder" />
</EntityType>
<EntityType Name="GuadanTimeSetting">
<Key>
@@ -4912,6 +5114,156 @@
</Dependent>
</ReferentialConstraint>
</Association>
<EntityType Name="AncestralTabletArea">
<Key>
<PropertyRef Name="AreaId" />
</Key>
<Property Name="AreaId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="AreaName" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="true" />
<Property Name="AreaCode" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="ParentAreaId" Type="Int32" />
<Property Name="AreaType" Type="String" MaxLength="10" FixedLength="false" Unicode="true" />
<Property Name="Price" Type="Int32" />
<Property Name="SortOrder" Type="Int32" />
<Property Name="IsDisabled" Type="Boolean" Nullable="false" />
<Property Name="Description" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
<NavigationProperty Name="AncestralTabletArea1" Relationship="Model.FK_AncestralTabletArea_Parent" FromRole="AncestralTabletArea" ToRole="AncestralTabletArea1" />
<NavigationProperty Name="AncestralTabletArea2" Relationship="Model.FK_AncestralTabletArea_Parent" FromRole="AncestralTabletArea1" ToRole="AncestralTabletArea" />
<NavigationProperty Name="AncestralTabletPosition" Relationship="Model.FK_Position_Area" FromRole="AncestralTabletArea" ToRole="AncestralTabletPosition" />
</EntityType>
<EntityType Name="AncestralTabletPosition">
<Key>
<PropertyRef Name="PositionId" />
</Key>
<Property Name="PositionId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="AreaId" Type="Int32" Nullable="false" />
<Property Name="PositionCode" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="PositionName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Price" Type="Int32" />
<Property Name="StatusCode" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="Description" Type="String" MaxLength="200" FixedLength="false" Unicode="true" />
<Property Name="RowNo" Type="Int32" />
<Property Name="ColumnNo" Type="Int32" />
<NavigationProperty Name="AncestralTabletArea" Relationship="Model.FK_Position_Area" FromRole="AncestralTabletPosition" ToRole="AncestralTabletArea" />
<NavigationProperty Name="AncestralTabletStatus" Relationship="Model.FK_Position_Status" FromRole="AncestralTabletPosition" ToRole="AncestralTabletStatus" />
<NavigationProperty Name="AncestralTabletRegistrant" Relationship="Model.FK_Registrant_Position" FromRole="AncestralTabletPosition" ToRole="AncestralTabletRegistrant" />
</EntityType>
<EntityType Name="AncestralTabletPositionRecord">
<Key>
<PropertyRef Name="RecordId" />
</Key>
<Property Name="RecordId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="RegistrantCode" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="NPTitle" Type="String" MaxLength="30" FixedLength="false" Unicode="true" />
<Property Name="NPStandDate" Type="DateTime" Nullable="false" Precision="0" />
<Property Name="NPYangShang" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="WPContent" Type="String" MaxLength="1000" FixedLength="false" Unicode="true" />
<Property Name="CreatedAt" Type="DateTime" Nullable="false" Precision="3" />
<Property Name="UpdatedAt" Type="DateTime" Precision="3" />
<NavigationProperty Name="AncestralTabletRegistrant" Relationship="Model.FK__Ancestral__Regis__5A1A5A11" FromRole="AncestralTabletPositionRecord" ToRole="AncestralTabletRegistrant" />
</EntityType>
<EntityType Name="AncestralTabletRegistrant">
<Key>
<PropertyRef Name="RegistrantCode" />
</Key>
<Property Name="RegistrantCode" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="Name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Phone" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Address" Type="String" MaxLength="60" FixedLength="false" Unicode="true" />
<Property Name="RegisterDate" Type="DateTime" Nullable="false" Precision="0" />
<Property Name="Price" Type="Int32" />
<Property Name="PositionId" Type="Int32" />
<Property Name="StartDate" Type="DateTime" Nullable="false" Precision="0" />
<Property Name="EndDate" Type="DateTime" Precision="0" />
<Property Name="IsLongTerm" Type="Boolean" Nullable="false" />
<Property Name="IsActive" Type="Boolean" Nullable="false" />
<Property Name="CreatedAt" Type="DateTime" Nullable="false" Precision="3" />
<Property Name="UpdatedAt" Type="DateTime" Precision="3" />
<Property Name="IsEnd" Type="Boolean" Nullable="false" />
<NavigationProperty Name="AncestralTabletPosition" Relationship="Model.FK_Registrant_Position" FromRole="AncestralTabletRegistrant" ToRole="AncestralTabletPosition" />
<NavigationProperty Name="AncestralTabletPositionRecord" Relationship="Model.FK__Ancestral__Regis__5A1A5A11" FromRole="AncestralTabletRegistrant" ToRole="AncestralTabletPositionRecord" />
</EntityType>
<EntityType Name="AncestralTabletStatus">
<Key>
<PropertyRef Name="StatusCode" />
</Key>
<Property Name="StatusCode" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="StatusName" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="StatusType" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
<NavigationProperty Name="AncestralTabletPosition" Relationship="Model.FK_Position_Status" FromRole="AncestralTabletStatus" ToRole="AncestralTabletPosition" />
</EntityType>
<Association Name="FK_AncestralTabletArea_Parent">
<End Type="Model.AncestralTabletArea" Role="AncestralTabletArea" Multiplicity="0..1" />
<End Type="Model.AncestralTabletArea" Role="AncestralTabletArea1" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletArea">
<PropertyRef Name="AreaId" />
</Principal>
<Dependent Role="AncestralTabletArea1">
<PropertyRef Name="ParentAreaId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Position_Area">
<End Type="Model.AncestralTabletArea" Role="AncestralTabletArea" Multiplicity="1" />
<End Type="Model.AncestralTabletPosition" Role="AncestralTabletPosition" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletArea">
<PropertyRef Name="AreaId" />
</Principal>
<Dependent Role="AncestralTabletPosition">
<PropertyRef Name="AreaId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Position_Status">
<End Type="Model.AncestralTabletStatus" Role="AncestralTabletStatus" Multiplicity="0..1" />
<End Type="Model.AncestralTabletPosition" Role="AncestralTabletPosition" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletStatus">
<PropertyRef Name="StatusCode" />
</Principal>
<Dependent Role="AncestralTabletPosition">
<PropertyRef Name="StatusCode" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Registrant_Position">
<End Type="Model.AncestralTabletPosition" Role="AncestralTabletPosition" Multiplicity="0..1" />
<End Type="Model.AncestralTabletRegistrant" Role="AncestralTabletRegistrant" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletPosition">
<PropertyRef Name="PositionId" />
</Principal>
<Dependent Role="AncestralTabletRegistrant">
<PropertyRef Name="PositionId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK__Ancestral__Regis__5A1A5A11">
<End Type="Model.AncestralTabletRegistrant" Role="AncestralTabletRegistrant" Multiplicity="1" />
<End Type="Model.AncestralTabletPositionRecord" Role="AncestralTabletPositionRecord" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="AncestralTabletRegistrant">
<PropertyRef Name="RegistrantCode" />
</Principal>
<Dependent Role="AncestralTabletPositionRecord">
<PropertyRef Name="RegistrantCode" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_GuaDanOrderGuest_Order">
<End Type="Model.GuaDanOrder" Role="GuaDanOrder" Multiplicity="0..1" />
<End Type="Model.GuaDanOrderGuest" Role="GuaDanOrderGuest" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="GuaDanOrder">
<PropertyRef Name="Uuid" />
</Principal>
<Dependent Role="GuaDanOrderGuest">
<PropertyRef Name="OrderUuid" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
@@ -5773,6 +6125,7 @@
<EntitySetMapping Name="GuaDanOrderGuest">
<EntityTypeMapping TypeName="Model.GuaDanOrderGuest">
<MappingFragment StoreEntitySet="GuaDanOrderGuest">
<ScalarProperty Name="OrderUuid" ColumnName="OrderUuid" />
<ScalarProperty Name="StatusCode" ColumnName="StatusCode" />
<ScalarProperty Name="CheckOutAt" ColumnName="CheckOutAt" />
<ScalarProperty Name="CheckInAt" ColumnName="CheckInAt" />
@@ -5885,6 +6238,79 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AncestralTabletArea">
<EntityTypeMapping TypeName="Model.AncestralTabletArea">
<MappingFragment StoreEntitySet="AncestralTabletArea">
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="IsDisabled" ColumnName="IsDisabled" />
<ScalarProperty Name="SortOrder" ColumnName="SortOrder" />
<ScalarProperty Name="Price" ColumnName="Price" />
<ScalarProperty Name="AreaType" ColumnName="AreaType" />
<ScalarProperty Name="ParentAreaId" ColumnName="ParentAreaId" />
<ScalarProperty Name="AreaCode" ColumnName="AreaCode" />
<ScalarProperty Name="AreaName" ColumnName="AreaName" />
<ScalarProperty Name="AreaId" ColumnName="AreaId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AncestralTabletPosition">
<EntityTypeMapping TypeName="Model.AncestralTabletPosition">
<MappingFragment StoreEntitySet="AncestralTabletPosition">
<ScalarProperty Name="ColumnNo" ColumnName="ColumnNo" />
<ScalarProperty Name="RowNo" ColumnName="RowNo" />
<ScalarProperty Name="Description" ColumnName="Description" />
<ScalarProperty Name="StatusCode" ColumnName="StatusCode" />
<ScalarProperty Name="Price" ColumnName="Price" />
<ScalarProperty Name="PositionName" ColumnName="PositionName" />
<ScalarProperty Name="PositionCode" ColumnName="PositionCode" />
<ScalarProperty Name="AreaId" ColumnName="AreaId" />
<ScalarProperty Name="PositionId" ColumnName="PositionId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AncestralTabletPositionRecord">
<EntityTypeMapping TypeName="Model.AncestralTabletPositionRecord">
<MappingFragment StoreEntitySet="AncestralTabletPositionRecord">
<ScalarProperty Name="UpdatedAt" ColumnName="UpdatedAt" />
<ScalarProperty Name="CreatedAt" ColumnName="CreatedAt" />
<ScalarProperty Name="WPContent" ColumnName="WPContent" />
<ScalarProperty Name="NPYangShang" ColumnName="NPYangShang" />
<ScalarProperty Name="NPStandDate" ColumnName="NPStandDate" />
<ScalarProperty Name="NPTitle" ColumnName="NPTitle" />
<ScalarProperty Name="RegistrantCode" ColumnName="RegistrantCode" />
<ScalarProperty Name="RecordId" ColumnName="RecordId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AncestralTabletRegistrant">
<EntityTypeMapping TypeName="Model.AncestralTabletRegistrant">
<MappingFragment StoreEntitySet="AncestralTabletRegistrant">
<ScalarProperty Name="IsEnd" ColumnName="IsEnd" />
<ScalarProperty Name="UpdatedAt" ColumnName="UpdatedAt" />
<ScalarProperty Name="CreatedAt" ColumnName="CreatedAt" />
<ScalarProperty Name="IsActive" ColumnName="IsActive" />
<ScalarProperty Name="IsLongTerm" ColumnName="IsLongTerm" />
<ScalarProperty Name="EndDate" ColumnName="EndDate" />
<ScalarProperty Name="StartDate" ColumnName="StartDate" />
<ScalarProperty Name="PositionId" ColumnName="PositionId" />
<ScalarProperty Name="Price" ColumnName="Price" />
<ScalarProperty Name="RegisterDate" ColumnName="RegisterDate" />
<ScalarProperty Name="Address" ColumnName="Address" />
<ScalarProperty Name="Phone" ColumnName="Phone" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="RegistrantCode" ColumnName="RegistrantCode" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="AncestralTabletStatus">
<EntityTypeMapping TypeName="Model.AncestralTabletStatus">
<MappingFragment StoreEntitySet="AncestralTabletStatus">
<ScalarProperty Name="StatusType" ColumnName="StatusType" />
<ScalarProperty Name="StatusName" ColumnName="StatusName" />
<ScalarProperty Name="StatusCode" ColumnName="StatusCode" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>

View File

@@ -151,6 +151,17 @@
<AssociationConnector Association="Model.FK_Room_Region" />
<AssociationConnector Association="Model.FK_RegionRoomBed_RoomUuid" />
<AssociationConnector Association="Model.FK_RegionRoomBed_StatusCode" />
<EntityTypeShape EntityType="Model.AncestralTabletArea" Width="1.5" PointX="25.375" PointY="22.375" />
<EntityTypeShape EntityType="Model.AncestralTabletPosition" Width="1.5" PointX="27.625" PointY="18.375" />
<EntityTypeShape EntityType="Model.AncestralTabletPositionRecord" Width="1.5" PointX="32.125" PointY="18.625" />
<EntityTypeShape EntityType="Model.AncestralTabletRegistrant" Width="1.5" PointX="29.875" PointY="18" />
<EntityTypeShape EntityType="Model.AncestralTabletStatus" Width="1.5" PointX="25.375" PointY="19.125" />
<AssociationConnector Association="Model.FK_AncestralTabletArea_Parent" />
<AssociationConnector Association="Model.FK_Position_Area" />
<AssociationConnector Association="Model.FK_Position_Status" />
<AssociationConnector Association="Model.FK_Registrant_Position" />
<AssociationConnector Association="Model.FK__Ancestral__Regis__5A1A5A11" />
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_Order" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>

View File

@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
/// <summary>
/// added
/// </summary>
namespace Model
{
[MetadataType(typeof(family_membersMetadata))]
public partial class family_members
{
private class family_membersMetadata
{
[JsonIgnore]
public virtual follower follower { get; set; }
}
}
}

View File

@@ -45,6 +45,19 @@ namespace Model
public virtual ICollection<followers_tablet> followers_tablet { get; set; }
[JsonIgnore]
public virtual appellation appellation { get; set; }
/// <summary>
/// added
/// </summary>
[JsonIgnore]
public virtual ICollection<family_members> family_members { get; set; }
[JsonIgnore]
public virtual ICollection<transfer_register> transfer_register { get; set; }
[JsonIgnore]
public virtual ICollection<transfer_register> transfer_register1 { get; set; }
[JsonIgnore]
public virtual ICollection<GuaDanOrder> GuaDanOrder { get; set; }
[JsonIgnore]
public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
}

View File

@@ -0,0 +1,180 @@
using Model;
using PagedList;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using static AncestralTabletPositionController;
using static regionController;
/// <summary>
/// AncestralTabletController 的摘要描述
/// </summary>
public class AncestralTabletAreaController: ApiController
{
private Model.ezEntities _db = new Model.ezEntities();
public class AreaViewModel
{
public int? AreaId { get; set; }
public string AreaName { get; set; }
[Required(ErrorMessage = "區域編號為必填")]
public string AreaCode { get; set; }
public int? ParentAreaId { get; set; }
public string AreaType { get; set; }
public int? Price { get; set; }
public int? SortOrder { get; set; }
public bool IsDisabled { get; set; } = false;
public string Description { get; set; }
}
public class RegionDto
{
public int AreaId { get; set; }
public string AreaName { get; set; }
public string AreaCode { get; set; }
public int? SortOrder { get; set; }
public int? ParentAreaId { get; set; }
public string AreaType { get; set; }
public bool IsDisabled { get; set; }
public string Description { get; set; }
public int? Price { set; get; }
public List<RegionDto> Children { get; set; } = new List<RegionDto>();
}
[HttpGet]
[Route("api/ancestraltablet/area/getlist")]
public IHttpActionResult GetList()
{
var allArea = _db.AncestralTabletArea.ToList();
var rootRegions = allArea
.Where(r => r.ParentAreaId == null)
.OrderBy(r => r.SortOrder)
.ToList();
var tree = rootRegions
.Select(r => BuildRegionDto(r, allArea))
.ToList();
return Ok(tree);
}
[HttpGet]
[Route("api/ancestraltablet/area/getereawithposition")]
public IHttpActionResult GetEreaWithPosition()
{
//获取有神位位置的区域
var allArea = _db.AncestralTabletArea
.Where(a => a.AncestralTabletPosition.Count()>0)
.Select(a => new
{
a.AreaId,
a.AreaName,
})
.ToList();
return Ok(allArea);
}
private RegionDto BuildRegionDto(AncestralTabletArea area, List<AncestralTabletArea> allArea)
{
return new RegionDto
{
AreaId = area.AreaId,
AreaName = area.AreaName,
AreaCode = area.AreaCode,
SortOrder = area.SortOrder,
ParentAreaId = area.ParentAreaId,
AreaType = area.AreaType,
IsDisabled = area.IsDisabled,
Description = area.Description,
Price = area.Price,
Children = allArea
.Where(r => r.ParentAreaId == area.AreaId)
.OrderBy(r => r.SortOrder)
.Select(child => BuildRegionDto(child, allArea))
.ToList(),
};
}
[HttpPost]
[Route("api/ancestraltablet/area/create")]
public async Task<IHttpActionResult> CreateArea([FromBody] AreaViewModel tabletArea)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
try
{
var area = new AncestralTabletArea
{
AreaName = tabletArea.AreaName,
AreaCode = tabletArea.AreaCode,
ParentAreaId = tabletArea.ParentAreaId,
AreaType = tabletArea.AreaType,
Price = tabletArea.Price,
SortOrder = tabletArea.SortOrder,
IsDisabled = tabletArea.IsDisabled,
Description = tabletArea.Description
};
_db.AncestralTabletArea.Add(area);
await _db.SaveChangesAsync();
tabletArea.AreaId = area.AreaId;
return Ok(new { message = "區域建立成功", area = tabletArea });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/ancestraltablet/area/edit")]
public async Task<IHttpActionResult> EditArea([FromBody] AreaViewModel tabletArea)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
try
{
var oldArea = _db.AncestralTabletArea.Find(tabletArea.AreaId);
if (oldArea == null)
{
return NotFound();
}
oldArea.AreaName = tabletArea.AreaName;
oldArea.AreaCode = tabletArea.AreaCode;
oldArea.ParentAreaId = tabletArea.ParentAreaId;
oldArea.Price = tabletArea.Price;
oldArea.SortOrder = tabletArea.SortOrder;
oldArea.Description = tabletArea.Description;
oldArea.IsDisabled = tabletArea.IsDisabled;
await _db.SaveChangesAsync();
return Ok(new { message = "區域修改成功", area = tabletArea });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpGet]
[Route("api/ancestraltablet/area/position/getlist")]
public IHttpActionResult GetPositionList([FromUri] int areaId)
{
var positions = _db.AncestralTabletPosition
.Where(p => p.AreaId == areaId)
.Select(p => new AncestralTabletPositionDto
{
PositionId = p.PositionId,
AreaId = p.AreaId,
PositionCode = p.PositionCode,
PositionName = p.PositionName,
Price = p.Price,
StatusCode = p.StatusCode,
Description = p.Description,
RowNo = p.RowNo,
ColumnNo = p.ColumnNo
})
.ToList();
return Ok(positions);
}
}

View File

@@ -0,0 +1,184 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Http;
/// <summary>
/// AncestralTabletPositionController 的摘要描述
/// </summary>
public class AncestralTabletPositionController: ApiController
{
private Model.ezEntities _db = new Model.ezEntities();
[HttpGet]
[Route("api/ancestraltablet/position/getlist")]
public IHttpActionResult GetList([FromUri] int areaId)
{
var positions = _db.AncestralTabletPosition
.Where(p => p.AreaId == areaId)
.Select(p => new
{
PositionId = p.PositionId,
AreaId = p.AreaId,
PositionCode = p.PositionCode,
PositionName = p.PositionName,
Price = p.Price,
StatusCode = p.StatusCode,
Description = p.Description,
RowNo = p.RowNo,
ColumnNo = p.ColumnNo,
AncestralTabletRegistrant = _db.AncestralTabletRegistrant
.Where(r => r.PositionId == p.PositionId && r.IsActive == true)
.Select(r => new
{
r.RegistrantCode,
r.Name,
r.Phone,
r.Address,
r.RegisterDate,
r.Price,
r.StartDate,
r.EndDate,
r.IsLongTerm,
r.IsActive,
// 嵌套查询牌位记录PositionRecord
TabletRecord = r.AncestralTabletPositionRecord
.Select(pr => new
{
pr.RecordId,
pr.RegistrantCode,
pr.NPTitle,
pr.NPStandDate,
pr.NPYangShang,
pr.WPContent
})
.FirstOrDefault()
})
.FirstOrDefault()
})
.ToList();
return Ok(positions);
}
[HttpGet]
[Route("api/ancestraltablet/position/shortlist")]
public IHttpActionResult GetListWithShort([FromUri] int areaId)
{
//获取位置列表,简单信息
var positions = _db.AncestralTabletPosition
.Where(p => p.AreaId == areaId)
.Select(p => new
{
PositionId = p.PositionId,
AreaId = p.AreaId,
PositionCode = p.PositionCode,
PositionName = p.PositionName,
Price = p.Price,
StatusCode = p.StatusCode,
Description = p.Description,
RowNo = p.RowNo,
ColumnNo = p.ColumnNo,
isCanUse = p.StatusCode == "available" ? true : false,
})
.ToList();
return Ok(positions);
}
[HttpPost]
[Route("api/ancestraltablet/position/batchcreate")]
public IHttpActionResult BatchCreatePosition([FromBody] List<AncestralTabletPositionDto> positions)
{
if (positions == null || positions.Count == 0)
return BadRequest("未接收到任何位置数据");
try
{
foreach (var dto in positions)
{
var entity = new AncestralTabletPosition
{
AreaId = dto.AreaId,
PositionCode = dto.PositionCode,
PositionName = dto.PositionName,
Price = dto.Price,
StatusCode = dto.StatusCode,
Description = dto.Description,
RowNo = dto.RowNo,
ColumnNo = dto.ColumnNo
};
_db.AncestralTabletPosition.Add(entity);
}
_db.SaveChanges();
return Ok(new { message = "批量新增成功", count = positions.Count });
}
catch (Exception ex)
{
string message = ex.InnerException?.InnerException?.Message ?? ex.Message;
return Content(HttpStatusCode.InternalServerError, new
{
message = "批量新增失败",
exceptionMessage = message
});
}
}
[HttpPost]
[Route("api/ancestraltablet/position/edit")]
public IHttpActionResult EditPosition([FromBody] AncestralTabletPositionDto pos)
{
var oldPos = _db.AncestralTabletPosition
.FirstOrDefault(p => p.AreaId == pos.AreaId && p.PositionCode == pos.PositionCode);
if(oldPos == null) return NotFound();
try
{
oldPos.PositionName = pos.PositionName;
oldPos.Price = pos.Price;
oldPos.StatusCode = pos.StatusCode;
// 保存到数据库
_db.SaveChanges();
}
catch (Exception ex)
{
return InternalServerError(ex);
}
return Ok(new { message="更新成功", code=200});
}
[HttpDelete]
[Route("api/ancestraltablet/position/delete/{positionId}")]
public IHttpActionResult DeletePosition(int positionId)
{
var pos = _db.AncestralTabletPosition.FirstOrDefault(p => p.PositionId == positionId);
if (pos == null)
{
return NotFound();
}
_db.AncestralTabletPosition.Remove(pos);
_db.SaveChanges();
return Ok("删除成功");
}
public class AncestralTabletPositionDto
{
public int PositionId { get; set; }
public int AreaId { get; set; }
public string PositionCode { get; set; }
public string PositionName { get; set; }
public int? Price { get; set; }
public string StatusCode { get; set; }
public string Description { get; set; }
public int? RowNo { get; set; }
public int? ColumnNo { get; set; }
}
}

View File

@@ -0,0 +1,361 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.UI.WebControls;
/// <summary>
/// AncestralTabletRecordController 的摘要描述
/// </summary>
public class AncestralTabletRecordController: ApiController
{
private Model.ezEntities _db = new Model.ezEntities();
[HttpGet]
[Route("api/ancestraltablet/registrant/getlist")]
public IHttpActionResult GetRegistrantList()
{
//获取登记人列表
var data = _db.AncestralTabletRegistrant.Select(x => new
{
x.RegistrantCode,
x.Name,
x.Phone,
x.Address,
x.RegisterDate,
x.Price,
x.PositionId,
x.StartDate,
x.EndDate,
x.IsLongTerm,
x.IsActive,
x.CreatedAt,
x.UpdatedAt
})
.Take(1000) // 取前1000条
.ToList(); ;
return Ok(data);
}
[HttpPost]
[Route("api/ancestraltablet/registrant/getlistbypage")]
public IHttpActionResult GetRegistrantListByPage([FromBody] RegistrantSearchDto searchDto)
{
//获取登记人列表
var query = _db.AncestralTabletRegistrant.AsQueryable();
if( !string.IsNullOrEmpty(searchDto.searchName))
{
query = query.Where(r => r.Name == searchDto.searchName);
}
var tatol = query.Count();
var data = query.Select(x => new
{
x.RegistrantCode,
x.Name,
x.Phone,
x.Address,
x.RegisterDate,
x.Price,
x.PositionId,
x.StartDate,
x.EndDate,
x.IsLongTerm,
x.IsActive,
x.CreatedAt,
x.UpdatedAt
})
.OrderByDescending(a => a.CreatedAt)
.Skip((searchDto.page - 1) * searchDto.pageSize)
.Take(searchDto.pageSize) // 取前1000条
.ToList();
return Ok(new
{
data = data,
total = tatol
});
}
[HttpGet]
[Route("api/ancestraltablet/registrant/getbycode")]
public IHttpActionResult GetRegistrantByCode([FromUri] string registrantCode)
{
var r = _db.AncestralTabletRegistrant.Find(registrantCode);
if (r == null)
{
return NotFound();
}
var rDto = new
{
r.RegistrantCode,
r.Name,
r.Phone,
r.Address,
r.RegisterDate,
r.Price,
r.StartDate,
r.EndDate,
r.IsLongTerm,
r.IsActive,
r.PositionId,
positionName = r.AncestralTabletPosition?.PositionName,
// 嵌套查询牌位记录PositionRecord
TabletRecord = r.AncestralTabletPositionRecord
.Select(pr => new
{
pr.RecordId,
pr.RegistrantCode,
pr.NPTitle,
pr.NPStandDate,
pr.NPYangShang,
pr.WPContent,
})
.FirstOrDefault()
};
return Ok(rDto);
}
[HttpPost]
[Route("api/ancestraltablet/registrant/create")]
public IHttpActionResult CreateRegistrant([FromBody] AncestralTabletRegistrantDto dto)
{
//新增登记人api
if (dto == null)
{
return BadRequest("请求体不能为空");
}
if(!string.IsNullOrEmpty(dto.RegistrantCode))
{
return BadRequest("RegistrantCode 应传递空");
}
try
{
dto.RegistrantCode = GenerateRegistrantCode();
// 设置默认创建时间
dto.CreatedAt = DateTime.Now;
var entity = new Model.AncestralTabletRegistrant
{
RegistrantCode = dto.RegistrantCode,
Name = dto.Name,
Phone = dto.Phone,
Address = dto.Address,
RegisterDate = dto.RegisterDate,
Price = dto.Price,
PositionId = dto.PositionId,
StartDate = dto.startDate,
EndDate = dto.endDate,
IsLongTerm = dto.isLongTerm,
IsActive = dto.isActive,
CreatedAt = dto.CreatedAt,
UpdatedAt = dto.UpdatedAt
};
// 假设你有一个 EF DbContext如 _db
_db.AncestralTabletRegistrant.Add(entity);
if (dto.PositionId != null)
{
var position = _db.AncestralTabletPosition
.FirstOrDefault(p => p.PositionId == dto.PositionId);
if (position != null)
{
position.StatusCode = "used"; // 或者根据你的枚举/字段设置
}
}
_db.SaveChanges();
return Ok(new { message = "登记成功", registrantCode = entity.RegistrantCode });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/ancestraltablet/registrant/update")]
public IHttpActionResult UpdateRegistrant([FromBody] AncestralTabletRegistrantDto dto)
{
if (dto == null)
{
return BadRequest("请求体不能为空");
}
if (string.IsNullOrWhiteSpace(dto.RegistrantCode))
{
return BadRequest("缺少 RegistrantCode无法进行更新操作");
}
try
{
// 查找原始资料
var entity = _db.AncestralTabletRegistrant
.FirstOrDefault(r => r.RegistrantCode == dto.RegistrantCode);
if (entity == null)
{
return NotFound(); // 没有对应记录
}
// ===== 处理安位状态 =====
if (entity.PositionId != dto.PositionId)
{
// 1. 原来的安位设置为可用
if (entity.PositionId != null)
{
var oldPosition = _db.AncestralTabletPosition
.FirstOrDefault(p => p.PositionId == entity.PositionId);
if (oldPosition != null)
{
oldPosition.StatusCode = "available"; // 可用
}
}
// 2. 新的安位设置为已使用
if (dto.PositionId != null)
{
var newPosition = _db.AncestralTabletPosition
.FirstOrDefault(p => p.PositionId == dto.PositionId);
if (newPosition != null)
{
newPosition.StatusCode = "used"; // 已使用
}
}
// 更新登记人安位
entity.PositionId = dto.PositionId;
}
// 更新其它字段
entity.Name = dto.Name;
entity.Phone = dto.Phone;
entity.Address = dto.Address;
entity.RegisterDate = dto.RegisterDate;
entity.Price = dto.Price;
entity.StartDate = dto.startDate;
entity.EndDate = dto.endDate;
entity.IsLongTerm = dto.isLongTerm;
entity.IsActive = dto.isActive;
entity.UpdatedAt = DateTime.Now;
_db.SaveChanges();
return Ok(new { message = "登记人更新成功", registrantCode = entity.RegistrantCode });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/ancestraltablet/pw/create")]
public IHttpActionResult CreatePW([FromBody] AncestralTabletPositionRecordDto dto)
{
if (dto == null)
return BadRequest("请求体不能为空");
if (string.IsNullOrEmpty(dto.RegistrantCode))
return BadRequest("登记人编号RegistrantCode不能为空");
try
{
// 映射到数据库实体
var entity = new Model.AncestralTabletPositionRecord
{
RegistrantCode = dto.RegistrantCode,
NPTitle = dto.NPTitle,
NPStandDate = dto.NPStandDate,
NPYangShang = dto.NPYangShang,
WPContent = dto.WPContent,
CreatedAt = DateTime.Now,
UpdatedAt = null
};
_db.AncestralTabletPositionRecord.Add(entity);
_db.SaveChanges();
return Ok(new { message = "牌位登记成功", recordId = entity.RecordId });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/ancestraltablet/pw/update")]
public IHttpActionResult UpdatePW([FromBody] AncestralTabletPositionRecordDto dto)
{
if (dto == null)
return BadRequest("请求体不能为空");
try
{
var entity = _db.AncestralTabletPositionRecord.Find(dto.RecordId);
// 映射到数据库实体
if (entity == null)
return BadRequest("牌位不存在,更新失败");
entity.RegistrantCode = dto.RegistrantCode;
entity.NPTitle = dto.NPTitle;
entity.NPStandDate = dto.NPStandDate;
entity.NPYangShang = dto.NPYangShang;
entity.WPContent = dto.WPContent;
entity.UpdatedAt = DateTime.Now;
_db.SaveChanges();
return Ok(new { message = "牌位更新成功", recordId = entity.RecordId });
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
public string GenerateRegistrantCode(string prefix = "REG", int randomLength = 6)
{
string datePart = DateTime.Now.ToString("yyyyMMdd");
string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var suffix = new string(Enumerable.Repeat(chars, randomLength)
.Select(s => s[random.Next(s.Length)]).ToArray());
return $"{prefix}{datePart}{suffix}";
}
public class AncestralTabletRegistrantDto
{
public string RegistrantCode { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public DateTime RegisterDate { get; set; }
public int? Price { get; set; }
public int? PositionId { get; set; }
public DateTime startDate { get; set; }
public DateTime? endDate { get; set; }
public bool isLongTerm { get; set; } = false;
public bool isActive { get; set; } = true;
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
public class AncestralTabletPositionRecordDto
{
public int? RecordId { get; set; }
public string RegistrantCode { get; set; }
public string NPTitle { get; set; }
public DateTime NPStandDate { get; set; }
public string NPYangShang { get; set; }
public string WPContent { get; set; }
}
public class RegistrantSearchDto
{
public int page { get; set; } = 1;
public int pageSize { get; set; } = 10;
public string searchName { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
/// <summary>
/// AncestralTabletStatisticsController 的摘要描述
/// </summary>
public class AncestralTabletStatisticsController:ApiController
{
private Model.ezEntities db = new Model.ezEntities();
[HttpGet]
[Route("api/ancestraltablet/statistics/positions/availablepositions")]
public IHttpActionResult GetAvailablePositions()
{
var query =
from a in db.AncestralTabletArea // 区域表
join p in db.AncestralTabletPosition
on a.AreaId equals p.AreaId into ap
from p in ap.DefaultIfEmpty()
join r in db.AncestralTabletRegistrant
on p.PositionId equals r.PositionId into pr
from r in pr.DefaultIfEmpty()
group new { a, p, r } by new { a.AreaId, a.AreaName } into g
select new
{
AreaId = g.Key.AreaId,
AreaName = g.Key.AreaName,
TotalPositions = g.Count(x => x.p != null), // 总位置数
AvailableCount = g.Count(x => x.p != null && x.r == null) // 可用位置数(未登记)
};
var result = query.ToList();
return Ok(result);
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
/// <summary>
/// AncestralTabletStatusController 的摘要描述
/// </summary>
public class AncestralTabletStatusController:ApiController
{
private Model.ezEntities _db = new Model.ezEntities();
[HttpGet]
[Route("api/ancestraltablet/status/list")]
public IHttpActionResult GetStatusList()
{
var statusList = _db.AncestralTabletStatus
.Select(s => new
{
s.StatusCode,
s.StatusName,
s.StatusType
})
.ToList();
return Ok(statusList);
}
}

View File

@@ -52,7 +52,7 @@ public class FilesSetController : ApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//var prod2 = _db.actItem_files.AsEnumerable().Where(q => q.files_num == id).ToList(); //刪除品項的相關文件
@@ -84,14 +84,14 @@ public class FilesSetController : ApiController
{
if (!string.IsNullOrEmpty(nums))
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.files.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var prod = _db.files.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
//刪除品項的相關文件
var prod2 = _db.actItem_files.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.files_num))).ToList();
if (prod2.Count > 0)
var prod2 = _db.actItem_files.Where(q => ids.Contains(q.files_num)).ToList();
if (prod2.Count() > 0)
{
_db.actItem_files.RemoveRange(prod2);
}
@@ -123,7 +123,7 @@ public class FilesSetController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.files q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.files.AsEnumerable();
var qry = _db.files.AsQueryable();
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject));
@@ -157,9 +157,12 @@ public class FilesSetController : ApiController
else
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.subject,
@@ -168,7 +171,7 @@ public class FilesSetController : ApiController
word = x.word,
}),
count = qry.Count()
count = count
};

View File

@@ -55,7 +55,7 @@ public class FollowerController : ApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.followers.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.followers.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
/*if (prod != null)
{
@@ -94,9 +94,9 @@ public class FollowerController : ApiController
{
if (!string.IsNullOrEmpty(nums))
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.followers.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var prod = _db.followers.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
foreach (var item in prod)
@@ -139,8 +139,8 @@ public class FollowerController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.follower q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
////var qry = _db.followers.Where(a => a.IsDel == false).AsEnumerable();////不確定是否新增欄位? 先註解
var qry = _db.followers.AsEnumerable();
////var qry = _db.followers.Where(a => a.IsDel == false).AsQueryable();////不確定是否新增欄位? 先註解
var qry = _db.followers.AsQueryable();
if (!string.IsNullOrEmpty(q.f_number))
qry = qry.Where(o => o.f_number.Contains(q.f_number.Trim()));
@@ -151,7 +151,7 @@ public class FollowerController : ApiController
if (q.birthday2.HasValue)
qry = qry.Where(o => o.birthday < Convert.ToDateTime(q.birthday2.Value).AddDays(1));
if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address !=null && o.address.Contains(q.address?.Trim()));
qry = qry.Where(o => o.address !=null && o.address.Contains(q.address.Trim()));
//if (q.num.HasValue && q.num.Value>0)
// qry = qry.Where(o => o.num==q.num.Value);
if (q.ept_self.HasValue && q.ept_self.Value )//排除自己
@@ -215,9 +215,10 @@ public class FollowerController : ApiController
var tdesc = publicFun.enum_desc<Model.follower.type>();
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
f_number = x.f_number,
@@ -339,9 +340,9 @@ public class FollowerController : ApiController
//int ccc = cc.Count();
var qry = _db.followers.AsEnumerable().Where(f => cc.Any(x => x == f.num) || cc.Any(x => x == f.leader));
// 優化:使用子查詢在數據庫層面執行,避免載入所有家族成員 ID
// 生成 SQL: WHERE num IN (SELECT...) OR leader IN (SELECT...)
var qry = _db.followers.Where(f => cc.Contains(f.num) || (f.leader.HasValue && cc.Contains(f.leader.Value)));
@@ -359,11 +360,12 @@ public class FollowerController : ApiController
qry = qry.OrderByDescending(o => o.num);
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var tdesc = publicFun.enum_desc<Model.follower.type>();
int i = 1;
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
int i = 1;
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -524,13 +526,14 @@ public class FollowerController : ApiController
if (_follower > 0)
{
var qry = _db.followers_tablet.AsEnumerable().Where(x=>( x.f_num??0) == _follower);
var qry = _db.followers_tablet.Where(x=> x.f_num == _follower);
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
int i = 1;
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -593,7 +596,7 @@ public class FollowerController : ApiController
[Route("api/follower/tabletDelete/{id}")]
public void tabletDelete(int id)
{
var prod = _db.followers_tablet.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.followers_tablet.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.followers_tablet.Remove(prod);

View File

@@ -52,7 +52,7 @@ public class accountingController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.accountings.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.accountings.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
var prod2 = prod.accounting_files;
@@ -89,12 +89,12 @@ public class accountingController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.accountings.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var prod = _db.accountings.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.accounting_files.AsEnumerable().Where(q => q.accounting_num.HasValue && getDelItem.Contains(q.accounting_num.Value)).ToList();
var prod2 = _db.accounting_files.Where(q => q.accounting_num.HasValue && getDelItem.Contains(q.accounting_num.Value)).ToList();
if (prod2.Count() > 0)
{
publicFun publicFun = new publicFun();
@@ -126,7 +126,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.accounting q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accountings.AsEnumerable();
var qry = _db.accountings.AsQueryable();
if (q.category.HasValue)
qry = qry.Where(o => o.category == q.category.Value);
@@ -215,10 +215,12 @@ public class accountingController : BaseApiController
qry = qry.OrderByDescending(o => o.num);
var tdesc = publicFun.enum_desc<Model.accounting.type>();
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
category = x.category,
@@ -245,7 +247,7 @@ public class accountingController : BaseApiController
total =(x.price ?? 0)+( x.tax?? 0),
}),
count = qry.Count()
count = count
};
@@ -259,7 +261,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetTitleKindList([FromBody] Model.ViewModel.accounting_kind q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accounting_kind.AsEnumerable();
var qry = _db.accounting_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -297,7 +299,7 @@ public class accountingController : BaseApiController
public IHttpActionResult GetAccountKindList([FromBody] Model.ViewModel.accounting_kind2 q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.accounting_kind2.AsEnumerable();
var qry = _db.accounting_kind2.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -341,15 +343,16 @@ public class accountingController : BaseApiController
if (q.accounting_num.HasValue && q.accounting_num.Value > 0)
{
//檢查
var qry = _db.accounting_files.AsEnumerable();
qry = qry.Where(o => o.accounting_num == q.accounting_num.Value);
qry.OrderByDescending(x => x.num);
var qry = _db.accounting_files.Where(o => o.accounting_num == q.accounting_num.Value);
qry = qry.OrderByDescending(x => x.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
int i = 1;
//已有值
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -357,7 +360,7 @@ public class accountingController : BaseApiController
pic1 = x.pic1,
pic1_name = x.pic1_name,
}),
count = qry.Count(),
count = count,
};
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
@@ -473,7 +476,7 @@ public class accountingController : BaseApiController
[Route("api/accounting/DeleteFilesItem/{id}")]//刪除相關檔案
public void DeleteFilesItem(int id)
{
var prod = _db.accounting_files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.accounting_files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
if (!string.IsNullOrEmpty(prod.pic1))

View File

@@ -63,17 +63,17 @@ public class activityController : ApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.activities.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.activities.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除相關資料
var prod2 = _db.activity_relating.AsEnumerable().Where(q => q.activity_num == id).ToList(); //相關項目
var prod2 = _db.activity_relating.Where(q => q.activity_num == id).ToList(); //相關項目
if (prod2.Count > 0)
{
//查詢結果全部刪除
_db.activity_relating.RemoveRange(prod2);
}
var prod3 = _db.activity_spares.AsEnumerable().Where(q => q.activity_num == id).ToList(); //備品項目
var prod3 = _db.activity_spares.Where(q => q.activity_num == id).ToList(); //備品項目
if (prod3.Count > 0)
{
_db.activity_spares.RemoveRange(prod3);
@@ -98,7 +98,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteItem/{id}")]
public void DeleteItem(int id)
{
var prod = _db.actItems.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.actItems.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
/*if (prod != null)
{
//var prod2 = _db.actItem_files.AsEnumerable().Where(q => q.actItem_num == id).ToList(); //相關項目
@@ -144,11 +144,11 @@ public class activityController : ApiController
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.activities.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var prod = _db.activities.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
//var prod2 = _db.activity_relating.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.activity_num))).ToList();
var prod2 = _db.activity_relating.AsEnumerable().Where(q => ids.Any(x => x == q.activity_num)).ToList();
var prod2 = _db.activity_relating.Where(q => ids.Contains(q.activity_num)).ToList();
if (prod2.Count > 0)
{
_db.activity_relating.RemoveRange(prod2);
@@ -156,7 +156,7 @@ public class activityController : ApiController
}
//var prod3 = _db.activity_spares.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.activity_num))).ToList();
var prod3 = _db.activity_spares.AsEnumerable().Where(q => ids.Any(x => x == q.activity_num)).ToList();
var prod3 = _db.activity_spares.Where(q => ids.Contains(q.activity_num)).ToList();
if (prod3.Count > 0)
{
_db.activity_spares.RemoveRange(prod3);
@@ -186,11 +186,11 @@ public class activityController : ApiController
if (!string.IsNullOrEmpty(nums))
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.actItems.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var prod = _db.actItems.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
//var prod2 = _db.actItem_files.AsEnumerable().Where(q => ids.Contains(Convert.ToInt32(q.actItem_num))).ToList();
var prod2 = _db.actItem_files.AsEnumerable().Where(q => ids.Any(x => x == q.actItem_num)).ToList();
var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList();
if (prod2.Count > 0)
{
_db.actItem_files.RemoveRange(prod2);
@@ -281,10 +281,10 @@ public class activityController : ApiController
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.subject,
@@ -319,7 +319,7 @@ public class activityController : ApiController
{
//var stockDt = _db.stocks.AsEnumerable(); ;//庫存
var fileDt = _db.files.AsEnumerable().Where(f => f.subject.Contains(q.fileTxt)).Select(f => f.num.ToString());//文件
var fileDt = _db.files.Where(f => f.subject.Contains(q.fileTxt)).Select(f => f.num.ToString());//文件
//每個品項在每個倉庫的結餘量
var stockDt = (
@@ -364,7 +364,7 @@ public class activityController : ApiController
}
if (!string.IsNullOrEmpty(q.kindTxt))
qry = qry.Where(o => o.actItem_kind?.kind != null && o.actItem_kind.kind.Contains(q.kindTxt));
qry = qry.Where(o => o.actItem_kind != null && o.actItem_kind.kind != null && o.actItem_kind.kind.Contains(q.kindTxt));
if (q.category.HasValue && q.category.Value > 0)
qry = qry.Where(o => o.category == q.category.Value);
if (!string.IsNullOrEmpty(q.categorys))
@@ -410,10 +410,10 @@ public class activityController : ApiController
var tdesc = publicFun.enum_desc<Model.activity.category>();
var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.subject,
@@ -711,7 +711,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteFilesItem/{id}")]//刪除品項的相關文件
public void DeleteFilesItem(int id)
{
var prod = _db.actItem_files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.actItem_files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -731,16 +731,15 @@ public class activityController : ApiController
if (this_id > 0)
{
//檢查
var qry = _db.activity_kind_detail.AsEnumerable();
qry = qry.Where(o => o.activity_kind_num == this_id);
var qry = _db.activity_kind_detail.Where(o => o.activity_kind_num == this_id);
int i = 1;
//已有值
var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -830,7 +829,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteActKindDetail/{id}")]//刪除活動分類的detail
public void DeleteActKindDetail(int id)
{
var prod = _db.activity_kind_detail.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_kind_detail.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -849,7 +848,7 @@ public class activityController : ApiController
if (this_act_id > 0)
{
//檢查
var prod = _db.activities.AsEnumerable().Where(o => o.num == this_act_id).FirstOrDefault();
var prod = _db.activities.Where(o => o.num == this_act_id).FirstOrDefault();
if (prod != null)
{
int kind = prod.kind ?? 0; //分類
@@ -927,13 +926,12 @@ public class activityController : ApiController
if (kind > 0)
{
int i = 1;
var qry2 = _db.activity_kind_detail.AsEnumerable();
qry2 = qry2.Where(o => o.activity_kind_num == kind);
var qry2 = _db.activity_kind_detail.Where(o => o.activity_kind_num == kind);
var count2 = qry2.Count(); //pageSize = count2;//一次取回??
if (pageSize > 0) qry2 = qry2.ToPagedList(page, pageSize);
var qry2List = (pageSize > 0) ? qry2.ToPagedList(page, pageSize).ToList() : qry2.ToList();
var ret = new
{
list = qry2.Select(x => new
list = qry2List.Select(x => new
{
id = i++,
num = 0,
@@ -992,7 +990,7 @@ public class activityController : ApiController
public IHttpActionResult GetKindList([FromBody] Model.ViewModel.activity_kind q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.activity_kind.AsEnumerable();
var qry = _db.activity_kind.AsQueryable();
if (q.num.HasValue && q.num > 0)
qry = qry.Where(o => o.num == q.num);
if (!string.IsNullOrEmpty(q.kind))
@@ -1031,7 +1029,7 @@ public class activityController : ApiController
{
if (id > 0)
{
var qry = _db.activity_kind.AsEnumerable();
var qry = _db.activity_kind.AsQueryable();
qry = qry.Where(o => o.num == id);
var prop3 = qry.FirstOrDefault();
if (prop3 != null)
@@ -1151,7 +1149,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteRelatingData/{id}")]//刪除活動的相關資料
public void DeleteRelatingData(int id)
{
var prod = _db.activity_relating.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_relating.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -1169,25 +1167,22 @@ public class activityController : ApiController
if (this_act_id > 0)
{
//檢查
var prod = _db.activities.AsEnumerable().Where(o => o.num == this_act_id).FirstOrDefault();
var prod = _db.activities.Where(o => o.num == this_act_id).FirstOrDefault();
if (prod != null)
{
int kind = prod.kind ?? 0; //分類
var qry1 = _db.activity_spares.AsEnumerable();
qry1 = qry1.Where(o => o.activity_num == this_act_id);
qry1 = qry1.OrderBy(o => o.num);
var qry1 = _db.activity_spares.Where(o => o.activity_num == this_act_id).OrderBy(o => o.num);
var count = qry1.Count(); //pageSize = count;//一次取回??
int i = 1;
if (pageSize > 0) qry1 = qry1.ToPagedList(page, pageSize);
var qry1List = (pageSize > 0) ? qry1.ToPagedList(page, pageSize).ToList() : qry1.ToList();
var ret = new
{
list = qry1.Select(x => new
list = qry1List.Select(x => new
{
id = i++,
num = x.num,
@@ -1278,7 +1273,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteSparesData/{id}")]//刪除活動的備品資料
public void DeleteSparesData(int id)
{
var prod = _db.activity_spares.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_spares.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -1388,10 +1383,10 @@ public class activityController : ApiController
var tdesc = publicFun.enum_desc<Model.activity_check.keyin1>();
var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.activity?.subject,
@@ -1416,7 +1411,7 @@ public class activityController : ApiController
[Route("api/activity/DeleteCheck/{id}")]
public void DeleteCheck(int id)
{
var prod = _db.activity_check.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_check.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -1439,7 +1434,7 @@ public class activityController : ApiController
if (!string.IsNullOrEmpty(num[i]))
ids[i] = Convert.ToInt32(num[i]);
}
var prod = _db.activity_check.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var prod = _db.activity_check.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
@@ -1458,7 +1453,7 @@ public class activityController : ApiController
{
DateTime _now = DateTime.Now;
var qry = _db.activities.AsEnumerable();
var qry = _db.activities.AsQueryable();
if (q.reg_time1.HasValue)
qry = qry.Where(o => o.reg_time >= q.reg_time1.Value);
@@ -1466,7 +1461,7 @@ public class activityController : ApiController
qry = qry.Where(o => o.reg_time < Convert.ToDateTime(q.reg_time2.Value).AddDays(1));
qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate?.Date.CompareTo(_now) <= 180));
qry = qry.Where(o => (_now >= o.startDate_solar && _now < o.endDate_lunar) || (_now < o.startDate_solar && o.dueDate.HasValue && o.dueDate.Value.Date.CompareTo(_now) <= 180));
qry = qry.OrderByDescending(o => o.num);
@@ -1510,7 +1505,7 @@ public class activityController : ApiController
public IHttpActionResult GetCategoryKindList([FromBody] Model.ViewModel.activity_category_kind q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.activity_category_kind.AsEnumerable();
var qry = _db.activity_category_kind.AsQueryable();
if (q.num.HasValue && q.num > 0)
qry = qry.Where(o => o.num == q.num);
if (!string.IsNullOrEmpty(q.kind))
@@ -1518,10 +1513,10 @@ public class activityController : ApiController
qry = qry.OrderBy(O => O.kind).ThenBy(o => o.num);
var count = qry.Count(); //pageSize = count;//一次取回??
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
num = x.num,
kind = x.kind,

View File

@@ -54,7 +54,7 @@ public class activity_kindController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.actItem_kind q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.actItem_kind.AsEnumerable();
var qry = _db.actItem_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
if (!string.IsNullOrEmpty(q.status))

View File

@@ -52,7 +52,7 @@ public class adminUserController : ApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.admins.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.admins.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -76,7 +76,7 @@ public class adminUserController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.admin q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.admins.AsEnumerable();
var qry = _db.admins.AsQueryable();
if (!string.IsNullOrEmpty(q.u_id))
qry = qry.Where(o => o.u_id.Contains(q.u_id));
@@ -90,17 +90,15 @@ public class adminUserController : ApiController
if(q.removeExist.HasValue && q.removeExist.Value)
{
// 優化:使用子查詢在數據庫層面執行,避免載入所有會員的 admin_num
var usedAdminNums = _db.members.Select(b => b.admin_num);
if (q.num.HasValue && q.num.Value > 0)
{
qry = qry.Where(o => (!(from b in _db.members.AsEnumerable()
select b.admin_num)
.Contains(o.num)) || o.num == Convert.ToInt32(q.num.Value));
qry = qry.Where(o => !usedAdminNums.Contains(o.num) || o.num == q.num.Value);
}
else
{
qry = qry.Where(o => (!(from b in _db.members.AsEnumerable()
select b.admin_num)
.Contains(o.num)));
qry = qry.Where(o => !usedAdminNums.Contains(o.num));
}
}
@@ -114,9 +112,12 @@ public class adminUserController : ApiController
else
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
u_id = x.u_id,
@@ -124,7 +125,7 @@ public class adminUserController : ApiController
power = x.power,
}),
count = qry.Count()
count = count
};

View File

@@ -44,19 +44,22 @@ public class appellationController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.appellation q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.appellations.AsEnumerable();
var qry = _db.appellations.AsQueryable();
qry = qry.OrderBy(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
title = x.title,
}),
count = qry.Count()
count = count
};

View File

@@ -42,7 +42,7 @@ public class bedController : BaseApiController
// DELETE api/<controller>/5
public void Delete(string id)
{
var prod = _db.bed_order.AsEnumerable().Where(q => q.bed_order_no == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.bed_order.Where(q => q.bed_order_no == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除訂單明細
@@ -80,7 +80,7 @@ public class bedController : BaseApiController
{
order_no = "ED" + DateTime.Now.ToString("yyMMdd");
var qry = _db.companies.AsEnumerable();
var qry = _db.companies.AsQueryable();
var prod = qry.Where(q => q.num == 1).FirstOrDefault();
if (prod != null)
{
@@ -157,16 +157,18 @@ public class bedController : BaseApiController
public IHttpActionResult GetDetailList([FromBody] Model.bed_order q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.bed_order_detail.AsEnumerable();
qry = qry.Where(o => o.bed_order_no == q.bed_order_no);
var qry = _db.bed_order_detail.Where(o => o.bed_order_no == q.bed_order_no);
qry = qry.OrderBy(o => o.checkIn_date ).ThenBy(o => o.num);
int i = 1;
var tdesc = publicFun.enum_desc<Model.bed_kind.bed_type>();
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -197,7 +199,7 @@ public class bedController : BaseApiController
},
license = x.license,
}),
count = qry.Count()
count = count
};
return Ok(ret);
@@ -250,7 +252,7 @@ public class bedController : BaseApiController
[Route("api/bed/DeleteBedDetail/{id}")]//刪除detail
public void DeleteBedDetail(int id)
{
var prod = _db.bed_order_detail.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.bed_order_detail.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{

View File

@@ -52,7 +52,7 @@ public class bed_kindController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.bed_kind q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.bed_kind.AsEnumerable();
var qry = _db.bed_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
if (!string.IsNullOrEmpty(q.sex))
@@ -60,16 +60,20 @@ public class bed_kindController : ApiController
if (q.root.HasValue)
qry = qry.Where(o => o.root.Value == q.root.Value);
qry = qry.OrderBy(o => o.range).ThenBy(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
kind = x.kind,
sex = x.sex,
}),
count = qry.Count()
count = count
};
return Ok(ret);
@@ -83,7 +87,7 @@ public class bed_kindController : ApiController
var tdesc = publicFun.enum_desc<Model.bed_kind.bed_type>();
//var tdesc2 = tdesc.ToArray().Select(x=>x.Value); //[0]單人床,[1]雙人床
//var tdesc3 = tdesc.ToArray().Select(x=>x.Key); //[0]1,[1]2
var qry = _db.bed_kind_detail.AsEnumerable();
var qry = _db.bed_kind_detail.AsQueryable();
if (q.bed_kind_id.HasValue)
qry = qry.Where(o => o.bed_kind_id == q.bed_kind_id);
if (!string.IsNullOrEmpty(q.bed_name))
@@ -103,17 +107,19 @@ public class bed_kindController : ApiController
if (q.inTime.HasValue )
{
//判斷日期沒庫存不能選
var bedDt = _db.bed_order_detail.AsEnumerable().Where(f => f.checkIn_date.HasValue && f.checkIn_date ==q.inTime.Value ).Select(f => f.bed_kind_detail_id.ToString());//掛單表單明細
qry = qry.Where(o => !bedDt.ToArray().Contains(o.num.ToString()));
var bedDt = _db.bed_order_detail.Where(f => f.checkIn_date.HasValue && f.checkIn_date ==q.inTime.Value && f.bed_kind_detail_id.HasValue).Select(f => f.bed_kind_detail_id.Value).ToList();//掛單表單明細
qry = qry.Where(o => !bedDt.Contains(o.num));
}
qry = qry.OrderBy(o => o.bed_name);
int i = 1;
if (pageSize > 0) qry = qry.ToPagedList(page, pageSize);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -122,7 +128,7 @@ public class bed_kindController : ApiController
bed_type_txt = x.bed_type.HasValue? tdesc[x.bed_type ?? 1] : "",
demo = x.demo,
}),
count = qry.Count()
count = count
};
return Ok(ret);
@@ -186,7 +192,7 @@ public class bed_kindController : ApiController
[Route("api/bed_kind/DeleteBedKindDetail/{id}")]//刪除分類的detail
public void DeleteActKindDetail(int id)
{
var prod = _db.bed_kind_detail.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.bed_kind_detail.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{

View File

@@ -44,22 +44,25 @@ public class countryController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.country q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.countries.AsEnumerable();
var qry = _db.countries.AsQueryable();
if (!string.IsNullOrEmpty(q.keyword))
qry = qry.Where(o => o.ID.Contains(q.keyword.Trim()) || o.name_en.Contains(q.keyword.Trim()) || o.name_zh.Contains(q.keyword.Trim()));
qry = qry.OrderBy(o => o.range).ThenBy(o => o.name_en);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = x.ID,
name_en = x.name_en,
name_zh = x.name_zh,
}),
count = qry.Count()
count = count
};

View File

@@ -98,7 +98,17 @@ public class familyMembersController : ApiController
[Route("api/familymembers/follower/{followerId}")]
public IHttpActionResult GetByFollower(int followerId)
{
//var originalLazyLoading = _db.Configuration.LazyLoadingEnabled;
//var originalProxyCreation = _db.Configuration.ProxyCreationEnabled;
//
//_db.Configuration.LazyLoadingEnabled = false;
//_db.Configuration.ProxyCreationEnabled = false;
var familyMembers = _db.family_members.Where(fm => fm.follower_num == followerId).ToList();
//_db.Configuration.LazyLoadingEnabled = originalLazyLoading;
//_db.Configuration.ProxyCreationEnabled = originalProxyCreation;
return Ok(familyMembers);
}

View File

@@ -66,6 +66,7 @@ public class guadanGuestQueryController: ApiController
checkoutdate = a.CheckOutAt,
guadanorderno = a.GuaDanOrderNo,
roomName = GetRoomAndBedString(a.RegionRoomBed),
statusName = a.RegionRoomBedStatus.Name
}).ToList();
return Ok(new
{

View File

@@ -7,8 +7,6 @@ using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using static regionController;
/// <summary>
/// guadanOderController 的摘要描述
/// </summary>
@@ -20,10 +18,19 @@ public class guadanOrderController : ApiController
[Route("api/guadan/list")]
public async Task<IHttpActionResult> getGuadanList([FromBody] guadan_order_search_dto search)
{
var lastCheckoutTime = _db.GuadanTimeSetting.FirstOrDefault();
string lastCheckoutTimeStr = null;
if (lastCheckoutTime != null)
{
lastCheckoutTimeStr = lastCheckoutTime.LatestCheckOut;
}
var query = _db.GuaDanOrder
.Where(a => a.IsCancel == false)
.Where(a => a.IsDeleted == false);
if(!string.IsNullOrEmpty(search.guaDanOrderNo))
{
query = query.Where(order => order.GuaDanOrderNo == search.guaDanOrderNo);
}
if (search.guadanUser != null)
{
query = query.Where(order => order.BookerName == search.guadanUser);
@@ -45,7 +52,8 @@ public class guadanOrderController : ApiController
}
}
var total = query.Count();
var data = await query
var data1 = await query.ToListAsync();
var data = data1
.OrderByDescending(b => b.CreatedAt)
.Select(a => new
{
@@ -56,6 +64,14 @@ public class guadanOrderController : ApiController
created_at = a.CreatedAt,
updated_at = a.UpdatedAt,
notes = a.Notes,
is_timeout = !string.IsNullOrEmpty(lastCheckoutTimeStr) &&
_db.GuaDanOrderGuest
.Where(g => g.GuaDanOrderNo == a.GuaDanOrderNo && !g.IsDeleted && g.StatusCode == GuaDanOrderGuest.STATUS_CHECKED_IN)
.ToList()
.Any(g =>
g.CheckOutAt.HasValue &&
DateTime.Parse(g.CheckOutAt.Value.ToString("yyyy-MM-dd") + " " + lastCheckoutTimeStr) < DateTime.Now
),
activity = _db.activities
.Where(act => act.num == a.ActivityNum)
.Select(act => new
@@ -68,23 +84,23 @@ public class guadanOrderController : ApiController
.Where(c => c.GuaDanOrderNo == a.GuaDanOrderNo && c.IsDeleted == false)
.Where(c => c.RegionRoomBedStatus.Code != GuaDanOrderGuest.STATUS_CANCELLED)
.Count(),
statusName = _db.GuaDanOrderGuest
guadan_status = _db.GuaDanOrderGuest
.Where(g => g.GuaDanOrderNo == a.GuaDanOrderNo && a.IsDeleted == false)
.Where(g => g.StatusCode != GuaDanOrderGuest.STATUS_CANCELLED)
.All(g => g.StatusCode == "401") ? "預約" :
.All(g => g.StatusCode == "401") ? new { code=501, name="預約" }:
_db.GuaDanOrderGuest
.Where(g => g.GuaDanOrderNo == a.GuaDanOrderNo && a.IsDeleted == false)
.Where(g => g.StatusCode != GuaDanOrderGuest.STATUS_CANCELLED)
.All(g => g.StatusCode == "403") ? "全部退房" :
.All(g => g.StatusCode == "403") ? new { code = 502, name = "全部退房" } :
_db.GuaDanOrderGuest
.Where(g => g.GuaDanOrderNo == a.GuaDanOrderNo && a.IsDeleted == false)
.Where(g => g.StatusCode != GuaDanOrderGuest.STATUS_CANCELLED)
.Any(g => g.StatusCode == "402" && a.IsCancel == false) ? "正在入住" :
"部分退房"
.Any(g => g.StatusCode == "402" && a.IsCancel == false) ? new { code = 503, name = "正在入住" } :
new { code = 504, name = "部分退房" }
})
.Skip((search.page - 1) * search.pageSize)
.Take(search.pageSize)
.ToListAsync();
.ToList();
return Ok(new
{
total,
@@ -214,7 +230,7 @@ public class guadanOrderController : ApiController
{
return NotFound();
}
if (_db.GuaDanOrderGuest.Any(a => a.GuaDanOrderNo == guadan.GuaDanOrderNo))
if (_db.GuaDanOrderGuest.Any(a => (a.GuaDanOrderNo == guadan.GuaDanOrderNo) && a.StatusCode != "404"))
{
return BadRequest($"該掛單已經存在掛單蓮友,不能取消!");
}
@@ -280,6 +296,7 @@ public class guadanOrderController : ApiController
public string guadanUser { get; set; }
public int page { get; set; } = 1;
public int pageSize { get; set; } = 10;
public string guaDanOrderNo { get; set; } = null;
}
}

View File

@@ -48,7 +48,7 @@ public class memberController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.members.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.members.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
if(!string.IsNullOrEmpty(prod.pic1))
@@ -79,7 +79,7 @@ public class memberController : BaseApiController
[Route("api/member/DeleteCheck/{id}")]
public void DeleteCheck(int id) //刪除考勤資料
{
var prod = _db.member_check.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.member_check.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.member_check.Remove(prod);
@@ -93,9 +93,9 @@ public class memberController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.members.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var prod = _db.members.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
publicFun publicFun = new publicFun();
@@ -107,8 +107,8 @@ public class memberController : BaseApiController
}
}
var prod2 = _db.member_check.AsEnumerable().Where(q => getDelItem.Contains(Convert.ToInt32(q.mem_num))).ToList();
if (prod2.Count > 0)
var prod2 = _db.member_check.Where(q => q.mem_num.HasValue && getDelItem.Contains(q.mem_num.Value)).ToList();
if (prod2.Count() > 0)
{
_db.member_check.RemoveRange(prod2);
//_db.SaveChanges();
@@ -135,8 +135,8 @@ public class memberController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.member_check.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.member_check.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
_db.member_check.RemoveRange(prod);
@@ -150,7 +150,7 @@ public class memberController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.member q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.members.AsEnumerable();
var qry = _db.members.AsQueryable();
if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim()));
@@ -220,10 +220,11 @@ public class memberController : BaseApiController
else
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
m_number = x.m_number,
@@ -242,7 +243,7 @@ public class memberController : BaseApiController
starttime = x.group_kind.HasValue ? x.member_group.starttime : (object)null,
demo = x.demo,
}),
count = qry.Count()
count = count
};
@@ -256,7 +257,7 @@ public class memberController : BaseApiController
public IHttpActionResult GetCheckList([FromBody] Model.ViewModel.member_check q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.member_check.AsEnumerable();
var qry = _db.member_check.AsQueryable();
if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.member.u_name.Contains(q.u_name));
@@ -317,9 +318,11 @@ public class memberController : BaseApiController
var tdesc = publicFun.enum_desc<Model.member.attendances.type>();
var tdesc2 = publicFun.enum_desc<Model.member.attendances.login>();
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
m_number = x.member.m_number,
@@ -332,7 +335,7 @@ public class memberController : BaseApiController
login_type_desc = tdesc2[x.login_type ?? 1]
}),
count = qry.Count()
count = count
};
@@ -346,7 +349,7 @@ public class memberController : BaseApiController
public IHttpActionResult GetGroupList([FromBody] Model.ViewModel.member_group q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.member_group.AsEnumerable();
var qry = _db.member_group.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -394,7 +397,7 @@ public class memberController : BaseApiController
public IHttpActionResult GetTitleList([FromBody] Model.ViewModel.member_title q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.member_title.AsEnumerable();
var qry = _db.member_title.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));

View File

@@ -52,7 +52,7 @@ public class member_titleController : ApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.member_title q,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.member_title.AsEnumerable();
var qry = _db.member_title.AsQueryable();
var ret = new { list = "", count = 0 };
return Ok(ret);
}

View File

@@ -49,11 +49,11 @@ public class newsController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.news.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.news.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除檔案
var prod2 = _db.news_files.AsEnumerable().Where(q => q.news_id == id).ToList();
var prod2 = _db.news_files.Where(q => q.news_id == id).ToList();
if (prod2.Count > 0)
{
foreach (var item in prod2)
@@ -91,12 +91,12 @@ public class newsController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.news.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var prod = _db.news.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.news_files.AsEnumerable().Where(q => getDelItem.Contains(q.news_id)).ToList();
var prod2 = _db.news_files.Where(q => getDelItem.Contains(q.news_id)).ToList();
if (prod2.Count > 0)
{
publicFun publicFun = new publicFun();
@@ -139,7 +139,7 @@ public class newsController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.news q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false, bool top = false)
{
var qry = _db.news.AsEnumerable();
var qry = _db.news.AsQueryable();
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject.Trim()));
@@ -258,10 +258,13 @@ public class newsController : BaseApiController
else
qry = qry.OrderByDescending(o => o.topping).ThenByDescending(o => o.num);
}
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
subject = x.subject,
@@ -282,7 +285,7 @@ public class newsController : BaseApiController
topping = x.topping
}),
count = qry.Count()
count = count
};
@@ -298,7 +301,7 @@ public class newsController : BaseApiController
{
var qry = _db.news_kind.AsEnumerable();
var qry = _db.news_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -319,17 +322,18 @@ public class newsController : BaseApiController
range = o.range,
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
var count = qry.Count();
var qry2List = (pageSize > 0) ? qry2.ToPagedList(page, pageSize).ToList() : qry2.ToList();
var ret = new
{
list = qry2.ToPagedList(page, pageSize).Select(x => new
list = qry2List.Select(x => new
{
num = x.num,
kind = new TreeView().RptDash(x.Level) + x.kind,
}),
count = qry.Count()
count = count
};

View File

@@ -99,7 +99,7 @@ public class orderController : ApiController
{
if (id > 0)
{
var prod = _db.pro_order_detail.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.pro_order_detail.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除掛單表單
@@ -134,7 +134,7 @@ public class orderController : ApiController
{
var ids = nums.TrimEnd(',').Split(',');
var prod = _db.pro_order.AsEnumerable().Where(q => ids.Contains(q.order_no)).ToList();
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.pro_order_detail.AsEnumerable().Where(q => ids.Contains(Convert.ToString(q.order_no))).ToList();
@@ -201,7 +201,7 @@ public class orderController : ApiController
string sortBy = "", bool sortDesc = false)
{
var qry = _db.pro_order.AsEnumerable();
var qry = _db.pro_order.AsQueryable();
//var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項
@@ -220,32 +220,32 @@ public class orderController : ApiController
if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim()));
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject?.Trim()));
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject.Trim()));
if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name?.Trim()));
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name.Trim()));
if (!string.IsNullOrEmpty(q.introducerTxt))
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt?.Trim()));
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt.Trim()));
if (!string.IsNullOrEmpty(q.actItemTxt))
{
//qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0);
// qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt?.Trim())).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt.Trim())).Count() > 0);
}
if (!string.IsNullOrEmpty(q.country))
qry = qry.Where(o => o.f_num != null && o.follower?.country == q.country);
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == q.country);
if (!string.IsNullOrEmpty(q.country2))
{
if (q.country2 == "1")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country == "158");
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == "158");
}
else if (q.country2 == "2")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country != "158");
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country != "158");
}
}
@@ -275,16 +275,16 @@ public class orderController : ApiController
else if (sortBy.Equals("u_name"))
{
if (sortDesc)
qry = qry.OrderByDescending(o => o.follower?.u_name);
qry = qry.OrderByDescending(o => o.follower != null ? o.follower.u_name : "");
else
qry = qry.OrderBy(o => o.follower?.u_name);
qry = qry.OrderBy(o => o.follower != null ? o.follower.u_name : "");
}
else if (sortBy.Equals("subject"))
{
if (sortDesc)
qry = qry.OrderByDescending(o => o.activity?.subject);
qry = qry.OrderByDescending(o => o.activity != null ? o.activity.subject : "");
else
qry = qry.OrderBy(o => o.activity?.subject);
qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : "");
}
else
qry = qry.OrderByDescending(o => o.reg_time);
@@ -801,15 +801,15 @@ public class orderController : ApiController
{
//家族 : 家長是我的人,跟我同家長的人,我的家長本人,我本人
var cc = _db.followers.Where(x => x.num == _follower || x.leader == _follower).Select(x => x.num);
var qry = _db.followers.AsEnumerable().Where(f => cc.Any(x => x == f.num) || cc.Any(x => x == f.leader));
var ccList = _db.followers.Where(x => x.num == _follower || x.leader == _follower).Select(x => x.num).ToList();
var qry = _db.followers.Where(f => ccList.Contains(f.num) || (f.leader.HasValue && ccList.Contains(f.leader.Value)));
//未付款資料
var unpayDt = _db.pro_order_detail.AsEnumerable();
var unpayDt = _db.pro_order_detail.AsQueryable();
var coDt = unpayDt.Where(x => x.keyin1 == (int)Model.pro_order.detailKeyin1.Collection);//只列出報名狀態為"收款中"的項目
//未付款訂單
var orderDt = _db.pro_order.AsEnumerable();
var orderDt = _db.pro_order.AsQueryable();
if (!string.IsNullOrEmpty(order_no))
orderDt = orderDt.Where(x => x.order_no == order_no);
orderDt = orderDt.Where(x => coDt.Select(d => d.order_no).Contains(x.order_no));
@@ -855,7 +855,7 @@ public class orderController : ApiController
{
//未付款資料
var unpayDt = _db.pro_order_detail.AsEnumerable();
var unpayDt = _db.pro_order_detail.AsQueryable();
unpayDt = unpayDt.Where(x => x.keyin1 == (int)Model.pro_order.detailKeyin1.Collection);//只列出報名狀態為"收款中"的項目
if (!string.IsNullOrEmpty(q.order_no))
@@ -1118,7 +1118,7 @@ public class orderController : ApiController
[Route("api/order/DeleteRecordDetail/{id}")]//刪除收款註記
public void DeleteRecordDetail(int id)
{
var prod = _db.pro_order_record.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.pro_order_record.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{

View File

@@ -27,14 +27,14 @@ public class orderdetailController:ApiController
//var OrderList = _db.pro_order.Where(u => u.activity_num == activity_num).Select(j => j.order_no).ToList();
//var gdzOrderList = _db.pro_order_detail.Where(o => OrderList.Contains(o.order_no) && o.print_id.Contains("主")).Select(o => o.order_no).Distinct().ToList();
//var qry = _db.pro_order.Where(u => gdzOrderList.Contains(u.order_no)).AsEnumerable();
var qry = _db.pro_order.Where( u => u.activity_num == activity_num).AsEnumerable();
qry = qry.OrderByDescending(o => o.reg_time);
var qry = _db.pro_order.Where( u => u.activity_num == activity_num).OrderByDescending(o => o.reg_time);
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
order_no = x.order_no,
f_num = x.f_num,
@@ -50,7 +50,7 @@ public class orderdetailController:ApiController
|| u.actItem.subject.Contains("牌")
|| !string.IsNullOrEmpty(u.f_num_tablet))
.Count(),
actItem = x.pro_order_detail.Where(u => u.printed_files != null).FirstOrDefault()?.print_id }
actItem = x.pro_order_detail.Where(u => u.printed_files != null).Select(u => u.print_id).FirstOrDefault() }
}),
count = count
};

View File

@@ -22,8 +22,12 @@ public class pivot01Controller : ApiController
var shopConnectionString = ConfigurationManager.ConnectionStrings["shopConn"]?.ConnectionString;
if (!string.IsNullOrEmpty(shopConnectionString))
{
// 移除不相容的 Provider 參數
_connectionString = shopConnectionString.Replace("Provider=SQLOLEDB;", "");
// 移除不相容的 Provider 參數(包含 SQLOLEDB 和 SQLNCLI11
_connectionString = shopConnectionString
.Replace("Provider=SQLOLEDB;", "")
.Replace("Provider=SQLNCLI11;", "")
.Replace(" Provider=SQLOLEDB", "")
.Replace(" Provider=SQLNCLI11", "");
}
else
{

View File

@@ -48,7 +48,7 @@ public class projectController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.projects.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.projects.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.project_sub.RemoveRange(prod.project_sub); //刪除活動資料
@@ -75,7 +75,7 @@ public class projectController : BaseApiController
if (!string.IsNullOrEmpty(nums))
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.projects.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var prod = _db.projects.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
foreach (var item in prod)
@@ -103,7 +103,7 @@ public class projectController : BaseApiController
{
if (id > 0)
{
var prod = _db.project_sub.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.project_sub.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.project_sub.Remove(prod);
@@ -117,7 +117,7 @@ public class projectController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.project q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.projects.AsEnumerable();
var qry = _db.projects.AsQueryable();
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.subject.Contains(q.subject.Trim()));
@@ -192,7 +192,7 @@ public class projectController : BaseApiController
public IHttpActionResult GetKindList([FromBody] Model.ViewModel.project_kind q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.project_kind.AsEnumerable();
var qry = _db.project_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -247,7 +247,7 @@ public class projectController : BaseApiController
if (q.num.HasValue)
{
var qry = _db.project_sub.AsEnumerable();
var qry = _db.project_sub.AsQueryable();
qry = qry.Where(o => o.pro_id == q.num.Value);
@@ -337,11 +337,11 @@ public class projectController : BaseApiController
public IHttpActionResult GetPatronizeList([FromBody] Model.ViewModel.pro_order_detail q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var projectDt = _db.projects.AsEnumerable(); ;//專案
var projectDt = _db.projects.AsQueryable(); ;//專案
try
{
var qry = _db.pro_order_detail.AsEnumerable();
var qry = _db.pro_order_detail.AsQueryable();
qry = qry.Where(o => (int?)o.actItem.category == (int)Model.activity.category.Patronize);
if (q.f_num.HasValue)

View File

@@ -54,7 +54,7 @@ public class stockController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.stocks.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.stocks.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
var prod2 = prod.stock_files;
@@ -85,11 +85,11 @@ public class stockController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.stocks.AsEnumerable().Where(q => getDelItem.Contains(q.num)).ToList();
var getDelItem = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.stocks.Where(q => getDelItem.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.stock_files.AsEnumerable().Where(q => q.stock_num.HasValue && getDelItem.Contains(q.stock_num.Value)).ToList();
var prod2 = _db.stock_files.Where(q => q.stock_num.HasValue && getDelItem.Contains(q.stock_num.Value)).ToList();
if (prod2.Count() > 0)
{
publicFun publicFun = new publicFun();
@@ -114,7 +114,7 @@ public class stockController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.stock q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.stocks.AsEnumerable();
var qry = _db.stocks.AsQueryable();
if (q.category.HasValue)
qry = qry.Where(o => o.category == q.category.Value);
@@ -198,10 +198,12 @@ public class stockController : BaseApiController
qry = qry.OrderByDescending(o => o.num);
var tdesc = publicFun.enum_desc<Model.stock.type>();
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
category = x.category,
@@ -230,7 +232,7 @@ public class stockController : BaseApiController
price = x.price,
}),
count = qry.Count()
count = count
};
@@ -244,7 +246,7 @@ public class stockController : BaseApiController
public IHttpActionResult GetKindList([FromBody] Model.ViewModel.stock_kind q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.stock_kind.AsEnumerable();
var qry = _db.stock_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -293,7 +295,7 @@ public class stockController : BaseApiController
public IHttpActionResult GetReasonList([FromBody] Model.ViewModel.stock_reason q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.stock_reason.AsEnumerable();
var qry = _db.stock_reason.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -335,15 +337,16 @@ public class stockController : BaseApiController
if (q.stock_num.HasValue && q.stock_num.Value>0)
{
//檢查
var qry = _db.stock_files.AsEnumerable();
qry = qry.Where(o => o.stock_num == q.stock_num.Value);
qry.OrderByDescending(x => x.num);
var qry = _db.stock_files.Where(o => o.stock_num == q.stock_num.Value);
qry = qry.OrderByDescending(x => x.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
int i = 1;
//已有值
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
id = i++,
num = x.num,
@@ -351,7 +354,7 @@ public class stockController : BaseApiController
pic1 = x.pic1,
pic1_name = x.pic1_name,
}),
count = qry.Count(),
count = count,
};
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
@@ -466,7 +469,7 @@ public class stockController : BaseApiController
[Route("api/stock/DeleteFilesItem/{id}")]//刪除相關檔案
public void DeleteFilesItem(int id)
{
var prod = _db.stock_files.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.stock_files.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
if (!string.IsNullOrEmpty(prod.pic1))

View File

@@ -50,7 +50,7 @@ public class supplierController : BaseApiController
// DELETE api/<controller>/5
public void Delete(int id)
{
var prod = _db.suppliers.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.suppliers.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
if (!string.IsNullOrEmpty(prod.pic1))
@@ -80,8 +80,8 @@ public class supplierController : BaseApiController
{
if (!string.IsNullOrEmpty(nums))
{
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s));
var prod = _db.suppliers.AsEnumerable().Where(q => ids.Contains(q.num)).ToList();
var ids = nums.TrimEnd(',').Split(',').Select(s => int.Parse(s)).ToList();
var prod = _db.suppliers.Where(q => ids.Contains(q.num)).ToList();
if (prod.Count() > 0)
{
publicFun publicFun = new publicFun();
@@ -113,7 +113,7 @@ public class supplierController : BaseApiController
public IHttpActionResult GetList([FromBody] Model.ViewModel.supplier q, int page, int pageSize = 10,
string sortBy = "", bool sortDesc = false)
{
var qry = _db.suppliers.AsEnumerable();
var qry = _db.suppliers.AsQueryable();
if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim()));
@@ -159,9 +159,12 @@ public class supplierController : BaseApiController
else
qry = qry.OrderByDescending(o => o.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qry.ToPagedList(page, pageSize).Select(x => new
list = qryList.Select(x => new
{
num = x.num,
u_name = x.u_name,
@@ -176,7 +179,7 @@ public class supplierController : BaseApiController
}).ToList(), x.kind) : "",
}),
count = qry.Count()
count = count
};
@@ -192,7 +195,7 @@ public class supplierController : BaseApiController
{
var qry = _db.supplier_kind.AsEnumerable();
var qry = _db.supplier_kind.AsQueryable();
if (!string.IsNullOrEmpty(q.kind))
qry = qry.Where(o => o.kind.Contains(q.kind));
@@ -205,17 +208,18 @@ public class supplierController : BaseApiController
range = o.range,
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
var count = qry.Count();
var qry2List = (pageSize > 0) ? qry2.ToPagedList(page, pageSize).ToList() : qry2.ToList();
var ret = new
{
list = qry2.ToPagedList(page, pageSize).Select(x => new
list = qry2List.Select(x => new
{
num = x.num,
kind = new TreeView().RptDash(x.Level) + x.kind,
}),
count = qry.Count()
count = count
};

View File

@@ -237,7 +237,7 @@ public class transfer_registerController : ApiController
x.draft,
follower = x.f_num != null ? _db.followers
.Where(f => f.num == x.f_num)
.AsEnumerable()
.ToList()
.Select(f => new {
f.num,
f.u_name,
@@ -399,6 +399,7 @@ public class transfer_registerController : ApiController
[Route("api/transfer_register/follower_orders")]
public IHttpActionResult GetFollowerOrders(int f_num)
{
// TODO: 優化建議 - 考慮加入分頁或日期範圍限制,避免單一信眾訂單過多時載入大量數據
// 取得該信眾的所有訂單及明細,並關聯活動名稱與品項名稱
var details = _db.pro_order
.Where(o => o.f_num == f_num)
@@ -417,7 +418,7 @@ public class transfer_registerController : ApiController
d.demo,
reg_time = o.reg_time // 報名日期
}))
.AsEnumerable()
.AsEnumerable() // 只在需要內存計算前轉換
.Select(x => new {
x.order_no,
x.activity_num,
@@ -481,7 +482,7 @@ public class transfer_registerController : ApiController
x.draft,
follower = x.f_num != null ? _db.followers
.Where(f => f.num == x.f_num)
.AsEnumerable()
.ToList()
.Select(f => new {
f.num,
f.u_name,
@@ -817,7 +818,7 @@ public class transfer_registerController : ApiController
tr.balance_act_item,
balance_actitem_name = tr.balance_act_item != null ? _db.actItems.Where(a => a.num == tr.balance_act_item).Select(a => a.subject).FirstOrDefault() : ""
})
.AsEnumerable()
.ToList()
.Select(tr => new
{
tr.id,
@@ -1044,6 +1045,9 @@ public class transfer_registerController : ApiController
[Route("api/transfer_register/activity_followers")]
public IHttpActionResult GetActivityFollowers(int activity_num)
{
// TODO: 性能優化 - 大型活動可能有數千筆訂單,建議:
// 1. 在數據庫層面先過濾出未完成沖帳項目(避免載入所有訂單)
// 2. 考慮加入 Take() 限制返回數量,或實作分頁
// 查詢該法會中有報名單且有未完成沖帳項目的信眾
var followers = _db.pro_order
.Where(o => o.activity_num == activity_num)
@@ -1054,7 +1058,7 @@ public class transfer_registerController : ApiController
d.price,
paid = d.pro_order_record.Select(r => r.price).DefaultIfEmpty(0).Sum()
}))
.AsEnumerable()
.AsEnumerable() // 只在需要內存計算前轉換
.Select(x => new {
x.f_num,
x.follower_name,
@@ -1104,7 +1108,7 @@ public class transfer_registerController : ApiController
d.demo,
reg_time = o.reg_time // 報名日期
}))
.AsEnumerable()
.ToList()
.Select(x => new {
x.order_no,
x.activity_num,

View File

@@ -55,17 +55,17 @@ public class apporderController : ApiController
// DELETE api/<controller>/5
public void Delete(string id)
{
var prod = _db.pro_order.AsEnumerable().Where(q => q.order_no == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.pro_order.Where(q => q.order_no == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除掛單表單
var prod3 = _db.bed_order.AsEnumerable().Where(q => q.order_no == id).ToList();
var prod3 = _db.bed_order.Where(q => q.order_no == id).ToList();
if (prod3.Count > 0)
{
//刪除掛單明細
foreach (var item3 in prod3)
{
var prod4 = _db.bed_order_detail.AsEnumerable().Where(q => q.bed_order_no == item3.bed_order_no).ToList();
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
if (prod4.Count > 0)
{
_db.bed_order_detail.RemoveRange(prod4); //查詢結果全部刪除
@@ -97,17 +97,17 @@ public class apporderController : ApiController
{
if (id > 0)
{
var prod = _db.pro_order_detail.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.pro_order_detail.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
//刪除掛單表單
var prod3 = _db.bed_order.AsEnumerable().Where(q => q.order_no == prod.order_no).ToList();
var prod3 = _db.bed_order.Where(q => q.order_no == prod.order_no).ToList();
if (prod3.Count > 0) //count = 1
{
//刪除掛單明細
foreach (var item3 in prod3)
{
var prod4 = _db.bed_order_detail.AsEnumerable().Where(q => q.bed_order_no == item3.bed_order_no).ToList();
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
if (prod4.Count > 0)
{
_db.bed_order_detail.RemoveRange(prod4); //查詢結果全部刪除
@@ -132,20 +132,20 @@ public class apporderController : ApiController
{
var ids = nums.TrimEnd(',').Split(',');
var prod = _db.pro_order.AsEnumerable().Where(q => ids.Contains(q.order_no)).ToList();
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.pro_order_detail.AsEnumerable().Where(q => ids.Contains(Convert.ToString(q.order_no))).ToList();
var prod2 = _db.pro_order_detail.Where(q => ids.Contains(Convert.ToString(q.order_no))).ToList();
if (prod2.Count > 0)
{
foreach (var item2 in prod2)
{
var prod3 = _db.bed_order.AsEnumerable().Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
var prod3 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
if (prod3.Count > 0)
{
foreach (var item3 in prod3)
{
var prod4 = _db.bed_order_detail.AsEnumerable().Where(q => q.bed_order_no == item3.bed_order_no).ToList();
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
if (prod4.Count > 0)
{
_db.bed_order_detail.RemoveRange(prod4);
@@ -156,8 +156,8 @@ public class apporderController : ApiController
}
//var prod32 = _db.bed_order.AsEnumerable().Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
//var prod42 = _db.bed_order_detail.AsEnumerable().Where(q => prod32.Select(qf => qf.order_no).ToArray().Contains(q.bed_order_no)).ToList();
//var prod32 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
//var prod42 = _db.bed_order_detail.Where(q => prod32.Select(qf => qf.order_no).ToArray().Contains(q.bed_order_no)).ToList();
//_db.bed_order_detail.RemoveRange(prod42);
//_db.bed_order.RemoveRange(prod32);
@@ -200,7 +200,7 @@ public class apporderController : ApiController
{
var qry = _db.pro_order.AsEnumerable();
//var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項
//var aIDt = _db.actItems.Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項
if (!string.IsNullOrEmpty(q.order_no))
@@ -218,32 +218,32 @@ public class apporderController : ApiController
if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim()));
if (!string.IsNullOrEmpty(q.subject))
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject?.Trim()));
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(q.subject.Trim()));
if (!string.IsNullOrEmpty(q.u_name))
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name?.Trim()));
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(q.u_name.Trim()));
if (!string.IsNullOrEmpty(q.introducerTxt))
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt?.Trim()));
qry = qry.Where(o => o.introducer.HasValue && o.follower1.u_name.Contains(q.introducerTxt.Trim()));
if (!string.IsNullOrEmpty(q.actItemTxt))
{
//qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.ToArray().Contains(f2.actItem_num?.ToString())).Count() > 0);
// qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.order_no == o.order_no && aIDt.Any(x => x == f2.actItem_num)).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt?.Trim())).Count() > 0);
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem.subject.Contains(q.actItemTxt.Trim())).Count() > 0);
}
if (!string.IsNullOrEmpty(q.country))
qry = qry.Where(o => o.f_num != null && o.follower?.country == q.country);
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == q.country);
if (!string.IsNullOrEmpty(q.country2))
{
if (q.country2 == "1")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country == "158");
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country == "158");
}
else if (q.country2 == "2")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country != "158");
qry = qry.Where(o => o.f_num != null && o.follower != null && o.follower.country != "158");
}
}
@@ -317,11 +317,11 @@ public class apporderController : ApiController
if (!string.IsNullOrEmpty( order_no ))
{
//檢查
var prod = _db.pro_order.AsEnumerable().Where(o => o.order_no == order_no).FirstOrDefault();
var prod = _db.pro_order.Where(o => o.order_no == order_no).FirstOrDefault();
if (prod != null)
{
int activity = prod.activity_num.HasValue ? prod.activity_num.Value : 0; //活動
var bedDt = _db.bed_order_detail.AsEnumerable().Where(b=>b.bed_order.order_no== order_no ); ;//掛單明細
var bedDt = _db.bed_order_detail.Where(b=>b.bed_order.order_no== order_no ); ;//掛單明細
//var qry1 = _db.pro_order_detail.AsEnumerable();
@@ -435,7 +435,7 @@ public class apporderController : ApiController
if (activity > 0)
{
i = 1;
var qry2 = _db.activity_relating.AsEnumerable();
var qry2 = _db.activity_relating.AsQueryable();
qry2 = qry2.Where(o => o.activity_num == activity);
if (q.actItem_kind_num.HasValue)
@@ -690,14 +690,14 @@ public class apporderController : ApiController
//家族 : 家長是我的人,跟我同家長的人,我的家長本人,我本人
var cc = _db.followers.Where(x => x.num == _follower || x.leader == _follower).Select(x => x.num);
var qry = _db.followers.AsEnumerable().Where(f => cc.Any(x => x == f.num) || cc.Any(x => x == f.leader));
var qry = _db.followers.Where(f => cc.Any(x => x == f.num) || cc.Any(x => x == f.leader));
//未付款資料
var unpayDt = _db.pro_order_detail.AsEnumerable();
var unpayDt = _db.pro_order_detail.AsQueryable();
var coDt = unpayDt.Where(x => x.keyin1 == (int)Model.pro_order.detailKeyin1.Collection);//只列出報名狀態為"收款中"的項目
//未付款訂單
var orderDt = _db.pro_order.AsEnumerable();
var orderDt = _db.pro_order.AsQueryable();
if (!string.IsNullOrEmpty(order_no))
orderDt = orderDt.Where(x => x.order_no == order_no);
orderDt = orderDt.Where(x => coDt.Select(d => d.order_no).Contains(x.order_no));
@@ -737,7 +737,7 @@ public class apporderController : ApiController
{
//未付款資料
var unpayDt = _db.pro_order_detail.AsEnumerable();
var unpayDt = _db.pro_order_detail.AsQueryable();
unpayDt = unpayDt.Where(x => x.keyin1 == (int)Model.pro_order.detailKeyin1.Collection);//只列出報名狀態為"收款中"的項目
if (!string.IsNullOrEmpty(q.order_no))
@@ -865,10 +865,10 @@ public class apporderController : ApiController
if (u_name >0 && (!string.IsNullOrEmpty(q.order_no)))
{
//檢查
var prod = _db.pro_order.AsEnumerable().Where(o => o.f_num == u_name && o.order_no != q.order_no).ToList();
var prod = _db.pro_order.Where(o => o.f_num == u_name && o.order_no != q.order_no).ToList();
if (prod.Count > 0)
{
var qry = _db.pro_order_detail.AsEnumerable().Where(o => prod.Any(x => x.order_no==o.order_no) );
var qry = _db.pro_order_detail.Where(o => prod.Any(x => x.order_no==o.order_no) );
int i = 1;
var ret = new
{
@@ -942,7 +942,7 @@ public class apporderController : ApiController
if (detail_num > 0 )
{
//檢查
var prod = _db.pro_order_record.AsEnumerable().Where(o => o.detail_num == detail_num )
var prod = _db.pro_order_record.Where(o => o.detail_num == detail_num )
.OrderByDescending(o=>o.pay_date).ToList();
int i = 1;
var ret = new
@@ -979,7 +979,7 @@ public class apporderController : ApiController
[Route("api/apporder/DeleteRecordDetail/{id}")]//刪除收款註記
public void DeleteRecordDetail(int id)
{
var prod = _db.pro_order_record.AsEnumerable().Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
var prod = _db.pro_order_record.Where(q => q.num == id).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -995,8 +995,8 @@ public class apporderController : ApiController
{
if (item.detail_num > 0)
{
float total = _db.pro_order_detail.AsEnumerable().Where(x => x.num == item.detail_num).Select(x => x.price.Value * x.qty.Value).Sum();
float pay = _db.pro_order_record.AsEnumerable().Where(x => x.detail_num == item.detail_num).Select(x => x.price.Value).Sum();
float total = _db.pro_order_detail.Where(x => x.num == item.detail_num).Select(x => x.price.Value * x.qty.Value).Sum();
float pay = _db.pro_order_record.Where(x => x.detail_num == item.detail_num).Select(x => x.price.Value).Sum();
if (pay + item.price.Value <= total)
{

View File

@@ -130,7 +130,8 @@ public partial class admin_hr_import : MyWeb.config
);
sd2.AppendChild(tr);
//查詢要匯出的資料
var list = _db.member_group.AsEnumerable().ToList();
// TODO: REVIEW - member_group 為固定少量資料表ToList() 可接受
var list = _db.member_group.ToList();
if (list.Count > 0)
{
foreach (var item in list)
@@ -178,7 +179,8 @@ public partial class admin_hr_import : MyWeb.config
);
sd3.AppendChild(tr);
//查詢要匯出的資料
var list2 = _db.member_title.AsEnumerable().ToList();
// TODO: REVIEW - member_title 為固定少量資料表ToList() 可接受
var list2 = _db.member_title.ToList();
if (list2.Count > 0)
{
foreach (var item in list2)
@@ -229,10 +231,16 @@ public partial class admin_hr_import : MyWeb.config
startRowNumber += 1;
}
var fDt = _db.followers.AsEnumerable().ToList(); //信眾
var aDt = _db.admins.AsEnumerable().ToList(); //後台系統
var gDt = _db.member_group.AsEnumerable().Select(x => x.num).ToList(); //組別
var tDt = _db.member_title.AsEnumerable().Select(x => x.num).ToList(); //職稱
// TODO: REVIEW - 整表載入性能評估:
// - followers (信眾) ⚠️ 會成長!若超過 1000 筆需優化為按需載入(先掃描 Excel 收集編號)
// - admins (管理員) ✓ 通常少量ToList() 可接受
// - member_group (組別) ✓ 固定少量,可接受
// - member_title (職稱) ✓ 固定少量,可接受
// 優化方案:先掃描 Excel → 只載入需要的編號 → 使用 Dictionary 加速查找O(1) vs O(n)
var fDt = _db.followers.ToList(); //信眾
var aDt = _db.admins.ToList(); //後台系統
var gDt = _db.member_group.Select(x => x.num).ToList(); //組別
var tDt = _db.member_title.Select(x => x.num).ToList(); //職稱
MyWeb.encrypt encrypt = new MyWeb.encrypt();
for (int currentRow = startRowNumber; currentRow <= endRowNumber; currentRow++)

View File

@@ -27,7 +27,6 @@ public partial class admin_hr_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var qry = _db.member_group.AsEnumerable();
var prod = _db.member_group.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -70,7 +69,6 @@ public partial class admin_hr_kind_reg : MyWeb.config
protected void TreeTopology()
{
var qry = _db.member_group.AsEnumerable();
var prod = _db.member_group.ToList();
//treeDt = prod.CopyToDataTable();
@@ -235,7 +233,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
try
{
var prod = _db.member_group.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.member_group.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -281,7 +279,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
del_product(num);
var prod = _db.member_group.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.member_group.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.member_group.Remove(prod);
@@ -302,7 +300,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.member_group.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.member_group.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -319,7 +317,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
}
public void del_product(int num)
{
var prod = _db.members.AsEnumerable().Where(q => q.group_kind == num).ToList();
var prod = _db.members.Where(q => q.group_kind == num).ToList();
if (prod.Count > 0)
{
//清空組別分類

View File

@@ -22,7 +22,6 @@ public partial class admin_hr_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var qry = _db.member_title.AsEnumerable();
var prod = _db.member_title.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -207,7 +206,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
}
try
{
var prod = _db.member_title.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.member_title.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -248,7 +247,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.member_title.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.member_title.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.member_title.Remove(prod);
@@ -269,7 +268,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.member_title.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.member_title.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -286,7 +285,7 @@ public partial class admin_hr_kind_reg : MyWeb.config
public void del_product(int num)
{
var prod = _db.members.AsEnumerable().Where(q => q.title_kind == num).ToList();
var prod = _db.members.Where(q => q.title_kind == num).ToList();
if (prod.Count > 0)
{
//清空分類

View File

@@ -21,7 +21,7 @@ public partial class admin_accounting_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.accounting_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.accounting_kind.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -215,7 +215,7 @@ public partial class admin_accounting_kind_reg : MyWeb.config
try
{
var prod = _db.accounting_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.accounting_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -254,7 +254,7 @@ public partial class admin_accounting_kind_reg : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.accounting_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.accounting_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.accounting_kind.Remove(prod);
@@ -272,7 +272,7 @@ public partial class admin_accounting_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.accounting_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.accounting_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -291,7 +291,7 @@ public partial class admin_accounting_kind_reg : MyWeb.config
public void del_product(int num)
{
var prod = _db.accountings.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.accountings.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////查詢結果全部刪除

View File

@@ -21,7 +21,7 @@ public partial class admin_accounting_kind_reg2 : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.accounting_kind2.AsEnumerable().Where(q => q.num == _num).FirstOrDefault();
var prod = _db.accounting_kind2.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
@@ -228,7 +228,7 @@ public partial class admin_accounting_kind_reg2 : MyWeb.config
try
{
var prod = _db.accounting_kind2.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.accounting_kind2.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -271,7 +271,7 @@ public partial class admin_accounting_kind_reg2 : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.accounting_kind2.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.accounting_kind2.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.accounting_kind2.Remove(prod);
@@ -288,7 +288,7 @@ public partial class admin_accounting_kind_reg2 : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.accounting_kind2.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.accounting_kind2.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -306,7 +306,7 @@ public partial class admin_accounting_kind_reg2 : MyWeb.config
public void del_product(int num)
{
var prod = _db.accountings.AsEnumerable().Where(q => q.kind2 == num).ToList();
var prod = _db.accountings.Where(q => q.kind2 == num).ToList();
if (prod.Count > 0)
{
////查詢結果全部刪除

View File

@@ -21,7 +21,7 @@ public partial class admin_activity_itemKind : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.actItem_kind.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -214,7 +214,7 @@ public partial class admin_activity_itemKind : MyWeb.config
try
{
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.actItem_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -252,7 +252,7 @@ public partial class admin_activity_itemKind : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.actItem_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
@@ -271,7 +271,7 @@ public partial class admin_activity_itemKind : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.actItem_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -289,7 +289,7 @@ public partial class admin_activity_itemKind : MyWeb.config
public void del_product(int num)
{
var prod = _db.actItems.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.actItems.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
//清空分類

View File

@@ -24,7 +24,7 @@ public partial class admin_activity_kind_reg : MyWeb.config
{
_this_id = ValString(Request["num"]);
int _num = Val(Request["num"]);
var prod = _db.activity_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
var prod = _db.activity_kind.Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
if (prod != null)
{
@@ -230,7 +230,7 @@ public partial class admin_activity_kind_reg : MyWeb.config
try
{
var prod = _db.activity_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.activity_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -284,7 +284,7 @@ public partial class admin_activity_kind_reg : MyWeb.config
{
int num = Val(Request["num"]);
del_product(num);
var prod = _db.activity_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.activity_kind.Remove(prod);
@@ -301,7 +301,7 @@ public partial class admin_activity_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.activity_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.activity_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -317,7 +317,7 @@ public partial class admin_activity_kind_reg : MyWeb.config
}
public void del_product(int num)
{
var prod = _db.activities.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.activities.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
//清空分類

View File

@@ -21,7 +21,7 @@ public partial class admin_activity_kind_reg2 : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.num == _num).Where(q => q.num == _num).FirstOrDefault();
var prod = _db.activity_category_kind.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
@@ -208,7 +208,7 @@ public partial class admin_activity_kind_reg2 : MyWeb.config
try
{
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.activity_category_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -247,7 +247,7 @@ public partial class admin_activity_kind_reg2 : MyWeb.config
del_product(num);
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.activity_category_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.activity_category_kind.Remove(prod);
@@ -265,7 +265,7 @@ public partial class admin_activity_kind_reg2 : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.activity_category_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -284,7 +284,7 @@ public partial class admin_activity_kind_reg2 : MyWeb.config
public void del_product(int num) //刪除訊息
{
//EF Model 資料庫拉關聯 , 故刪除類型前,一定要先刪除訊息,否則關聯會出錯
var prod = _db.activities.AsEnumerable().Where(q => q.category_kind == num).ToList();
var prod = _db.activities.Where(q => q.category_kind == num).ToList();
if (prod.Count > 0)
{

View File

@@ -0,0 +1,908 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletarea_index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<nav class="mb-2 ps-3">
<button class="btn btn-primary me-2" type="button" @click="showNewtAreadialogMethod">
<i class="mdi mdi-plus"></i> 新增區域
</button>
<button class="btn btn-secondary me-2" @click="expandAll" type="button">
<i class="mdi mdi-arrow-expand-all"></i> 全部展開
</button>
<button class="btn btn-secondary" @click="collapseAll" type="button">
<i class="mdi mdi-arrow-collapse-all"></i> 全部收起
</button>
</nav>
<nav>
<button type="button" class="btn btn-primary" @click="toggleAreaData">
{{ showAreaDataFlag ? '隱藏區域資料' : '顯示區域資料' }}
</button>
</nav>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 col-lg-3">
<div class="card shadow-sm my-2">
<div class="card-header">神主牌區域列表</div>
<div class="card-body">
<ul class="tree">
<li v-for="area in ancestral_tablet_areas" :key="area.AreaId">
<region-item
:item="area"
:selected-id="currentSelectAreaId"
@select-area="selectAreaMethod"
:expand-all="expandAllFlag"
:collapse-all="collapseAllFlag"
@clear-expand-all="expandAllFlag = false"
@clear-collapse-all="collapseAllFlag = false"
/>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4 col-lg-9" v-if="currentSelectArea && showAreaDataFlag">
<div class="card shadow-sm my-2"style="position: sticky; top: 20px;">
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
<div>
<span class="fw-bold">
{{ ' ' + currentSelectArea?.areaName + ' ' }}
</span>
<span>
資料
</span>
</div>
<div>
<button class="btn btn-primary" type="button" @click="showEidtAreadialogMethod">
編輯
</button>
</div>
</div>
<div class="card-body">
<div class="container">
<div class="row">
<div class="col-12 col-sm-6">
<label>區域名稱</label>
<input v-model="currentSelectArea.areaName" type="text" class="form-control" readonly/>
</div>
<div class="col-12 col-sm-6">
<label>區域編號</label>
<input v-model="currentSelectArea.areaCode" type="text" class="form-control" readonly/>
</div>
<div class="col-12 col-sm-6">
<label>上層區域(可選)</label>
<input v-model="currentSelectArea.parentAreaId" type="text" class="form-control" readonly />
</div>
<div class="col-12 col-sm-6">
<label>區域類型(可空)</label>
<input v-model="currentSelectArea.areaType" type="text" class="form-control" readonly/>
</div>
<div class="col-12 col-sm-6">
<label>價格</label>
<input v-model="currentSelectArea.price" class="form-control" readonly/>
</div>
<div class="col-12 col-sm-6">
<label>排序</label>
<input v-model="currentSelectArea.sortOrder" class="form-control" readonly/>
</div>
<div class="col-12 col-sm-6">
<div style="display: flex; align-items: center; height: 100%; margin-top: 8px;">
<input
v-model="currentSelectArea.isDisabled"
type="checkbox"
disabled
id="disabledToggle"
style="width: 20px; height: 20px; margin-right: 8px; cursor: pointer;"
/>
<label
for="disabledToggle"
style="font-weight: bold; font-size: 14px; color: #333; margin: 0;"
>
是否停用
</label>
</div>
</div>
<div class="col-12 mt-3">
<label>描述</label>
<textarea v-model="currentSelectArea.description" rows="3" class="form-control" readonly></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4 col-lg-9" v-if="currentSelectArea">
<div class="card shadow-sm my-2" style="flex: 1 1 auto; min-height: 0; overflow: auto;">
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;background-color: #ffc107;">
<div>
{{currentSelectArea.areaName + ' - ' + '神主牌位置'}}
</div>
<div>
<v-btn color="primary" @click="openNewPositionDialogMethod">批次新增神主牌位置</v-btn>
</div>
</div>
<div class="card-body">
<div class="grid-container">
<div
v-for="pos in positions"
:key="pos.positionCode"
class="grid-item"
:class="'status-' + pos.statusCode"
:style="{ gridRow: pos.rowNo, gridColumn: pos.columnNo }"
>
<div class="position-name">{{ pos.positionName }}</div>
<div class="position-content">
<!-- 這裡可以放更多資訊,比如價格或狀態 -->
<!-- 例如:價格: {{ pos.price }} -->
<v-btn small @click="editPositionMethod(pos)">修改</v-btn>
<v-btn small @click="deletePositionMethod(pos)">刪除</v-btn>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 新增區域彈出視窗 -->
<div>
<v-dialog v-model="showNewAreadialogFlag" max-width="1200px">
<v-card
style="min-height: 50vh; max-height: 80vh; overflow-y: auto;"
>
<v-card-title>
<span class="headline">新增區域</span>
</v-card-title>
<v-card-text>
<div class="container">
<div class="row">
<div class="col-12 col-sm-6">
<label>區域名稱</label>
<input v-model="newArea.areaName" type="text" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>區域編號</label>
<input v-model="newArea.areaCode" type="text" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>上層區域(可選)</label>
<select v-model="newArea.parentAreaId" class="form-control" >
<option value="">請選擇</option>
<!-- 手動添加選項 -->
<option v-for="r in flatAreas"
:value="r.areaId"
:disabled="disabledParentOptions.includes(r.areaId)">{{ r.areaName }}
</option>
</select>
</div>
<div class="col-12 col-sm-6">
<label>區域類型(可空)</label>
<input type="text" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>價格</label>
<input v-model="newArea.price" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>排序</label>
<input v-model="newArea.sortOrder" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<div style="display: flex; align-items: center; height: 100%; margin-top: 8px;">
<input
v-model="newArea.isDisabled"
type="checkbox"
style="width: 20px; height: 20px; margin-right: 8px; cursor: pointer;"
/>
<label
for="disabledToggle"
style="font-weight: bold; font-size: 14px; color: #333; margin: 0;"
>
是否停用
</label>
</div>
</div>
<div class="col-12 mt-3">
<label>描述</label>
<textarea v-model="newArea.description" rows="3" class="form-control" ></textarea>
</div>
</div>
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="grey" text @click="closeNewAreadialogMethod">取消</v-btn>
<v-btn color="primary" @click="createNewAreaMethod">確定新增</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
<!-- 編輯區域彈出視窗 -->
<div>
<v-dialog v-model="showEidtAreadialogFlag" max-width="1200px">
<v-card
style="min-height: 50vh; max-height: 80vh; overflow-y: auto;"
>
<v-card-title>
<span class="headline">編輯區域</span>
</v-card-title>
<v-card-text>
<div class="container">
<div class="row">
<div class="col-12 col-sm-6">
<label>區域名稱</label>
<input v-model="editArea.areaName" type="text" class="form-control" required />
</div>
<div class="col-12 col-sm-6">
<label>區域編號</label>
<input v-model="editArea.areaCode" type="text" class="form-control" required />
</div>
<div class="col-12 col-sm-6">
<label>上層區域(可選)</label>
<select v-model="editArea.parentAreaId" class="form-control" >
<option value="">請選擇</option>
<!-- 手動添加選項 -->
<option v-for="r in flatAreas"
:value="r.areaId"
:disabled="disabledParentOptions.includes(r.areaId)">{{ r.areaName }}
</option>
</select>
</div>
<div class="col-12 col-sm-6">
<label>區域類型(可空)</label>
<input v-model="editArea.areaType" type="text" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>價格</label>
<input v-model="editArea.price" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<label>排序</label>
<input v-model="editArea.sortOrder" class="form-control" />
</div>
<div class="col-12 col-sm-6">
<div style="display: flex; align-items: center; height: 100%; margin-top: 8px;">
<input
v-model="editArea.isDisabled"
type="checkbox"
id="disabledToggle1"
style="width: 20px; height: 20px; margin-right: 8px; cursor: pointer;"
/>
<label
for="disabledToggle"
style="font-weight: bold; font-size: 14px; color: #333; margin: 0;"
>
是否停用
</label>
</div>
</div>
<div class="col-12 mt-3">
<label>描述</label>
<textarea v-model="editArea.description" rows="3" class="form-control" ></textarea>
</div>
</div>
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="grey" text @click="closeEidtAreadialogMethod">取消</v-btn>
<v-btn color="primary" @click="editAreaMethod">送出修改</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
<!-- 批次新增神主牌彈出視窗 -->
<div>
<!-- 彈出視窗組件 -->
<v-dialog v-model="showNewPositionDialogFlag" max-width="800px">
<v-card>
<v-card-title>
批次新增神主牌位置
<v-spacer></v-spacer>
<v-btn icon @click="closeNewPositionDialogMethod">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-card-text>
<div class="card p-3 mt-4">
<div class="row mb-2">
<div class="col">
<label>起始行</label>
<input v-model.number="batchPositionForm.startRow" type="number" class="form-control" />
</div>
<div class="col">
<label>起始列</label>
<input v-model.number="batchPositionForm.startCol" type="number" class="form-control" />
</div>
<div class="col">
<label>行數</label>
<input v-model.number="batchPositionForm.rows" type="number" class="form-control" />
</div>
<div class="col">
<label>列數</label>
<input v-model.number="batchPositionForm.cols" type="number" class="form-control" />
</div>
</div>
<div class="row mb-2">
<div class="col">
<label>價格</label>
<input v-model.number="batchPositionForm.price" type="number" class="form-control" />
</div>
<div class="col">
<label>狀態</label>
<select v-model="batchPositionForm.status" class="form-control">
<option v-for="s in statusList" :key="s.statusCode" :value="s.statusCode">
{{ s.statusName }}
</option>
</select>
</div>
<div class="col">
<label>Name模板</label>
<input v-model="batchPositionForm.nameTemplate" class="form-control" placeholder="如:神位編號{code}" />
</div>
</div>
<div class="row mb-3">
<div class="col">
<label>Code起始值</label>
<input v-model.number="batchPositionForm.startCode" type="number" class="form-control" />
</div>
<div class="col">
<label>Code長度</label>
<input v-model.number="batchPositionForm.codeLength" type="number" class="form-control" />
</div>
</div>
</div>
<div v-if="previewPositions.length">
<h3>預覽新增位置</h3>
<ul>
<li v-for="pos in previewPositions" :key="pos.PositionCode">
{{ pos.PositionCode }} - {{ pos.PositionName }} (行: {{ pos.RowNo }}, 列: {{ pos.ColumnNo }})
</li>
</ul>
</div>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn color="primary" @click="generatePositionsMethod">生成預覽</v-btn>
<v-btn color="pirmary" @click="clearPreviewPositionsMethod">清除預覽</v-btn>
<v-btn color="primary" @click="confirmAddPositionsMethod">確認新增</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
<!-- 編輯牌位位置彈出視窗 -->
<div v-if="currentEditPosition">
<v-dialog v-model="editPositionFormVisible" max-width="500">
<v-card>
<v-card-title class="text-h6">
編輯位置:{{ currentEditPosition?.positionName || '未選擇' }}
</v-card-title>
<v-card-text>
<div class="form-row">
<label>位置名稱:</label>
<input v-model="currentEditPosition.positionName" class="form-control" />
</div>
<div class="form-row">
<label>價格:</label>
<input v-model="currentEditPosition.price" type="number" class="form-control" />
</div>
<div class="form-row">
<label>狀態:</label>
<select v-model="currentEditPosition.statusCode" class="form-control">
<option v-for="s in statusList" :key="s.statusCode" :value="s.statusCode">
{{ s.statusName }}
</option>
</select>
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" @click="saveEditPositionMethod">保存</v-btn>
<v-btn text @click="editPositionFormVisible = false">取消</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
Vue.component('region-item', {
props: ['item', 'selectedId', 'expandAll', 'collapseAll'],
data() {
return {
expanded: false, // 預設全部收起
}
},
watch: {
expandAll(newVal) {
if (newVal) {
this.expanded = true;
// 執行完後發事件通知父組件清除標誌
this.$nextTick(() => this.$emit('clear-expand-all'));
}
},
collapseAll(newVal) {
if (newVal) {
this.expanded = false;
this.$nextTick(() => this.$emit('clear-collapse-all'));
}
}
},
computed: {
hasChildren() {
return this.item.children && this.item.children.length > 0;
},
icon() {
// 無論有無子節點,皆可點擊展開/收起
return this.expanded ? '▼' : '▶';
},
isSelected() {
return this.item.areaId === this.selectedId;
}
},
methods: {
toggle() {
this.expanded = !this.expanded;
},
select() {
this.$emit('select-area', this.item);
},
},
template: `
<div>
<span class="toggle-icon" @click="toggle">{{ icon }}</span>
<span @click="select"
class="region-item-label"
:class="{ 'selected': isSelected }">
{{ item.areaName }}
</span>
<!-- 子區域列表 -->
<ul v-if="hasChildren && expanded">
<li v-for="child in item.children" :key="child.areaId">
<region-item
:item="child"
:selected-id="selectedId"
:expand-all="expandAll"
:collapse-all="collapseAll"
@select-area="$emit('select-area', $event)"
@clear-expand-all="$emit('clear-expand-all')"
@clear-collapse-all="$emit('clear-collapse-all')"
/>
</li>
</ul>
</div>
`
});
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
expandAllFlag: false, // 控制全部展開
collapseAllFlag: false, // 控制全部收起
ancestral_tablet_areas: [], //神主牌區域列表
currentSelectArea: null,
currentSelectAreaId: null,
showEidtAreadialogFlag: false,
showNewAreadialogFlag: false,
showAreaDataFlag: false,//是否顯示區域資料
flatAreas: [],//所有區域展平
disabledParentOptions: [],//某個區域禁止選擇作為父區域的函數
newArea: {
areaId: null, // 自增主鍵,新增時通常為 null
areaName: null, // 區域名稱,必填
areaCode: null, // 區域編號,必填
parentAreaId: null, // 上層區域 ID可為 null
areaType: null, // 區域類型,可空
price: null, // 價格,可空
sortOrder: null, // 排序,可空
description: null, // 區域描述
isDisabled: null
},
editArea: {
areaId: null, // 自增主鍵,新增時通常為 null
areaName: null, // 區域名稱,必填
areaCode: null, // 區域編號,必填
parentAreaId: null, // 上層區域 ID可為 null
areaType: null, // 區域類型,可空
price: null, // 價格,可空
sortOrder: null, // 排序,可空
description: null, // 區域描述
isDisabled: null
},
statusList: [],
//--------------------------------神主牌位置變數
showNewPositionDialogFlag: false,//控制是否顯示批次新增神主牌彈出視窗
editPositionFormVisible: false, // 控制是否顯示編輯彈出視窗
currentEditPosition: null, // 儲存當前正在編輯的位置資訊
batchPositionForm: {
startRow: 1,
startCol: 1,
rows: 5,
cols: 10,
price: 0,
status: 'available',
nameTemplate: '神位{code}',
startCode: 1,
codeLength: 3
},
positions: [],
// 預覽數據
previewPositions: [],
//--------------------------------神主牌位置變數
}
},
methods: {
selectAreaMethod(area) {
this.currentSelectAreaId = area.areaId;
this.currentSelectArea = area;
const node = this.findRegionById(this.ancestral_tablet_areas, area.areaId);
this.disabledParentOptions = this.getAllDescendants(node);
this.loadTabletPositionsMethod(area.areaId);
},
showEidtAreadialogMethod() {
this.showEidtAreadialogFlag = true;
if (this.currentSelectArea) {
this.editArea = {
areaId: this.currentSelectArea?.areaId,
areaName: this.currentSelectArea?.areaName,
areaCode: this.currentSelectArea?.areaCode,
parentAreaId: this.currentSelectArea?.parentAreaId ?? null,
areaType: this.currentSelectArea?.areaType ?? null,
price: this.currentSelectArea?.price ?? null,
sortOrder: this.currentSelectArea?.sortOrder ?? null,
description: this.currentSelectArea?.description ?? null,
isDisabled: this.currentSelectArea?.isDisabled ?? true
};
}
},
closeEidtAreadialogMethod() {
this.showEidtAreadialogFlag = false;
this.resetEditArea();
},
showNewtAreadialogMethod() {
this.showNewAreadialogFlag = true;
},
closeNewAreadialogMethod() {
this.showNewAreadialogFlag = false;
this.resetNewArea();
},
createNewAreaMethod() {
//新建區域
axios.post(HTTP_HOST + 'api/ancestraltablet/area/create', this.newArea)
.then(response => {
this.closeEidtAreadialogMethod();
this.getAreaListMethod();
})
.catch(error => {
console.error('失敗:', error);
});
},
editAreaMethod() {
//修改區域資料
axios.post(HTTP_HOST + 'api/ancestraltablet/area/edit', this.editArea)
.then(response => {
this.currentSelectArea = response.data.area;
this.getAreaListMethod();
this.closeEidtAreadialogMethod();
})
.catch(error => {
console.error('失敗:', error);
});
},
resetNewArea() {
this.newArea = {
areaId: null,
areaName: null,
areaCode: null,
parentAreaId: null,
areaType: null,
price: null,
sortOrder: null,
description: null,
isDisabled: false
};
},
resetEditArea() {
this.editArea = {
areaId: null,
areaName: null,
areaCode: null,
parentAreaId: null,
areaType: null,
price: null,
sortOrder: null,
description: null,
isDisabled: false
};
},
getAreaListMethod() {
//獲取區域列表
axios.get(HTTP_HOST + 'api/ancestraltablet/area/getlist')
.then(res => {
this.ancestral_tablet_areas = res.data
this.flatAreas = this.flattenAreas(res.data);
})
},
expandAll() {
this.expandAllFlag = true;
this.collapseAllFlag = false;
},
collapseAll() {
this.collapseAllFlag = true;
this.expandAllFlag = false;
},
//區域展開是否可以被選擇作為上級區域相關函數
flattenAreas(data, list = []) {
data.forEach(item => {
list.push({ areaId: item.areaId, areaName: item.areaName });
if (item.children && item.children.length) {
this.flattenAreas(item.children, list);
}
});
return list;
},
findRegionById(list, areaId) {
for (const item of list) {
if (item.areaId === areaId) return item;
if (item.children) {
const found = this.findRegionById(item.children, areaId);
if (found) return found;
}
}
return null;
},
getAllDescendants(node) {
//尋找某個區域的所有子區域
const ids = [];
const dfs = (n) => {
ids.push(n.areaId);
if (n.children) {
n.children.forEach(child => dfs(child));
}
};
dfs(node);
return ids;
},
toggleAreaData() {
this.showAreaDataFlag = !this.showAreaDataFlag;
},
//--------------------------------神主牌位置相關函數
padCodeMethod(codeNum, length) {
return codeNum.toString().padStart(length, '0');
},
loadTabletPositionsMethod(areaId) {
axios.get(HTTP_HOST + 'api/ancestraltablet/area/position/getlist', {
params: {
areaId: areaId
}
})
.then(response => {
this.positions = response.data;
})
.catch(error => {
console.error('失敗:', error);
});
},
generatePositionsMethod() {
const form = this.batchPositionForm;
const positions = [];
let codeCounter = form.startCode;
for (let i = 0; i < form.rows; i++) {
for (let j = 0; j < form.cols; j++) {
const row = form.startRow + i;
const col = form.startCol + j;
const paddedCode = this.padCodeMethod(codeCounter, form.codeLength);
const positionCode = paddedCode;
const positionName = form.nameTemplate.replace('{code}', paddedCode);
positions.push({
AreaId: this.currentSelectArea.areaId,
RowNo: row,
ColumnNo: col,
PositionCode: positionCode,
PositionName: positionName,
Price: form.price,
StatusCode: form.status,
Description: ''
});
codeCounter++;
}
}
this.previewPositions = positions; // 先賦值預覽,不發請求
},
async confirmAddPositionsMethod() {
if (this.previewPositions.length === 0) {
alert('請先生成預覽數據');
return;
}
// 調用後端批次新增介面
try {
const response = await axios.post(
`${HTTP_HOST}api/ancestraltablet/position/batchcreate`,
this.previewPositions
);
// 如果後端成功響應HTTP 200/201
alert('批次新增成功');
this.loadTabletPositionsMethod(this.currentSelectArea.areaId); // 刷新數據
} catch (error) {
// 捕獲錯誤響應如500、400等
console.error('批次新增失敗', error);
let msg = '批次新增失敗';
if (error.response && error.response.data && error.response.data.exceptionMessage) {
msg += `${error.response.data.exceptionMessage}`;
}
alert(msg);
}
this.previewPositions = []; // 清空預覽
},
clearPreviewPositionsMethod() {
this.previewPositions = [];
},
openNewPositionDialogMethod() {
this.showNewPositionDialogFlag = true;
this.batchPositionForm.price = this.currentSelectArea.price
},
closeNewPositionDialogMethod() {
this.showNewPositionDialogFlag = false;
this.previewPositions = [];
},
editPositionMethod(position) {
// 彈出編輯表單、打開模態框或跳轉到編輯頁面
this.currentEditPosition = position;
this.editPositionFormVisible = true;
},
async saveEditPositionMethod() {
try {
await axios.post(`${HTTP_HOST}api/ancestraltablet/position/edit`, this.currentEditPosition);
this.$message?.success?.('保存成功') || alert('保存成功');
this.editPositionFormVisible = false;
this.loadTabletPositionsMethod(this.currentSelectArea.areaId);
this.currentEditPosition = null
} catch (error) {
console.error(error);
this.$message?.error?.('保存失敗') || alert('保存失敗');
}
},
async deletePositionMethod(position) {
if (confirm(`確定要刪除【${position.positionName}】嗎?`)) {
try {
await axios.delete(`${HTTP_HOST}api/ancestraltablet/position/delete/${position.positionId}`);
this.$message?.success?.('刪除成功'); // 如果用的是 Element Plus 或其他 UI 框架
this.loadTabletPositionsMethod(this.currentSelectArea.areaId); // 刷新數據
} catch (error) {
console.error('刪除失敗', error);
this.$message?.error?.('刪除失敗,請檢查網路或稍後再試');
}
}
},
//--------------------------------神主牌位置相關函數
async loadStatusList() {
//獲取狀態列表
try {
const response = await axios.get(`${HTTP_HOST}api/ancestraltablet/status/list`);
this.statusList = response.data;
} catch (err) {
console.error('獲取狀態列表失敗', err);
}
}
},
watch: {
},
mounted() {
this.getAreaListMethod();
this.loadStatusList();
}
});
</script>
<style>
.tree, .tree ul {
list-style: none;
margin: 0;
padding-left: 1rem;
}
.toggle-icon {
cursor: pointer;
user-select: none;
width: 1rem;
display: inline-block;
color: #007bff;
}
.region-item-label {
cursor: pointer;
padding: 2px 6px;
border-radius: 4px;
display: inline-block;
}
.region-item-label.selected {
background-color: #eaf4ff;
color: #0d6efd;
font-weight: bold;
}
.grid-container {
display: grid;
grid-template-columns: repeat(10, 120px); /* 6列 */
grid-auto-rows: 100px; /* 行高 */
gap: 10px;
}
/* 可用(綠色) */
.status-available {
background-color: #d4edda;
border-color: #28a745;
}
/* 維護中(黃色) */
.status-maintenance {
background-color: #fff3cd;
border-color: #ffc107;
}
/* 預訂中(藍色) */
.status-reserved {
background-color: #cce5ff;
border-color: #007bff;
}
/* 已使用(灰色) */
.status-used {
background-color: #e2e3e5;
border-color: #6c757d;
}
.grid-item {
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
}
.position-name {
background-color: #f0f0f0;
padding: 4px 8px;
font-weight: bold;
font-size: 14px;
text-align: center;
border-bottom: 1px solid #ddd;
}
.position-content {
flex-grow: 1;
padding: 3px;
font-size: 12px;
color: #666;
}
</style>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletarea_index : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,569 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletposition_index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<nav class="mb-2 ps-3">
<button class="btn btn-secondary me-2" @click="expandAll" type="button">
<i class="mdi mdi-arrow-expand-all"></i> 全部展開
</button>
<button class="btn btn-secondary" @click="collapseAll" type="button">
<i class="mdi mdi-arrow-collapse-all"></i> 全部收起
</button>
</nav>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 col-lg-2">
<div class="card shadow-sm my-2">
<div class="card-header">神主牌區域列表</div>
<div class="card-body">
<ul class="tree">
<li v-for="area in ancestral_tablet_areas" :key="area.AreaId">
<region-item
:item="area"
:selected-id="currentSelectAreaId"
@select-area="selectAreaMethod"
:expand-all="expandAllFlag"
:collapse-all="collapseAllFlag"
@clear-expand-all="expandAllFlag = false"
@clear-collapse-all="collapseAllFlag = false"
/>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-4 col-lg-10" v-if="currentSelectArea">
<div class="card shadow-sm my-2" style="position: sticky; top: 20px; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;">
<div class="card-header" style="display: flex; justify-content: space-between; align-items: center;background-color: #ffc107;">
<div>
{{currentSelectArea.areaName + ' - ' + '神主牌位置'}}
</div>
</div>
<div class="card-body" style="flex: 1 1 auto; min-height: 0; overflow: auto;">
<div class="grid-container">
<div
v-for="pos in positions"
:key="pos.positionCode"
class="grid-item"
:class="'status-' + pos.statusCode"
:style="{ gridRow: pos.rowNo, gridColumn: pos.columnNo }"
>
<div class="position-name">{{ pos.positionName }}</div>
<div class="position-content">
<span v-if="pos.statusCode == 'maintenance'">維護中</span>
<v-btn v-else-if="!pos.ancestralTabletRegistrant" @click="showCreatePWMethod(pos)">登記</v-btn>
<!-- 已預訂 -->
<div v-else>
<div>登記人:{{ pos.ancestralTabletRegistrant?.name }}</div>
<div>登記日期:{{ pos.ancestralTabletRegistrant?.registerDate|timeString('YYYY/MM/DD') }}</div>
<v-btn small color="btn-primary" @click="showEditPWMethod(pos)">
詳細資訊
</v-btn>
</>
</div>
<!-- 已使用 -->
<div v-else-if="pos.statusCode === 'used'">
<div>已使用</div>
<div v-if="pos.usedBy">使用人:{{ pos.usedBy }}</div>
<div v-if="pos.usedDate">使用日期:{{ pos.usedDate|timeString('YYYY/MM/DD') }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 登記資料彈出視窗 -->
<div>
<v-dialog v-model="showCreatePWFlag" max-width="800">
<v-card>
<v-card-title class="headline">登記資料({{'位置: ' + selectedPos?.positionName}})</v-card-title>
<v-card-text>
<!-- 登記人資料 -->
<hr />
<h5>登記人資料</h5>
<label>姓名:
<input class="form-control" type="text" v-model="form.createRegister.name" />
</label><br />
<label>電話:
<input class="form-control" type="text" v-model="form.createRegister.phone" />
</label><br />
<label>住址:
<input class="form-control" type="text" v-model="form.createRegister.address" />
</label><br />
<label>費用:
<input class="form-control" v-model="form.createRegister.price" />
</label><br />
<label>登記時間:
<input class="form-control" type="date" v-model="form.createRegister.registerDate" />
</label><br />
<label>開始時間:
<input class="form-control" type="date" v-model="form.createRegister.startDate" />
</label><br />
<label>結束時間:
<input class="form-control" type="date" v-model="form.createRegister.endDate" />
</label><br />
<label>長期有效:
<input type="checkbox" v-model="form.createRegister.isLongTerm" />
</label><br />
<label>是否啟用:
<input type="checkbox" v-model="form.createRegister.isActive" />
</label><br />
<div class="mt-2 mb-4">
<button
v-if="!form.createRegister.registrantCode"
class="btn btn-primary"
type="button"
@click="saveRegistrantMethod">
保存登記人
</button>
<button
v-else
class="btn btn-primary"
type="button"
@click="updateRegistrantMethod">
送出修改
</button>
</div>
<!-- 牌位資料 -->
<hr />
<h5>牌位資料</h5>
<label>牌位標題:
<input class="form-control" type="text" v-model="form.createPositionRecord.npTitle" />
</label><br />
<label>立牌時間:
<input class="form-control" type="date" v-model="form.createPositionRecord.npStandDate" />
</label><br />
<label>陽上:
<input class="form-control" type="text" v-model="form.createPositionRecord.npYangShang" />
</label><br />
<label>內牌內容:</label>
<textarea
class="form-control"
rows="4"
v-model="form.createPositionRecord.wpContent"
style="width: 100%; box-sizing: border-box;"
></textarea><br />
<div class="mt-2 mb-2">
<button v-if="form.createPositionRecord.recordId == null" class="btn btn-primary" type="button" @click="saveCreatePositionRecordMethod">保存牌位</button>
<button v-else type="button" class="btn btn-primary" @click="updateCreatePositionRecordMethod">
送出修改
</button>
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<button class="btn btn-secondary" type="button" @click="closePWDialogMethod">關閉</button>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
Vue.component('region-item', {
props: ['item', 'selectedId', 'expandAll', 'collapseAll'],
data() {
return {
expanded: false, // 預設全部收起
}
},
watch: {
expandAll(newVal) {
if (newVal) {
this.expanded = true;
// 執行完後發事件通知父組件清除標誌
this.$nextTick(() => this.$emit('clear-expand-all'));
}
},
collapseAll(newVal) {
if (newVal) {
this.expanded = false;
this.$nextTick(() => this.$emit('clear-collapse-all'));
}
}
},
computed: {
hasChildren() {
return this.item.children && this.item.children.length > 0;
},
icon() {
// 無論有無子節點,皆可點擊展開/收起
return this.expanded ? '▼' : '▶';
},
isSelected() {
return this.item.areaId === this.selectedId;
}
},
methods: {
toggle() {
this.expanded = !this.expanded;
},
select() {
this.$emit('select-area', this.item);
},
},
template: `
<div>
<span class="toggle-icon" @click="toggle">{{ icon }}</span>
<span @click="select"
class="region-item-label"
:class="{ 'selected': isSelected }">
{{ item.areaName }}
</span>
<!-- 子區域列表 -->
<ul v-if="hasChildren && expanded">
<li v-for="child in item.children" :key="child.areaId">
<region-item
:item="child"
:selected-id="selectedId"
:expand-all="expandAll"
:collapse-all="collapseAll"
@select-area="$emit('select-area', $event)"
@clear-expand-all="$emit('clear-expand-all')"
@clear-collapse-all="$emit('clear-collapse-all')"
/>
</li>
</ul>
</div>
`
});
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
expandAllFlag: false, // 控制全部展開
collapseAllFlag: false, // 控制全部收起
ancestral_tablet_areas: [], //神主牌區域列表
currentSelectArea: null,
currentSelectAreaId: null,
statusList: [],
//--------------------------------神主牌位置變數
positions: [],
selectedPos: null, //點擊登記的的pos
showCreatePWFlag: false, //控制是否打開登記神主牌位資料彈出視窗
form: {
createRegister: {
//新增登記人form
registrantCode: null, // 登記編號
positionId: null,
name: null,
phone: null,
address: null,
registerDate: null,
price: null,
startDate: null,
endDate: null,
isLongTerm: false,
isActive: true,
},
createPositionRecord: {
//新增牌位登記form
recordId: null, // 自增主鍵,前端一般不用填
registrantCode: null, // 外鍵,關聯登記人編號
npTitle: null,
npStandDate: null,
npYangShang: null,
wpContent: null,
},
},
//--------------------------------神主牌位置變數
}
},
methods: {
selectAreaMethod(area) {
this.currentSelectAreaId = area.areaId;
this.currentSelectArea = area;
this.loadTabletPositionsMethod(area.areaId);
},
getAreaListMethod() {
//獲取區域列表
axios.get(HTTP_HOST + 'api/ancestraltablet/area/getlist')
.then(res => {
this.ancestral_tablet_areas = res.data
})
},
expandAll() {
this.expandAllFlag = true;
this.collapseAllFlag = false;
},
collapseAll() {
this.collapseAllFlag = true;
this.expandAllFlag = false;
},
//--------------------------------神主牌位置相關函數
loadTabletPositionsMethod(areaId) {
axios.get(HTTP_HOST + 'api/ancestraltablet/position/getlist', {
params: {
areaId: areaId
}
})
.then(response => {
this.positions = response.data;
})
.catch(error => {
console.error('失敗:', error);
});
},
showCreatePWMethod(pos) {
//打開新增彈出視窗
this.selectedPos = pos;
this.showCreatePWFlag = true;
this.form.createRegister.positionId = pos.positionId
this.form.createRegister.price = pos.price
},
showEditPWMethod(pos) {
//打開編輯彈出視窗
this.selectedPos = pos;
const registrant = pos.ancestralTabletRegistrant;
if (registrant) {
this.form.createRegister.registrantCode = registrant.registrantCode;
this.form.createRegister.positionId = pos.positionId;
this.form.createRegister.name = registrant.name;
this.form.createRegister.phone = registrant.phone;
this.form.createRegister.address = registrant.address;
this.form.createRegister.registerDate = registrant.registerDate
? registrant.registerDate?.split('T')[0]
: '';
this.form.createRegister.price = registrant.price;
this.form.createRegister.startDate = registrant.startDate ? registrant.startDate?.split('T')[0]
: '';
this.form.createRegister.endDate = registrant.endDate ? registrant.endDate?.split('T')[0]
: '';
this.form.createRegister.isLongTerm = registrant.isLongTerm;
this.form.createRegister.isActive = registrant.isActive;
this.form.createPositionRecord.registrantCode = registrant.registrantCode;
this.showCreatePWFlag = true;
if (registrant.tabletRecord) {
this.form.createPositionRecord.recordId = registrant.tabletRecord.recordId;
this.form.createPositionRecord.registrantCode = registrant.tabletRecord.registrantCode;
this.form.createPositionRecord.npTitle = registrant.tabletRecord.npTitle;
this.form.createPositionRecord.npStandDate = registrant.tabletRecord.npStandDate ? registrant.tabletRecord.npStandDate.split('T')[0]
: '';
this.form.createPositionRecord.npYangShang = registrant.tabletRecord.npYangShang;
this.form.createPositionRecord.wpContent = registrant.tabletRecord.wpContent;
}
}
},
closePWDialogMethod(pos) {
//關閉編輯彈出視窗
this.selectedPos = null;
// 重設登記人欄位
this.form.createRegister = {
registrantCode: null,
positionId: null,
name: null,
phone: null,
address: null,
registerDate: null,
price: null,
startDate: null,
endDate: null,
isLongTerm: false,
isActive: false
};
// 清空牌位記錄
this.form.createPositionRecord = {
recordId: null,
registrantCode: null,
npTitle: null,
npStandDate: null,
npYangShang: null,
wpContent: null
};
this.showCreatePWFlag = false;
},
//--------------------------------神主牌位置相關函數
//--------------------------------登記人相關函數 start
async saveRegistrantMethod() {
try {
const response = await axios.post(HTTP_HOST + 'api/ancestraltablet/registrant/create', this.form.createRegister);
console.log('保存成功', response.data);
// 可選:提示用戶、關閉對話框、刷新數據等
this.$toast?.success('登記人保存成功'); // 取決於你是否使用 toast 插件
this.form.createRegister.registrantCode = response.data.registrantCode
this.form.createPositionRecord.registrantCode = response.data.registrantCode
this.loadTabletPositionsMethod(this.selectedPos.areaId)
alert("修改成功")
} catch (error) {
console.error('保存失敗', error);
this.$toast?.error('登記人保存失敗');
}
},
updateRegistrantMethod() {
axios.post(HTTP_HOST + 'api/ancestraltablet/registrant/update', this.form.createRegister)
.then(response => {
console.log('登記人更新成功:', response.data);
this.$toast?.success?.('登記人更新成功'); // 可選:使用 toast 彈出提示
//this.showCreatePWFlag = false; // 關閉彈出視窗
// 可選:刷新列表等
this.loadTabletPositionsMethod(this.selectedPos.areaId)
alert("修改成功")
})
.catch(error => {
console.error('更新登記人失敗:', error);
this.$toast?.error?.('更新失敗,請檢查數據');
});
},
//--------------------------------登記人相關函數 end
//--------------------------------牌位資料相關函數 Start
saveCreatePositionRecordMethod() {
// 校驗必須欄位
if (!this.form.createPositionRecord.registrantCode) {
alert('請先填寫登記人資料並且送出保存!');
return;
}
axios.post(HTTP_HOST + 'api/ancestraltablet/pw/create', this.form.createPositionRecord)
.then(res => {
if (res.data && res.data.message) {
alert(res.data.message);
} else {
alert('保存成功');
}
// 成功後可以關閉彈出視窗或清空表單
//this.showCreatePWFlag = false;
})
.catch(err => {
console.error('保存失敗:', err);
alert('保存失敗,請檢查伺服器日誌');
});
},
updateCreatePositionRecordMethod() {
// 校驗必須欄位
if (!this.form.createPositionRecord.recordId) {
alert('不存在牌位資料,無法更新');
return;
}
axios.post(HTTP_HOST + 'api/ancestraltablet/pw/update', this.form.createPositionRecord)
.then(res => {
if (res.data && res.data.message) {
alert(res.data.message);
} else {
alert('牌位資料更新成功');
}
// 成功後可以關閉彈出視窗或清空表單
//this.showCreatePWFlag = false;
})
.catch(err => {
alert('更新失敗:', err);
});
},
//--------------------------------牌位資料相關函數 end
async loadStatusList() {
//獲取狀態列表
try {
const response = await axios.get(`${HTTP_HOST}api/ancestraltablet/status/list`);
this.statusList = response.data;
} catch (err) {
console.error('獲取狀態列表失敗', err);
}
}
},
watch: {
},
mounted() {
this.getAreaListMethod();
this.loadStatusList();
}
});
</script>
<style>
.tree, .tree ul {
list-style: none;
margin: 0;
padding-left: 1rem;
}
.toggle-icon {
cursor: pointer;
user-select: none;
width: 1rem;
display: inline-block;
color: #007bff;
}
.region-item-label {
cursor: pointer;
padding: 2px 6px;
border-radius: 4px;
display: inline-block;
}
.region-item-label.selected {
background-color: #eaf4ff;
color: #0d6efd;
font-weight: bold;
}
.grid-container {
display: grid;
grid-template-columns: repeat(10, 150px); /* 6列 */
grid-auto-rows: 150px; /* 行高 */
gap: 10px;
}
/* 可用(綠色) */
.status-available {
background-color: #d4edda;
border-color: #28a745;
}
/* 維護中(黃色) */
.status-maintenance {
background-color: #fff3cd;
border-color: #ffc107;
}
/* 已使用(灰色) */
.status-used {
background-color: #e2e3e5;
border-color: #6c757d;
}
.grid-item {
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
}
.position-name {
background-color: #f0f0f0;
padding: 4px 8px;
font-weight: bold;
font-size: 14px;
text-align: center;
border-bottom: 1px solid #ddd;
}
.position-content {
flex-grow: 1;
padding: 3px;
font-size: 12px;
color: #666;
}
</style>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletposition_index : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,126 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletstatistics_index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container">
<h2 class="title">區域牌位統計</h2>
<table class="stats-table" border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th>區域編號</th>
<th>區域名稱</th>
<th>總位置數</th>
<th>可用位置數</th>
</tr>
</thead>
<tbody>
<tr v-for="area in areas" :key="area.areaId">
<td>{{ area.areaId }}</td>
<td>{{ area.areaName }}</td>
<td>{{ area.totalPositions }}</td>
<td>{{ area.availableCount }}</td>
</tr>
</tbody>
</table>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
areas: []
}
},
methods: {
getAncestralTabletPositionsStatisticsMethod() {
axios.get(HTTP_HOST + 'api/ancestraltablet/statistics/positions/availablepositions')
.then((res) => {
this.areas = res.data
})
.catch((error) => {
})
}
},
mounted() {
this.getAncestralTabletPositionsStatisticsMethod()
}
})
</script>
<style>
.container {
max-width: 800px;
margin: 50px auto;
background: #ffffff;
padding: 25px 30px;
border-radius: 10px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
font-family: "Microsoft YaHei", sans-serif;
}
.title {
text-align: center;
color: #2c3e50;
font-size: 22px;
font-weight: 600;
margin-bottom: 25px;
letter-spacing: 1px;
}
.stats-table {
width: 100%;
border-collapse: collapse;
font-size: 15px;
text-align: center;
color: #333;
}
.stats-table th {
background-color: #1976d2;
color: #fff;
padding: 12px;
font-weight: 600;
border: none;
}
.stats-table td {
padding: 10px;
border: 1px solid #e0e0e0;
}
/* 奇偶行區分 */
.stats-table tbody tr:nth-child(odd) {
background-color: #f8f9fa;
}
/* 滑鼠懸停高亮 */
.stats-table tbody tr:hover {
background-color: #e3f2fd;
transition: 0.3s ease;
}
/* 響應式支持 */
@media (max-width: 600px) {
.container {
padding: 15px;
}
.title {
font-size: 18px;
}
.stats-table th, .stats-table td {
padding: 8px;
font-size: 13px;
}
}
</style>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletstatistics_index : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,15 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="create.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletuselist_create" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
這是新增頁面
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletuselist_create : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,99 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="detail.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletuselist_detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<nav>
<a :href="'edit.aspx?registrantCode=' + registrantCode" class="btn btn-primary">修改資料</a>
</nav>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
{{registrantCode}}
</div>
<div>
<div class="card">
<h2>登記人資訊</h2>
<p><strong>登記編碼:</strong> {{ registrant.registrantCode }}</p>
<p><strong>姓名:</strong> {{ registrant.name }}</p>
<p><strong>電話:</strong> {{ registrant.phone }}</p>
<p><strong>地址:</strong> {{ registrant.address }}</p>
<p><strong>登記日期:</strong> {{ formatDate(registrant.registerDate) }}</p>
<div style="border: 1px solid #007bff; background-color: #f0f8ff; padding: 10px 15px; border-radius: 5px; display: flex; flex-direction: column; gap: 5px; max-width: 400px; margin-bottom: 10px;">
<div>
<label style="font-weight: bold; margin-right: 5px;">已選擇位置:</label>
<span>{{ registrant?.positionName || '未選擇' }}</span>
</div>
</div>
<p><strong>價格:</strong> {{ registrant.price }}</p>
<p><strong>開始日期:</strong> {{ formatDate(registrant.startDate) }}</p>
<p><strong>結束日期:</strong> {{ formatDate(registrant.endDate) }}</p>
<p><strong>是否長期:</strong> {{ registrant.isLongTerm ? '是' : '否' }}</p>
<p><strong>是否啟用:</strong> {{ registrant.isActive ? '是' : '否' }}</p>
</div>
<div class="card" v-if="registrant.tabletRecord">
<h2>牌位資料</h2>
<p><strong>記錄ID:</strong> {{ registrant.tabletRecord.recordId }}</p>
<p><strong>登記編碼:</strong> {{ registrant.tabletRecord.registrantCode }}</p>
<p><strong>牌位標題:</strong> {{ registrant.tabletRecord.npTitle }}</p>
<p><strong>立牌日期:</strong> {{ formatDate(registrant.tabletRecord.npStandDate) }}</p>
<p><strong>陽上:</strong> {{ registrant.tabletRecord.npYangShang }}</p>
<p><strong>內牌內容:</strong> {{ registrant.tabletRecord.wpContent }}</p>
</div>
<div class="card" v-else>
<h2>牌位資料</h2>
<p>暫無牌位資料</p>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
registrantCode: '<%=Request.QueryString["registrantCode"]%>',
registrant: {}
}
},
methods: {
formatDate(dateStr) {
if (!dateStr) return "";
const date = new Date(dateStr);
return date.toLocaleDateString();
},
getRegistrantByCodeMethod(code) {
axios.get(HTTP_HOST + 'api/ancestraltablet/registrant/getbycode', {
params: {
registrantCode: code
}
})
.then((res => {
this.registrant = res.data
}))
.catch((error => {
}))
}
},
mounted() {
this.getRegistrantByCodeMethod(this.registrantCode);
}
})
</script>
<style>
.card {
border: 1px solid #ccc;
padding: 15px;
margin-bottom: 20px;
border-radius: 5px;
background-color: #fafafa;
}
</style>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletuselist_detail : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,419 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="edit.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletuselist_edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<nav>
<a :href="'detail.aspx?registrantCode=' + registrantCode" class="btn btn-secondary">返回詳情</a>
</nav>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<!-- 登記人資料編輯區域 -->
<div class="card">
<h2>編輯登記人資訊</h2>
<label>登記編碼:</label>
<input type="text" v-model="registrant.registrantCode" class="form-control" disabled />
<label>姓名:</label>
<input type="text" v-model="registrant.name" class="form-control" />
<label>電話:</label>
<input type="text" v-model="registrant.phone" class="form-control" />
<label>地址:</label>
<input type="text" v-model="registrant.address" class="form-control" />
<label>登記日期:</label>
<input type="date" v-model="registrant.registerDate" class="form-control" />
<div class="mt-4" style="border: 1px solid #007bff; background-color: #f0f8ff; padding: 10px 15px; border-radius: 5px; display: flex; flex-direction: column; gap: 5px; max-width: 400px; margin-bottom: 10px;">
<div>
<label style="font-weight: bold; margin-right: 5px;">已選擇位置:</label>
<span>{{ registrant?.positionName || '未選擇' }}</span>
</div>
<div v-if="newPositionId">
<label style="font-weight: bold; margin-right: 5px;">新選擇位置:</label>
<span>{{ this.newPositionEntity?.positionName }}</span>
</div>
<button type="button" @click="isShowPositionDialog=true"
style="align-self: flex-start; padding: 5px 10px; background-color: #007bff; color: #fff; border: none; border-radius: 3px; cursor: pointer;"
>
{{registrant?.positionId ? '更換位置' : '選擇位置'}}
</button>
</div>
<label>價格:</label>
<input type="number" v-model="registrant.price" class="form-control" />
<label>開始日期:</label>
<input type="date" v-model="registrant.startDate" class="form-control" />
<label>結束日期:</label>
<input type="date" v-model="registrant.endDate" class="form-control" />
<div class="mt-3" style="display:flex; align-items:center; gap:15px; margin-bottom:10px; font-family:Arial, sans-serif;">
<label style="font-weight:500;">是否長期:</label>
<input type="checkbox" v-model="registrant.isLongTerm" style="width:16px; height:16px; cursor:pointer;" />
<span>是</span>
</div>
<div style="display:flex; align-items:center; gap:15px; margin-bottom:10px; font-family:Arial, sans-serif;">
<label style="font-weight:500;">是否啟用:</label>
<input type="checkbox" v-model="registrant.isActive" style="width:16px; height:16px; cursor:pointer;" />
<span>是</span>
</div>
<button type="button" class="btn btn-primary mt-2" @click="updateRegistrant">保存登記資料</button>
</div>
<!-- 牌位資料區域 -->
<div class="card" v-if="registrant.tabletRecord">
<h2>編輯牌位資料</h2>
<label>記錄ID:</label>
<input type="text" v-model="registrant.tabletRecord.recordId" class="form-control" disabled />
<label>登記編碼 (外鍵):</label>
<input type="text" v-model="registrant.tabletRecord.registrantCode" class="form-control" disabled />
<label>牌位標題:</label>
<input type="text" v-model="registrant.tabletRecord.npTitle" class="form-control" />
<label>立牌日期:</label>
<input type="date" v-model="registrant.tabletRecord.npStandDate" class="form-control" />
<label>陽上:</label>
<input type="text" v-model="registrant.tabletRecord.npYangShang" class="form-control" />
<label>內牌內容:</label>
<textarea v-model="registrant.tabletRecord.wpContent" class="form-control"></textarea>
<button type="button" class="btn btn-success mt-2" @click="updateTabletRecord">保存牌位資料</button>
</div>
<div class="card" v-else>
<h2>牌位資料</h2>
<p>暫無牌位資料</p>
<button type="button" class="btn btn-primary" @click="createTabletRecordForm">新增牌位資料</button>
<div v-if="creatingTablet" class="mt-3">
<label>牌位標題:</label>
<input type="text" v-model="newTablet.npTitle" class="form-control" />
<label>立牌日期:</label>
<input type="date" v-model="newTablet.npStandDate" class="form-control" />
<label>陽上:</label>
<input type="text" v-model="newTablet.npYangShang" class="form-control" />
<label>牌位內容:</label>
<textarea v-model="newTablet.wpContent" class="form-control"></textarea>
<button type="button" class="btn btn-success mt-2" @click="createTabletRecord">保存新增</button>
</div>
</div>
<div>
<v-dialog v-model="isShowPositionDialog" persistent
width="80%"
height="80%">
<v-card style="
width: 80vw;
height: 80vh;
display: flex;
flex-direction: column;
">
<v-card-title
style="display: flex; align-items: center; font-weight: 600; font-size: 18px;"
>
<span>選擇位置:</span>
<select
class="form-control"
style="
flex: 0 0 200px;
padding: 6px 10px;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #fff;
font-size: 14px;
cursor: pointer;
outline: none;
transition: border-color 0.2s;
"
v-model="selectedArea"
@focus="e => e.target.style.borderColor = '#007bff'"
@blur="e => e.target.style.borderColor = '#ccc'"
@change="onAreaChange"
>
<option value="">請選擇區域</option>
<option v-for="area in areaList" :value="area.areaId" :key="area.areaId">{{area.areaName}}</option>
</select>
</v-card-title>
<v-card-text style="flex: 1; overflow: auto;">
<div class="grid-container">
<div
v-for="pos in positionList"
:key="pos.positionId"
class="grid-item"
:class="'status-' + (pos.isCanUse? 'canuse':'cannotuse')"
:style="{ gridRow: pos.rowNo, gridColumn: pos.columnNo }"
>
<div class="position-name">{{ pos.positionName }}</div>
<div class="position-content">
<button type="button" v-if="pos.isCanUse"
class="btn btn-primary"
@click="chooseNewPositionMethod(pos)"
>選擇</button>
<span v-else>已被使用</span>
</div>
</div>
</div>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<div class="me-5">新位置:{{newPositionEntity?.positionName}}</div>
<v-btn color="primary" @click="saveChoosePositionMethod">確定</v-btn>
<v-btn color="grey" @click="cancelChoosePositionMethod">取消</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
registrantCode: '<%=Request.QueryString["registrantCode"]%>',
registrant: {},
creatingTablet: false,
newPositionId: null,
newPositionEntity: null,
newTablet: {
//新增牌位登記form
recordId: null, // 自增主鍵,前端一般不用填
registrantCode: null, // 外鍵,關聯登記人編號
npTitle: null,
npStandDate: null,
npYangShang: null,
wpContent: null,
},
positionList: [],//選擇神位位置的時候獲取的位置列表
isShowPositionDialog: false,
selectedArea: "",
areaList: [],
}
},
methods: {
formatDate(dateStr) {
if (!dateStr) return "";
return dateStr.split('T')[0];
},
getRegistrantByCodeMethod(code) {
axios.get(HTTP_HOST + 'api/ancestraltablet/registrant/getbycode', {
params: {
registrantCode: code
}
})
.then((res => {
const data = res.data;
// 格式化登記日期欄位
if (data.registerDate) data.registerDate = this.formatDate(data.registerDate);
if (data.startDate) data.startDate = this.formatDate(data.startDate);
if (data.endDate) data.endDate = this.formatDate(data.endDate);
// 格式化牌位日期欄位
if (data.tabletRecord && data.tabletRecord.npStandDate)
data.tabletRecord.npStandDate = this.formatDate(data.tabletRecord.npStandDate);
this.registrant = data;
}))
.catch((error => {
}))
},
// 更新登記資料
updateRegistrant() {
const newPositionId = this.newPositionId; // 假設 newPositionId 存在組件裡
// 如果 newPositionId 不為空,則更新 registrant.PositionId
if (newPositionId != null && newPositionId !== '') {
this.registrant.PositionId = newPositionId;
}
axios.post(HTTP_HOST + 'api/ancestraltablet/registrant/update', this.registrant)
.then(() => {
alert('登記資料已保存!')
this.getRegistrantByCodeMethod(this.registrantCode);
this.newPositionId = null;
}
)
.catch(err => {
console.error(err);
alert('保存失敗!');
});
},
// 更新牌位資料
updateTabletRecord() {
axios.post(HTTP_HOST + 'api/ancestraltablet/pw/update', this.registrant.tabletRecord)
.then(() => alert('牌位資料已更新!'))
.catch(err => {
console.error(err);
alert('保存失敗!');
});
},
// 顯示新增牌位表單
createTabletRecordForm() {
this.creatingTablet = true;
},
// 新增牌位資料
createTabletRecord() {
const data = {
...this.newTablet,
registrantCode: this.registrant.registrantCode,
};
axios.post(HTTP_HOST + 'api/ancestraltablet/pw/create', data)
.then(() => {
alert('牌位資料已新增!');
this.creatingTablet = false;
this.getRegistrantByCodeMethod(this.registrantCode);
})
.catch(err => {
console.error(err);
alert('新增失敗!');
});
},
getPositionList(areaId) {
axios.get(HTTP_HOST + 'api/ancestraltablet/position/shortlist',
{
params: {
areaId: areaId
}
})
.then((res) => {
this.positionList = res.data
})
.catch((error) => {
});
},
getArea() {
axios.get(HTTP_HOST + 'api/ancestraltablet/area/getereawithposition')
.then((res) => {
this.areaList = res.data;
})
.catch();
},
onAreaChange() {
//獲取有神位的區域
if (!this.selectedArea) {
this.positionList = [];
return; // 如果沒有選擇,不請求
}
this.getPositionList(this.selectedArea)
},
chooseNewPositionMethod(newPos) {
this.newPositionEntity = newPos
},
closeChoosePositionDialogMethod() {
this.isShowPositionDialog = false;
this.selectedArea = "";
this.positionList = [];
},
cancelChoosePositionMethod() {
this.newPositionEntity = null;
this.closeChoosePositionDialogMethod()
},
saveChoosePositionMethod() {
this.newPositionId = this.newPositionEntity.positionId
this.closeChoosePositionDialogMethod()
},
},
mounted() {
this.getRegistrantByCodeMethod(this.registrantCode);
this.getArea()
}
})
</script>
<style>
.card {
border: 1px solid #ccc;
padding: 15px;
margin-bottom: 20px;
border-radius: 5px;
background-color: #fafafa;
width: 90%;
max-width: 900px;
min-width: 300px; /* 最小寬度防止太窄 */
margin: 0 auto; /* 居中 */
}
.grid-container {
display: grid;
grid-template-columns: repeat(10, 150px); /* 6列 */
grid-auto-rows: 150px; /* 行高 */
gap: 10px;
}
.status-available {
background-color: #d4edda;
border-color: #28a745;
}
/* 維護中(黃色) */
.status-maintenance {
background-color: #fff3cd;
border-color: #ffc107;
}
/* 已使用(灰色) */
.status-used {
background-color: #e2e3e5;
border-color: #6c757d;
}
/* 可以使用(綠色) */
.status-canuse {
background-color: #d4edda; /* 淺綠色背景 */
border-color: #28a745; /* 綠色邊框 */
color: #155724; /* 深綠色文字 */
}
/* 不能使用(紅色) */
.status-cannotuse {
background-color: #f8d7da; /* 淺紅色背景 */
border-color: #dc3545; /* 紅色邊框 */
color: #721c24; /* 深紅文字 */
}
.grid-item {
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
}
.position-name {
background-color: #f0f0f0;
padding: 4px 8px;
font-weight: bold;
font-size: 14px;
text-align: center;
border-bottom: 1px solid #ddd;
}
.position-content {
flex-grow: 1;
padding: 3px;
font-size: 12px;
color: #666;
}
</style>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletuselist_edit : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,192 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_ancestraltablet_ancestraltabletuselist_index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<nav>
<!--
<a :href="'create.aspx'" class="btn btn-primary">
新增使用申請
</a>
-->
<div style="display: inline">
<span>
查詢條件 :
</span>
<input v-model="search.registrantUserName" class="form-control" style="display:inline-block; width: auto;"
placeholder="請輸入登記人"
/>
<button type="button" class="btn btn-primary" @click="handleSearch">搜尋</button>
<button type="button" class="btn btn-primary" @click="clearSearch">清除條件</button>
</div>
</nav>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
神主牌使用記錄
<div>
<v-data-table
:items="registrantList"
:headers="headers"
hide-default-footer>
<template #item.registerdate="{item}">
{{item.registerDate |timeString('YYYY-MM-DD')}}
</template>
<template #item.startdate="{item}">
{{item.startDate |timeString('YYYY-MM-DD')}}
</template>
<template #item.enddate="{item}">
{{item.endDate |timeString('YYYY-MM-DD')}}
</template>
<template #item.createdat="{item}">
{{item.createdAt |timeString('YYYY-MM-DD HH:MM')}}
</template>
<template #item.islongterm="{item}">
{{item.isLongTerm ? "是": "否"}}
</template>
<template #item.isactive="{item}">
{{item.isActive ? "是" : "否"}}
</template>
<template #item.actions="{item}">
<a :href="'detail.aspx?registrantCode=' + item.registrantCode" class="btn btn-primary">詳細資訊</a>
</template>
</v-data-table>
<v-container>
<v-row class="align-baseline" wrap="false">
<v-col cols="12" md="8">
<v-pagination
v-model="options.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ total }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="options.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="options.page = parseInt($event, 10)"
></v-text-field>
</v-col>
<!-- 每頁條數選擇 -->
<v-col cols="12" md="1">
<v-select
v-model="options.itemsPerPage"
:items="[5, 10, 20, 50]"
label="每頁條數"
dense
hide-details
style="width: 100px;"
></v-select>
</v-col>
</v-row>
</v-container>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
new Vue({
el: "#app",
vuetify: new Vuetify(vuetify_options),
data() {
return {
registrantList: [],
headers: [
{ text: '登記編號', value: 'registrantCode' },
{ text: '姓名', value: 'name' },
{ text: '電話', value: 'phone' },
{ text: '住址', value: 'address' },
{ text: '登記日期', value: 'registerdate' },
{ text: '費用', value: 'price' },
{ text: '牌位編號', value: 'positionId' },
{ text: '開始時間', value: 'startdate' },
{ text: '結束時間', value: 'enddate' },
{ text: '是否長期', value: 'islongterm' },
{ text: '是否有效', value: 'isactive' },
{ text: '創建時間', value: 'createdat' },
{ text: '', value: 'actions' },
],
options: {
page: 1, // 當前頁
itemsPerPage: 10, // 每頁條數
sortBy: [],
sortDesc: []
},
search: {
registrantUserName: null,
},
total: 0,
loading: false,
}
},
methods: {
getRegistrantListMethod() {
axios.get(HTTP_HOST + 'api/ancestraltablet/registrant/getlist')
.then((res) => {
this.registrantList = res.data;
}).catch((error) => {
alert("載入失敗")
})
},
getRegistrantListByPageMethod() {
if (this.loading) return;
this.loading = true;
axios.post(HTTP_HOST + 'api/ancestraltablet/registrant/getlistbypage', {
page: this.options.page,
pageSize: this.options.itemsPerPage,
searchName: this.search.registrantUserName
})
.then((res) => {
this.registrantList = res.data.data;
this.total = res.data.total;
}).catch((err) => {
console.log(err);
}).finally(() => {
this.loading = false;
});
},
resetTableOptions() {
this.options = {
page: 1,
itemsPerPage: 10,
sortBy: [],
sortDesc: []
};
},
clearSearch() {
this.search.registrantUserName = null;
this.resetTableOptions();
},
handleSearch() {
this.resetTableOptions();
}
},
watch: {
options: {
handler() {
this.getRegistrantListByPageMethod();
},
deep: true,
}
},
mounted() {
this.getRegistrantListByPageMethod()
},
computed: {
pageCount() {
return Math.ceil(this.total / this.options.itemsPerPage)
},
}
})
</script>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_ancestraltablet_ancestraltabletuselist_index : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -30,7 +30,7 @@ public partial class admin_bed_kind_reg : MyWeb.config
{
_this_id = ValString(Request["num"]);
int _num = Val(Request["num"]);
var prod = _db.bed_kind.AsEnumerable().Where(q => q.num == _num).FirstOrDefault();
var prod = _db.bed_kind.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
@@ -250,7 +250,7 @@ public partial class admin_bed_kind_reg : MyWeb.config
try
{
var prod = _db.bed_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.bed_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -293,7 +293,7 @@ public partial class admin_bed_kind_reg : MyWeb.config
{
int num = Val(Request["num"]);
del_product(num);
var prod = _db.bed_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.bed_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.bed_kind.Remove(prod);
@@ -310,7 +310,7 @@ public partial class admin_bed_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.bed_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.bed_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -327,14 +327,14 @@ public partial class admin_bed_kind_reg : MyWeb.config
public void del_product(int num)
{
//床位資料
var prod = _db.bed_kind_detail.AsEnumerable().Where(q => q.bed_kind_id == num).ToList();
var prod = _db.bed_kind_detail.Where(q => q.bed_kind_id == num).ToList();
if (prod.Count > 0)
{
//清空分類
foreach (var item in prod)
{
//掛單資料
var prod2 = _db.bed_order_detail.AsEnumerable().Where(q => q.bed_kind_detail_id == item.num).ToList();
var prod2 = _db.bed_order_detail.Where(q => q.bed_kind_detail_id == item.num).ToList();
if (prod2.Count > 0)
{
//清空分類
@@ -349,7 +349,7 @@ public partial class admin_bed_kind_reg : MyWeb.config
}
//掛單資料
var prod3 = _db.bed_order_detail.AsEnumerable().Where(q => q.bed_kind1 == num || q.bed_kind2 == num).ToList();
var prod3 = _db.bed_order_detail.Where(q => q.bed_kind1 == num || q.bed_kind2 == num).ToList();
if (prod3.Count > 0)
{
//清空分類

View File

@@ -42,7 +42,7 @@ public partial class admin_follower_index : MyWeb.config
//國籍
s_country.Items.Clear();
s_country.Items.Add(new ListItem("請選擇", ""));
var qry =_db.countries.AsEnumerable().OrderBy(x => x.range).ThenBy(x => x.name_en).ToList();
var qry =_db.countries.OrderBy(x => x.range).ThenBy(x => x.name_en).ToList();
if (qry.Count > 0)
{
foreach(var x in qry)
@@ -222,7 +222,7 @@ public partial class admin_follower_index : MyWeb.config
{
//查詢要匯出的資料
var qry = _db.followers.AsEnumerable();
var qry = _db.followers.AsQueryable();
//紀錄匯出條件
if (!isStrNull(s_f_number.Value))

View File

@@ -25,7 +25,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
//紀錄匯出條件
string _query = "";
var qry = _db.followers.AsEnumerable();
var qry = _db.followers.AsQueryable();
if (!string.IsNullOrEmpty(Request["f_number"]))
{
qry = qry.Where(o => o.f_number.Contains(Request["f_number"].Trim()));
@@ -57,7 +57,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
if (!string.IsNullOrEmpty(Request["country"]))
{
qry = qry.Where(o => o.country == Request["country"]);
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"" )+ "\n";
_query += "國家:" + (_db.countries.Where(x => x.ID == Request["country"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"" )+ "\n";
}
if (!string.IsNullOrEmpty(Request["country2"]))
{
@@ -70,7 +70,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
qry = qry.Where(o => o.country != "158");
}
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country2"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
_query += "國家:" + (_db.countries.Where(x => x.ID == Request["country2"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
}
//管理報表

View File

@@ -1084,7 +1084,7 @@
newCheckoutDate: this.guadanguest.xuzhu.newCheckoutDate
};
axios.post('/api/guadanorderguest/xuzhu', payload)
axios.post(HTTP_HOST + 'api/guadanorderguest/xuzhu', payload)
.then((res) => {
this.$refs.messageModal.open({
title: '续住成功',
@@ -1113,13 +1113,13 @@
},
//续住相關方法--------------------end
getActivityList() {
axios.post('/api/activity/GetList?page=1&pageSize=500', { kind: 0, subject: "" })
axios.post(HTTP_HOST + 'api/activity/GetList?page=1&pageSize=500', { kind: 0, subject: "" })
.then((res) => {
this.activityList = res.data.list
})
},
getavailablebedcountbytime(startTime, endTime) {
axios.get('/api/region/bed/getavailablebedcountbytime', {
axios.get(HTTP_HOST + 'api/region/bed/getavailablebedcountbytime', {
params: {
startTime: startTime,
endTime: endTime
@@ -1141,7 +1141,7 @@
},
confirmAllocation() {
//確認分配
axios.post('/api/region/bed/confirmallocation', {
axios.post(HTTP_HOST + 'api/region/bed/confirmallocation', {
preBeds: this.automaticBedAllocation.preBeds,
orderNo: this.guadanorder.order_form.orderNo,
checkInAt: this.guadanorder.order_form.startdate,
@@ -1169,7 +1169,7 @@
CheckInAt: this.guadanorder.order_form.startdate || new Date(), // 入住時間
CheckOutAt: this.guadanorder.order_form.enddate || null // 退房時間,可為空
};
axios.post('/api/region/bed/preallocation', payload)
axios.post(HTTP_HOST + 'api/region/bed/preallocation', payload)
.then(res => {
this.automaticBedAllocation.preBeds = res.data.data;
})
@@ -1217,7 +1217,7 @@
getMultiSelectFollowers: function () {
var fm = this.automaticBedAllocation.followerModal;
var self = this;
axios.post('/api/lianyou/getfollowers', null, {
axios.post(HTTP_HOST + 'api/lianyou/getfollowers', null, {
params: {
page: fm.page,
pageSize: fm.pageSize,
@@ -1288,7 +1288,7 @@
},
getGuadanOrderById() {
if (this.guadanorder.order_form.uuid) {
axios.get('/api/guadan/getorderbyid', {
axios.get(HTTP_HOST + 'api/guadan/getorderbyid', {
params: {
orderId: this.guadanorder.order_form.uuid
}
@@ -1307,7 +1307,7 @@
},
getGuadanOrderGuestByOrderNo() {
if (this.guadanorder.order_form.orderNo) {
axios.get('/api/guadanorderguest/getbyorderno', {
axios.get(HTTP_HOST + 'api/guadanorderguest/getbyorderno', {
params: {
orderNo: this.guadanorder.order_form.orderNo
}
@@ -1317,7 +1317,7 @@
}
},
getGuadanOrderStatus() {
axios.get('/api/region/guadan/status/list')
axios.get(HTTP_HOST + 'api/region/guadan/status/list')
.then((res) => {
this.guadanorder.status_items = res.data;
})
@@ -1326,7 +1326,7 @@
if (!this.validateOrderForm()) {
return;
}
axios.post('/api/guadan/create', this.guadanorder.order_form)
axios.post(HTTP_HOST + 'api/guadan/create', this.guadanorder.order_form)
.then((res => {
this.$refs.messageModal.open({
title: '掛單提示',
@@ -1350,7 +1350,7 @@
if (!this.validateOrderForm()) {
return;
}
axios.post('/api/guadan/update', this.guadanorder.order_form)
axios.post(HTTP_HOST + 'api/guadan/update', this.guadanorder.order_form)
.then((res => {
this.$refs.messageModal.open({
title: '掛單提示',
@@ -1393,7 +1393,7 @@
message: `確定要將 ${guest.follower.u_name || ''} 退房嗎?`,
onConfirm: async () => {
try {
const response = await axios.post(`/api/guadanorderguest/checkout`, null, {
const response = await axios.post(HTTP_HOST + HTTP_HOST + `api/guadanorderguest/checkout`, null, {
params: { uuid: guest.uuid }
});
@@ -1495,13 +1495,13 @@
},
createCheckInGuest() {
return axios.post('/api/guadanorderguest/create', this.checkInGuest.inGuest)
return axios.post(HTTP_HOST + 'api/guadanorderguest/create', this.checkInGuest.inGuest)
},
checkBedAndFollower() {
this.checkInGuest.inGuest
},
getGuadanGuestStatus() {
axios.get('/api/region/bed/status/list')
axios.get(HTTP_HOST + 'api/region/bed/status/list')
.then((res) => {
this.checkInGuest.status = res.data.filter(item => item.category === 4 && item.code != '404');
})
@@ -1524,7 +1524,7 @@
pageSize: itemsPerPage,
searchName: this.selectGuestModal.searchNameOrPhone
};
axios.post('/api/lianyou/getfollowers', null, {
axios.post(HTTP_HOST + 'api/lianyou/getfollowers', null, {
params: params
}).then((res) => {
this.selectGuestModal.items = res.data.data
@@ -1559,7 +1559,7 @@
},
async saveEditGuadanOrderGuest() {
try {
const res = await axios.post('/api/guadanorderguest/update', this.checkInGuest.inGuest)
const res = await axios.post(HTTP_HOST + 'api/guadanorderguest/update', this.checkInGuest.inGuest)
this.getGuadanOrderGuestByOrderNo();
this.closeCheckInModal();
} catch (error) {
@@ -1570,7 +1570,7 @@
},
deleteGuadanOrderGuest(guest) {
axios.post('/api/guadanorderguest/cancel?uuid=' + guest.uuid)
axios.post(HTTP_HOST + 'api/guadanorderguest/cancel?uuid=' + guest.uuid)
.then((res) => {
this.guadanguest.items = this.guadanguest.items.filter(i => i.uuid != guest.uuid);
}).catch((error) => {
@@ -1594,7 +1594,7 @@
onConfirm: async () => {
try {
// 發送請求到後端 API
const response = await axios.post(`/api/guadanorderguest/checkin`, null, {
const response = await axios.post(HTTP_HOST + `api/guadanorderguest/checkin`, null, {
params: { uuid: guest.uuid }
});
@@ -1628,7 +1628,7 @@
//床位選擇相關方法----------------start
async loadRegions() {
const res = await axios.post('/api/region/getRegionList');
const res = await axios.post(HTTP_HOST + 'api/region/getRegionList');
this.region_modal.regions = res.data;
},
async loadRegionsByGender() {
@@ -1643,7 +1643,7 @@
}
}
const res = await axios.post('/api/region/getRegionListByGender', {
const res = await axios.post(HTTP_HOST + 'api/region/getRegionListByGender', {
IsMale: isMale
});
@@ -1660,7 +1660,7 @@
this.region_modal.selectedType = 'room';
this.region_modal.currentSelectBeds = room.beds;
if (this.checkInGuest.inGuest.checkInAt && this.checkInGuest.inGuest.checkOutAt) {
axios.get('/api/region/room/bed/list', {
axios.get(HTTP_HOST + 'api/region/room/bed/list', {
params: {
roomUuid: room.uuid,
StartTime: this.checkInGuest.inGuest.checkInAt,
@@ -1678,7 +1678,7 @@
},
GetRegionRoomBedListByRoomId(roomUuid) {
if (this.checkInGuest.inGuest.checkInAt && this.checkInGuest.inGuest.checkOutAt) {
axios.get('/api/region/bed/list')
axios.get(HTTP_HOST + 'api/region/bed/list')
.then((res) => {
})

View File

@@ -74,7 +74,7 @@
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ }} 筆, 頁數:
共 {{ total }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
@@ -162,6 +162,7 @@ button:hover {
{ text: '入住日期', value: 'checkindate' },
{ text: '退房日期', value: 'checkoutdate' },
{ text: '房間號', value: 'roomName' },
{ text: '狀態', value: 'statusName'},
],
guests: [], // 表格數據
@@ -197,7 +198,7 @@ button:hover {
}
if (this.loading) return;
this.loading = true;
axios.post('/api/guadan/guest/query/list',
axios.post(HTTP_HOST + 'api/guadan/guest/query/list',
{
page: this.options.page,
pageSize: this.options.itemsPerPage,

View File

@@ -7,6 +7,8 @@
<a href="create.aspx" class="btn btn-primary" >新建掛單</a>
</nav>
<div class="d-flex align-items-center gap-3">
<label class="mb-0">掛單單號</label>
<input class="form-control w-auto" style="width:150px;" v-model="search.guaDanOrderNo" />
<label class="mb-0">掛單登記人</label>
<input class="form-control w-auto" style="width:150px;" v-model="search.guadanUser" />
@@ -28,10 +30,21 @@
<v-data-table
:items="items"
:headers="headers"
:item-class="item => item.is_timeout ? 'row-timeout' : ''"
hide-default-footer>
<template #item.actions="{item}">
<a :href="'create.aspx?orderId='+item.guaDanOrderNo" class="btn btn-secondary">編輯</a>
<a class="btn btn-outline-danger" @click="deleteGuadanOrder(item)">取消</a>
<a :href="'view.aspx?orderId='+item.guaDanOrderNo" class="btn btn-primary">查看</a>
<a :href="'create.aspx?orderId='+item.guaDanOrderNo" class="btn btn-secondary"
:style="item.guadan_status?.code == 502 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''">編輯</a>
<a
class="btn btn-outline-danger"
href="#"
:style="item.guest_count != 0 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''"
@click.prevent="item.guest_count != 0 ? null : deleteGuadanOrder(item)"
>
取消
</a>
</template>
<template #item.room="{item}">
{{item.room.name}}
@@ -39,8 +52,8 @@
<template #item.bed="{item}">
{{item.bed.name}}
</template>
<template #item.status="{item}">
{{item.status}}
<template #item.guadan_status="{item}">
{{item.guadan_status?.name}}
</template>
<template #item.start_date="{item}">
{{item.start_date | timeString('YYYY/MM/DD')}}
@@ -54,42 +67,45 @@
<template #item.activity="{item}">
{{item.activity?.subject}}
</template>
<template #item.is_timeout="{item}">
{{item.is_timeout ? '已超時': '否'}}
</template>
</v-data-table>
<v-container>
<v-row class="align-baseline" wrap="false">
<v-col cols="12" md="8">
<v-pagination
v-model="options.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ total }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="options.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="options.page = parseInt($event, 10)"
></v-text-field>
</v-col>
<!-- 每页条数选择 -->
<v-col cols="12" md="1">
<v-select
v-model="options.itemsPerPage"
:items="[5, 10, 20, 50]"
label="每頁條數"
dense
hide-details
style="width: 100px;"
></v-select>
</v-col>
</v-row>
</v-container>
<v-row class="align-baseline" wrap="false">
<v-col cols="12" md="8">
<v-pagination
v-model="options.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ total }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="options.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="options.page = parseInt($event, 10)"
></v-text-field>
</v-col>
<!-- 每頁條數選擇 -->
<v-col cols="12" md="1">
<v-select
v-model="options.itemsPerPage"
:items="[5, 10, 20, 50]"
label="每頁條數"
dense
hide-details
style="width: 100px;"
></v-select>
</v-col>
</v-row>
</v-container>
</div>
<!-- 更新修改確認彈出視窗 -->
<message-modal ref="messageModal"></message-modal>
@@ -97,7 +113,6 @@
<confirm-modal ref="confirmModal"></confirm-modal>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
<div>test</div>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
@@ -111,13 +126,15 @@
return {
items: [],
headers: [
{ text: '登记挂单莲友', value: 'bookerName' },
{ text: '登記掛單蓮友', value: 'bookerName' },
{ text: '掛單單號', value: 'guaDanOrderNo'},
{ text: '起始日期', value: 'start_date', align: 'center' },
{ text: '結束日期', value: 'end_date', align: 'center' },
{ text: '掛單人數', value: 'guest_count' },
{ text: '狀態', value: 'statusName', align: 'center' },
{ text: '狀態', value: 'guadan_status', align: 'center' },
{ text: '建立時間', value: 'created_at', align: 'center' },
{ text: '關聯活動', value: 'activity', align: 'center' },
{ text: '超時退房', value: 'is_timeout', align: 'center' },
{ text: '操作', value: 'actions', align: 'center' }
],
options: {
@@ -130,6 +147,7 @@
startDate: null,
endDate: null,
guadanUser: null,
guaDanOrderNo: null,
},
total: 0,
loading: false,
@@ -146,6 +164,12 @@
};
},
handleSearch() {
let orderNo = this.search.guaDanOrderNo;
if (orderNo) {
orderNo = orderNo.replace(/\s+/g, '');
this.search.guaDanOrderNo = orderNo;
}
const val = this.search.guadanUser;
// 驗證是否包含空格
@@ -169,14 +193,16 @@
this.search.startDate = null;
this.search.endDate = null;
this.search.guadanUser = null;
this.search.guaDanOrderNo = null;
this.resetTableOptions();
},
getGuadanOrder() {
if (this.loading) return;
axios.post('/api/guadan/list', {
axios.post(HTTP_HOST + 'api/guadan/list', {
startDate: this.search.startDate,
endDate: this.search.endDate,
guadanUser: this.search.guadanUser,
guaDanOrderNo: this.search.guaDanOrderNo,
page: this.options.page,
pageSize: this.options.itemsPerPage
})
@@ -193,7 +219,7 @@
this.$refs.confirmModal.open({
message: '確認取消掛單?',
onConfirm: () => {
axios.post('/api/guadan/cancel', null, {
axios.post(HTTP_HOST + 'api/guadan/cancel', null, {
params: {
uuid: order.uuid
}
@@ -230,5 +256,10 @@
}
});
</script>
</asp:Content>
<style>
.row-timeout {
background-color: #ffdddd !important;
}
</style>
</asp:Content>

View File

@@ -326,7 +326,7 @@
saveAs(new Blob([wbout], { type: "application/octet-stream" }), "statistics.xlsx");
},
GetGuadanStatistics() {
axios.get('/api/guadanStatistics/GetGuadanStatistics')
axios.get(HTTP_HOST + 'api/guadanStatistics/GetGuadanStatistics')
.then((res) => {
this.guadanStatistics = res.data.guadanStatistics;
})

539
web/admin/guadan/view.aspx Normal file
View File

@@ -0,0 +1,539 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="view.aspx.cs" Inherits="admin_guadan_view" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<fieldset class="border rounded p-4 mb-5 shadow-sm bg-white">
<legend class="w-auto px-3 font-weight-bold text-primary">掛單資訊</legend>
<!-- 🟢 區塊一:掛單資訊 -->
<div class="border rounded p-3 bg-white shadow-sm" style="pointer-events: none; user-select: none; background: #1c5bd9; padding: 5px;">
<h6 class="text-secondary mb-3">📝掛單資訊</h6>
<div class="form-group row mt-3">
<label class="col-sm-2 col-form-label text-center">掛單單號(不可修改)</label>
<div class="col-sm-4 text-left">
<input class="form-control" v-model="guadanorder.order_form.orderNo" readonly />
</div>
<label class="col-sm-2 col-form-label text-center">關聯活動</label>
<div class="col-sm-4">
<select class="form-control" v-model="guadanorder.order_form.activityNum" >
<option :value="null">未關聯</option>
<option v-for="activity in activityList" :key="activity.num" :value="activity.num">
{{activity.subject}}
</option>
</select>
</div>
</div>
<div class="form-group row mt-3">
<label class="col-sm-2 col-form-label text-center">
預約開始日期
</label>
<div class="col-sm-4 text-left">
<input class="form-control" type="date" v-model="guadanorder.order_form.startdate" />
</div>
<label class="col-sm-2 col-form-label text-center">
預約結束日期
</label>
<div class="col-sm-4">
<input class="form-control" type="date" v-model="guadanorder.order_form.enddate" />
</div>
</div>
<div class="form-group row mt-3">
<label class="col-sm-2 col-form-label text-center">預定人姓名</label>
<div class="col-sm-4">
<input class="form-control" v-model="guadanorder.order_form.bookerName" />
</div>
<label class="col-sm-2 col-form-label text-center">預定人電話</label>
<div class="col-sm-4">
<input class="form-control" v-model="guadanorder.order_form.bookerPhone" />
</div>
</div>
<div class="form-group row mt-3">
<label class="col-sm-2 col-form-label text-center">備註</label>
<div class="col-sm-4">
<textarea class="form-control" v-model="guadanorder.order_form.note"></textarea>
</div>
</div>
</div>
</fieldset>
<fieldset class="border rounded p-4 mb-5 shadow-sm bg-white">
<!-- 表格標題緊貼表格上方,居中 -->
<div class="d-flex align-items-center mb-3">
<!-- 中間標題flex-grow撐開居中 -->
<div class="flex-grow-1 text-center">
<h5 class="text-primary fw-bold mb-0">
<i class="bi bi-people-fill me-2"></i>掛單蓮友
</h5>
</div>
</div>
<!-- v-data-table 表格 -->
<v-data-table :headers="guadanguest.headers" :items="guadanguest.items" class="elevation-1 rounded" dense>
<template #item.checkinat="{item}">
{{item.checkinat |timeString('YYYY-MM-DD')}}
</template>
<template #item.checkoutat="{item}">
{{item.checkoutat |timeString('YYYY-MM-DD')}}
</template>
<template v-slot:item.name="{item}">
{{item.follower?.u_name}}
</template>
<template v-slot:item.sex="{item}">
{{item.follower?.sex}}
</template>
</v-data-table>
</fieldset>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<style>
/* 調整 fieldset 風格 */
fieldset {
border: 1px solid #dee2e6;
border-radius: 0.5rem;
background-color: #fff;
}
legend {
font-size: 1.25rem;
font-weight: 700;
color: #0d6efd;
width: auto;
padding: 0 0.75rem;
}
.form-group label {
font-weight: 600;
}
/* 按鈕置右 */
.text-right {
text-align: right;
}
/* 選擇床位相關 */
.tree,
.tree ul {
list-style: none;
margin: 0;
padding-left: 1rem;
}
.toggle-icon {
cursor: pointer;
user-select: none;
width: 1rem;
display: inline-block;
color: #007bff;
}
.region-item-label {
cursor: pointer;
padding: 2px 6px;
border-radius: 4px;
display: inline-block;
}
.region-item-label.selected {
background-color: #eaf4ff;
color: #0d6efd;
font-weight: bold;
}
.selected-room {
background-color: #cce5ff;
font-weight: bold;
}
/* 選擇床位相關 */
</style>
<script>
Vue.component('region-item', {
props: ['item', 'selectedId', 'selectedType', 'expandAll', 'collapseAll'],
data() {
return {
expanded: false, // 預設全部收起
selectedRoomId: null,
}
},
watch: {
expandAll(newVal) {
if (newVal) {
this.expanded = true;
// 執行完後發事件通知父組件清除標誌
this.$nextTick(() => this.$emit('clear-expand-all'));
}
},
collapseAll(newVal) {
if (newVal) {
this.expanded = false;
this.$nextTick(() => this.$emit('clear-collapse-all'));
}
}
},
computed: {
hasChildren() {
return this.item.children && this.item.children.length > 0;
},
icon() {
// 無論有無子節點,皆可點擊展開/收起
return this.expanded ? '▼' : '▶';
},
isSelected() {
return this.selectedType === 'region' && this.item.uuid === this.selectedId;
}
},
methods: {
toggle() {
this.expanded = !this.expanded;
},
select() {
this.$emit('select-region', this.item);
},
selectRoom(room) {
this.selectedRoomId = room.uuid;
this.$emit('select-room', room); // 可以發事件給父組件
}
},
template: `
<div>
<span class="toggle-icon" @click="toggle">{{ icon }}</span>
<span @click="select"
class="region-item-label"
:class="{ 'selected': isSelected }">
{{ item.rooms.length>0 ? (item.name + '(' + item.rooms.length + '房)'): item.name }}
</span>
<!-- 子區域列表 -->
<ul v-if="hasChildren && expanded">
<li v-for="(child, index) in item.children" :key="child.id + '-' + index">
<region-item
:item="child"
:selected-id="selectedId"
:selected-type="selectedType"
:expand-all="expandAll"
:collapse-all="collapseAll"
@select-region="$emit('select-region', $event)"
@select-room="$emit('select-room', $event)"
@clear-expand-all="$emit('clear-expand-all')"
@clear-collapse-all="$emit('clear-collapse-all')"
/>
</li>
</ul>
<!-- 客房列表:無論是否有子區域,只要展開就顯示 -->
<ul v-if="item.rooms && item.rooms.length > 0 && expanded">
<li v-for="room in item.rooms" :key="'room-' + room.uuid"
@click="selectRoom(room)"
:class="{ 'selected-room': selectedType === 'room' && selectedId === room.uuid }"
style="cursor: pointer;">
<span class="bed-label">
🛏️ {{ room.name + ' (' + room.beds.length + '床) ' + (room.gender === true ? '(男客房)' : room.gender === false ? '(女客房)' : '') }}
</span>
</li>
</ul>
</div>
`
});
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
activityList: [],
availableBedCount: {
male: 0,
female: 0,
},
guadanorder: {
order_form: {
uuid: '<%= Request.QueryString["orderid"] %>' || null,
startdate: null,
enddate: null,
note: null,
orderNo: null,
bookerName: null,
bookerPhone: null,
bookerFollowerNum: null,
activityNum: null,
},
status_items: [],
},
guadanguest: {
guest: {
uuid: null, // int?
fullName: '', // string
gender: null, // int?
phone: '', // string
idNumber: '', // string
birthday: null, // Date (建議用 date picker)
email: '', // string
address: '', // string
emergencyContact: '', // string
emergencyPhone: '', // string
status: null, // int?
notes: '' // string
},
headers: [{
text: '姓名',
value: 'name'
},
{
text: '性別',
value: 'sex'
},
{
text: '掛單開始時間',
value: 'checkinat'
},
{
text: '掛單結束時間',
value: 'checkoutat'
},
{
text: '床位',
value: 'bedName'
},
{
text: '狀態',
value: 'statusName'
},
{
text: '備註',
value: 'note'
},
{
text: '',
value: 'actions'
},
],
items: [],
showCreateGuestModal: false,
xuzhu: {
showXuzhuGuestModal: false,
currentCheckoutDate: null,
newCheckoutDate: null,
guestUuid: null,
guestBedUuid: null,
}
},
checkInGuest: {
showSelectGuadanOrderGuest: false,
isEdit: false,
inGuest: {
uuid: null,
orderNo: null,
followerNum: null,
roomUuid: null,
bedUuid: null,
checkInAt: null,
checkOutAt: null,
statuscode: null,
},
status: [],
},
region_modal: {
regions: [],
currentSelectRegion: null,
currentSelectRoom: null,
currentSelectBeds: [],
currentSelectBed: null,
showSelectBedModal: false,
selectedId: null, // 被選中項目ID
selectedType: null, // 'region' 或 'room'
expandAllFlag: false, // 控制全部展開
collapseAllFlag: false, // 控制全部收起
currentSelectBedText: null,
},
selectGuestModal: {
showSelectGuestModal: false,
currentSelectedGuest: null,
fullNameText: null,
headers: [{
text: '姓名',
value: 'u_name'
},
{
text: '電話',
value: 'phone'
},
{
text: '',
value: 'actions'
},
],
items: [],
options: { //v-data-table參數
page: 1,
itemsPerPage: 10,
sortBy: [],
sortDesc: [],
multiSort: false,
},
page: 1,
pageSize: 10,
count: 0,
footer: {
showFirstLastPage: true,
disableItemsPerPage: true,
itemsPerPageAllText: '',
itemsPerPageText: '',
},
searchNameOrPhone: null,
},
automaticBedAllocation: {
showModal: false,
// 蓮友選擇彈出視窗
followerModal: {
showModal: false,
followerList: [],
selectedFollowerItems: [],
page: 1,
pageSize: 10,
totalCount: 0,
searchNameOrPhone: '',
headers: [
{ text: '姓名', value: 'u_name' },
{ text: '電話', value: 'phone' },
{ text: '操作', value: 'actions', sortable: false }
],
},
// 已選擇的待分配列表
selectedFollowers: [],
preBeds: [],
headers: [
{ text: '姓名', value: 'u_name' },
{ text: '電話', value: 'phone' },
{ text: '性別', value: 'sex' },
{ text: '預分配床位', value: 'prebed' },
{ text: '', value: 'actions' }
],
},
}
},
methods: {
getActivityList() {
axios.post(HTTP_HOST + 'api/activity/GetList?page=1&pageSize=500', { kind: 0, subject: "" })
.then((res) => {
this.activityList = res.data.list
})
},
//掛單相關方法-------------------start
validateOrderForm() {
if (!this.guadanorder.order_form.startdate) {
this.$refs.messageModal.open({
message: '請輸入必填資訊'
});
return false;
}
if (!this.guadanorder.order_form.enddate) {
this.$refs.messageModal.open({
message: '請輸入必填資訊'
});
return false;
}
if (!this.guadanorder.order_form.bookerName) {
this.$refs.messageModal.open({
message: '請輸入姓名'
});
return false;
}
if (this.guadanorder.order_form.bookerPhone && !/^\d{2,4}-?\d{3,4}-?\d{3,4}$/.test(this.guadanorder.order_form.bookerPhone)) {
this.$refs.messageModal.open({
message: '電話輸入有誤'
});
return false;
}
return true;
},
getGuadanOrderById() {
if (this.guadanorder.order_form.uuid) {
axios.get(HTTP_HOST + 'api/guadan/getorderbyid', {
params: {
orderId: this.guadanorder.order_form.uuid
}
}).then((res) => {
this.guadanorder.order_form.note = res.data.notes;
this.guadanorder.order_form.startdate = res.data.startDate;
this.guadanorder.order_form.enddate = res.data.endDate;
this.guadanorder.order_form.orderNo = res.data.guaDanOrderNo;
this.guadanorder.order_form.bookerName = res.data.bookerName;
this.guadanorder.order_form.bookerPhone = res.data.bookerPhone;
this.guadanorder.order_form.bookerFollowerNum = res.data.bookerFollowerNum;
this.guadanorder.order_form.uuid = res.data.uuid;
this.guadanorder.order_form.activityNum = res.data.activityNum;
})
}
},
getGuadanOrderGuestByOrderNo() {
if (this.guadanorder.order_form.orderNo) {
axios.get(HTTP_HOST + 'api/guadanorderguest/getbyorderno', {
params: {
orderNo: this.guadanorder.order_form.orderNo
}
}).then((res => {
this.guadanguest.items = res.data;
}))
}
},
//掛單相關方法-------------------end
},
watch: {
'guadanorder.order_form.orderNo'(newValue, oldValue) {
if (newValue) {
this.getGuadanOrderGuestByOrderNo();
}
},
'selectGuestModal.options': {
handler() {
this.getGuadanFollowers();
},
deep: true
},
// 分頁變化時自動刷新
'automaticBedAllocation.followerModal.page': function () {
this.getMultiSelectFollowers();
},
'automaticBedAllocation.followerModal.pageSize': function () {
this.getMultiSelectFollowers();
}
},
mounted() {
if (this.guadanorder.order_form.uuid) {
this.getGuadanOrderById();
this.getGuadanOrderGuestByOrderNo();
}
this.getActivityList();
},
computed: {
pageCount() {
return Math.ceil(this.selectGuestModal.count / this.selectGuestModal.pageSize)
},
pageCount2: function () {
var fm = this.automaticBedAllocation.followerModal;
return Math.ceil(fm.totalCount / fm.pageSize) || 1;
}
},
});
</script>
</asp:Content>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_guadan_view : MyWeb.config
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -21,7 +21,7 @@ public partial class admin_news_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.news_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
var prod = _db.news_kind.Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
if (prod != null)
{
@@ -214,7 +214,7 @@ public partial class admin_news_kind_reg : MyWeb.config
try
{
var prod = _db.news_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.news_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -255,7 +255,7 @@ public partial class admin_news_kind_reg : MyWeb.config
del_product(num);
var prod = _db.news_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.news_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.news_kind.Remove(prod);
@@ -273,7 +273,7 @@ public partial class admin_news_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.news_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.news_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -292,7 +292,7 @@ public partial class admin_news_kind_reg : MyWeb.config
public void del_product(int num) //刪除訊息
{
//EF Model 資料庫拉關聯 , 故刪除分類前,一定要先刪除訊息,否則關聯會出錯
var prod = _db.news.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.news.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////刪除檔案

View File

@@ -27,7 +27,7 @@ public partial class admin_news_news_reg : MyWeb.config
else
{
int _num = Val(Request["num"]);
var qry = _db.news.AsEnumerable();
var qry = _db.news.AsQueryable();
//var prod = _db.news.Where(q => q.num == _num).ToList();
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
@@ -410,13 +410,11 @@ public partial class admin_news_news_reg : MyWeb.config
#region
protected void initNewsFiles(int num = 0)
{
var qry = _db.news_files.AsEnumerable();
var qry = _db.news_files.AsQueryable();
if (num > 0)
qry = qry.Where(q => q.news_id == num).ToList();
else
qry = qry.ToList();
qry = qry.Where(q => q.news_id == num);
fileRepeater.DataSource = qry;
fileRepeater.DataSource = qry.ToList();
fileRepeater.DataBind();
}
protected void fileRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)

View File

@@ -47,7 +47,7 @@ public partial class admin_order_index : MyWeb.config
//國籍
s_country.Items.Clear();
s_country.Items.Add(new ListItem("請選擇", ""));
var qry = _db.countries.AsEnumerable().OrderBy(x => x.range).ThenBy(x => x.name_en).ToList();
var qry = _db.countries.OrderBy(x => x.range).ThenBy(x => x.name_en).ToList();
if (qry.Count > 0)
{
foreach (var x in qry)
@@ -128,8 +128,8 @@ public partial class admin_order_index : MyWeb.config
sd.AppendChild(tr);
//查詢要匯出的資料
var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(s_actItemTxt.Value.Trim())).Select(f => f.num.ToString());//品項
var qry = _db.pro_order.AsEnumerable();
var aIDt = _db.actItems.Where(f => f.subject.Contains(s_actItemTxt.Value.Trim())).Select(f => f.num.ToString());//品項
var qry = _db.pro_order.AsQueryable();
if (!isStrNull(s_order_no.Value))
qry = qry.Where(o => o.order_no.Contains(s_order_no.Value.Trim()));
@@ -154,7 +154,7 @@ public partial class admin_order_index : MyWeb.config
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
var bedDt = _db.bed_order_detail.AsEnumerable();//掛單明細
var bedDt = _db.bed_order_detail.AsQueryable();//掛單明細
//left join 使用 GroupJoin
@@ -167,7 +167,7 @@ public partial class admin_order_index : MyWeb.config
order_no = o.order_no,
up_time = o.up_time,
keyin1 = o.keyin1,
f_num = o.follower?.u_name, //姓名/名稱
f_num = o.follower != null ? o.follower.u_name : "", //姓名/名稱
phone = o.phone,
activity_num = o.activity_num.HasValue ? o.activity.subject : "",
address = o.address,

View File

@@ -25,7 +25,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
//紀錄匯出條件
string _query = "";
var qry = _db.pro_order.AsEnumerable();
var qry = _db.pro_order.AsQueryable();
if (!string.IsNullOrEmpty(Request["order_no"]))
{
qry = qry.Where(o => o.order_no.Contains(Request["order_no"].Trim()));
@@ -73,21 +73,21 @@ public partial class admin_follower_print_ : System.Web.UI.Page
}
if (!string.IsNullOrEmpty(Request["country"]))
{
qry = qry.Where(o => o.f_num != null && o.follower?.country == Request["country"]);
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country"]).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
qry = qry.Where(o => o.f_num != null && o.follower.country == Request["country"]);
_query += "國家:" + (_db.countries.Where(x => x.ID == Request["country"]).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
}
if (!string.IsNullOrEmpty(Request["country2"]))
{
if (Request["country2"] == "1")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country == "158");
qry = qry.Where(o => o.f_num != null && o.follower.country == "158");
}
else if (Request["country2"] == "2")
{
qry = qry.Where(o => o.f_num != null && o.follower?.country != "158");
qry = qry.Where(o => o.f_num != null && o.follower.country != "158");
}
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country2"]).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
_query += "國家:" + (_db.countries.Where(x => x.ID == Request["country2"]).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
}
if (!string.IsNullOrEmpty(Request["hasPrice"]))
{
@@ -175,7 +175,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
}
if (!string.IsNullOrEmpty(Request["year"]))
qry = qry.OrderByDescending(o => o.activity?.startDate_solar).ThenByDescending(o=>o.up_time).ThenByDescending(o=>o.order_no);
qry = qry.OrderByDescending(o => o.activity != null ? o.activity.startDate_solar : null).ThenByDescending(o=>o.up_time).ThenByDescending(o=>o.order_no);
else
qry = qry.OrderByDescending(o => o.order_no);
@@ -186,8 +186,9 @@ public partial class admin_follower_print_ : System.Web.UI.Page
tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
//明細
_detail = _db.pro_order_detail.AsEnumerable().Where(x => prod.Select(o => o.order_no).Contains( x.order_no)).ToList();
_bedDt = _db.bed_order_detail.AsEnumerable().Where(x => prod.Select(o => o.order_no).Contains( x.bed_order.order_no)).ToList();
var orderNos = prod.Select(o => o.order_no).ToList();
_detail = _db.pro_order_detail.Where(x => orderNos.Contains(x.order_no)).ToList();
_bedDt = _db.bed_order_detail.Where(x => orderNos.Contains(x.bed_order.order_no)).ToList();
Repeater1.DataSource = prod;
Repeater1.DataBind();

View File

@@ -1159,7 +1159,7 @@
this.tab1.activities = [];
try {
const response = await axios.get('/api/pivot01/activity_stats', {
const response = await axios.get(HTTP_HOST + 'api/pivot01/activity_stats', {
params: { year: this.tab1.year }
});
@@ -1197,7 +1197,7 @@
this.loading = true;
try {
const response = await axios.get('/api/pivot01/registration_details', {
const response = await axios.get(HTTP_HOST + 'api/pivot01/registration_details', {
params: {
activityNum: activity.num
}

View File

@@ -891,7 +891,7 @@
}
// 呼叫 API
const response = await axios.get('/api/pivot/activity_stats', {
const response = await axios.get(HTTP_HOST + 'api/pivot/activity_stats', {
params: {
startDate: startDate,
endDate: endDate
@@ -923,7 +923,7 @@
try {
// 一次性查詢完整報名明細(不分頁)
const response = await axios.get('/api/pivot/registration_details', {
const response = await axios.get(HTTP_HOST + 'api/pivot/registration_details', {
params: {
activityNum: activity.activity_num,
pageSize: 9999 // 取得全部資料

View File

@@ -21,7 +21,7 @@ public partial class admin_project_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.project_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.project_kind.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -210,7 +210,7 @@ public partial class admin_project_kind_reg : MyWeb.config
try
{
var prod = _db.project_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.project_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -248,7 +248,7 @@ public partial class admin_project_kind_reg : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.project_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.project_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.project_kind.Remove(prod);
@@ -265,7 +265,7 @@ public partial class admin_project_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.project_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.project_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -283,7 +283,7 @@ public partial class admin_project_kind_reg : MyWeb.config
public void del_product(int num)
{
var prod = _db.projects.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.projects.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////查詢結果全部刪除

View File

@@ -39,9 +39,8 @@ public partial class admin_project_list : MyWeb.config
//品項
s_actItem_num.Items.Clear();
s_actItem_num.Items.Add(new ListItem("請選擇", ""));
var qry = _db.actItems.AsEnumerable();
qry = qry.Where(o => (int?)o.category==(int)Model.activity.category.Patronize);//贊助項目
qry = qry.OrderByDescending(o => o.num).ToList();
var qry = _db.actItems.Where(o => (int?)o.category==(int)Model.activity.category.Patronize);//贊助項目
qry = qry.OrderByDescending(o => o.num);
if(qry.Count() > 0)
foreach(var qq in qry)
s_actItem_num.Items.Add(new ListItem(qq.subject, qq.num.ToString()));
@@ -99,7 +98,7 @@ public partial class admin_project_list : MyWeb.config
sd.AppendChild(tr);
//查詢要匯出的資料
var qry = _db.pro_order_detail.AsEnumerable();
var qry = _db.pro_order_detail.AsQueryable();
qry = qry.Where(o => (int?)o.actItem.category == (int)Model.activity.category.Patronize);
if (!string.IsNullOrEmpty(s_f_num.Value))
@@ -111,7 +110,8 @@ public partial class admin_project_list : MyWeb.config
var list = qry.ToList();
if (list.Count > 0)
{
var projectDt = _db.projects.AsEnumerable(); //專案
// TODO: REVIEW - projects 資料量可能成長,若超過數千筆需優化為按需查詢
var projectDt = _db.projects.ToList(); //專案
foreach (var item in list)
{
var projects = from s in projectDt

View File

@@ -58,7 +58,7 @@
},
methods: {
getStatusList() {
axios.get('/api/region/bed/status/list')
axios.get(HTTP_HOST + 'api/region/bed/status/list')
.then((res) => {
this.items = res.data
this.loading = false;
@@ -73,7 +73,7 @@
})
},
deleteStatus(item) {
axios.post('/api/region/bed/status/delete', null, {
axios.post(HTTP_HOST + 'api/region/bed/status/delete', null, {
params: { code: item.code }
})
.then(() => {

View File

@@ -316,7 +316,7 @@
unoccupied: this.filter.unoccupied,
gender: this.filter.Gender,
};
axios.post('/api/region/list', payload)
axios.post(HTTP_HOST + 'api/region/list', payload)
.then((res) => {
this.regions = res.data.regions;
this.summary = res.data.summary; // 保存後端統計
@@ -347,7 +347,7 @@
console.log(this.filter.Gender);
},
getRegionWithRoom() {
axios.get('/api/region/regionwithroom')
axios.get(HTTP_HOST + 'api/region/regionwithroom')
.then((res) => {
this.filter.areas = res.data;
})

View File

@@ -578,7 +578,7 @@
this.expandAllFlag = false;
},
async loadRegions() {
const res = await axios.post('/api/region/getRegionList');
const res = await axios.post(HTTP_HOST + 'api/region/getRegionList');
this.regions = res.data;
this.flatRegions = this.flatten(res.data);
if (this.currentSelectRoom) {
@@ -586,7 +586,7 @@
}
},
loadRegionType() {
axios.post('/api/region/getRegionType')
axios.post(HTTP_HOST + 'api/region/getRegionType')
.then(res => {
this.regionTypes = res.data
});
@@ -799,7 +799,7 @@
});
},
confirmDeleteBed(bed) {
axios.post('/api/region/bed/delete', null, {
axios.post(HTTP_HOST + 'api/region/bed/delete', null, {
params: { uuid: bed.uuid }
}) // 假設後端吃的是 id
.then(() => {
@@ -840,7 +840,7 @@
async saveEditBed() {
try {
await axios.post('/api/region/bed/update', this.room_bed.newBedForm);
await axios.post(HTTP_HOST + 'api/region/bed/update', this.room_bed.newBedForm);
this.room_bed.showBedModal = false;
const updated = this.room_bed.newBedForm;
@@ -882,7 +882,7 @@
},
getBedStatus() {
//獲取床位狀態
axios.get('/api/region/bed/status/list')
axios.get(HTTP_HOST + 'api/region/bed/status/list')
.then((res) => {
this.room_bed.bed_status = res.data;
})
@@ -907,7 +907,7 @@
});
return;
}
axios.post('/api/region/room/create', this.room.room_form)
axios.post(HTTP_HOST + 'api/region/room/create', this.room.room_form)
.then((res) => {
this.room.showCreateRoomDialog = false;
this.currentSelectRegion.rooms.push(res.data);
@@ -924,7 +924,7 @@
},
async roomUpdate() {
try {
const res = await axios.post('/api/region/room/update', this.room.room_form);
const res = await axios.post(HTTP_HOST + 'api/region/room/update', this.room.room_form);
this.$refs.messageModal.open({
message: '客房資料更新成功'
});
@@ -950,7 +950,7 @@
},
roomDelete() {
axios.post('/api/region/room/delete', { uuid: this.currentSelectRoom.uuid })
axios.post(HTTP_HOST + 'api/region/room/delete', { uuid: this.currentSelectRoom.uuid })
.then((res) => {
const region = this.findRegionById(this.regions, this.currentSelectRoom.regionUuid)//當前room所在的region
if (region) {

View File

@@ -61,7 +61,7 @@
},
methods: {
getRegionTypeList() {
axios.post('/api/regiontype/getreiontypelist')
axios.post(HTTP_HOST + 'api/regiontype/getreiontypelist')
.then((res) => {
this.items = res.data;
})
@@ -71,7 +71,7 @@
'title': '刪除提示',
'message': `確定要刪除 ${item.name} ?`,
onConfirm: () => {
axios.post('/api/regiontype/delete',null, {
axios.post(HTTP_HOST + 'api/regiontype/delete',null, {
params: { uuid: item.uuid }
})
.then(() => {

View File

@@ -21,7 +21,7 @@ public partial class admin_stock_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.stock_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.stock_kind.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -210,7 +210,7 @@ public partial class admin_stock_kind_reg : MyWeb.config
try
{
var prod = _db.stock_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.stock_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -248,7 +248,7 @@ public partial class admin_stock_kind_reg : MyWeb.config
int num = Val(Request["num"]);
del_product(num);
var prod = _db.stock_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.stock_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.stock_kind.Remove(prod);
@@ -266,7 +266,7 @@ public partial class admin_stock_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.stock_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.stock_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -285,7 +285,7 @@ public partial class admin_stock_kind_reg : MyWeb.config
public void del_product(int num)
{
var prod = _db.stocks.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.stocks.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////查詢結果全部刪除

View File

@@ -22,7 +22,7 @@ public partial class admin_stock_reason_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.stock_reason.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.stock_reason.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -221,7 +221,7 @@ public partial class admin_stock_reason_reg : MyWeb.config
try
{
var prod = _db.stock_reason.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.stock_reason.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -257,7 +257,7 @@ public partial class admin_stock_reason_reg : MyWeb.config
{
int num = Val(Request["num"]);
var prod = _db.stock_reason.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.stock_reason.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.stock_reason.Remove(prod);
@@ -275,7 +275,7 @@ public partial class admin_stock_reason_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.stock_reason.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.stock_reason.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)

View File

@@ -21,7 +21,7 @@ public partial class admin_supplier_kind_reg : MyWeb.config
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.supplier_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
var prod = _db.supplier_kind.Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
if (prod != null)
{
@@ -210,7 +210,7 @@ public partial class admin_supplier_kind_reg : MyWeb.config
try
{
var prod = _db.supplier_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
var prod = _db.supplier_kind.Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
@@ -248,7 +248,7 @@ public partial class admin_supplier_kind_reg : MyWeb.config
int num = Val(Request["num"]);
//del_product(num);
var prod = _db.supplier_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
var prod = _db.supplier_kind.Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.supplier_kind.Remove(prod);
@@ -266,7 +266,7 @@ public partial class admin_supplier_kind_reg : MyWeb.config
public void Del_Ohter_Items(int d_num)
{
var prod = _db.supplier_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
var prod = _db.supplier_kind.Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
@@ -285,7 +285,7 @@ public partial class admin_supplier_kind_reg : MyWeb.config
public void del_product(int num)
{
var prod = _db.suppliers.AsEnumerable().Where(q => q.kind == num).ToList();
var prod = _db.suppliers.Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////查詢結果全部刪除

View File

@@ -0,0 +1,28 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_asenumerable_check.aspx.cs" Inherits="test_asenumerable_check" %>
<!DOCTYPE html>
<html>
<head>
<title>AsEnumerable 修改檢測工具</title>
<style>
body { font-family: 'Consolas', monospace; margin: 20px; background: #1e1e1e; color: #d4d4d4; }
.success { color: #4ec9b0; font-weight: bold; }
.error { color: #f48771; font-weight: bold; }
.warning { color: #dcdcaa; font-weight: bold; }
.sql-box { background: #252526; padding: 15px; margin: 10px 0; border-left: 4px solid #007acc; }
.test-item { margin: 20px 0; padding: 15px; background: #2d2d30; border-radius: 4px; }
h2 { color: #4ec9b0; }
h3 { color: #dcdcaa; margin-top: 20px; }
pre { white-space: pre-wrap; word-wrap: break-word; }
</style>
</head>
<body>
<h1>🔍 AsEnumerable 修改檢測報告</h1>
<form runat="server">
<asp:Button ID="btnRunTest" runat="server" Text="▶ 執行檢測" OnClick="btnRunTest_Click"
style="padding: 10px 20px; font-size: 16px; cursor: pointer;" />
<hr />
<asp:Literal ID="litResult" runat="server"></asp:Literal>
</form>
</body>
</html>

View File

@@ -0,0 +1,346 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Linq;
using Model;
public partial class test_asenumerable_check : System.Web.UI.Page
{
private StringBuilder output = new StringBuilder();
private int passCount = 0;
private int failCount = 0;
private int warnCount = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
litResult.Text = "<p style='color:#888;'>點擊「執行檢測」開始測試修改結果</p>";
}
}
protected void btnRunTest_Click(object sender, EventArgs e)
{
output.Clear();
passCount = 0;
failCount = 0;
warnCount = 0;
output.AppendLine("<div style='margin-bottom: 20px;'>");
output.AppendLine($"<p>測試時間: {DateTime.Now:yyyy-MM-dd HH:mm:ss}</p>");
output.AppendLine("</div>");
// 執行所有測試
TestAccountingKind();
TestActivityKind();
TestFollowers();
TestMembers();
TestOrders();
// 顯示總結
output.AppendLine("<hr />");
output.AppendLine("<h2>📊 測試總結</h2>");
output.AppendLine($"<p class='success'>✅ 通過: {passCount} 項</p>");
output.AppendLine($"<p class='error'>❌ 失敗: {failCount} 項</p>");
output.AppendLine($"<p class='warning'>⚠️ 警告: {warnCount} 項</p>");
if (failCount == 0)
{
output.AppendLine("<h3 class='success'>🎉 所有測試通過!修改成功!</h3>");
}
else
{
output.AppendLine("<h3 class='error'>⚠️ 發現問題,請檢查失敗的項目</h3>");
}
litResult.Text = output.ToString();
}
private void TestAccountingKind()
{
output.AppendLine("<h3>測試 1: accounting_kind 查詢優化</h3>");
using (var db = new ezEntities())
{
var sqlLog = new StringBuilder();
db.Database.Log = sql => sqlLog.AppendLine(sql);
try
{
// 測試 1.1: 單筆查詢
sqlLog.Clear();
var sw = Stopwatch.StartNew();
var result = db.accounting_kind.Where(q => q.num == 1).FirstOrDefault();
sw.Stop();
CheckQuery("單筆查詢 (Where + FirstOrDefault)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveSelectAll: false,
maxTime: 50);
// 測試 1.2: 檢查子資料 (應該用 Any)
sqlLog.Clear();
sw.Restart();
var hasChildren = db.accounting_kind.Any(q => q.root == 1);
sw.Stop();
CheckQuery("檢查子資料存在 (Any)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveExists: true,
maxTime: 30);
// 測試 1.3: 取得子資料清單
sqlLog.Clear();
sw.Restart();
var children = db.accounting_kind.Where(q => q.root == 1).ToList();
sw.Stop();
CheckQuery("取得子資料清單 (Where + ToList)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveSelectAll: false,
maxTime: 100);
}
catch (Exception ex)
{
LogError($"accounting_kind 測試失敗: {ex.Message}");
}
}
}
private void TestActivityKind()
{
output.AppendLine("<h3>測試 2: activity_kind 查詢優化</h3>");
using (var db = new ezEntities())
{
var sqlLog = new StringBuilder();
db.Database.Log = sql => sqlLog.AppendLine(sql);
try
{
// 單筆查詢 + 排序
sqlLog.Clear();
var sw = Stopwatch.StartNew();
var result = db.activity_kind
.Where(q => q.num == 1)
.OrderBy(q => q.kind)
.FirstOrDefault();
sw.Stop();
CheckQuery("單筆查詢 + 排序 (Where + OrderBy + FirstOrDefault)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveOrderBy: true,
maxTime: 50);
}
catch (Exception ex)
{
LogError($"activity_kind 測試失敗: {ex.Message}");
}
}
}
private void TestFollowers()
{
output.AppendLine("<h3>測試 3: followers 查詢優化</h3>");
using (var db = new ezEntities())
{
var sqlLog = new StringBuilder();
db.Database.Log = sql => sqlLog.AppendLine(sql);
try
{
// 測試字串查詢 (Contains)
sqlLog.Clear();
var sw = Stopwatch.StartNew();
var result = db.followers
.Where(q => q.f_number.Contains("A"))
.Take(10)
.ToList();
sw.Stop();
CheckQuery("字串查詢 (Contains)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveLike: true,
maxTime: 100);
}
catch (Exception ex)
{
LogError($"followers 測試失敗: {ex.Message}");
}
}
}
private void TestMembers()
{
output.AppendLine("<h3>測試 4: members 查詢優化</h3>");
using (var db = new ezEntities())
{
var sqlLog = new StringBuilder();
db.Database.Log = sql => sqlLog.AppendLine(sql);
try
{
// 測試批次查詢
var ids = new[] { 1, 2, 3 };
sqlLog.Clear();
var sw = Stopwatch.StartNew();
var result = db.members.Where(q => ids.Contains(q.num)).ToList();
sw.Stop();
CheckQuery("批次 ID 查詢 (Contains)",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveIn: true,
maxTime: 100);
}
catch (Exception ex)
{
LogError($"members 測試失敗: {ex.Message}");
}
}
}
private void TestOrders()
{
output.AppendLine("<h3>測試 5: pro_order_detail 聚合查詢</h3>");
using (var db = new ezEntities())
{
var sqlLog = new StringBuilder();
db.Database.Log = sql => sqlLog.AppendLine(sql);
try
{
// 測試 Count
sqlLog.Clear();
var sw = Stopwatch.StartNew();
var count = db.pro_order_detail.Count(q => q.num > 0);
sw.Stop();
CheckQuery("Count 查詢",
sqlLog.ToString(),
sw.ElapsedMilliseconds,
shouldHaveWhere: true,
shouldHaveCount: true,
maxTime: 50);
}
catch (Exception ex)
{
LogError($"pro_order_detail 測試失敗: {ex.Message}");
}
}
}
private void CheckQuery(string testName, string sql, long milliseconds,
bool shouldHaveWhere = false,
bool shouldHaveSelectAll = false,
bool shouldHaveExists = false,
bool shouldHaveOrderBy = false,
bool shouldHaveLike = false,
bool shouldHaveIn = false,
bool shouldHaveCount = false,
long maxTime = 100)
{
output.AppendLine("<div class='test-item'>");
output.AppendLine($"<h4>🔸 {testName}</h4>");
output.AppendLine($"<p>執行時間: {milliseconds}ms</p>");
bool passed = true;
var issues = new StringBuilder();
// 檢查是否有 WHERE 條件
if (shouldHaveWhere && !sql.Contains("WHERE"))
{
issues.AppendLine("❌ 缺少 WHERE 條件(可能載入整表)<br/>");
passed = false;
}
// 檢查是否有不當的 SELECT *
if (!shouldHaveSelectAll && sql.Contains("SELECT") && !sql.Contains("WHERE") && !sql.Contains("TOP"))
{
issues.AppendLine("❌ SELECT 沒有條件限制(載入整表)<br/>");
passed = false;
}
// 檢查是否使用 EXISTSAny 應該產生)
if (shouldHaveExists && !sql.Contains("EXISTS"))
{
issues.AppendLine("⚠️ 建議使用 EXISTS 而非載入資料<br/>");
warnCount++;
}
// 檢查是否有 ORDER BY
if (shouldHaveOrderBy && !sql.Contains("ORDER BY"))
{
issues.AppendLine("❌ 缺少 ORDER BY排序應該在資料庫執行<br/>");
passed = false;
}
// 檢查是否有 LIKEContains 應該產生)
if (shouldHaveLike && !sql.Contains("LIKE"))
{
issues.AppendLine("❌ 字串查詢未轉為 LIKE<br/>");
passed = false;
}
// 檢查是否有 IN批次查詢應該產生
if (shouldHaveIn && !sql.Contains("IN"))
{
issues.AppendLine("❌ 批次查詢未轉為 IN<br/>");
passed = false;
}
// 檢查是否有 COUNT聚合函數應該在資料庫執行
if (shouldHaveCount && !sql.Contains("COUNT"))
{
issues.AppendLine("❌ COUNT 未在資料庫執行<br/>");
passed = false;
}
// 檢查執行時間
if (milliseconds > maxTime)
{
issues.AppendLine($"⚠️ 執行時間較長 (>{maxTime}ms),可能仍有優化空間<br/>");
warnCount++;
}
if (passed)
{
output.AppendLine("<p class='success'>✅ 測試通過</p>");
passCount++;
}
else
{
output.AppendLine("<p class='error'>❌ 測試失敗</p>");
output.AppendLine($"<div style='color:#f48771;'>{issues}</div>");
failCount++;
}
// 顯示 SQL
output.AppendLine("<div class='sql-box'>");
output.AppendLine("<strong>產生的 SQL:</strong><br/>");
output.AppendLine($"<pre>{System.Web.HttpUtility.HtmlEncode(sql)}</pre>");
output.AppendLine("</div>");
output.AppendLine("</div>");
}
private void LogError(string message)
{
output.AppendLine($"<p class='error'>❌ {message}</p>");
failCount++;
}
}