0.1 #4

Open
minom wants to merge 9 commits from 0.1 into dapper
37 changed files with 3826 additions and 717 deletions
+1
View File
@@ -94,6 +94,7 @@ namespace Model
public virtual DbSet<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; } public virtual DbSet<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; }
public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; } public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; }
public virtual DbSet<GuaDanOrderGuest> GuaDanOrderGuest { get; set; } public virtual DbSet<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
public virtual DbSet<auto_enroll> auto_enroll { get; set; }
public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount) public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount)
{ {
+1 -1
View File
@@ -1,4 +1,4 @@
// 已啟用模型 'D:\17168ERP\web\App_Code\Model\Model.edmx' 的 T4 程式碼產生。 // 已啟用模型 'E:\17168ERP\web\App_Code\Model\Model.edmx' 的 T4 程式碼產生。
// 若要啟用舊版程式碼產生,請將 [程式碼產生策略] 設計工具屬性的值 // 若要啟用舊版程式碼產生,請將 [程式碼產生策略] 設計工具屬性的值
//變更為 [舊版 ObjectContext]。當模型在設計工具中開啟時,這個屬性便可 //變更為 [舊版 ObjectContext]。當模型在設計工具中開啟時,這個屬性便可
//以在 [屬性] 視窗中使用。 //以在 [屬性] 視窗中使用。
+36
View File
@@ -184,6 +184,7 @@ namespace Model
public string partno { get; set; } public string partno { get; set; }
public string print_init { get; set; } public string print_init { get; set; }
public string is_reconcile { get; set; } public string is_reconcile { get; set; }
public Nullable<int> sort_order { get; set; }
public virtual actItem_kind actItem_kind { get; set; } public virtual actItem_kind actItem_kind { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
@@ -405,6 +406,10 @@ namespace Model
public Nullable<float> price { get; set; } public Nullable<float> price { get; set; }
public Nullable<int> qty { get; set; } public Nullable<int> qty { get; set; }
public Nullable<System.DateTime> reg_time { get; set; } public Nullable<System.DateTime> reg_time { get; set; }
public Nullable<bool> has_yang_limit { get; set; }
public Nullable<bool> has_chao_limit { get; set; }
public Nullable<int> yang_limit_count { get; set; }
public Nullable<int> chao_limit_count { get; set; }
public virtual actItem actItem { get; set; } public virtual actItem actItem { get; set; }
public virtual activity activity { get; set; } public virtual activity activity { get; set; }
@@ -676,6 +681,31 @@ namespace Model
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
public partial class auto_enroll
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public auto_enroll()
{
this.pro_order = new HashSet<pro_order>();
}
public int num { get; set; }
public int f_num { get; set; }
public System.DateTime start_date { get; set; }
public System.DateTime end_date { get; set; }
public string receipt_title { get; set; }
public string receipt_address { get; set; }
public virtual follower followers { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order> pro_order { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class bed_kind public partial class bed_kind
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
@@ -802,6 +832,7 @@ namespace Model
public string smtp_def { get; set; } public string smtp_def { get; set; }
public string use_sender { get; set; } public string use_sender { get; set; }
public string bed_order_no { get; set; } public string bed_order_no { get; set; }
public string last_auto_order_no { get; set; }
} }
} }
namespace Model namespace Model
@@ -903,6 +934,7 @@ namespace Model
this.transfer_register1 = new HashSet<transfer_register>(); this.transfer_register1 = new HashSet<transfer_register>();
this.GuaDanOrder = new HashSet<GuaDanOrder>(); this.GuaDanOrder = new HashSet<GuaDanOrder>();
this.GuaDanOrderGuest = new HashSet<GuaDanOrderGuest>(); this.GuaDanOrderGuest = new HashSet<GuaDanOrderGuest>();
this.auto_enroll = new HashSet<auto_enroll>();
} }
public int num { get; set; } public int num { get; set; }
@@ -967,6 +999,8 @@ namespace Model
public virtual ICollection<GuaDanOrder> GuaDanOrder { get; set; } public virtual ICollection<GuaDanOrder> GuaDanOrder { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; } public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<auto_enroll> auto_enroll { get; set; }
} }
} }
namespace Model namespace Model
@@ -1340,6 +1374,7 @@ namespace Model
public Nullable<int> introducer { get; set; } public Nullable<int> introducer { get; set; }
public Nullable<bool> send_receipt { get; set; } public Nullable<bool> send_receipt { get; set; }
public string receipt_title { get; set; } public string receipt_title { get; set; }
public Nullable<int> au_num { get; set; }
public virtual activity activity { get; set; } public virtual activity activity { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
@@ -1348,6 +1383,7 @@ namespace Model
public virtual follower follower1 { get; set; } public virtual follower follower1 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order_detail> pro_order_detail { get; set; } public virtual ICollection<pro_order_detail> pro_order_detail { get; set; }
public virtual auto_enroll auto_enroll { get; set; }
} }
} }
namespace Model namespace Model
+150 -29
View File
@@ -91,6 +91,7 @@
<Property Name="customize_data" Type="nvarchar(max)" /> <Property Name="customize_data" Type="nvarchar(max)" />
<Property Name="reg_time" Type="datetime" /> <Property Name="reg_time" Type="datetime" />
<Property Name="is_reconcile" Type="nvarchar" MaxLength="1" /> <Property Name="is_reconcile" Type="nvarchar" MaxLength="1" />
<Property Name="sort_order" Type="int" />
</EntityType> </EntityType>
<EntityType Name="actItem_files"> <EntityType Name="actItem_files">
<Key> <Key>
@@ -189,6 +190,10 @@
<Property Name="price" Type="real" /> <Property Name="price" Type="real" />
<Property Name="qty" Type="int" /> <Property Name="qty" Type="int" />
<Property Name="reg_time" Type="datetime" /> <Property Name="reg_time" Type="datetime" />
<Property Name="has_yang_limit" Type="bit" />
<Property Name="has_chao_limit" Type="bit" />
<Property Name="yang_limit_count" Type="int" />
<Property Name="chao_limit_count" Type="int" />
</EntityType> </EntityType>
<EntityType Name="activity_spares"> <EntityType Name="activity_spares">
<Key> <Key>
@@ -329,6 +334,17 @@
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" /> <Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="title" Type="nvarchar" MaxLength="10" /> <Property Name="title" Type="nvarchar" MaxLength="10" />
</EntityType> </EntityType>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="f_num" Type="int" Nullable="false" />
<Property Name="start_date" Type="date" Nullable="false" />
<Property Name="end_date" Type="date" Nullable="false" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="receipt_address" Type="nchar" MaxLength="200" />
</EntityType>
<EntityType Name="bed_kind"> <EntityType Name="bed_kind">
<Key> <Key>
<PropertyRef Name="num" /> <PropertyRef Name="num" />
@@ -400,6 +416,7 @@
<Property Name="smtp_def" Type="nvarchar" MaxLength="1" /> <Property Name="smtp_def" Type="nvarchar" MaxLength="1" />
<Property Name="use_sender" Type="nvarchar" MaxLength="1" /> <Property Name="use_sender" Type="nvarchar" MaxLength="1" />
<Property Name="bed_order_no" Type="nvarchar" MaxLength="20" /> <Property Name="bed_order_no" Type="nvarchar" MaxLength="20" />
<Property Name="last_auto_order_no" Type="nvarchar" MaxLength="20" />
</EntityType> </EntityType>
<EntityType Name="country"> <EntityType Name="country">
<Key> <Key>
@@ -480,7 +497,7 @@
<Property Name="country" Type="nvarchar" MaxLength="5" /> <Property Name="country" Type="nvarchar" MaxLength="5" />
<Property Name="appellation_id" Type="int" /> <Property Name="appellation_id" Type="int" />
<Property Name="follower_hash" Type="nvarchar" MaxLength="100" /> <Property Name="follower_hash" Type="nvarchar" MaxLength="100" />
<Property Name="search_keywords" Type="nvarchar(max)" /> <Property Name="search_keywords" Type="varchar(max)" />
</EntityType> </EntityType>
<EntityType Name="followers_tablet"> <EntityType Name="followers_tablet">
<Key> <Key>
@@ -604,8 +621,8 @@
</Key> </Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" /> <Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="kind" Type="nvarchar" MaxLength="100" /> <Property Name="kind" Type="nvarchar" MaxLength="100" />
<Property Name="starttime" Type="time" Precision="0" /> <Property Name="starttime" Type="time" Precision="7" />
<Property Name="offtime" Type="time" Precision="0" /> <Property Name="offtime" Type="time" Precision="7" />
<Property Name="resttime" Type="int" /> <Property Name="resttime" Type="int" />
<Property Name="root" Type="int" /> <Property Name="root" Type="int" />
<Property Name="range" Type="int" /> <Property Name="range" Type="int" />
@@ -696,6 +713,7 @@
<Property Name="introducer" Type="int" /> <Property Name="introducer" Type="int" />
<Property Name="send_receipt" Type="bit" /> <Property Name="send_receipt" Type="bit" />
<Property Name="receipt_title" Type="nvarchar(max)" /> <Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="au_num" Type="int" />
</EntityType> </EntityType>
<EntityType Name="pro_order_detail"> <EntityType Name="pro_order_detail">
<Key> <Key>
@@ -980,7 +998,7 @@
<Property Name="balance_act_item" Type="int" /> <Property Name="balance_act_item" Type="int" />
<Property Name="balance_pro_order_detail" Type="int" /> <Property Name="balance_pro_order_detail" Type="int" />
</EntityType> </EntityType>
<Association Name="FK__Ancestral__Regis__4DF47A4E"> <Association Name="FK__Ancestral__Regis__1A9EF37A">
<End Role="AncestralTabletRegistrant" Type="Self.AncestralTabletRegistrant" Multiplicity="1" /> <End Role="AncestralTabletRegistrant" Type="Self.AncestralTabletRegistrant" Multiplicity="1" />
<End Role="AncestralTabletPositionRecord" Type="Self.AncestralTabletPositionRecord" Multiplicity="*" /> <End Role="AncestralTabletPositionRecord" Type="Self.AncestralTabletPositionRecord" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
@@ -1079,7 +1097,9 @@
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_act_bom_actItem1"> <Association Name="FK_act_bom_actItem1">
<End Role="actItem" Type="Self.actItem" Multiplicity="0..1" /> <End Role="actItem" Type="Self.actItem" Multiplicity="0..1">
<OnDelete Action="Cascade" />
</End>
<End Role="act_bom" Type="Self.act_bom" Multiplicity="*" /> <End Role="act_bom" Type="Self.act_bom" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
<Principal Role="actItem"> <Principal Role="actItem">
@@ -1128,18 +1148,6 @@
</Dependent> </Dependent>
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_activity_activity_kind">
<End Role="activity_kind" Type="Self.activity_kind" Multiplicity="0..1" />
<End Role="activity" Type="Self.activity" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="activity_kind">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="activity">
<PropertyRef Name="kind" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_activity_check_activity"> <Association Name="FK_activity_check_activity">
<End Role="activity" Type="Self.activity" Multiplicity="0..1"> <End Role="activity" Type="Self.activity" Multiplicity="0..1">
<OnDelete Action="Cascade" /> <OnDelete Action="Cascade" />
@@ -1211,7 +1219,9 @@
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_activity_relating_activity"> <Association Name="FK_activity_relating_activity">
<End Role="activity" Type="Self.activity" Multiplicity="1" /> <End Role="activity" Type="Self.activity" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="activity_relating" Type="Self.activity_relating" Multiplicity="*" /> <End Role="activity_relating" Type="Self.activity_relating" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
<Principal Role="activity"> <Principal Role="activity">
@@ -1272,6 +1282,18 @@
</Dependent> </Dependent>
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_auto_enroll_followers">
<End Role="followers" Type="Self.followers" Multiplicity="1" />
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="followers">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_bed_kind_detail_bed_kind"> <Association Name="FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" Type="Self.bed_kind" Multiplicity="0..1" /> <End Role="bed_kind" Type="Self.bed_kind" Multiplicity="0..1" />
<End Role="bed_kind_detail" Type="Self.bed_kind_detail" Multiplicity="*" /> <End Role="bed_kind_detail" Type="Self.bed_kind_detail" Multiplicity="*" />
@@ -1637,7 +1659,9 @@
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_pro_order_activity"> <Association Name="FK_pro_order_activity">
<End Role="activity" Type="Self.activity" Multiplicity="0..1" /> <End Role="activity" Type="Self.activity" Multiplicity="0..1">
<OnDelete Action="Cascade" />
</End>
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" /> <End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
<Principal Role="activity"> <Principal Role="activity">
@@ -1648,6 +1672,18 @@
</Dependent> </Dependent>
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_pro_order_auto_enroll">
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="0..1" />
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_detail_actItem"> <Association Name="FK_pro_order_detail_actItem">
<End Role="actItem" Type="Self.actItem" Multiplicity="0..1"> <End Role="actItem" Type="Self.actItem" Multiplicity="0..1">
<OnDelete Action="Cascade" /> <OnDelete Action="Cascade" />
@@ -1687,7 +1723,9 @@
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_pro_order_detail_pro_order"> <Association Name="FK_pro_order_detail_pro_order">
<End Role="pro_order" Type="Self.pro_order" Multiplicity="1" /> <End Role="pro_order" Type="Self.pro_order" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="pro_order_detail" Type="Self.pro_order_detail" Multiplicity="*" /> <End Role="pro_order_detail" Type="Self.pro_order_detail" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
<Principal Role="pro_order"> <Principal Role="pro_order">
@@ -1699,7 +1737,9 @@
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<Association Name="FK_pro_order_followers"> <Association Name="FK_pro_order_followers">
<End Role="followers" Type="Self.followers" Multiplicity="0..1" /> <End Role="followers" Type="Self.followers" Multiplicity="0..1">
<OnDelete Action="Cascade" />
</End>
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" /> <End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
<ReferentialConstraint> <ReferentialConstraint>
<Principal Role="followers"> <Principal Role="followers">
@@ -2114,6 +2154,7 @@
<EntitySet Name="AncestralTabletRegistrant" EntityType="Self.AncestralTabletRegistrant" 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="AncestralTabletStatus" EntityType="Self.AncestralTabletStatus" Schema="dbo" store:Type="Tables" />
<EntitySet Name="appellation" EntityType="Self.appellation" Schema="dbo" store:Type="Tables" /> <EntitySet Name="appellation" EntityType="Self.appellation" Schema="dbo" store:Type="Tables" />
<EntitySet Name="auto_enroll" EntityType="Self.auto_enroll" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind" EntityType="Self.bed_kind" 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" /> <EntitySet Name="bed_kind_detail" EntityType="Self.bed_kind_detail" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_order" EntityType="Self.bed_order" Schema="dbo" store:Type="Tables" /> <EntitySet Name="bed_order" EntityType="Self.bed_order" Schema="dbo" store:Type="Tables" />
@@ -2157,7 +2198,7 @@
<EntitySet Name="supplier" EntityType="Self.supplier" Schema="dbo" store:Type="Tables" /> <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="supplier_kind" EntityType="Self.supplier_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="transfer_register" EntityType="Self.transfer_register" Schema="dbo" store:Type="Tables" /> <EntitySet Name="transfer_register" EntityType="Self.transfer_register" Schema="dbo" store:Type="Tables" />
<AssociationSet Name="FK__Ancestral__Regis__4DF47A4E" Association="Self.FK__Ancestral__Regis__4DF47A4E"> <AssociationSet Name="FK__Ancestral__Regis__1A9EF37A" Association="Self.FK__Ancestral__Regis__1A9EF37A">
<End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" /> <End Role="AncestralTabletRegistrant" EntitySet="AncestralTabletRegistrant" />
<End Role="AncestralTabletPositionRecord" EntitySet="AncestralTabletPositionRecord" /> <End Role="AncestralTabletPositionRecord" EntitySet="AncestralTabletPositionRecord" />
</AssociationSet> </AssociationSet>
@@ -2205,10 +2246,6 @@
<End Role="activity_category_kind" EntitySet="activity_category_kind" /> <End Role="activity_category_kind" EntitySet="activity_category_kind" />
<End Role="activity" EntitySet="activity" /> <End Role="activity" EntitySet="activity" />
</AssociationSet> </AssociationSet>
<AssociationSet Name="FK_activity_activity_kind" Association="Self.FK_activity_activity_kind">
<End Role="activity_kind" EntitySet="activity_kind" />
<End Role="activity" EntitySet="activity" />
</AssociationSet>
<AssociationSet Name="FK_activity_check_activity" Association="Self.FK_activity_check_activity"> <AssociationSet Name="FK_activity_check_activity" Association="Self.FK_activity_check_activity">
<End Role="activity" EntitySet="activity" /> <End Role="activity" EntitySet="activity" />
<End Role="activity_check" EntitySet="activity_check" /> <End Role="activity_check" EntitySet="activity_check" />
@@ -2249,6 +2286,10 @@
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" /> <End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" /> <End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" />
</AssociationSet> </AssociationSet>
<AssociationSet Name="FK_auto_enroll_followers" Association="Self.FK_auto_enroll_followers">
<End Role="followers" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_bed_kind_detail_bed_kind" Association="Self.FK_bed_kind_detail_bed_kind"> <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" EntitySet="bed_kind" />
<End Role="bed_kind_detail" EntitySet="bed_kind_detail" /> <End Role="bed_kind_detail" EntitySet="bed_kind_detail" />
@@ -2373,6 +2414,10 @@
<End Role="activity" EntitySet="activity" /> <End Role="activity" EntitySet="activity" />
<End Role="pro_order" EntitySet="pro_order" /> <End Role="pro_order" EntitySet="pro_order" />
</AssociationSet> </AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Self.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_detail_actItem" Association="Self.FK_pro_order_detail_actItem"> <AssociationSet Name="FK_pro_order_detail_actItem" Association="Self.FK_pro_order_detail_actItem">
<End Role="actItem" EntitySet="actItem" /> <End Role="actItem" EntitySet="actItem" />
<End Role="pro_order_detail" EntitySet="pro_order_detail" /> <End Role="pro_order_detail" EntitySet="pro_order_detail" />
@@ -2613,6 +2658,7 @@
<Property Name="print_init" Type="String" MaxLength="100" FixedLength="false" Unicode="true" /> <Property Name="print_init" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<NavigationProperty Name="transfer_register" Relationship="Model.FK_transfer_register_actItem" FromRole="actItem" ToRole="transfer_register" /> <NavigationProperty Name="transfer_register" Relationship="Model.FK_transfer_register_actItem" FromRole="actItem" ToRole="transfer_register" />
<Property Name="is_reconcile" Type="String" MaxLength="1" FixedLength="false" Unicode="true" /> <Property Name="is_reconcile" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="sort_order" Type="Int32" />
</EntityType> </EntityType>
<EntityType Name="actItem_files"> <EntityType Name="actItem_files">
<Key> <Key>
@@ -2733,6 +2779,10 @@
<Property Name="reg_time" Type="DateTime" Precision="3" /> <Property Name="reg_time" Type="DateTime" Precision="3" />
<NavigationProperty Name="actItem" Relationship="Self.FK_activity_relating_actItem" FromRole="activity_relating" ToRole="actItem" /> <NavigationProperty Name="actItem" Relationship="Self.FK_activity_relating_actItem" FromRole="activity_relating" ToRole="actItem" />
<NavigationProperty Name="activity" Relationship="Self.FK_activity_relating_activity" FromRole="activity_relating" ToRole="activity" /> <NavigationProperty Name="activity" Relationship="Self.FK_activity_relating_activity" FromRole="activity_relating" ToRole="activity" />
<Property Name="has_yang_limit" Type="Boolean" />
<Property Name="has_chao_limit" Type="Boolean" />
<Property Name="yang_limit_count" Type="Int32" />
<Property Name="chao_limit_count" Type="Int32" />
</EntityType> </EntityType>
<EntityType Name="activity_spares"> <EntityType Name="activity_spares">
<Key> <Key>
@@ -2896,6 +2946,7 @@
<Property Name="smtp_def" Type="String" MaxLength="1" FixedLength="false" Unicode="true" /> <Property Name="smtp_def" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="use_sender" Type="String" MaxLength="1" FixedLength="false" Unicode="true" /> <Property Name="use_sender" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="bed_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" /> <Property Name="bed_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="last_auto_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
</EntityType> </EntityType>
<EntityType Name="country"> <EntityType Name="country">
<Key> <Key>
@@ -2972,8 +3023,9 @@
<NavigationProperty Name="transfer_register" Relationship="Model.FK_transfer_register_followers" FromRole="follower" ToRole="transfer_register" /> <NavigationProperty Name="transfer_register" Relationship="Model.FK_transfer_register_followers" FromRole="follower" ToRole="transfer_register" />
<NavigationProperty Name="transfer_register1" Relationship="Model.FK_transfer_register_followers_match" FromRole="follower" ToRole="transfer_register" /> <NavigationProperty Name="transfer_register1" Relationship="Model.FK_transfer_register_followers_match" FromRole="follower" ToRole="transfer_register" />
<NavigationProperty Name="GuaDanOrder" Relationship="Model.FK_GuaDanOrder_Followers" FromRole="follower" ToRole="GuaDanOrder" /> <NavigationProperty Name="GuaDanOrder" Relationship="Model.FK_GuaDanOrder_Followers" FromRole="follower" ToRole="GuaDanOrder" />
<Property Name="search_keywords" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /> <Property Name="search_keywords" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<NavigationProperty Name="GuaDanOrderGuest" Relationship="Model.FK_GuaDanOrderGuest_FOLLOWERS" FromRole="follower" ToRole="GuaDanOrderGuest" /> <NavigationProperty Name="GuaDanOrderGuest" Relationship="Model.FK_GuaDanOrderGuest_FOLLOWERS" FromRole="follower" ToRole="GuaDanOrderGuest" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_auto_enroll_followers" FromRole="follower" ToRole="auto_enroll" />
</EntityType> </EntityType>
<EntityType Name="followers_tablet"> <EntityType Name="followers_tablet">
<Key> <Key>
@@ -3062,8 +3114,8 @@
</Key> </Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" /> <Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="kind" Type="String" MaxLength="100" FixedLength="false" Unicode="true" /> <Property Name="kind" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="starttime" Type="Time" Precision="0" /> <Property Name="starttime" Type="Time" Precision="7" />
<Property Name="offtime" Type="Time" Precision="0" /> <Property Name="offtime" Type="Time" Precision="7" />
<Property Name="resttime" Type="Int32" /> <Property Name="resttime" Type="Int32" />
<Property Name="root" Type="Int32" /> <Property Name="root" Type="Int32" />
<Property Name="range" Type="Int32" /> <Property Name="range" Type="Int32" />
@@ -3152,6 +3204,8 @@
<NavigationProperty Name="pro_order_detail" Relationship="Self.FK_pro_order_detail_pro_order" FromRole="pro_order" ToRole="pro_order_detail" /> <NavigationProperty Name="pro_order_detail" Relationship="Self.FK_pro_order_detail_pro_order" FromRole="pro_order" ToRole="pro_order_detail" />
<Property Name="send_receipt" Type="Boolean" /> <Property Name="send_receipt" Type="Boolean" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" /> <Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="au_num" Type="Int32" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_pro_order_auto_enroll" FromRole="pro_order" ToRole="auto_enroll" />
</EntityType> </EntityType>
<EntityType Name="pro_order_detail"> <EntityType Name="pro_order_detail">
<Key> <Key>
@@ -4549,6 +4603,15 @@
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" /> <End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
<End Role="RegionAndRoomAndBedSchedule" EntitySet="RegionAndRoomAndBedSchedule" /> <End Role="RegionAndRoomAndBedSchedule" EntitySet="RegionAndRoomAndBedSchedule" />
</AssociationSet> </AssociationSet>
<EntitySet Name="auto_enroll" EntityType="Model.auto_enroll" />
<AssociationSet Name="FK_auto_enroll_followers" Association="Model.FK_auto_enroll_followers">
<End Role="follower" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Model.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
</EntityContainer> </EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result"> <ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" /> <Property Type="Int32" Name="version" Nullable="true" />
@@ -5266,6 +5329,45 @@
</Dependent> </Dependent>
</ReferentialConstraint> </ReferentialConstraint>
</Association> </Association>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="f_num" Type="Int32" Nullable="false" />
<Property Name="start_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="end_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<NavigationProperty Name="followers" Relationship="Model.FK_auto_enroll_followers" FromRole="auto_enroll" ToRole="follower" />
<NavigationProperty Name="pro_order" Relationship="Model.FK_pro_order_auto_enroll" FromRole="auto_enroll" ToRole="pro_order" />
</EntityType>
<Association Name="FK_auto_enroll_followers">
<End Type="Model.follower" Role="follower" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="follower">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_auto_enroll">
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="0..1" />
<End Type="Model.pro_order" Role="pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema> </Schema>
</edmx:ConceptualModels> </edmx:ConceptualModels>
<!-- C-S mapping content --> <!-- C-S mapping content -->
@@ -5334,6 +5436,7 @@
<EntitySetMapping Name="actItems"> <EntitySetMapping Name="actItems">
<EntityTypeMapping TypeName="Model.actItem"> <EntityTypeMapping TypeName="Model.actItem">
<MappingFragment StoreEntitySet="actItem"> <MappingFragment StoreEntitySet="actItem">
<ScalarProperty Name="sort_order" ColumnName="sort_order" />
<ScalarProperty Name="is_reconcile" ColumnName="is_reconcile" /> <ScalarProperty Name="is_reconcile" ColumnName="is_reconcile" />
<ScalarProperty Name="print_init" ColumnName="print_init" /> <ScalarProperty Name="print_init" ColumnName="print_init" />
<ScalarProperty Name="partno" ColumnName="partno" /> <ScalarProperty Name="partno" ColumnName="partno" />
@@ -5448,6 +5551,10 @@
<EntitySetMapping Name="activity_relating"> <EntitySetMapping Name="activity_relating">
<EntityTypeMapping TypeName="Model.activity_relating"> <EntityTypeMapping TypeName="Model.activity_relating">
<MappingFragment StoreEntitySet="activity_relating"> <MappingFragment StoreEntitySet="activity_relating">
<ScalarProperty Name="chao_limit_count" ColumnName="chao_limit_count" />
<ScalarProperty Name="yang_limit_count" ColumnName="yang_limit_count" />
<ScalarProperty Name="has_chao_limit" ColumnName="has_chao_limit" />
<ScalarProperty Name="has_yang_limit" ColumnName="has_yang_limit" />
<ScalarProperty Name="num" ColumnName="num" /> <ScalarProperty Name="num" ColumnName="num" />
<ScalarProperty Name="activity_num" ColumnName="activity_num" /> <ScalarProperty Name="activity_num" ColumnName="activity_num" />
<ScalarProperty Name="actItem_num" ColumnName="actItem_num" /> <ScalarProperty Name="actItem_num" ColumnName="actItem_num" />
@@ -5587,6 +5694,7 @@
<EntitySetMapping Name="companies"> <EntitySetMapping Name="companies">
<EntityTypeMapping TypeName="Model.company"> <EntityTypeMapping TypeName="Model.company">
<MappingFragment StoreEntitySet="company"> <MappingFragment StoreEntitySet="company">
<ScalarProperty Name="last_auto_order_no" ColumnName="last_auto_order_no" />
<ScalarProperty Name="num" ColumnName="num" /> <ScalarProperty Name="num" ColumnName="num" />
<ScalarProperty Name="com_name" ColumnName="com_name" /> <ScalarProperty Name="com_name" ColumnName="com_name" />
<ScalarProperty Name="com_mail" ColumnName="com_mail" /> <ScalarProperty Name="com_mail" ColumnName="com_mail" />
@@ -5821,6 +5929,7 @@
<EntitySetMapping Name="pro_order"> <EntitySetMapping Name="pro_order">
<EntityTypeMapping TypeName="Model.pro_order"> <EntityTypeMapping TypeName="Model.pro_order">
<MappingFragment StoreEntitySet="pro_order"> <MappingFragment StoreEntitySet="pro_order">
<ScalarProperty Name="au_num" ColumnName="au_num" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" /> <ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="send_receipt" ColumnName="send_receipt" /> <ScalarProperty Name="send_receipt" ColumnName="send_receipt" />
<ScalarProperty Name="order_no" ColumnName="order_no" /> <ScalarProperty Name="order_no" ColumnName="order_no" />
@@ -6314,6 +6423,18 @@
</MappingFragment> </MappingFragment>
</EntityTypeMapping> </EntityTypeMapping>
</EntitySetMapping> </EntitySetMapping>
<EntitySetMapping Name="auto_enroll">
<EntityTypeMapping TypeName="Model.auto_enroll">
<MappingFragment StoreEntitySet="auto_enroll">
<ScalarProperty Name="receipt_address" ColumnName="receipt_address" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="end_date" ColumnName="end_date" />
<ScalarProperty Name="start_date" ColumnName="start_date" />
<ScalarProperty Name="f_num" ColumnName="f_num" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping> </EntityContainerMapping>
</Mapping> </Mapping>
</edmx:Mappings> </edmx:Mappings>
+4 -1
View File
@@ -9,7 +9,7 @@
<EntityTypeShape EntityType="Model.accounting_files" Width="1.5" PointX="15.75" PointY="27.75" IsExpanded="true" /> <EntityTypeShape EntityType="Model.accounting_files" Width="1.5" PointX="15.75" PointY="27.75" IsExpanded="true" />
<EntityTypeShape EntityType="Model.accounting_kind" Width="1.5" PointX="11.25" PointY="27.625" IsExpanded="true" /> <EntityTypeShape EntityType="Model.accounting_kind" Width="1.5" PointX="11.25" PointY="27.625" IsExpanded="true" />
<EntityTypeShape EntityType="Model.accounting_kind2" Width="1.5" PointX="13.5" PointY="11.25" IsExpanded="true" /> <EntityTypeShape EntityType="Model.accounting_kind2" Width="1.5" PointX="13.5" PointY="11.25" IsExpanded="true" />
<EntityTypeShape EntityType="Model.actItem" Width="1.5" PointX="9.25" PointY="7.875" IsExpanded="true" /> <EntityTypeShape EntityType="Model.actItem" Width="1.5" PointX="8.375" PointY="27.25" IsExpanded="true" />
<EntityTypeShape EntityType="Model.actItem_files" Width="1.5" PointX="16.5" PointY="5.875" IsExpanded="true" /> <EntityTypeShape EntityType="Model.actItem_files" Width="1.5" PointX="16.5" PointY="5.875" IsExpanded="true" />
<EntityTypeShape EntityType="Model.actItem_kind" Width="1.5" PointX="6.125" PointY="7.875" IsExpanded="true" /> <EntityTypeShape EntityType="Model.actItem_kind" Width="1.5" PointX="6.125" PointY="7.875" IsExpanded="true" />
<EntityTypeShape EntityType="Model.activity" Width="1.5" PointX="3" PointY="8.875" IsExpanded="true" /> <EntityTypeShape EntityType="Model.activity" Width="1.5" PointX="3" PointY="8.875" IsExpanded="true" />
@@ -162,6 +162,9 @@
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_RoomUuid" /> <AssociationConnector Association="Model.FK_GuaDanOrderGuest_RoomUuid" />
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_StatusCode" /> <AssociationConnector Association="Model.FK_GuaDanOrderGuest_StatusCode" />
<AssociationConnector Association="Model.FK_Schedule_GuaDanOrderGuest" /> <AssociationConnector Association="Model.FK_Schedule_GuaDanOrderGuest" />
<EntityTypeShape EntityType="Model.auto_enroll" Width="1.5" PointX="5.25" PointY="37.875" />
<AssociationConnector Association="Model.FK_auto_enroll_followers" />
<AssociationConnector Association="Model.FK_pro_order_auto_enroll" />
</Diagram> </Diagram>
</edmx:Diagrams> </edmx:Diagrams>
</edmx:Designer> </edmx:Designer>
+1 -1
View File
@@ -28,7 +28,7 @@ namespace MyWeb
public AdmItem info { get; set; } public AdmItem info { get; set; }
//定義欄位cookie==================start //定義欄位cookie==================start
public class AdmItem public class AdmItem
{ {
public int num { get; set; } public int num { get; set; }
public string u_id { get; set; } public string u_id { get; set; }
+377 -18
View File
@@ -1,15 +1,20 @@
using System; using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Office2010.Excel;
using Model;
using MyWeb;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using PagedList;
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Web.Http; using System.Web.Http;
using PagedList; using System.Web.Razor.Tokenizer;
using Newtonsoft.Json;
using System.Collections;
using DocumentFormat.OpenXml.Office2010.Excel;
using MyWeb;
using System.Data.Entity;
// api/Follower // api/Follower
//[ezAuthorize(Roles = "admin")]//群組:* //[ezAuthorize(Roles = "admin")]//群組:*
@@ -103,17 +108,18 @@ public class FollowerController : ApiController
{ {
foreach (var item in prod) foreach (var item in prod)
{ {
foreach (var item2 in item.pro_order_detail1) //foreach (var item2 in item.pro_order_detail1)
item2.from_id = null; //清空訂單明細的陽上報恩者from_id //f_num設定串聯刪除 // item2.from_id = null; //清空訂單明細的陽上報恩者from_id //f_num設定串聯刪除
foreach (var item2 in item.pro_order) //foreach (var item2 in item.pro_order)
item2.introducer = null; // item2.introducer = null;
item.leader = null;//清空leader //item.leader = null;//清空leader
_db.followers.RemoveRange(prod);
} }
_db.followers.RemoveRange(prod); //_db.followers.RemoveRange(prod);
_db.SaveChanges(); _db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
@@ -150,8 +156,10 @@ public class FollowerController : ApiController
qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim())); qry = qry.Where(o => o.u_name.Contains(q.u_name.Trim()));
if (q.birthday.HasValue) if (q.birthday.HasValue)
qry = qry.Where(o => o.birthday >= q.birthday.Value); qry = qry.Where(o => o.birthday >= q.birthday.Value);
if (q.birthday2.HasValue) if (q.birthday2.HasValue) {
qry = qry.Where(o => o.birthday < Convert.ToDateTime(q.birthday2.Value).AddDays(1)); var tmpBirthday2 = Convert.ToDateTime(q.birthday2.Value).AddDays(1);
qry = qry.Where(o => o.birthday < tmpBirthday2);
}
if (!string.IsNullOrEmpty(q.address)) 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) //if (q.num.HasValue && q.num.Value>0)
@@ -173,7 +181,7 @@ public class FollowerController : ApiController
} }
} }
// 電話/證號搜尋 (使用 search_keywords HEX 編碼) // 電話/證號搜尋 (使用 search_keywords HEX 編碼)
if (!string.IsNullOrEmpty(q.phone_idcode) && GlobalVariables.UseSearchKeywords) if (!string.IsNullOrEmpty(q.phone_idcode) && GlobalVariables.UseSearchKeywords)
{ {
@@ -528,6 +536,203 @@ public class FollowerController : ApiController
} }
[HttpGet]
[Route("api/follower/GetAutoEnrollList/{id}")]
public IHttpActionResult GetAutoEnrollList(int id)
{
var prod = _db.auto_enroll.Where(q => q.f_num == id).ToList();
var ret = new
{
list = prod.Select(x => new
{
num = x.num,
auto_enroll_start_date = x.start_date.ToString("yyyy-MM-dd"),
auto_enroll_end_date = x.end_date.ToString("yyyy-MM-dd"),
auto_enroll_receipt_title = x.receipt_title?? "",
auto_enroll_receipt_address = x.receipt_address?? "",
}),
};
return Ok(ret);
}
[HttpPost]
[Route("api/follower/SaveAutoEnrollList")]
public IHttpActionResult SaveAutoEnrollList([FromBody] Model.auto_enroll item)
{
Model.auto_enroll autoEnroll;
if (item.num == 0)
{
// ===== 新增 =====
autoEnroll = new Model.auto_enroll()
{
f_num = item.f_num,
start_date = item.start_date,
end_date = item.end_date,
receipt_title = string.IsNullOrEmpty(item.receipt_title) ? null : item.receipt_title.Trim(),
receipt_address = string.IsNullOrEmpty(item.receipt_address) ? null : item.receipt_address.Trim(),
}
;
_db.auto_enroll.Add(autoEnroll);
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
else
{
// ===== 更新 =====
autoEnroll = _db.auto_enroll.Where(q => q.num == item.num).FirstOrDefault();
if (autoEnroll == null) return NotFound();
autoEnroll.start_date = item.start_date;
autoEnroll.end_date = item.end_date;
autoEnroll.receipt_title = item.receipt_title?.Trim() ?? null;
autoEnroll.receipt_address = item.receipt_address?.Trim() ?? null;
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
try
{
var ret = new
{
num = autoEnroll.num,
start_date = autoEnroll.start_date.ToString("yyyy-MM-dd"),
end_date = autoEnroll.end_date.ToString("yyyy-MM-dd"),
receipt_title = autoEnroll.receipt_title,
receipt_address = autoEnroll.receipt_address,
};
return Ok(ret);
}
catch(Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/follower/GetAffectedOrders")]
public IHttpActionResult GetAffectedOrders([FromBody] Model.auto_enroll item, bool is_delete = false)
{
if (item == null) return BadRequest();
try
{
IQueryable<pro_order> query = _db.pro_order
.Where(o => o.f_num == item.f_num
&& o.order_no.StartsWith("AU")
&& o.au_num == item.num);
if (is_delete)
{
// 刪除:查期間內所有自動報名訂單
query = query.Where(o =>
o.activity.startDate_solar >= item.start_date &&
o.activity.startDate_solar <= item.end_date
);
}
else
{
// 修改:查不在新範圍內的訂單
query = query.Where(o =>
o.activity.startDate_solar < item.start_date ||
o.activity.startDate_solar > item.end_date
);
}
var rawOrders = query.Select(o => new
{
o.order_no,
o.activity.subject,
o.activity.startDate_solar
}).ToList();
var affectedOrders = rawOrders.Select(o => new
{
order_no = o.order_no,
activityname = o.subject,
activitydate = o.startDate_solar?.ToString("yyyy/MM/dd") ?? ""
}).ToList();
return Ok(new
{
count = affectedOrders.Count,
list = affectedOrders
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpDelete]
[Route("api/follower/DeleteAutoEnroll/{id}")]
public IHttpActionResult DeleteAutoEnroll(int id)
{
try
{
var prod = _db.auto_enroll.Where(q => q.num == id).FirstOrDefault();
if (prod != null)
{
_db.auto_enroll.Remove(prod);
_db.SaveChanges();
return Ok();
}
else return NotFound();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet]
[Route("api/follower/GetUnfilledActivityOrders/{id}")]
public IHttpActionResult GetUnfilledActivityOrders(int id, int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
try
{
var config = _db.auto_enroll.FirstOrDefault(x => x.num == id);
if (config == null) return NotFound();
var query = from o in _db.pro_order
join a in _db.activities on o.activity_num equals a.num
where o.f_num == config.f_num
&& a.startDate_solar >= config.start_date
&& a.startDate_solar <= config.end_date
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, a };
int totalCount = query.Count();
var pagedData = query
.OrderByDescending(x => x.o.order_no)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList()
.Select(x => new {
order_no = x.o.order_no,
startdate = x.a.startDate_solar?.ToString("yyyy/MM/dd") ?? "",
enddate = x.a.endDate_solar?.ToString("yyyy/MM/dd") ?? "",
activityname = x.a.subject,
category = x.a.activity_category_kind?.kind ?? ""
});
return Ok(new
{
list = pagedData,
count = totalCount,
page = page,
pageSize = pageSize
});
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost] [HttpPost]
[Route("api/follower/GetTabletList")] [Route("api/follower/GetTabletList")]
@@ -655,8 +860,10 @@ public class FollowerController : ApiController
list = orderrecord.Select(x => new list = orderrecord.Select(x => new
{ {
orderno = x.order_no, orderno = x.order_no,
startdate = x.reg_time, //startdate = x.reg_time,
endtime = x.up_time, //endtime = x.up_time,
startdate = x.activity.startDate_solar,
enddate = x.activity.endDate_solar,
pwcount = x.pro_order_detail.Where(a => a.actItem.act_bom.Where(b => b.item_num == a.actItem_num && b.package_num == null).Count() == 0).Count(), pwcount = x.pro_order_detail.Where(a => a.actItem.act_bom.Where(b => b.item_num == a.actItem_num && b.package_num == null).Count() == 0).Count(),
amount = x.pro_order_detail.Select(o => (float?)o.price).Sum(), amount = x.pro_order_detail.Select(o => (float?)o.price).Sum(),
activityname = x.activity.subject, activityname = x.activity.subject,
@@ -667,6 +874,31 @@ public class FollowerController : ApiController
return Ok(data); return Ok(data);
} }
[HttpPost] [HttpPost]
[Route("api/follower/pending_orders")]
public IHttpActionResult GetPendingOrders(int id, string targetDate)
{
DateTime today = DateTime.Today;
if (!DateTime.TryParse(targetDate, out DateTime limitDate))
{
limitDate = new DateTime(2099, 12, 31);
}
var orderrecord = _db.pro_order
.Where(x => x.f_num == id && x.activity.startDate_solar >= today && x.activity.startDate_solar < limitDate)
.Include(x => x.activity)
.ToList();
var data = new
{
list = orderrecord.Select(x => new
{
orderno = x.order_no,
activitydate = x.activity.startDate_solar.Value.ToString("yyyy/MM/dd"),
activityname = x.activity.subject,
})
};
return Ok(data);
}
[HttpPost]
[Route("api/follower/totalorderamount")] [Route("api/follower/totalorderamount")]
public IHttpActionResult GetTotalOrderCount(int id) public IHttpActionResult GetTotalOrderCount(int id)
{ {
@@ -702,5 +934,132 @@ public class FollowerController : ApiController
}; };
return Ok(data); return Ok(data);
} }
private void CreateOrdersForActivities(int f_num, int au_num, DateTime start_date, DateTime end_date, string receipt_title, string receipt_address)
{
var follower = _db.followers.Where(x => x.num == f_num).FirstOrDefault();
var activities = _db.activities
.Where(x =>
x.startDate_solar >= start_date &&
x.startDate_solar <= end_date
)
.ToList();
foreach (var activity in activities)
{
var existOrder = _db.pro_order
.Where(o => o.activity_num == activity.num && o.f_num == f_num)
.FirstOrDefault();
if (existOrder != null) {
existOrder.au_num = au_num;
_db.SaveChanges();
continue;
}
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
string finalPhone = follower?.cellphone ?? follower?.phone ?? "";
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = f_num,
au_num = au_num,
phone = finalPhone,
address = string.IsNullOrEmpty(receipt_address) ? "" : receipt_address,
activity_num = activity.num,
receipt_title = receipt_title ?? "",
demo = "",
customize_data = "",
};
_db.pro_order.Add(newOrder);
// 抓取同活動分類的上一筆訂單,複製品項
var latestOrder = _db.pro_order
.Where(o =>
o.f_num == f_num &&
o.activity.kind == activity.kind &&
o.order_no != newOrderNo &&
_db.pro_order_detail.Any(d => d.order_no == o.order_no)
)
.OrderByDescending(o => o.order_no)
.FirstOrDefault();
if (latestOrder != null)
{
var prevDetails = _db.pro_order_detail
.Where(d => d.order_no == latestOrder.order_no)
.ToList();
foreach (var detail in prevDetails)
{
var newDetail = new pro_order_detail
{
order_no = newOrderNo,
actItem_num = detail.actItem_num,
parent_num = detail.parent_num,
print_id = detail.print_id,
f_num = detail.f_num,
f_num_tablet = detail.f_num_tablet,
address = detail.address,
from_id = detail.from_id,
from_id_tablet = detail.from_id_tablet,
bed_type = detail.bed_type,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = detail.pay,
keyin1 = detail.keyin1,
demo = detail.demo,
customize_data = detail.customize_data,
printed_files = detail.printed_files,
UpdateTime = DateTime.Now,
};
_db.pro_order_detail.Add(newDetail);
}
}
}
_db.SaveChanges();
}
} }
public static class AutoOrderService
{
private static readonly object _lock = new object();
public static string CreateAutoOrderNumber(Model.ezEntities _db)
{
lock (_lock)
{
string prefix = "AU" + DateTime.Now.ToString("yyMMdd");
var company = _db.companies.FirstOrDefault(q => q.num == 1);
if (company == null) return "";
string order_no;
if (!string.IsNullOrEmpty(company.last_auto_order_no) && company.last_auto_order_no.StartsWith(prefix))
{
string serialStr = company.last_auto_order_no.Replace(prefix, "");
int nextSerial = int.Parse(serialStr) + 1;
order_no = prefix + nextSerial.ToString("0000");
}
else
{
order_no = prefix + "0001";
}
company.last_auto_order_no = order_no;
_db.SaveChanges();
return order_no;
}
}
}
+213 -16
View File
@@ -1,14 +1,19 @@
using System; using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using Model;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using PagedList;
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Web.Http; using System.Web.Http;
using PagedList; using System.Web.Services;
using Newtonsoft.Json;
using System.Collections;
using static TreeView; using static TreeView;
using System.Data.Entity;
// api/activity // api/activity
//[ezAuthorize(Roles = "admin")]//群組:* //[ezAuthorize(Roles = "admin")]//群組:*
@@ -126,6 +131,12 @@ public class activityController : ApiController
if (prod != null) if (prod != null)
{ {
////prod.IsDel = true; ////不確定是否新增欄位? 先註解 ////prod.IsDel = true; ////不確定是否新增欄位? 先註解
// 先刪除子項目
var prod2 = _db.act_bom.Where(q => q.package_num == prod.num).ToList();
_db.act_bom.RemoveRange(prod2);
_db.actItems.Remove(prod);
_db.SaveChanges(); _db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
MyWeb.admin admin = new MyWeb.admin();//api裡不可以用MyWeb MyWeb.admin admin = new MyWeb.admin();//api裡不可以用MyWeb
@@ -190,12 +201,18 @@ public class activityController : ApiController
if (prod.Count() > 0) 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.Contains(Convert.ToInt32(q.actItem_num))).ToList();
var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList(); //var prod2 = _db.actItem_files.Where(q => ids.Contains(q.actItem_num)).ToList();
if (prod2.Count > 0) //if (prod2.Count > 0)
{ //{
_db.actItem_files.RemoveRange(prod2); // _db.actItem_files.RemoveRange(prod2);
//_db.SaveChanges(); // //_db.SaveChanges();
} //}
// 先刪除子項目
var parentBoms = _db.act_bom.Where(q => q.item_num.HasValue && ids.Contains(q.item_num.Value)).ToList();
var parentIds = parentBoms.Select(x => x.num).ToList(); // 取得母件 id
var childBoms = _db.act_bom.Where(q => q.package_num.HasValue && parentIds.Contains(q.package_num.Value)).ToList();
_db.act_bom.RemoveRange(childBoms);
_db.actItems.RemoveRange(prod); _db.actItems.RemoveRange(prod);
_db.SaveChanges(); _db.SaveChanges();
@@ -312,6 +329,36 @@ public class activityController : ApiController
return Ok(ret); return Ok(ret);
} }
public class SortOrderRequest
{
public List<int> ids { get; set; }
}
[HttpPost]
[Route("api/activity/SaveItemList")]
public IHttpActionResult UpdateSortOrder([FromBody] SortOrderRequest request)
{
if (request == null || request.ids == null) return BadRequest();
using (Model.ezEntities _db = new Model.ezEntities())
{
int totalCount = request.ids.Count;
for (int i = 0; i < totalCount; i++)
{
int id = request.ids[i];
var item = _db.actItems.FirstOrDefault(x => x.num == id);
if (item != null)
{
// 改成總數減去索引,這樣第一筆 (i=0) 會拿到最大的數字
item.sort_order = totalCount - i;
}
}
_db.SaveChanges();
}
return Ok();
}
[HttpPost] [HttpPost]
[Route("api/activity/GetItemList")] [Route("api/activity/GetItemList")]
public IHttpActionResult GetItemList([FromBody] Model.ViewModel.actItem q, int page, int pageSize = 10, public IHttpActionResult GetItemList([FromBody] Model.ViewModel.actItem q, int page, int pageSize = 10,
@@ -416,8 +463,14 @@ public class activityController : ApiController
else else
qry = qry.OrderBy(o => o.status); qry = qry.OrderBy(o => o.status);
} }
else else if (sortBy.Equals("num"))
{
qry = qry.OrderByDescending(o => o.num); qry = qry.OrderByDescending(o => o.num);
}
else
{
qry = qry.OrderByDescending(o => o.sort_order);
}
var tdesc = publicFun.enum_desc<Model.activity.category>(); var tdesc = publicFun.enum_desc<Model.activity.category>();
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
@@ -750,7 +803,7 @@ public class activityController : ApiController
//已有值 //已有值
var count = qry.Count(); //pageSize = count;//一次取回?? var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.OrderBy(a=>a.num).ToPagedList(page, pageSize).ToList() : qry.ToList(); var qryList = (pageSize > 0) ? qry.OrderBy(a => a.num).ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new var ret = new
{ {
list = qryList.Select(x => new list = qryList.Select(x => new
@@ -906,6 +959,10 @@ public class activityController : ApiController
}, },
price = x.price ?? 0, price = x.price ?? 0,
qty = x.qty ?? 0, qty = x.qty ?? 0,
has_yang_limit = x.has_yang_limit ?? false,
has_chao_limit = x.has_yang_limit ?? false,
yang_limit_count = x.yang_limit_count ?? 0,
chao_limit_count = x.chao_limit_count ?? 0,
files = x.actItem?.actItem_files.Select(f => new files = x.actItem?.actItem_files.Select(f => new
{ {
num = f.file.num, num = f.file.num,
@@ -1123,6 +1180,10 @@ public class activityController : ApiController
if (item.qty.HasValue) { _data.qty = item.qty.Value; } if (item.qty.HasValue) { _data.qty = item.qty.Value; }
else { _data.qty = null; } else { _data.qty = null; }
_data.reg_time = DateTime.Now; _data.reg_time = DateTime.Now;
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.yang_limit_count >= 0) { _data.yang_limit_count = item.yang_limit_count.Value; }
if (item.has_chao_limit.HasValue) { _data.has_chao_limit = item.has_chao_limit; }
if (item.chao_limit_count >= 0) { _data.chao_limit_count = item.chao_limit_count.Value; }
_db.SaveChanges(); _db.SaveChanges();
var ret = _data.num; var ret = _data.num;
@@ -1143,6 +1204,10 @@ public class activityController : ApiController
if (item.qty.HasValue) { _data.qty = item.qty.Value; } if (item.qty.HasValue) { _data.qty = item.qty.Value; }
else { _data.qty = null; } else { _data.qty = null; }
_data.reg_time = DateTime.Now; _data.reg_time = DateTime.Now;
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.yang_limit_count >= 0) { _data.yang_limit_count = item.yang_limit_count.Value; }
if (item.has_chao_limit.HasValue) { _data.has_chao_limit = item.has_chao_limit; }
if (item.chao_limit_count >= 0) { _data.chao_limit_count = item.chao_limit_count.Value; }
_db.activity_relating.Add(_data); _db.activity_relating.Add(_data);
_db.SaveChanges(); _db.SaveChanges();
@@ -1301,7 +1366,7 @@ public class activityController : ApiController
[Route("api/activity/OrderCheckIn")] [Route("api/activity/OrderCheckIn")]
public IHttpActionResult OrderCheckIn([FromBody] Model.activity_check item) public IHttpActionResult OrderCheckIn([FromBody] Model.activity_check item)
{ {
if (item.f_num.HasValue && item.activity_num.HasValue && item.qty.HasValue && item.status.HasValue) if (item.f_num.HasValue && item.activity_num.HasValue && item.status.HasValue)
{ {
//同一天不能簽到兩次以上 //同一天不能簽到兩次以上
Model.activity_check check = _db.activity_check Model.activity_check check = _db.activity_check
@@ -1495,13 +1560,13 @@ public class activityController : ApiController
var r1 = qry.ToList(); var r1 = qry.ToList();
var r2 = r1.Select(x => new { num = x.num, subject = x.subject }); var r2 = r1.Select(x => new { num = x.num, subject = x.subject });
var count = qry.Count(); var count = qry.Count();
// 計算昨天和今天的日期範圍 // 計算昨天和今天的日期範圍
var yesterdayStart = _now.Date.AddDays(-1); var yesterdayStart = _now.Date.AddDays(-1);
var yesterdayEnd = _now.Date; var yesterdayEnd = _now.Date;
var todayStart = _now.Date; var todayStart = _now.Date;
var todayEnd = _now.Date.AddDays(1); var todayEnd = _now.Date.AddDays(1);
var ret = new var ret = new
{ {
list = r1.Select(x => new list = r1.Select(x => new
@@ -1555,4 +1620,136 @@ public class activityController : ApiController
return Ok(ret); return Ok(ret);
} }
[HttpGet]
[Route("api/activity/GetUnfilledOrdersByActivity/{num}")]
public IHttpActionResult GetUnfilledOrdersByActivity(int num)
{
try
{
var activityExists = _db.activities.Any(a => a.num == num);
if (!activityExists) return NotFound();
var query = from o in _db.pro_order
join f in _db.followers on o.f_num equals f.num into fg
from f in fg.DefaultIfEmpty()
where o.activity_num == num
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, f };
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var unfilledOrders = query.ToList().Select(x => new
{
order_no = x.o.order_no,
f_number = x.f.f_number,
u_name = x.f != null ? x.f.u_name : "未知",
phone = !string.IsNullOrEmpty(x.f.cellphone) ? encrypt.DecryptAutoKey(x.f.cellphone) : (encrypt.DecryptAutoKey(x.f.phone) ?? ""),
order_date = x.o.reg_time.HasValue ? x.o.reg_time.Value.ToString("yyyy/MM/dd") : "",
}).ToList();
return Ok(new
{
list = unfilledOrders,
count = unfilledOrders.Count
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpPost]
[Route("api/activity/TriggerAutoEnroll/{activity_num}")]
public IHttpActionResult TriggerAutoEnroll(int activity_num)
{
try
{
var activity = _db.activities.FirstOrDefault(a => a.num == activity_num);
if (activity == null) return NotFound();
if (!activity.startDate_solar.HasValue) return BadRequest("該活動沒有設定開始日期,無法執行自動報名。");
DateTime actDate = activity.startDate_solar.Value;
var validConfigs = _db.auto_enroll
.Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
.ToList();
int successCount = 0;
foreach (var config in validConfigs)
{
if (_db.pro_order.Any(o => o.activity_num == activity_num && o.f_num == config.f_num))
continue;
var follower = _db.followers.FirstOrDefault(f => f.num == config.f_num);
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = config.f_num,
au_num = config.num,
phone = follower?.cellphone ?? follower?.phone ?? "",
address = config.receipt_address ?? "",
activity_num = activity_num,
receipt_title = config.receipt_title ?? "",
demo = "系統於新增活動時自動報名",
};
_db.pro_order.Add(newOrder);
CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
successCount++;
}
_db.SaveChanges();
return Ok(new
{
message = $"自動報名執行完畢,共為 {successCount} 位信眾完成報名。",
count = successCount
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
private void CopyLatestOrderDetails(string newOrderNo, int f_num, int activityKind)
{
var latestOrder = _db.pro_order
.Where(o => o.f_num == f_num && o.activity.kind == activityKind && _db.pro_order_detail.Any(d => d.order_no == o.order_no))
.OrderByDescending(o => o.order_no)
.FirstOrDefault();
if (latestOrder != null)
{
var prevDetails = _db.pro_order_detail.Where(d => d.order_no == latestOrder.order_no).ToList();
foreach (var detail in prevDetails)
{
_db.pro_order_detail.Add(new pro_order_detail
{
order_no = newOrderNo,
actItem_num = detail.actItem_num,
parent_num = detail.parent_num,
print_id = detail.print_id,
f_num = detail.f_num,
f_num_tablet = detail.f_num_tablet,
address = detail.address,
from_id = detail.from_id,
from_id_tablet = detail.from_id_tablet,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = 0,
UpdateTime = DateTime.Now
});
}
}
}
} }
+117 -85
View File
@@ -1,17 +1,21 @@
using System; using DocumentFormat.OpenXml.Drawing.Charts;
using Model;
using MyWeb;
using Newtonsoft.Json;
using PagedList;
using System;
using System.Activities.Expressions;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Diagnostics;
using System.IdentityModel.Metadata;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Web.Http; using System.Web.Http;
using PagedList;
using Newtonsoft.Json;
using System.Collections;
using static TreeView; using static TreeView;
using Model;
using System.IdentityModel.Metadata;
using MyWeb;
using DocumentFormat.OpenXml.Drawing.Charts;
// api/order // api/order
@@ -206,7 +210,7 @@ public class orderController : ApiController
string sortBy = "", bool sortDesc = false) string sortBy = "", bool sortDesc = false)
{ {
var qry = _db.pro_order.AsQueryable(); var qry = _db.pro_order.Include("activity").Include("activity.activity_check").AsQueryable();
//var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項 //var aIDt = _db.actItems.AsEnumerable().Where(f => f.subject.Contains(q.actItemTxt.Trim())).Select(f => f.num);//品項
@@ -221,7 +225,10 @@ public class orderController : ApiController
if (q.up_time1.HasValue) if (q.up_time1.HasValue)
qry = qry.Where(o => o.up_time >= q.up_time1.Value); qry = qry.Where(o => o.up_time >= q.up_time1.Value);
if (q.up_time2.HasValue) if (q.up_time2.HasValue)
qry = qry.Where(o => o.up_time < Convert.ToDateTime(q.up_time2.Value).AddDays(1)); {
var tmp_up_time2 = Convert.ToDateTime(q.up_time2.Value).AddDays(1);
qry = qry.Where(o => o.up_time < tmp_up_time2);
}
if (!string.IsNullOrEmpty(q.address)) if (!string.IsNullOrEmpty(q.address))
qry = qry.Where(o => o.address.Contains(q.address.Trim())); qry = qry.Where(o => o.address.Contains(q.address.Trim()));
if (!string.IsNullOrEmpty(q.subject)) if (!string.IsNullOrEmpty(q.subject))
@@ -291,6 +298,13 @@ public class orderController : ApiController
else else
qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : ""); qry = qry.OrderBy(o => o.activity != null ? o.activity.subject : "");
} }
else if(sortBy.Equals("status"))
{
if (sortDesc)
qry = qry.OrderByDescending(o => o.activity.activity_check.FirstOrDefault(a => o.activity_num == a.activity_num && o.f_num == a.f_num).status ?? 0);
else
qry = qry.OrderBy(o => o.activity.activity_check.FirstOrDefault(a => o.activity_num == a.activity_num && o.f_num == a.f_num).status ?? 0);
}
else else
qry = qry.OrderByDescending(o => o.reg_time); qry = qry.OrderByDescending(o => o.reg_time);
@@ -307,6 +321,7 @@ public class orderController : ApiController
keyin1 = x.keyin1, keyin1 = x.keyin1,
up_time = x.up_time, up_time = x.up_time,
keyin1_txt = Model.pro_order.keyin1_value_to_text(x.keyin1), keyin1_txt = Model.pro_order.keyin1_value_to_text(x.keyin1),
status = x.activity.activity_check.FirstOrDefault(a => x.activity_num == a.activity_num && x.f_num == a.f_num)?.status ?? 0,
}), }),
count = count count = count
}; };
@@ -338,7 +353,7 @@ public class orderController : ApiController
//var qry1 = _db.pro_order_detail.AsEnumerable(); //var qry1 = _db.pro_order_detail.AsEnumerable();
//qry1 = qry1.Where(o => o.order_no == order_no); //qry1 = qry1.Where(o => o.order_no == order_no);
//var qry1 = prod.pro_order_detail.AsEnumerable(); //var qry1 = prod.pro_order_detail.AsEnumerable();
var qry1 = prod.pro_order_detail.AsQueryable(); var qry1 = prod.pro_order_detail.AsQueryable().Include(o => o.pro_order.activity.activity_relating);
//if (!string.IsNullOrEmpty(q.subject)) //if (!string.IsNullOrEmpty(q.subject))
// qry = qry.Where(o => o.subject.Contains(q.subject)); // qry = qry.Where(o => o.subject.Contains(q.subject));
@@ -367,7 +382,7 @@ public class orderController : ApiController
qry1 = qry1.OrderByDescending(o => o.num); qry1 = qry1.OrderByDescending(o => o.num);
} }
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>(); var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
int i = 1; int i = 1;
@@ -377,82 +392,91 @@ public class orderController : ApiController
(List<pro_order_detail>)qry1_list.ToPagedList(page, pageSize); (List<pro_order_detail>)qry1_list.ToPagedList(page, pageSize);
var count = qry1_list.Count(); var count = qry1_list.Count();
var ret = new var ret = new
{ {
list = qry1_list.Select(x => new list = qry1_list.Select(x => {
{ var tmpActivityRelating = x.pro_order?.activity?.activity_relating?.Where(a => a.actItem_num == x.actItem_num).FirstOrDefault();
id = i++, return new
num = x.num,
order_no = x.order_no,
actitem_num_selected = new
{ {
text = x.actItem_num.HasValue ? x.actItem.subject : "", has_yang_limit = tmpActivityRelating?.has_yang_limit ?? false,
val = x.actItem_num.HasValue ? x.actItem_num.Value : 0, has_chao_limit = tmpActivityRelating?.has_chao_limit ?? false,
}, yang_limit_count = tmpActivityRelating?.yang_limit_count ?? 0,
parent_num = x.parent_num, chao_limit_count = tmpActivityRelating?.chao_limit_count ?? 0,
f_num_selected = new id = i++,
{ num = x.num,
text = x.f_num.HasValue ? x.follower.u_name : "", order_no = x.order_no,
val = x.f_num.HasValue ? x.f_num.Value : 0, actitem_num_selected = new
}, {
f_num_tablet = x.f_num_tablet, text = x.actItem_num.HasValue ? x.actItem.subject : "",
print_id = x.print_id, val = x.actItem_num.HasValue ? x.actItem_num.Value : 0,
address = x.address, },
due_date = x.due_date, parent_num = x.parent_num,
start_date = x.start_date, f_num_selected = new
extend_date = x.extend_date, {
from_id_selected = new text = x.f_num.HasValue ? x.follower.u_name : "",
{ val = x.f_num.HasValue ? x.f_num.Value : 0,
text = x.from_id.HasValue ? x.follower1.u_name : "", },
val = x.from_id.HasValue ? x.from_id : 0, f_num_tablet = x.f_num_tablet,
}, print_id = x.print_id,
from_id_tablet = x.from_id_tablet, address = x.address,
price = x.price ?? 0, due_date = x.due_date,
qty = x.qty ?? 0, start_date = x.start_date,
writeBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量 extend_date = x.extend_date,
notBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量 from_id_selected = new
//total = x.total.HasValue ? x.total.Value : 0, {
category = x.actItem?.category, text = x.from_id.HasValue ? x.follower1.u_name : "",
//pay = x.pay ?? 0, val = x.from_id.HasValue ? x.from_id : 0,
pay = x.pro_order_record.Select(c => c.price).Sum(), },
pay_date = x.pay_date, from_id_tablet = x.from_id_tablet,
keyin1_selected = new price = x.price ?? 0,
{ qty = x.qty ?? 0,
text = tdesc[x.keyin1.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1], writeBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量
val = x.keyin1, notBedQty = bedDt.Where(b => b.bed_order.o_detail_id.Value == x.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量
}, //total = x.total.HasValue ? x.total.Value : 0,
demo = x.demo, category = x.actItem?.category,
files = x.actItem?.actItem_files.Select(f => new //pay = x.pay ?? 0,
{ pay = x.pro_order_record.Select(c => c.price).Sum(),
num = f.file.num, pay_date = x.pay_date,
subject = f.file.subject, keyin1_selected = new
word = f.file.word, {
cuz_column = f.file.customize_data ?? "", //?? text = tdesc[x.keyin1.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1],
paperset = f.file.paperset ?? "", val = x.keyin1,
}), },
customize_data = x.customize_data ?? "", demo = x.demo,
customize_data_comb = new files = x.actItem?.actItem_files.Select(f => new
{ {
from_id_cuz_data = "", num = f.file.num,
activity_cuz_data = "", subject = f.file.subject,
actitem_cuz_data = "", word = f.file.word,
order_cuz_data = "", cuz_column = f.file.customize_data ?? "", //??
}, paperset = f.file.paperset ?? "",
printed_files = x.printed_files ?? "", }),
isPackage = (x.actItem.act_bom customize_data = x.customize_data ?? "",
.Any(ab => ab.package_num == null && ab.item_num != null) customize_data_comb = new
? 1 : 0), {
bom_order = (x.actItem.act_bom from_id_cuz_data = "",
.Any(ab => ab.package_num == null && ab.item_num != null) activity_cuz_data = "",
? x.num.ToString() actitem_cuz_data = "",
: (x.parent_num.ToString() + x.num.ToString()) order_cuz_data = "",
), },
//cash_record = x.pro_order_record.Select( c => new { printed_files = x.printed_files ?? "",
// c, isPackage = (x.actItem.act_bom
// //pay_kind = tdesc2[c.payment.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1], .Any(ab => ab.package_num == null && ab.item_num != null)
//}), ? 1 : 0),
bom_order = (x.actItem.act_bom
.Any(ab => ab.package_num == null && ab.item_num != null)
? x.num.ToString()
: (x.parent_num.ToString() + x.num.ToString())
),
//cash_record = x.pro_order_record.Select( c => new {
// c,
// //pay_kind = tdesc2[c.payment.HasValue && x.keyin1.Value > 0 ? x.keyin1.Value : 1],
//}),
}) };
})
.ToList() .ToList()
.OrderByDescending(x => (x.isPackage + (x.parent_num == null ? 0 : 1))) .OrderByDescending(x => (x.isPackage + (x.parent_num == null ? 0 : 1)))
//.ThenBy(x => (x.parent_num == null ? 1 : 2)) // Top-level items first //.ThenBy(x => (x.parent_num == null ? 1 : 2)) // Top-level items first
@@ -498,6 +522,10 @@ public class orderController : ApiController
text = ar.actItem.subject, text = ar.actItem.subject,
val = ar.actItem_num, val = ar.actItem_num,
}, },
has_yang_limit = ar.has_yang_limit ?? false,
has_chao_limit = ar.has_chao_limit ?? false,
yang_limit_count = ar.yang_limit_count ?? 0,
chao_limit_count = ar.chao_limit_count ?? 0,
parent_num = q.num, parent_num = q.num,
f_num_selected = new f_num_selected = new
{ {
@@ -578,6 +606,10 @@ public class orderController : ApiController
text = x.actItem.subject, text = x.actItem.subject,
val = x.actItem.num, val = x.actItem.num,
}, },
has_yang_limit = x.has_yang_limit,
has_chao_limit = x.has_chao_limit,
yang_limit_count = x.yang_limit_count,
chao_limit_count = x.chao_limit_count,
f_num_selected = new f_num_selected = new
{ {
text = "", text = "",
@@ -683,7 +715,7 @@ public class orderController : ApiController
.Where(q => q.num == item.num) .Where(q => q.num == item.num)
.FirstOrDefault();//修改 .FirstOrDefault();//修改
if (order != null) if (order != null)
{ {
order.actItem_num = (item.actItem_num.HasValue && item.actItem_num.Value > 0) order.actItem_num = (item.actItem_num.HasValue && item.actItem_num.Value > 0)
? item.actItem_num : null; ? item.actItem_num : null;
order.f_num = (item.f_num.HasValue && item.f_num.Value > 0) order.f_num = (item.f_num.HasValue && item.f_num.Value > 0)
@@ -16,6 +16,8 @@
<asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound"> <asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound">
<ItemTemplate> <ItemTemplate>
<a class="nav-link" href="<%#ResolveUrl(ValString(Eval("url"))) %>" <a class="nav-link" href="<%#ResolveUrl(ValString(Eval("url"))) %>"
onclick="sessionStorage.removeItem('member_list_cache'); sessionStorage.removeItem('member_query_params');
sessionStorage.removeItem('order_list_cache'); sessionStorage.removeItem('order_query_params');"
target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>"> target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>">
<%#Eval("title") %></a> <%#Eval("title") %></a>
</ItemTemplate> </ItemTemplate>
+216 -115
View File
@@ -7,19 +7,20 @@
<div class="mb-2 mb-sm-0"> <div class="mb-2 mb-sm-0">
<ul class="nav ps-0"> <ul class="nav ps-0">
<li class="nav-item pe-3"> <li class="nav-item pe-3">
<select class="form-select" v-model="search.kind" @change="btn_search"> <select class="form-select" v-model="search.kind" @change="btn_search" :disabled="isEditing">
<option value="">選擇分類</option> <option value="">選擇分類</option>
<option v-for="item in itemKindList" :value="item.num">{{item.kind}}</option> <option v-for="item in itemKindList" :value="item.num">{{item.kind}}</option>
</select> </select>
</li> </li>
<li class="nav-item pe-1"> <li class="nav-item pe-1">
<a href="item_reg.aspx" class="btn btn-primary"> <a href="item_reg.aspx" class="btn btn-primary" :class="{ 'disabled': isEditing }" >
<i class="mdi mdi-plus"></i>新增 <i class="mdi mdi-plus"></i>新增
</a> </a>
</li> </li>
<li class="nav-item pe-1">
<a @click="deleteAll" class="btn btn-outline-danger" title="刪除勾選的資料" ><i class="mdi mdi-trash-can"></i> 刪除勾選</a> <li class="nav-item pe-1">
</li> <a @click="deleteAll" class="btn btn-outline-danger" title="刪除勾選的資料" :class="{ 'disabled': isEditing }" ><i class="mdi mdi-trash-can"></i> 刪除勾選</a>
</li>
</ul> </ul>
<%-- <div class="input-group mb-3" data-search-control="search1" @click="search_show(search_dialog.controls.search1)"> <%-- <div class="input-group mb-3" data-search-control="search1" @click="search_show(search_dialog.controls.search1)">
<input class="form-control search-text" type="text" readonly <input class="form-control search-text" type="text" readonly
@@ -29,26 +30,31 @@
<i class="mdi mdi-view-list-outline"></i> <i class="mdi mdi-view-list-outline"></i>
</button> </button>
</div>--%> </div>--%>
</div> </div>
<div>
<div class="">
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton> <a v-if="!isEditing" @click="editClick" class="btn btn-outline-secondary" title="編輯排列順序"><i class="mdi mdi-swap-vertical"></i> 編輯排列順序</a>
<a v-else @click="editClick" class="btn btn-outline-secondary" title="完成編輯排列順序"><i class="mdi mdi-swap-vertical"></i> 完成編輯</a>
<div :style="isEditing ? 'pointer-events: none; opacity: 0.5;' : ''" style="display:inline-block;">
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click" ><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
</div> </div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server"> <asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.14.0/Sortable.min.js"></script>
<script> <script>
Vue.filter('timeString', function (value, myFormat) { Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss'); return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
}); });
let VueApp=new Vue({ let VueApp = new Vue({
el: '#app', el: '#app',
vuetify: new Vuetify(vuetify_options), vuetify: new Vuetify(vuetify_options),
data() { data() {
return { return {
isEditing: false,
options: { multiSort: false }, options: { multiSort: false },
data_table: { data_table: {
loading: true, loading: true,
@@ -63,20 +69,20 @@
{ text: '項目分類', value: 'kindsTxt' }, { text: '項目分類', value: 'kindsTxt' },
{ text: '類別', value: 'categoryTxt' }, { text: '類別', value: 'categoryTxt' },
{ text: '預設金額', value: 'price' }, { text: '預設金額', value: 'price' },
{ text: '庫存狀態', value: 'stock' }, { text: '庫存狀態', value: 'stock' },
{ text: '停用', value: 'status' }, { text: '停用', value: 'status' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' }, { text: '', value: 'slot_btn', sortable: false, align: 'end' },
], ],
footer:{ footer: {
showFirstLastPage: true, showFirstLastPage: true,
itemsPerPageOptions:[5,10,20,30], itemsPerPageOptions: [5, 10, 20, 30],
}, },
}, },
search: { search: {
kind: '', kind: '',
subject: '', subject: '',
selltime1:'', selltime1: '',
selltime2: '', selltime2: '',
uptime1: '', uptime1: '',
uptime2: '', uptime2: '',
@@ -98,7 +104,7 @@
{ id: 'kind', title: '品項分類', value: '' }, { id: 'kind', title: '品項分類', value: '' },
], ],
selected: {}, selected: {},
select(t,data) { select(t, data) {
data.search.kind = t.num; data.search.kind = t.num;
data.btn_search() data.btn_search()
console.log("select search1", t); console.log("select search1", t);
@@ -120,9 +126,9 @@
}, snackbar: { }, snackbar: {
show: false, show: false,
text: "", text: "",
}, itemKindList:{ }, itemKindList: {
num: 0, num: 0,
kind:'' kind: ''
} }
} }
}, },
@@ -149,9 +155,9 @@
if (!isNaN(actItemPage) && actItemPage !== 1) { if (!isNaN(actItemPage) && actItemPage !== 1) {
this.options.page = actItemPage; this.options.page = actItemPage;
} }
} }
}, },
methods: { methods: {
initKindList() { initKindList() {
axios axios
//.get(HTTP_HOST + 'api/activity_kind') //.get(HTTP_HOST + 'api/activity_kind')
@@ -174,26 +180,45 @@
}, },
getDefault(clearpage = false) { getDefault(clearpage = false) {
const { sortBy, sortDesc, page, itemsPerPage } = this.options if (this.isEditing) {
const params = { const { sortBy, sortDesc, page, itemsPerPage } = this.options
sortBy: sortBy[0], sortDesc: sortDesc[0], const params = {
page: clearpage ? '1' :page, pageSize: itemsPerPage sortBy: "sort_order", sortDesc: sortDesc[0],
}; page: clearpage ? '1' : page, pageSize: 0
this.data_table.loading = true };
axios this.data_table.loading = true
.post(HTTP_HOST + 'api/activity/GetItemList', this.search, { params: params }) axios
.then(response => { .post(HTTP_HOST + 'api/activity/GetItemList', this.search, { params: params })
this.data_table.list = response.data.list .then(response => {
this.data_table.count = response.data.count; this.data_table.list = response.data.list
this.data_table.loading = false this.data_table.count = response.data.count;
}) this.data_table.loading = false
.catch(error => console.log(error)) })
}, .catch(error => console.log(error))
editItem(item) { }
console.log("edit", item); else {
const { sortBy, sortDesc, page, itemsPerPage } = this.options
const params = {
sortBy: sortBy[0], sortDesc: sortDesc[0],
page: clearpage ? '1' : page, pageSize: itemsPerPage
};
this.data_table.loading = true
axios
.post(HTTP_HOST + 'api/activity/GetItemList', this.search, { params: params })
.then(response => {
this.data_table.list = response.data.list
this.data_table.count = response.data.count;
this.data_table.loading = false
})
.catch(error => console.log(error))
}
}, },
deleteItem(item) { editItem(item) {
console.log("edit", item);
},
deleteItem(item) {
if (confirm('是否確定刪除此筆資料?')) { if (confirm('是否確定刪除此筆資料?')) {
const index = this.data_table.list.indexOf(item) const index = this.data_table.list.indexOf(item)
if (index != -1) { if (index != -1) {
@@ -203,7 +228,7 @@
this.getDefault(); this.getDefault();
}) })
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
} }
}, },
deleteAll() { deleteAll() {
@@ -225,100 +250,155 @@
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
}, },
btn_search() { editClick() {
if (this.isEditing) {
this.isEditing = false;
const sortedIds = this.data_table.list.map(item => item.num);
axios.post(HTTP_HOST + 'api/activity/SaveItemList', { ids: sortedIds })
.then(response => {
this.isEditing = false;
this.getDefault();
})
.catch(error => {
alert("儲存排序失敗:" + error);
})
.finally(() => {
this.data_table.loading = false;
});
}
else {
this.isEditing = true;
this.getDefault()
}
},
btn_search() {
this.getDefault(true) this.getDefault(true)
}, },
btn_all() { btn_all() {
clearObjProps(this.search); clearObjProps(this.search);
this.btn_search() this.btn_search()
}, },
//=== //===
search_show(curr) { search_show(curr) {
//console.log("btn_click:", curr, curr.api_url); //console.log("btn_click:", curr, curr.api_url);
this.search_dialog.current = curr; this.search_dialog.current = curr;
this.search_clear() this.search_clear()
//this.search_get()//清除完自動會重抓, 故取消 //this.search_get()//清除完自動會重抓, 故取消
this.search_dialog.show = true; this.search_dialog.show = true;
}, },
search_clear() { search_clear() {
if (!this.search_dialog.current.keys) return; if (!this.search_dialog.current.keys) return;
this.search_dialog.current.keys.forEach((t, i) => { t.value = '' }) this.search_dialog.current.keys.forEach((t, i) => { t.value = '' })
this.search_get() this.search_get()
}, },
search_get() { search_get() {
if (!this.search_dialog.current.keys) return; if (!this.search_dialog.current.keys) return;
let api_url = this.search_dialog.current.api_url; let api_url = this.search_dialog.current.api_url;
let keys = this.search_dialog.current.keys; let keys = this.search_dialog.current.keys;
//const { page, itemsPerPage } = this.options //const { page, itemsPerPage } = this.options
//const { sortBy, sortDesc, page, itemsPerPage } = this.options //const { sortBy, sortDesc, page, itemsPerPage } = this.options
this.search_dialog.page = this.options.page ?? 1 this.search_dialog.page = this.options.page ?? 1
let params = { page: this.search_dialog.page, pageSize: 10 };//url params let params = { page: this.search_dialog.page, pageSize: 10 };//url params
var search = {};//post body var search = {};//post body
keys.forEach((t, i) => { keys.forEach((t, i) => {
search[t.id] = t.value; search[t.id] = t.value;
}); });
console.log("search_get", api_url, search, params, this.options); console.log("search_get", api_url, search, params, this.options);
this.search_dialog.loading = true this.search_dialog.loading = true
axios.post(api_url, search, { params: params }) axios.post(api_url, search, { params: params })
.then(response => { .then(response => {
this.search_dialog.list = response.data.list this.search_dialog.list = response.data.list
this.search_dialog.count = response.data.count this.search_dialog.count = response.data.count
this.search_dialog.loading = false this.search_dialog.loading = false
})
.catch(error => {
console.log(error)
this.search_dialog.list = []
this.search_dialog.count = 0
this.search_dialog.loading = false
this.snackbar.text = "錯誤:" + error
this.snackbar.show = true
})
},
search_headers() {
if (!this.search_dialog.current.columns) return;
r = [];
this.search_dialog.current.columns.forEach((t, i) => {
r.push({
text: t.title,
align: 'start',
sortable: false,
value: t.id,
})
}) })
.catch(error => { return r
console.log(error) },
this.search_dialog.list = [] search_select(row) {
this.search_dialog.count = 0 let curr = this.search_dialog.current;
this.search_dialog.loading = false let target = $(`[data-search-control=${curr.id}]`);
this.snackbar.text = "錯誤:" + error curr.selected = row;
this.snackbar.show = true target.children("input.search-text").val(curr.selected[curr.text_prop])//text
}) target.children("input:hidden").val(curr.selected[curr.value_prop])//value
}, if (curr.select instanceof Function) {
search_headers() { curr.select(row, this);
if (!this.search_dialog.current.columns) return; }
r = []; this.search_dialog.show = false;
this.search_dialog.current.columns.forEach((t, i) => { },
r.push({ saveOrder(event) {
text: t.title, const movedItem = this.data_table.list.splice(event.oldIndex, 1)[0];
align: 'start', this.data_table.list.splice(event.newIndex, 0, movedItem);
sortable: false, },
value: t.id,
})
})
return r
},
search_select(row) {
let curr = this.search_dialog.current;
let target = $(`[data-search-control=${curr.id}]`);
curr.selected = row;
target.children("input.search-text").val(curr.selected[curr.text_prop])//text
target.children("input:hidden").val(curr.selected[curr.value_prop])//value
if (curr.select instanceof Function) {
curr.select(row,this);
}
this.search_dialog.show = false;
},
}, },
computed: { computed: {
pageCount() { pageCount() {
return Math.ceil(this.data_table.count / this.data_table.pageSize) return Math.ceil(this.data_table.count / this.data_table.pageSize)
}, },
computedHeaders() {
return this.data_table.header.map(h => {
if (h.value === 'slot_btn') {
return { ...h, sortable: false };
}
return {
...h,
sortable: this.isEditing ? false : (h.sortable !== false)
};
});
},
}, },
filters: { filters: {
currency: function (value) { currency: function (value) {
return value == null || value == "" ? "" : return value == null || value == "" ? "" :
('$' + parseFloat(value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").replace(".00", "")); ('$' + parseFloat(value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").replace(".00", ""));
}, },
} },
directives: {
sortableDataTable: {
bind(el, binding, vnode) {
const options = {
animation: 150,
onUpdate: function (event) {
vnode.child.$emit('sorted', event)
}
}
Sortable.create(el.getElementsByTagName('tbody')[0], options)
}
}
},
}) })
</script> </script>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" /> <uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid"> <div id="content" class="container-fluid">
<v-data-table <v-data-table
v-sortable-data-table
@sorted="saveOrder"
:headers="computedHeaders"
v-model="data_table.selected" v-model="data_table.selected"
:items="data_table.list" :items="data_table.list"
:search-props="search" :search-props="search"
@@ -332,8 +412,29 @@
show-select show-select
hide-default-footer hide-default-footer
:page.sync="data_table.page" :page.sync="data_table.page"
:items-per-page.sync="data_table.pageSize" :items-per-page.sync= "isEditing ? -1 :data_table.pageSize"
class="elevation-1"> class="elevation-1">
<template v-slot:header.data-table-select="{ on, props }">
<v-simple-checkbox
v-if="!isEditing"
v-bind="props"
v-on="on"
></v-simple-checkbox>
<v-icon v-else small>mdi-swap-vertical</v-icon>
</template>
<template v-slot:item.data-table-select="{ item, isSelected, select }">
<v-simple-checkbox
v-if="!isEditing"
:value="isSelected"
@input="select($event)"
></v-simple-checkbox>
<div v-else class="handle" style="cursor: grab;">
<v-icon color="grey darken-1">mdi-drag-vertical</v-icon>
</div>
</template>
<template #item.price="{ item }" > <template #item.price="{ item }" >
{{item.price | currency }} {{item.price | currency }}
</template> </template>
@@ -352,12 +453,12 @@
</template> </template>
<template #item.slot_btn="{ item }"> <template #item.slot_btn="{ item }" >
<a :href="'item_reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a> <a v-if="!isEditing" :href="'item_reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a>
<a @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></i>刪除</a> <a v-if="!isEditing" @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></i>刪除</a>
</template> </template>
</v-data-table> </v-data-table>
<v-container> <v-container v-if="!isEditing">
<v-row class="align-baseline" wrap> <v-row class="align-baseline" wrap>
<v-col cols="12" md="9"> <v-col cols="12" md="9">
<v-pagination <v-pagination
+1 -1
View File
@@ -148,7 +148,7 @@ public partial class admin_activity_index2 : MyWeb.config
} }
var tdesc = publicFun.enum_desc<Model.activity.category>(); var tdesc = publicFun.enum_desc<Model.activity.category>();
qry = qry.OrderByDescending(o => o.num); qry = qry.OrderByDescending(o => o.sort_order);
var list = qry.ToList(); var list = qry.ToList();
if (list.Count > 0) if (list.Count > 0)
{ {
+1 -4
View File
@@ -604,10 +604,7 @@
</div> </div>
</div> </div>
<div class="row mb-1 label-sm-right"> <div class="row mb-1 label-sm-right">
<label class="col-sm-2 col-form-label">料號</label>
<div class="col-sm-4">
<asp:TextBox ID="PARTNO" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入料號"></asp:TextBox>
</div>
<label class="col-sm-2 col-form-label">項目名稱 *</label> <label class="col-sm-2 col-form-label">項目名稱 *</label>
<div class="col-sm-4"> <div class="col-sm-4">
<asp:TextBox ID="subject" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入品項名稱"></asp:TextBox> <asp:TextBox ID="subject" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入品項名稱"></asp:TextBox>
+3 -4
View File
@@ -42,7 +42,6 @@ public partial class admin_activity_item_reg : MyWeb.config
BuildKind(); BuildKind();
subject.Text = prod.subject; subject.Text = prod.subject;
print_init.Text = prod.print_init; print_init.Text = prod.print_init;
PARTNO.Text = prod.partno;
//kind.SelectedValue = prod.kind.ToString(); //kind.SelectedValue = prod.kind.ToString();
if (prod.kind.HasValue) if (prod.kind.HasValue)
{ {
@@ -118,9 +117,9 @@ public partial class admin_activity_item_reg : MyWeb.config
L_msg.Text = ""; L_msg.Text = "";
Model.actItem actItem = new Model.actItem();//新增 Model.actItem actItem = new Model.actItem();//新增
int maxSort = _db.actItems.Max(x => (int?)x.sort_order) ?? 0;
actItem.subject = subject.Text; actItem.subject = subject.Text;
actItem.print_init = print_init.Text; actItem.print_init = print_init.Text;
actItem.partno = PARTNO.Text;
//if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; } //if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; }
if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; } if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; }
if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; } if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; }
@@ -131,6 +130,7 @@ public partial class admin_activity_item_reg : MyWeb.config
actItem.is_reconcile = is_reconcile_item.Checked ? "Y" : "N"; actItem.is_reconcile = is_reconcile_item.Checked ? "Y" : "N";
actItem.demo = demo.Text; actItem.demo = demo.Text;
actItem.customize_data = customize_data.Text; actItem.customize_data = customize_data.Text;
actItem.sort_order = maxSort + 1;
_db.actItems.Add(actItem); _db.actItems.Add(actItem);
_db.SaveChanges(); _db.SaveChanges();
@@ -167,7 +167,6 @@ public partial class admin_activity_item_reg : MyWeb.config
{ {
actItem.subject = subject.Text; actItem.subject = subject.Text;
actItem.print_init = print_init.Text; actItem.print_init = print_init.Text;
actItem.partno = PARTNO.Text;
//if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; } //if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; }
if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; } if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; }
if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; } if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; }
+224 -3
View File
@@ -165,6 +165,8 @@
{ text: '* 品項名稱', value: 'act_item_selected.text', sortable: false }, { text: '* 品項名稱', value: 'act_item_selected.text', sortable: false },
{ text: '預設金額', value: 'price', sortable: false }, { text: '預設金額', value: 'price', sortable: false },
{ text: '數量', value: 'qty', sortable: false }, { text: '數量', value: 'qty', sortable: false },
{ text: '陽上/祈福人數限制', value: 'limit_yang', sortable: false },
{ text: '超渡人數限制', value: 'limit_chao', sortable: false },
{ text: '', value: 'actions', sortable: false, width: "200px" }, { text: '', value: 'actions', sortable: false, width: "200px" },
], ],
footersDetail: { footersDetail: {
@@ -191,6 +193,10 @@
price: 0, price: 0,
qty: 0, qty: 0,
files: [], files: [],
has_yang_limit: false,
has_chao_limit: false,
yang_limit_count: 0,
chao_limit_count: 0,
}, },
defaultItem: { defaultItem: {
id: 0, id: 0,
@@ -203,6 +209,10 @@
price: 0, price: 0,
qty: 0, qty: 0,
files: [], files: [],
has_yang_limit: false,
has_chao_limit: false,
yang_limit_count: 0,
chao_limit_count: 0,
}, },
//列印 //列印
data_table: { data_table: {
@@ -267,10 +277,25 @@
order_dialog: { order_dialog: {
show: false, show: false,
}, },
unfilled_list: {
loading: false,
search: '',
headers: [
{ text: '訂單編號', value: 'order_no' },
{ text: '信眾編號', value: 'f_number' },
{ text: '信眾姓名', value: 'u_name' },
{ text: '聯絡電話', value: 'phone' },
{ text: '建立日期', value: 'order_date' },
],
items: [
{ order_no: "D", member_name: "S", order_date:"2025-12-07"}
],
},
} }
}, },
mounted() { mounted() {
this.search_dialog.current = this.search_dialog.controls.search1 this.search_dialog.current = this.search_dialog.controls.search1
this.loadUnfilledList();
//console.log("mounted"); //console.log("mounted");
}, },
watch: { watch: {
@@ -434,9 +459,8 @@
this.close(); this.close();
}, },
spliceNullData() { spliceNullData() {
//if new data ,then splice it //if new data ,then splice it
if (this.editedItem.num == 0) { if (this.editedItem.num == 0) {
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) { for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
if (this.desserts[i].id == this.editedItem.id) { if (this.desserts[i].id == this.editedItem.id) {
this.desserts.splice(i, 1); break; this.desserts.splice(i, 1); break;
@@ -482,6 +506,10 @@
actItem_num: this.editedItem.act_item_selected.val, actItem_num: this.editedItem.act_item_selected.val,
price: this.editedItem.price, price: this.editedItem.price,
qty: this.editedItem.qty, qty: this.editedItem.qty,
has_yang_limit: this.editedItem.has_yang_limit,
has_chao_limit: this.editedItem.has_chao_limit,
yang_limit_count: this.editedItem.yang_limit_count,
chao_limit_count: this.editedItem.chao_limit_count,
} }
axios axios
.post(HTTP_HOST + 'api/activity/SaveRelatingData', pro_order_detail) .post(HTTP_HOST + 'api/activity/SaveRelatingData', pro_order_detail)
@@ -808,6 +836,113 @@
const _date = $('#<%= startDate_solar.ClientID%>').val(); const _date = $('#<%= startDate_solar.ClientID%>').val();
return _subject + " " + _date; return _subject + " " + _date;
}, },
loadUnfilledList() {
if (!this.this_id) return;
this.unfilled_list.loading = true;
axios.get(HTTP_HOST + 'api/activity/GetUnfilledOrdersByActivity/' + this.this_id)
.then(response => {
this.unfilled_list.items = response.data.list || [];
})
.catch(error => {
console.log(error);
this.snackbar.text = "名單載入失敗:" + error;
this.snackbar.show = true;
})
.finally(() => {
this.unfilled_list.loading = false;
});
},
async printUnfilledList() {
if (!this.this_id) return;
try {
const response = await axios.get(
HTTP_HOST + `api/activity/GetUnfilledOrdersByActivity/${this.this_id}`,
{ params: { page: 1, pageSize: 99999 } }
);
const allItems = response.data.list || [];
if (allItems.length === 0) {
this.snackbar.text = "目前沒有未填寫品項的資料可供列印!";
this.snackbar.show = true;
return;
}
const activityTitle = this.titleword();
const rows = allItems.map(item => `
<tr>
<td>${item.order_no}</td>
<td>${item.f_number || ''}</td>
<td>${item.u_name}</td>
<td>${item.phone}</td>
<td>${item.order_date}</td>
</tr>
`).join('');
const win = window.open('', '_blank');
win.document.write(`
<html>
<head>
<title>未填寫品項名單 - ${activityTitle}</title>
<style>
body { font-family: "Microsoft JhengHei", Arial, sans-serif; padding: 20px; color: #000; }
.header-container { text-align: center; margin-bottom: 30px; }
h2 { margin-bottom: 5px; font-size: 24px; }
h4 { margin-top: 0; color: #333; font-weight: normal; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #000; padding: 10px 8px; text-align: left; font-size: 14px; }
th { background-color: #eee; font-weight: bold; }
.text-center { text-align: center; }
@media print {
@page { margin: 1.5cm; }
button { display: none; }
}
</style>
</head>
<body>
<div class="header-container">
<h2>尚未報名品項之信眾清單</h2>
<h4>活動名稱:${activityTitle}</h4>
</div>
<table>
<thead>
<tr>
<th width="18%">訂單編號</th>
<th width="15%">信眾編號</th>
<th width="20%">信眾姓名</th>
<th width="20%">聯絡電話</th>
<th width="27%">建單日期</th>
</tr>
</thead>
<tbody>${rows}</tbody>
</table>
<div style="margin-top: 20px; text-align: right; font-size: 12px;">
列印時間:${new Date().toLocaleString()}
</div>
</body>
</html>
`);
win.document.close();
// 確保內容載入完成後再呼叫列印
setTimeout(() => {
win.print();
win.close();
}, 300);
} catch (error) {
console.error("列印出錯:", error);
this.snackbar.text = "讀取列印資料失敗:" + error;
this.snackbar.show = true;
}
}
}, },
computed: { computed: {
}, },
@@ -827,7 +962,7 @@
<div class=""> <div class="">
<asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary" /> <asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary" />
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" /> <asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
<asp:Button ID="goback" runat="server" Text="回列表" Visible="false" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" /> <asp:Button ID="goback" runat="server" Text="取消" Visible="true" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
@@ -847,6 +982,10 @@
<button v-if="this_id!=''" class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3" <button v-if="this_id!=''" class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3"
type="button" role="tab" aria-controls="profile" aria-selected="false"> type="button" role="tab" aria-controls="profile" aria-selected="false">
備品項目</button> 備品項目</button>
<button v-if="this_id!=''" class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4"
type="button" role="tab" aria-controls="profile" aria-selected="false" @click="loadUnfilledList">
未填寫名單
</button>
</div> </div>
</nav> </nav>
</div> </div>
@@ -1019,6 +1158,54 @@
<v-text-field v-model="editedItem.qty" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field> <v-text-field v-model="editedItem.qty" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field>
<span v-else>{{item.qty}}</span> <span v-else>{{item.qty}}</span>
</template> </template>
<template v-slot:item.limit_yang="{ item }">
<div class="d-flex align-center">
<v-text-field v-model="editedItem.yang_limit_count" v-if="item.id === editedItem.id"
type="number"
dense
:hide-details="true"
single-line
:disabled="!editedItem.has_yang_limit"
suffix="人" >
</v-text-field>
<v-checkbox v-if="item.id === editedItem.id"
v-model="editedItem.has_yang_limit"
label="不限"
hide-details
class="ml-2 mt-0"
:true-value="false"
:false-value="true"
:disabled="item.id !== editedItem.id">
</v-checkbox>
<span v-if="item.id !== editedItem.id && !item.has_yang_limit">不限</span>
<span v-if="item.id !== editedItem.id && item.has_yang_limit">{{item.yang_limit_count}} 人</span>
</div>
</template>
<template v-slot:item.limit_chao="{ item }">
<div class="d-flex align-center">
<v-text-field v-model="editedItem.chao_limit_count" v-if="item.id === editedItem.id"
type="number"
dense
:hide-details="true"
single-line
:disabled="!editedItem.has_chao_limit"
suffix="人" >
</v-text-field>
<v-checkbox v-if="item.id === editedItem.id"
v-model="editedItem.has_chao_limit"
label="不限"
hide-details
class="ml-2 mt-0"
:true-value="false"
:false-value="true"
:disabled="item.id !== editedItem.id">
</v-checkbox>
<span v-if="item.id !== editedItem.id && !item.has_chao_limit">不限</span>
<span v-if="item.id !== editedItem.id && item.has_chao_limit">{{item.chao_limit_count}} 人</span>
</div>
</template>
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<template v-if="item.id === editedItem.id"> <template v-if="item.id === editedItem.id">
<v-icon color="red" class="mr-2" @click="cancel"> <v-icon color="red" class="mr-2" @click="cancel">
@@ -1128,6 +1315,40 @@
</div> </div>
<div class="tab-pane fade" id="sec2-page4" role="tabpanel" aria-labelledby="sec2-tab4" v-if="this_id!=''">
<v-card class="mx-auto" outlined id="print-unfilled-area">
<v-data-table
:headers="unfilled_list.headers"
:items="unfilled_list.items"
:loading="unfilled_list.loading"
:search="unfilled_list.search"
class="elevation-1"
fixed-header
height="350px">
<template v-slot:top>
<v-toolbar flat color="white" class="d-print-none">
<div class="d-flex w-100">
<v-text-field
v-model="unfilled_list.search"
append-icon="mdi-magnify"
label="搜尋姓名或訂單號"
dense outlined single-line hide-details>
</v-text-field>
<v-btn color="primary" class="ml-2 white--text" @click="printUnfilledList">
<v-icon left>mdi-printer</v-icon>列印所有名單
</v-btn>
</div>
</v-toolbar>
</template>
<template v-slot:item.status="{ item }">
<v-chip small color="error">未選品項</v-chip>
</template>
</v-data-table>
</v-card>
</div>
</div> </div>
</asp:Panel> </asp:Panel>
</div> </div>
+113 -3
View File
@@ -235,6 +235,36 @@ public partial class admin_activity_reg : MyWeb.config
#endregion #endregion
#region #region
protected string createOrderNumber()
{
Application.Lock();
string order_no = "AA" + DateTime.Now.ToString("yyMMdd");
var qry = _db.companies.AsQueryable();
//var prod = qry.Where(q => q.last_order_no.Contains(order_no)).FirstOrDefault();
var prod = qry.Where(q => q.num == 1).FirstOrDefault();
if (prod != null)
{
if (!isStrNull(prod.last_order_no) && prod.last_order_no.Contains(order_no))
{
int tmp = Convert.ToInt32(prod.last_order_no.Replace(order_no, "")) + 1;
order_no = order_no + tmp.ToString("0000");
}
else
{
order_no = order_no + "0001";
}
prod.last_order_no = order_no;
_db.SaveChanges();
}
else
order_no = "";
Application.UnLock();
return order_no;
}
protected void add_Click(object sender, EventArgs e) protected void add_Click(object sender, EventArgs e)
{ {
@@ -290,9 +320,10 @@ public partial class admin_activity_reg : MyWeb.config
int _id = activity.num; int _id = activity.num;
if (_id > 0) if (_id > 0)
{ {
RunAutoEnroll(_id);
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, subject.Text); admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, subject.Text);
Response.Redirect("index.aspx"); Response.Redirect("index.aspx");
} }
else else
@@ -367,6 +398,8 @@ public partial class admin_activity_reg : MyWeb.config
activity.category_kind = Val(category_kind.Value); activity.category_kind = Val(category_kind.Value);
_db.SaveChanges(); _db.SaveChanges();
RunAutoEnroll(activity.num);
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text); admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text);
} }
@@ -386,8 +419,85 @@ public partial class admin_activity_reg : MyWeb.config
} }
} }
private void RunAutoEnroll(int activityNum)
{
var activity = _db.activities.FirstOrDefault(a => a.num == activityNum);
if (activity == null || !activity.startDate_solar.HasValue) return;
DateTime actDate = activity.startDate_solar.Value;
var validConfigs = _db.auto_enroll
.Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
.ToList();
foreach (var config in validConfigs)
{
if (_db.pro_order.Any(o => o.activity_num == activity.num && o.f_num == config.f_num))
continue;
var follower = _db.followers.FirstOrDefault(f => f.num == config.f_num);
if (follower == null) continue;
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
Model.pro_order proOrder = new Model.pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = follower.num,
au_num = config.num,
phone = !string.IsNullOrEmpty(follower.cellphone) ? follower.cellphone : (follower.phone ?? ""),
activity_num = activity.num,
address = config.receipt_address ?? "",
receipt_title = config.receipt_title ?? "",
demo = "",
customize_data = ""
};
_db.pro_order.Add(proOrder);
CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
}
_db.SaveChanges();
}
private void CopyLatestOrderDetails(string newOrderNo, int f_num, int activityKind)
{
var latestOrder = _db.pro_order
.Where(o => o.f_num == f_num && o.activity.kind == activityKind && _db.pro_order_detail.Any(d => d.order_no == o.order_no))
.OrderByDescending(o => o.order_no)
.FirstOrDefault();
if (latestOrder != null)
{
var prevDetails = _db.pro_order_detail.Where(d => d.order_no == latestOrder.order_no).ToList();
foreach (var detail in prevDetails)
{
Model.pro_order_detail newDetail = new Model.pro_order_detail
{
order_no = newOrderNo,
actItem_num = detail.actItem_num,
parent_num = detail.parent_num,
print_id = detail.print_id,
f_num = detail.f_num,
f_num_tablet = detail.f_num_tablet,
address = detail.address,
from_id = detail.from_id,
from_id_tablet = detail.from_id_tablet,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = 0,
UpdateTime = DateTime.Now
};
_db.pro_order_detail.Add(newDetail);
}
}
}
#endregion #endregion
} }
+1 -1
View File
@@ -260,7 +260,7 @@ public partial class admin_follower_import : MyWeb.config
follower.introducer = ValString(sheet.Cells[currentRow, 17].Text.Trim()); follower.introducer = ValString(sheet.Cells[currentRow, 17].Text.Trim());
//檢查國籍代碼是否存在 //檢查國籍代碼是否存在
var country = _country.Where(x => x.name_zh == ValString(sheet.Cells[currentRow, 18].Text.Trim())).FirstOrDefault(); var country = _country.Where(x => x.name_zh == ValString(sheet.Cells[currentRow, 18].Text.Trim())).FirstOrDefault();
if(country != null) if(country != null)
{ {
//follower.country = ValString(sheet.Cells[currentRow, 18].Text.Trim()); //follower.country = ValString(sheet.Cells[currentRow, 18].Text.Trim());
+146 -20
View File
@@ -13,10 +13,12 @@
<a @click="print_dialog.show=true" class="btn btn-outline-primary btn-print" target="_blank"> <a @click="print_dialog.show=true" class="btn btn-outline-primary btn-print" target="_blank">
<i class="mdi mdi-printer"></i>列印管理報表 <i class="mdi mdi-printer"></i>列印管理報表
</a> </a>
<a @click="goPrint" class="btn btn-outline-primary btn-print" target="_blank"> <a @click="goPrint" class="btn btn-outline-primary btn-print" :class="{ 'disabled': data_table.list.length === 0 }" target="_blank">
<i class="mdi mdi-printer"></i>列印查詢資料 <i class="mdi mdi-printer"></i>列印查詢資料
</a> </a>
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton> <div :style="data_table.list.length === 0 ? 'pointer-events: none; opacity: 0.5;' : ''" style="display:inline-block;">
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="export_Click"><span class="fa-solid fa-file-excel"></span> 匯出查詢資料(Excel</asp:LinkButton>
</div>
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server"> <asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
@@ -24,11 +26,13 @@
Vue.filter('timeString', function (value, myFormat) { Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss'); return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
}); });
let VueApp=new Vue({ let VueApp = new Vue({
el: '#app', el: '#app',
vuetify: new Vuetify(vuetify_options), vuetify: new Vuetify(vuetify_options),
data() { data() {
return { return {
isSearched: false,
print_error_msg: '',
options: { multiSort: false }, options: { multiSort: false },
search_options: { multiSort: false }, search_options: { multiSort: false },
data_table: { data_table: {
@@ -38,10 +42,10 @@
singleSelect: false, singleSelect: false,
count: 0, count: 0,
page: 1, page: 1,
pageSize: 10, pageSize: 10,
header: [ header: [
{ text: '信眾編號', value: 'f_number', align: 'start' }, { text: '信眾編號', value: 'f_number', align: 'start' },
{ text: '信眾姓名', value: 'u_name'}, { text: '信眾姓名', value: 'u_name' },
{ text: '身分別', value: 'identity_type_desc' }, { text: '身分別', value: 'identity_type_desc' },
{ text: '性別', value: 'sex' }, { text: '性別', value: 'sex' },
{ text: '生日', value: 'birthday' }, { text: '生日', value: 'birthday' },
@@ -49,9 +53,9 @@
{ text: '', value: 'slot', sortable: false }, { text: '', value: 'slot', sortable: false },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' }, { text: '', value: 'slot_btn', sortable: false, align: 'end' },
], ],
footer:{ footer: {
showFirstLastPage: true, showFirstLastPage: true,
pageSizeOptions:[5,10,20,30], pageSizeOptions: [5, 10, 20, 30],
}, },
}, },
search: { search: {
@@ -60,7 +64,7 @@
sex: '', sex: '',
//birthday: new Date().toISOString().split('T')[0], //birthday: new Date().toISOString().split('T')[0],
//birthday2: new Date().toISOString().split('T')[0] //birthday2: new Date().toISOString().split('T')[0]
birthday:'', birthday: '',
birthday2: '', birthday2: '',
address: '', address: '',
country: '', country: '',
@@ -69,14 +73,14 @@
/*注意這邊的參數不能跟下方print_search重複*/ /*注意這邊的參數不能跟下方print_search重複*/
}, },
//列印管理報表 //列印管理報表
print_conditions:'yy', print_conditions: 'yy',
print_search: { print_search: {
year: '', year: '',
month: '', month: '',
season: '', season: '',
}, },
select_items: { select_items: {
month: [{ month: [{
text: "請選擇", text: "請選擇",
val: 0 val: 0
},], },],
@@ -126,13 +130,18 @@
itemsPerPageText: '', itemsPerPageText: '',
}, },
}, },
} }
}, },
watch: { watch: {
options: { options: {
handler() { handler() {
this.getList() if (this.isSearched) {
this.getList()
}
else {
this.data_table.loading = false;
}
}, },
deep: true, deep: true,
}, },
@@ -141,23 +150,101 @@
this.search_get() this.search_get()
}, },
deep: true, deep: true,
}, }
}, mounted() { }, mounted() {
const printResult = document.getElementById('<%= hid_err_msg.ClientID %>').value;
document.getElementById('<%= hid_err_msg.ClientID %>').value = '';
window._printResult = printResult
this.search_dialog.current = this.search_dialog.controls.search1 ///default this.search_dialog.current = this.search_dialog.controls.search1 ///default
this.initPrintSearch(); this.initPrintSearch();
const navEntries = performance.getEntriesByType("navigation"); const navEntries = performance.getEntriesByType("navigation");
const isReload = navEntries.length > 0 && navEntries[0].type === "reload"; const isReload = navEntries.length > 0 && navEntries[0].type === "reload";
const url = new URL(window.location.href);
let params = url.searchParams;
if (params.get('dirty') === '1') { // 資料有更新時執行 getlist
this.search = JSON.parse(sessionStorage.getItem("member_query_params"));
this.getList();
params.delete('dirty');
window.history.replaceState({}, '', url.pathname + url.search);
}
if (isReload) { if (isReload) {
sessionStorage.removeItem("followerpage"); sessionStorage.removeItem("followerpage");
sessionStorage.removeItem("member_list_cache");
sessionStorage.removeItem("member_query_params");
}
else if ("<%=lastAddedID%>" !== "") {
const newQuery = { f_number: '<%=lastAddedID%>' };
sessionStorage.setItem('member_query_params', JSON.stringify(newQuery));
this.search = newQuery;
this.isSearched = true;
} }
else { else {
const savedPage = parseInt(sessionStorage.getItem('followerpage')); const savedPage = parseInt(sessionStorage.getItem('followerpage'));
const savedData = sessionStorage.getItem("member_list_cache");
const savedQuery = JSON.parse(sessionStorage.getItem("member_query_params"));
if (savedQuery) {
this.search = savedQuery;
this.isSearched = true;
}
if (savedPage) { if (savedPage) {
this.options.page = savedPage; this.options.page = savedPage;
} }
if (savedData && savedData !== "undefined") {
this.data_table = JSON.parse(savedData);
this.isSearched = true;
}
} }
if (printResult === 'nodata' || printResult === 'success') {
this.$nextTick(() => {
this.print_search.year = parseInt(document.getElementById('<%= hid_print_year.ClientID %>').value) || this.print_search.year;
this.print_search.month = parseInt(document.getElementById('<%= hid_print_month.ClientID %>').value) || this.print_search.month;
this.print_search.season = parseInt(document.getElementById('<%= hid_print_season.ClientID %>').value) || this.print_search.season;
this.print_conditions = document.getElementById('<%= hid_print_mode.ClientID %>').value || 'yy';
this.print_dialog.show = true;
if (printResult === 'nodata') {
this.print_error_msg = "查無資料,請重新選擇區間";
}
});
}
this.$nextTick(() => {
setTimeout(() => {
// 清空 URL
const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
window.history.replaceState({}, '', cleanUrl);
}, 100);
});
}, },
methods: { methods: {
triggerManagementExport(mode) {
this.print_dialog.show = false;
this.print_error_msg = "";
if (this.print_search.year == '') {
msgbox('請輸入年份');
return;
}
document.getElementById('<%= hid_print_mode.ClientID %>').value = this.print_conditions;
document.getElementById('<%= hid_print_year.ClientID %>').value = this.print_search.year;
if (this.print_conditions == 'mm') {
document.getElementById('<%= hid_print_month.ClientID %>').value = this.print_search.month;
}
else if (this.print_conditions == 'ss') {
document.getElementById('<%= hid_print_season.ClientID %>').value = this.print_search.season;
}
if (mode === 'print') {
document.getElementById('<%= print_management.ClientID %>').click();
}
else if (mode === "excel") {
document.getElementById('<%= excel_management.ClientID %>').click();
}
},
search_show(curr) { search_show(curr) {
//console.log("btn_click:", curr, curr.api_url); //console.log("btn_click:", curr, curr.api_url);
this.search_dialog.current = curr; this.search_dialog.current = curr;
@@ -228,6 +315,7 @@
//console.log(row, row["u_name"], row["f_number"], curr.id, target); //console.log(row, row["u_name"], row["f_number"], curr.id, target);
}, },
getList(clearpage = false) { getList(clearpage = false) {
console.log("do getlist")
const { sortBy, sortDesc, page, itemsPerPage } = this.options const { sortBy, sortDesc, page, itemsPerPage } = this.options
const params = { const params = {
sortBy: sortBy[0], sortDesc: sortDesc[0], sortBy: sortBy[0], sortDesc: sortDesc[0],
@@ -241,6 +329,9 @@
this.data_table.list = response.data.list this.data_table.list = response.data.list
this.data_table.count = response.data.count; this.data_table.count = response.data.count;
this.data_table.loading = false this.data_table.loading = false
const dataToStore = JSON.stringify(this.data_table);
sessionStorage.setItem("member_list_cache", dataToStore);
}) })
.catch( .catch(
error => console.log(error) error => console.log(error)
@@ -262,7 +353,7 @@
const index = this.data_table.list.indexOf(item) const index = this.data_table.list.indexOf(item)
if (index != -1) { if (index != -1) {
axios axios
.delete(HTTP_HOST + 'api/follower/' + item.num) .delete(HTTP_HOST + 'api/follower/Delete/' + item.num)
.then(response => { .then(response => {
this.getList(); this.getList();
}) })
@@ -282,18 +373,23 @@
//} //}
//this.data_table.selected = []; //this.data_table.selected = [];
//this.data_table.count = this.data_table.list.length //this.data_table.count = this.data_table.list.length
location.reload(); //location.reload();
this.getList();
}) })
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
}, },
btn_search() { btn_search() {
this.isSearched = true;
sessionStorage.setItem("member_query_params", JSON.stringify(this.search));
this.getList(true) this.getList(true)
bootstrap.Offcanvas.getInstance(document.getElementById("offcanvasRight")).hide() bootstrap.Offcanvas.getInstance(document.getElementById("offcanvasRight")).hide()
}, },
btn_all() { btn_all() {
this.isSearched = false;
clearObjProps(this.search); clearObjProps(this.search);
this.btn_search() sessionStorage.setItem("member_query_params", JSON.stringify(this.search));
//this.btn_search()
}, },
goPrint() { goPrint() {
//debugger; //debugger;
@@ -309,6 +405,7 @@
//列印管理報表 //列印管理報表
print_close() { print_close() {
this.print_dialog.show = false; this.print_dialog.show = false;
this.print_error_msg = "";
} }
, ,
initPrintSearch() { initPrintSearch() {
@@ -391,10 +488,31 @@
$('#country2').val(''); $('#country2').val('');
VueApp.search.country2 = ''; VueApp.search.country2 = '';
}); });
$(document).ready(function () {
// 判斷是否彈出 search dialog
let hasSearchResult = sessionStorage.getItem("member_list_cache") !== null;
if (!hasSearchResult && window._printResult === '') {
let $btn = $("a[data-bs-target='#offcanvasRight'][href='#search_panel']");
$btn.click();
let el = document.getElementById('offcanvasRight');
let offcanvas = bootstrap.Offcanvas.getOrCreateInstance(el);
offcanvas.show();
}
});
</script> </script>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" /> <uc1:alert runat="server" ID="L_msg" Text="" />
<asp:HiddenField ID="hid_err_msg" runat="server" />
<asp:HiddenField ID="hid_print_year" runat="server" />
<asp:HiddenField ID="hid_print_month" runat="server" />
<asp:HiddenField ID="hid_print_season" runat="server" />
<asp:HiddenField ID="hid_print_mode" runat="server" />
<asp:HiddenField ID="hid_qry" runat="server" />
<asp:LinkButton ID="excel_management" runat="server" OnClick="export_Click" style="display:none;" />
<asp:LinkButton ID="print_management" runat="server" OnClick="export_Click" style="display:none;" />
<div id="content" class="container-fluid"> <div id="content" class="container-fluid">
<v-data-table <v-data-table
v-model="data_table.selected" v-model="data_table.selected"
@@ -508,9 +626,17 @@
</v-col> </v-col>
</v-row> </v-row>
<v-row>
<v-col>
<div v-if="print_error_msg" class="red--text mt-2 text-center" style="font-weight: bold;">
{{ print_error_msg }}
</div>
</v-col>
</v-row>
<v-row densee class="pt-3" > <v-row densee class="pt-3" >
<v-col :cols="12" class="pt-3 text-center" > <v-col :cols="12" class="pt-3 text-center" >
<v-btn class="ma-2" color="primary" dark @click="goPrint2" > 列印 </v-btn> <v-btn class="ma-2" color="primary" dark @click="triggerManagementExport('print')" > 列印 </v-btn>
<v-btn class="ma-2" color="primary" dark @click="triggerManagementExport('excel')"> 匯出 Excel </v-btn>
<v-btn class="ma-2" color="green" dark @click="print_close" > 取消 </v-btn> <v-btn class="ma-2" color="green" dark @click="print_close" > 取消 </v-btn>
</v-col> </v-col>
</v-row> </v-row>
+294 -183
View File
@@ -1,17 +1,20 @@
using System; using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Configuration; using System.Windows.Controls;
using System.IO; using System.Windows.Interop;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
using System.Linq;
using static TreeView; using static TreeView;
@@ -19,16 +22,22 @@ public partial class admin_follower_index : MyWeb.config
{ {
public int page = 1; public int page = 1;
private Model.ezEntities _db = new Model.ezEntities(); private Model.ezEntities _db = new Model.ezEntities();
protected string lastAddedID;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
if (!IsPostBack) if (!IsPostBack)
{ {
if (Session["LastAddedID"] != null)
{
lastAddedID = Session["LastAddedID"].ToString();
Session.Remove("LastAddedID");
}
BuildKind(); BuildKind();
} }
else else
{ {
} }
} }
@@ -42,10 +51,10 @@ public partial class admin_follower_index : MyWeb.config
//國籍 //國籍
s_country.Items.Clear(); s_country.Items.Clear();
s_country.Items.Add(new ListItem("請選擇", "")); s_country.Items.Add(new ListItem("請選擇", ""));
var qry =_db.countries.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) if (qry.Count > 0)
{ {
foreach(var x in qry) foreach (var x in qry)
s_country.Items.Add(new ListItem(x.name_zh, x.ID)); s_country.Items.Add(new ListItem(x.name_zh, x.ID));
} }
@@ -68,208 +77,310 @@ public partial class admin_follower_index : MyWeb.config
#endregion #endregion
#region Excel #region
protected void excel_Click(object sender, EventArgs e) protected void export_Click(object sender, EventArgs e)
{ {
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
LinkButton btn = sender as LinkButton;
if (btn == null) return;
bool isPrintMode = (btn.ID == "print_management");
bool isExcelMode = (btn.ID == "excel_management" || btn.ID == "excel");
bool isManagementMode = (btn.ID == "excel_management" || btn.ID == "print_management");
//查詢要匯出的資料
string _query = ""; // 紀錄匯出條件
var list = searchData(ref _query, isManagementMode);
if (isExcelMode)
{ {
var wb = doc.AddWorkbookPart();
wb.Workbook = new Workbook();
var sheets = wb.Workbook.AppendChild(new Sheets());
//建立第一個頁籤
var ws = wb.AddNewPart<WorksheetPart>();
ws.Worksheet = new Worksheet();
sheets.Append(new Sheet()
{
Id = wb.GetIdOfPart(ws),
SheetId = 1,
Name = "信眾資料"
});
//設定欄寬
var cu = new Columns();
cu.Append(
new Column { Min = 1, Max = 2, Width = 15, CustomWidth = true },
new Column { Min = 3, Max = 3, Width = 10, CustomWidth = true },
new Column { Min = 4, Max = 11, Width = 15, CustomWidth = true },
new Column { Min = 12, Max = 12, Width = 25, CustomWidth = true },
new Column { Min = 13, Max = 13, Width = 8, CustomWidth = true },
new Column { Min = 14, Max = 14, Width = 35, CustomWidth = true },
new Column { Min = 15, Max = 16, Width = 15, CustomWidth = true }
);
ws.Worksheet.Append(cu);
//建立資料頁
var sd = new SheetData();
ws.Worksheet.AppendChild(sd);
//第一列資料
var tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue("信眾編號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("信眾姓名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("性別"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("身分別"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("生日(國曆)"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("聯絡電話"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("手機號碼"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("皈依道場"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("皈依法名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("皈依日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("加入日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("緊急連絡人"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("緊急連絡人電話"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("血型"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("國籍"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("收件地址"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("介紹人"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("LINE帳號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("其它社群帳號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("建檔日期"), DataType = CellValues.String }
,new Cell() { CellValue = new CellValue("身分證號"), DataType = CellValues.String }
//,new Cell() { CellValue = new CellValue("SHA"), DataType = CellValues.String }
);
sd.AppendChild(tr);
//查詢要匯出的資料
//紀錄匯出條件
string _query = "";
var list = searchData(ref _query);
if (list.Count > 0) if (list.Count > 0)
{ {
MyWeb.encrypt encrypt = new MyWeb.encrypt(); using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
Model.country country = new Model.country();
var tdesc = publicFun.enum_desc<Model.follower.type>();
foreach (var item in list)
{ {
//新增資料列 var wb = doc.AddWorkbookPart();
tr = new Row(); wb.Workbook = new Workbook();
string s1, s2, sha; var sheets = wb.Workbook.AppendChild(new Sheets());
s1= encrypt.DecryptAutoKey(item.phone);
s2= encrypt.DecryptAutoKey(item.id_code); //建立第一個頁籤
sha = encrypt.followerHash(s1, s2); var ws = wb.AddNewPart<WorksheetPart>();
ws.Worksheet = new Worksheet();
sheets.Append(new Sheet()
{
Id = wb.GetIdOfPart(ws),
SheetId = 1,
Name = "信眾資料"
});
//設定欄寬
var cu = new Columns();
cu.Append(
new Column { Min = 1, Max = 2, Width = 15, CustomWidth = true },
new Column { Min = 3, Max = 3, Width = 10, CustomWidth = true },
new Column { Min = 4, Max = 11, Width = 15, CustomWidth = true },
new Column { Min = 12, Max = 12, Width = 25, CustomWidth = true },
new Column { Min = 13, Max = 13, Width = 8, CustomWidth = true },
new Column { Min = 14, Max = 14, Width = 35, CustomWidth = true },
new Column { Min = 15, Max = 16, Width = 15, CustomWidth = true }
);
ws.Worksheet.Append(cu);
//建立資料頁
var sd = new SheetData();
ws.Worksheet.AppendChild(sd);
//第一列資料
var tr = new Row();
tr.Append( tr.Append(
new Cell() { CellValue = new CellValue(item.f_number), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("信眾編號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.u_name), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("信眾姓名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.sex), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("性別"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(!isStrNull(item.identity_type)? tdesc[item.identity_type ?? 1] :""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("身分別"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.birthday.HasValue ? ValDate(item.birthday.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("生日(國曆)"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("聯絡電話"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.cellphone)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("手機號碼"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refuge_area), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("皈依道場"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refuge_name), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("皈依法名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refugedate.HasValue ? ValDate(item.refugedate.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("皈依日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.join_date.HasValue ? ValDate(item.join_date.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("加入日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.contactor), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("緊急連絡人"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.contactor_phone)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("緊急連絡人電話"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.blood), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("血型"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(!isStrNull(item.country) ? item.country1.name_zh : ""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("國籍"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.address), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("收件地址"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.introducer), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("介紹人"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.socialid1), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("LINE帳號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.socialid2), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("其它社群帳號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.reg_time.HasValue ? ValDate(item.reg_time.Value).ToString("yyyy/MM/dd HH:mm:ss") : ""), DataType = CellValues.String } new Cell() { CellValue = new CellValue("建檔日期"), DataType = CellValues.String }
,new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.id_code)), DataType = CellValues.String } , new Cell() { CellValue = new CellValue("身分證號"), DataType = CellValues.String }
//, new Cell() { CellValue = new CellValue(sha), DataType = CellValues.String } //,new Cell() { CellValue = new CellValue("SHA"), DataType = CellValues.String }
); );
sd.AppendChild(tr); sd.AppendChild(tr);
MyWeb.encrypt encrypt = new MyWeb.encrypt();
Model.country country = new Model.country();
var tdesc = publicFun.enum_desc<Model.follower.type>();
foreach (var item in list)
{
//新增資料列
tr = new Row();
string s1, s2, sha;
s1 = encrypt.DecryptAutoKey(item.phone);
s2 = encrypt.DecryptAutoKey(item.id_code);
sha = encrypt.followerHash(s1, s2);
tr.Append(
new Cell() { CellValue = new CellValue(item.f_number), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.u_name), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.sex), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(!isStrNull(item.identity_type) ? tdesc[item.identity_type ?? 1] : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.birthday.HasValue ? ValDate(item.birthday.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.cellphone)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refuge_area), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refuge_name), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.refugedate.HasValue ? ValDate(item.refugedate.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.join_date.HasValue ? ValDate(item.join_date.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.contactor), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.contactor_phone)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.blood), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(!isStrNull(item.country) ? item.country1.name_zh : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.address), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.introducer), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.socialid1), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.socialid2), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.reg_time.HasValue ? ValDate(item.reg_time.Value).ToString("yyyy/MM/dd HH:mm:ss") : ""), DataType = CellValues.String }
, new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.id_code)), DataType = CellValues.String }
//, new Cell() { CellValue = new CellValue(sha), DataType = CellValues.String }
);
sd.AppendChild(tr);
}
//空一列
tr = new Row();
sd.AppendChild(tr);
//匯出資訊
string _data = "匯出時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
_data += " " + admin.info.u_id;
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
_data = "匯出條件 : " + (!isStrNull(_query) ? _query : "-");
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.f_number + x.u_name).ToList()));
} }
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=信眾_data.xlsx");
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
HttpContext.Current.Response.End();
//空一列 hid_err_msg.Value = "success";
tr = new Row();
sd.AppendChild(tr);
//匯出資訊
string _data = "匯出時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
_data += " " + admin.info.u_id;
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
_data = "匯出條件 : " + (!isStrNull(_query) ? _query : "-");
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.f_number + x.u_name).ToList()));
} }
else else
{ {
ScriptMsg2("查無資料"); //ScriptMsg2("查無資料");
hid_err_msg.Value = "nodata";
} }
} }
else if (isPrintMode)
{
string urlParams = "";
int selYear = !string.IsNullOrEmpty(hid_print_year.Value) ? int.Parse(hid_print_year.Value) : 0;
int selMonth = !string.IsNullOrEmpty(hid_print_month.Value) ? int.Parse(hid_print_month.Value) : 0;
int selSeason = !string.IsNullOrEmpty(hid_print_season.Value) ? int.Parse(hid_print_season.Value) : 0;
string selMode = !string.IsNullOrEmpty(hid_print_mode.Value) ? hid_print_mode.Value : "";
var qry = _db.followers.AsQueryable();
if (selYear > 0)
{
urlParams += "&year=" + selYear;
}
if (selMode == "mm" && selMonth > 0)
{
urlParams += "&month=" + selMonth;
}
else if (selMode == "ss" && selSeason > 0)
{
urlParams += "&season=" + selSeason;
}
HttpContext.Current.Response.Clear(); if (list.Count > 0)
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=信眾_data.xlsx"); {
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; hid_err_msg.Value = "success";
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray()); hid_print_year.Value = selYear.ToString();
HttpContext.Current.Response.End(); hid_print_month.Value = selMonth.ToString();
hid_print_season.Value = selSeason.ToString();
hid_print_mode.Value = selMode;
string script = $@"window.open('print.aspx?{urlParams}&mode={selMode}', '列印信眾資料', 'noopener,noreferrer');";
ScriptManager.RegisterStartupScript(this, GetType(), "ExecutePrint", script, true);
}
else
{
hid_err_msg.Value = "nodata";
}
}
} }
protected List<Model.follower> searchData(ref string _query) protected List<Model.follower> searchData(ref string _query, bool isManagementMode = false)
{ {
//查詢要匯出的資料 //查詢要匯出的資料
var qry = _db.followers.AsQueryable(); var qry = _db.followers.AsQueryable();
//紀錄匯出條件 // 管理報表
if (!isStrNull(s_f_number.Value)) if (isManagementMode)
{ {
qry = qry.Where(o => o.f_number.Contains(s_f_number.Value.Trim())); int selYear = !string.IsNullOrEmpty(hid_print_year.Value) ? int.Parse(hid_print_year.Value) : 0;
int selMonth = !string.IsNullOrEmpty(hid_print_month.Value) ? int.Parse(hid_print_month.Value) : 0;
_query += "信眾編號:" + s_f_number.Value.Trim() + "\n"; int selSeason = !string.IsNullOrEmpty(hid_print_season.Value) ? int.Parse(hid_print_season.Value) : 0;
string selMode = !string.IsNullOrEmpty(hid_print_mode.Value) ? hid_print_mode.Value : "";
}
if (!isStrNull(s_u_name.Value)) if (selYear > 0)
{
qry = qry.Where(o => o.u_name.Contains(s_u_name.Value.Trim()));
_query += "信眾姓名:" + s_u_name.Value.Trim() + "\n";
}
if (!isStrNull(s_address.Value))
{
qry = qry.Where(o => o.address.Contains(s_address.Value.Trim()));
_query += "地址:" + s_u_name.Value.Trim() + "\n";
}
// 電話/證號搜尋 (使用 search_keywords HEX 編碼)
if (!isStrNull(s_phone_idcode.Value) && GlobalVariables.UseSearchKeywords)
{
MyWeb.encrypt encrypt = new MyWeb.encrypt();
string hexSearch = encrypt.ConvertToHex(s_phone_idcode.Value.Trim());
if (!string.IsNullOrEmpty(hexSearch))
{ {
qry = qry.Where(o => o.search_keywords != null && o.search_keywords.Contains(hexSearch)); qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Year == selYear);
_query += "電話/證號:" + s_phone_idcode.Value.Trim() + "\n"; _query += "年份:" + selYear + "\n";
} }
if (selMode == "mm" && selMonth > 0)
{
qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Month == selMonth);
_query += "月份:" + selMonth + "\n";
}
else if (selMode == "ss" && selSeason > 0)
{
if (selSeason == 1)
{
qry = qry.Where(o => o.join_date.HasValue)
.Where(o => o.join_date.Value.Month == 1 || o.join_date.Value.Month == 2 || o.join_date.Value.Month == 3);
}
else if (selSeason == 2)
{
qry = qry.Where(o => o.join_date.HasValue)
.Where(o => o.join_date.Value.Month == 4 || o.join_date.Value.Month == 5 || o.join_date.Value.Month == 6);
}
else if (selSeason == 3)
{
qry = qry.Where(o => o.join_date.HasValue)
.Where(o => o.join_date.Value.Month == 7 || o.join_date.Value.Month == 8 || o.join_date.Value.Month == 9);
}
else if (selSeason == 4)
{
qry = qry.Where(o => o.join_date.HasValue)
.Where(o => o.join_date.Value.Month == 10 || o.join_date.Value.Month == 11 || o.join_date.Value.Month == 12);
}
_query += "季度:" + selSeason + "\n";
}
qry = qry.OrderByDescending(o => o.num);
return qry.ToList();
} }
else
if (!isStrNull(s_birthday.Value) && isDate(s_birthday.Value)) // 匯出查詢資料
{ {
qry = qry.Where(o => o.birthday >= ValDate(s_birthday.Value)); //紀錄匯出條件
_query += "生日(起):" + s_birthday.Value.Trim() + "\n"; if (!isStrNull(s_f_number.Value))
{
qry = qry.Where(o => o.f_number.Contains(s_f_number.Value.Trim()));
_query += "信眾編號:" + s_f_number.Value.Trim() + "\n";
}
if (!isStrNull(s_u_name.Value))
{
qry = qry.Where(o => o.u_name.Contains(s_u_name.Value.Trim()));
_query += "信眾姓名:" + s_u_name.Value.Trim() + "\n";
}
if (!isStrNull(s_address.Value))
{
qry = qry.Where(o => o.address.Contains(s_address.Value.Trim()));
_query += "地址:" + s_address.Value.Trim() + "\n";
}
// 電話/證號搜尋 (使用 search_keywords HEX 編碼)
if (!isStrNull(s_phone_idcode.Value) && GlobalVariables.UseSearchKeywords)
{
MyWeb.encrypt encrypt = new MyWeb.encrypt();
string hexSearch = encrypt.ConvertToHex(s_phone_idcode.Value.Trim());
if (!string.IsNullOrEmpty(hexSearch))
{
qry = qry.Where(o => o.search_keywords != null && o.search_keywords.Contains(hexSearch));
_query += "電話/證號:" + s_phone_idcode.Value.Trim() + "\n";
}
}
if (!isStrNull(s_birthday.Value) && isDate(s_birthday.Value))
{
var tmp_s_birthday = ValDate(s_birthday.Value);
qry = qry.Where(o => o.birthday >= tmp_s_birthday);
_query += "生日(起):" + s_birthday.Value.Trim() + "\n";
}
if (!isStrNull(s_birthday2.Value) && isDate(s_birthday2.Value))
{
var tmp_s_birthday2 = Convert.ToDateTime(s_birthday2.Value).AddDays(1);
qry = qry.Where(o => o.birthday < tmp_s_birthday2);
_query += "生日(訖):" + s_birthday2.Value.Trim() + "\n";
}
qry = qry.OrderByDescending(o => o.num);
return qry.ToList();
} }
if (!isStrNull(s_birthday2.Value) && isDate(s_birthday2.Value))
{
qry = qry.Where(o => o.birthday < Convert.ToDateTime(s_birthday2.Value).AddDays(1));
_query += "生日(訖):" + s_birthday2.Value.Trim() + "\n";
}
qry = qry.OrderByDescending(o => o.num);
return qry.ToList();
} }
+1
View File
@@ -8,6 +8,7 @@
<span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal> <span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal>
</div> </div>
</div> </div>
<a href="index.aspx" class="btn btn-outline-secondary">返回</a>
</asp:Content> </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container-fluid"> <div class="container-fluid">
+5 -4
View File
@@ -4,10 +4,11 @@
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex"> <div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
<div class="ms-3"> <div class="ms-3">
<span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal> <span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal>
</div> </div>
</div> </div>
<a href="order_record.aspx?userid=<%=Request["userid"] %>" class="btn btn-outline-secondary">返回</a>
</asp:Content> </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container-fluid"> <div class="container-fluid">
+17 -3
View File
@@ -3,6 +3,7 @@ using DocumentFormat.OpenXml.Vml.Office;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
@@ -26,7 +27,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
//紀錄匯出條件 //紀錄匯出條件
string _query = ""; string _query = "";
var qry = _db.followers.AsQueryable(); var qry = _db.followers.AsQueryable();
// ❌ 錯誤寫法: qry = qry.Where(o => o.f_number.Contains(Request["f_number"].Trim())); // ❌ 錯誤寫法: qry = qry.Where(o => o.f_number.Contains(Request["f_number"].Trim()));
// LINQ to Entities 無法轉換 Request[] 方法,必須先轉換為變數再使用 // LINQ to Entities 無法轉換 Request[] 方法,必須先轉換為變數再使用
string fNumberParam = Request["f_number"]?.Trim(); string fNumberParam = Request["f_number"]?.Trim();
@@ -60,7 +61,8 @@ public partial class admin_follower_print_ : System.Web.UI.Page
if (!string.IsNullOrEmpty(Request["birthday2"])) if (!string.IsNullOrEmpty(Request["birthday2"]))
{ {
DateTime birthday2Param = Convert.ToDateTime(Request["birthday2"].Trim()); DateTime birthday2Param = Convert.ToDateTime(Request["birthday2"].Trim());
qry = qry.Where(o => o.birthday < birthday2Param.AddDays(1)); var tmpBirthday2Param = birthday2Param.AddDays(1);
qry = qry.Where(o => o.birthday < tmpBirthday2Param);
_query += "生日(訖):" + birthday2Param.ToString("yyyy/MM/dd") + "\n"; _query += "生日(訖):" + birthday2Param.ToString("yyyy/MM/dd") + "\n";
} }
// ❌ 錯誤寫法: _db.countries.Where(x => x.ID == Request["country"].ToString()) // ❌ 錯誤寫法: _db.countries.Where(x => x.ID == Request["country"].ToString())
@@ -85,7 +87,19 @@ public partial class admin_follower_print_ : System.Web.UI.Page
} }
_query += "國家:" + (_db.countries.Where(x => x.ID == country2Id).Select(x => x.name_zh).FirstOrDefault() ?? "") + "\n"; _query += "國家:" + (_db.countries.Where(x => x.ID == country2Id).Select(x => x.name_zh).FirstOrDefault() ?? "") + "\n";
} }
string phone_ipcode = Request["phone_idcode"]?.ToString();
if (!string.IsNullOrEmpty(phone_ipcode) && GlobalVariables.UseSearchKeywords)
{
MyWeb.encrypt encrypt = new MyWeb.encrypt();
string hexSearch = encrypt.ConvertToHex(phone_ipcode.Trim());
if (!string.IsNullOrEmpty(hexSearch))
{
qry = qry.Where(o => o.search_keywords != null && o.search_keywords.Contains(hexSearch));
_query += "電話/證號:" + phone_ipcode.Trim() + "\n";
}
}
//管理報表 //管理報表
if (!string.IsNullOrEmpty(Request["year"])) if (!string.IsNullOrEmpty(Request["year"]))
{ {
+650 -37
View File
@@ -116,6 +116,7 @@
vuetify: new Vuetify(vuetify_options), vuetify: new Vuetify(vuetify_options),
data() { data() {
return { return {
last_confirmed_date: '',
tabArray: tabtmp, tabArray: tabtmp,
tabArray2: "", tabArray2: "",
follower_id: '<%= Request["num"] %>', follower_id: '<%= Request["num"] %>',
@@ -124,6 +125,20 @@
multiSort: false, multiSort: false,
//itemsPerPage: -1, //itemsPerPage: -1,
}, },
confirm_dialog: {
show: false,
headers: [
{ text: '活動日期', value: 'activitydate' },
{ text: '活動名稱', value: 'activityname'},
],
title: '',
desc: '',
orders: [],
pendingData: null,
pendingDeleteItem: null,
btn_cancel_text: '', // 「取消報名」按鈕文字
btn_keep_text: '' // 「保留活動」按鈕文字
},
search_dialog: { search_dialog: {
controls: { controls: {
search1: { search1: {
@@ -190,7 +205,7 @@
text_prop: 'name_zh', text_prop: 'name_zh',
value_prop: 'id', value_prop: 'id',
keys: [ keys: [
{ id: 'keyword', title: '關鍵字' }, { id: 'keyword', title: '關鍵字' },
], ],
api_url: HTTP_HOST + 'api/country/GetList', api_url: HTTP_HOST + 'api/country/GetList',
columns: [ columns: [
@@ -208,11 +223,11 @@
title: '稱謂', title: '稱謂',
text_prop: 'title', text_prop: 'title',
value_prop: 'num', value_prop: 'num',
keys: [ keys: [
], ],
api_url: HTTP_HOST + 'api/appellation/GetList', api_url: HTTP_HOST + 'api/appellation/GetList',
columns: [ columns: [
{ id: 'title', title: '稱謂' }, { id: 'title', title: '稱謂' },
], ],
selected: {}, selected: {},
select(item, index, t) { select(item, index, t) {
@@ -230,7 +245,7 @@
{ id: 'f_number', title: '編號' }, { id: 'f_number', title: '編號' },
{ id: 'u_name', title: '姓名' }, { id: 'u_name', title: '姓名' },
{ id: 'address', title: '地址' }, { id: 'address', title: '地址' },
{ id: 'onlyfamily', title: '只查親屬'}, { id: 'onlyfamily', title: '只查親屬' },
], ],
api_url: HTTP_HOST + 'api/follower/GetList', api_url: HTTP_HOST + 'api/follower/GetList',
columns: [ columns: [
@@ -241,7 +256,7 @@
selected: {}, selected: {},
select(item, index, t) { select(item, index, t) {
console.log("select search5", t); console.log("select search5", t);
} }
}, },
}, },
@@ -314,10 +329,10 @@
birthday: '', birthday: '',
phoneDes: '', phoneDes: '',
demo: '', demo: '',
appellation_id_selected : appellation_id_selected:
{ {
text : '', text: '',
val : 0, val: 0,
}, },
}, },
@@ -372,33 +387,33 @@
], ],
tabletsDetail: { multiSort: false }, tabletsDetail: { multiSort: false },
tabletTable: { tabletTable: {
Loading:true, Loading: true,
disableButton: true, disableButton: true,
searchDetail: '', searchDetail: '',
headersDetail: [ headersDetail: [
{ text: '超渡/陽上', value: 'type', sortable: false, width: "100px" }, { text: '超渡/陽上', value: 'type', sortable: false, width: "100px" },
{ text: '* 牌位標題', value: 'title', sortable: true }, { text: '* 牌位標題', value: 'title', sortable: true },
{ text: '', value: 'actions', sortable: false, width: "100px" }, { text: '', value: 'actions', sortable: false, width: "100px" },
], ],
desserts: [], desserts: [],
desserts_count: 0, desserts_count: 0,
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
id: 0, id: 0,
num: 0, num: 0,
f_num: 0, f_num: 0,
title: '', title: '',
}, },
defaultItem: { defaultItem: {
id: 0, id: 0,
num: 0, num: 0,
f_num: 0, f_num: 0,
type: this.selectedTabletType, type: this.selectedTabletType,
title:'', title: '',
}, },
}, },
//新:家人 //新:家人
family:{ family: {
dialog: false, dialog: false,
isEditing: false, isEditing: false,
is_tw: true, is_tw: true,
@@ -420,8 +435,8 @@
chinese_year: "", chinese_year: "",
zodiac: "", zodiac: "",
birth_time: "", birth_time: "",
city:"", city: "",
area:"", area: "",
address: "", address: "",
phone: "", phone: "",
mobile: "", mobile: "",
@@ -440,8 +455,8 @@
chinese_year: "", chinese_year: "",
zodiac: "", zodiac: "",
birth_time: "", birth_time: "",
city:"", city: "",
area:"", area: "",
address: "", address: "",
phone: "", phone: "",
mobile: "", mobile: "",
@@ -454,15 +469,65 @@
{ text: '', value: 'actions', sortable: false, width: "100px" }, { text: '', value: 'actions', sortable: false, width: "100px" },
], ],
}, },
// 全年報名表格
auto_enroll: {
headers: [
{ text: '開始日期(西元)', value: 'auto_enroll_start_date', sortable: false },
{ text: '結束日期(西元)', value: 'auto_enroll_end_date', sortable: false },
{ text: '收據抬頭', value: 'auto_enroll_receipt_title', sortable: false },
{ text: '收據地址', value: 'auto_enroll_receipt_address', sortable: false },
{ text: '狀態', value: 'auto_enroll_status', sortable: false },
{ text: '', value: 'actions', sortable: false, width: "150px" },
],
items: [],
editedIndex: -1,
editedItem: {
num: 0,
auto_enroll_start_date: '',
auto_enroll_end_date: '',
auto_enroll_receipt_title: '',
auto_enroll_receipt_address: '',
},
defaultItem: {
num: 0,
auto_enroll_start_date: '',
auto_enroll_end_date: '',
auto_enroll_receipt_title: '',
auto_enroll_receipt_address: '',
},
search:""
},
unfilled_dialog: {
show: false,
headers: [
{ text: '報名單號', value: 'order_no', sortable: false },
{ text: '活動分類', value: 'category', sortable: false },
{ text: '活動名稱', value: 'activityname', sortable: false },
{ text: '開始日期', value: 'startdate', sortable: false },
{ text: '結束日期', value: 'enddate', sortable: false },
],
items: [],
footer: {
showFirstLastPage: true,
disableItemsPerPage: true,
itemsPerPageAllText: '',
itemsPerPageText: '',
current_item: null,
},
count: 0,
page: 1,
pageSize: 10,
loading: false,
},
cityOptions: [], // 城市選項 cityOptions: [], // 城市選項
areaOptions: {}, // 區域選項 areaOptions: {}, // 區域選項
//天干地支:甲子, 乙丑... //天干地支:甲子, 乙丑...
chineseYears: [ chineseYears: [
'甲子', '乙丑', '丙寅', '丁卯', '戊辰', '己巳', '庚午', '辛未', '壬申', '癸酉', '甲子', '乙丑', '丙寅', '丁卯', '戊辰', '己巳', '庚午', '辛未', '壬申', '癸酉',
'甲戌', '乙亥', '丙子', '丁丑', '戊寅', '己卯', '庚辰', '辛巳', '壬午', '癸未', '甲戌', '乙亥', '丙子', '丁丑', '戊寅', '己卯', '庚辰', '辛巳', '壬午', '癸未',
'甲申', '乙酉', '丙戌', '丁亥', '戊子', '己丑', '庚寅', '辛卯', '壬辰', '癸巳', '甲申', '乙酉', '丙戌', '丁亥', '戊子', '己丑', '庚寅', '辛卯', '壬辰', '癸巳',
'甲午', '乙未', '丙申', '丁酉', '戊戌', '己亥', '庚子', '辛丑', '壬寅', '癸卯', '甲午', '乙未', '丙申', '丁酉', '戊戌', '己亥', '庚子', '辛丑', '壬寅', '癸卯',
'甲辰', '乙巳', '丙午', '丁未', '戊申', '己酉', '庚戌', '辛亥', '壬子', '癸丑', '甲辰', '乙巳', '丙午', '丁未', '戊申', '己酉', '庚戌', '辛亥', '壬子', '癸丑',
'甲寅', '乙卯', '丙辰', '丁巳', '戊午', '己未', '庚申', '辛酉', '壬戌', '癸亥' '甲寅', '乙卯', '丙辰', '丁巳', '戊午', '己未', '庚申', '辛酉', '壬戌', '癸亥'
], ],
//生肖 //生肖
@@ -485,7 +550,7 @@
] ]
} }
}, },
mounted() {//一開始就載入 mounted() {
this.search_dialog.current = this.search_dialog.controls.search1 ///default this.search_dialog.current = this.search_dialog.controls.search1 ///default
//console.log("mounted"); //console.log("mounted");
//this.initialize(); //this.initialize();
@@ -494,6 +559,7 @@
this.getFamilyMembers(); this.getFamilyMembers();
this.getCityOptions(); this.getCityOptions();
this.onCityChange(); this.onCityChange();
this.initAutoEnroll();
}, },
watch: { watch: {
options: { options: {
@@ -537,6 +603,323 @@
} }
}, },
methods: { methods: {
initAutoEnroll() {
if (this.follower_id != '') {
axios.get(HTTP_HOST + `api/follower/GetAutoEnrollList/${this.follower_id}`)
.then(response => {
this.auto_enroll.items = response.data.list.map(item => ({
...item,
id: item.num
}));
})
}
},
// 取得報名狀態
getEnrollStatus(item) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const start = new Date(item.auto_enroll_start_date);
const end = new Date(item.auto_enroll_end_date);
if (today < start) return { label: '未開始', color: 'blue lighten-4', textColor: 'blue darken-3' };
if (today > end) return { label: '已結束', color: 'grey lighten-2', textColor: 'grey darken-2' };
return { label: '報名中', color: 'green lighten-4', textColor: 'green darken-3' };
},
// 新增
auto_enroll_add() {
if (this.auto_enroll.editedIndex !== -1) return;
const newItem = {
...this.auto_enroll.defaultItem,
id: -Date.now()
};
this.auto_enroll.items.unshift(newItem);
this.auto_enroll.editedItem = { ...newItem };
this.auto_enroll.editedIndex = 0;
},
// 編輯
auto_enroll_edit(item) {
this.auto_enroll.editedIndex = this.auto_enroll.items.indexOf(item);
this.auto_enroll.editedItem = { ...item };
},
// 取消
auto_enroll_cancel() {
// 若是新增的空白列,取消時移除
const item = this.auto_enroll.items[this.auto_enroll.editedIndex];
if (item && !item.auto_enroll_start_date && !item.auto_enroll_end_date) {
this.auto_enroll.items.splice(this.auto_enroll.editedIndex, 1);
}
this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
this.auto_enroll.editedIndex = -1;
},
// 儲存
auto_enroll_save() {
const { id, num, auto_enroll_start_date, auto_enroll_end_date, auto_enroll_receipt_title, auto_enroll_receipt_address } = this.auto_enroll.editedItem;
if (!auto_enroll_start_date || !auto_enroll_end_date) {
alert('請填寫開始與結束日期');
return;
}
if (auto_enroll_start_date > auto_enroll_end_date) {
alert('開始日期不可晚於結束日期');
return;
}
// 檢查是否與其他列日期重疊
const isOverlap = this.auto_enroll.items.some(item => {
if (item.id === id) return false; // 跳過自己
const existStart = item.auto_enroll_start_date;
const existEnd = item.auto_enroll_end_date;
return auto_enroll_start_date <= existEnd && auto_enroll_end_date >= existStart;
});
if (isOverlap) {
alert('此報名期間與現有資料重疊,請重新確認日期');
return;
}
var auto_enroll =
{
num: num,
f_num: Number('<%= Request["num"] %>'),
start_date: auto_enroll_start_date,
end_date: auto_enroll_end_date,
receipt_title: auto_enroll_receipt_title,
receipt_address: auto_enroll_receipt_address,
}
this.open_confirm_dialog(auto_enroll);
//axios.post(HTTP_HOST + 'api/follower/SaveAutoEnrollList', auto_enroll)
// .then(response => {
// const savedData = response.data;
// const updatedItem = {
// ...this.auto_enroll.editedItem,
// num: Number(savedData.num),
// id: Number(savedData.num),
// auto_enroll_start_date: savedData.start_date,
// auto_enroll_end_date: savedData.end_date,
// auto_enroll_receipt_title: savedData.receipt_title,
// auto_enroll_receipt_address: savedData.receipt_address,
// };
// this.$set(this.auto_enroll.items, this.auto_enroll.editedIndex, updatedItem);
// this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
// this.auto_enroll.editedIndex = -1;
// })
},
// 刪除
auto_enroll_delete(item) {
// 先查受影響訂單
axios.post(HTTP_HOST + 'api/follower/GetAffectedOrders', {
num: item.num,
f_num: Number('<%= Request["num"] %>'),
start_date: item.auto_enroll_start_date,
end_date: item.auto_enroll_end_date,
}, {
params: { is_delete: true }
})
.then(response => {
this.confirm_dialog.pendingData = null;
this.confirm_dialog.pendingDeleteItem = item;
if (response.data.list.length > 0) {
this.confirm_dialog.orders = response.data.list;
this.confirm_dialog.title = "刪除全年報名";
this.confirm_dialog.desc = "刪除後,以下已報名的活動是否一併取消?";
this.confirm_dialog.btn_keep_text = "保留現有活動";
this.confirm_dialog.btn_cancel_text = "取消全部活動";
this.confirm_dialog.show = true;
} else {
this.doDelete(item);
}
})
},
doDelete(item) {
axios.delete(HTTP_HOST + `api/follower/DeleteAutoEnroll/${item.num}`)
.then(() => {
const index = this.auto_enroll.items.indexOf(item);
this.auto_enroll.items.splice(index, 1);
this.confirm_dialog.pendingDeleteItem = null; // 清空暫存
})
.catch(error => {
console.log("刪除失敗", error);
this.snackbar.text = "刪除失敗:" + error;
this.snackbar.show = true;
})
},
// 顯示尚未填寫項目的活動
unfilled_dialog_show(item) {
this.unfilled_dialog.current_item = item;
this.unfilled_dialog.page = 1;
this.unfilled_dialog.show = true;
this.unfilled_dialog_load();
},
unfilled_dialog_load() {
const item = this.unfilled_dialog.current_item;
const { page, pageSize, sortBy, sortDesc } = this.unfilled_dialog;
this.unfilled_dialog.loading = true;
axios
.get(HTTP_HOST + `api/follower/GetUnfilledActivityOrders/${item.num}`, {
params: {
page,
pageSize,
sortBy: Array.isArray(sortBy) ? sortBy[0] : sortBy,
sortDesc: Array.isArray(sortDesc) ? sortDesc[0] : sortDesc
}
})
.then(response => {
this.unfilled_dialog.items = response.data.list;
this.unfilled_dialog.count = response.data.count;
})
.finally(() => {
this.unfilled_dialog.loading = false;
});
},
// 列印
async exportUnfilledOrders() {
const item = this.unfilled_dialog.current_item;
// 取得全部資料
const response = await axios.get(
HTTP_HOST + `api/follower/GetUnfilledActivityOrders/${item.num}`,
{ params: { page: 1, pageSize: 99999 } }
);
const allItems = response.data.list;
const fullTitle = this.titleword();
const infoParts = fullTitle.split(' ');
const followerNum = infoParts[0] || "未知編號";
const followerName = infoParts[1] ? infoParts[1].split('')[0] : "未知姓名";
const rows = allItems.map(item => `
<tr>
<td>${item.order_no}</td>
<td>${item.category}</td>
<td>${item.activityname}</td>
<td>${item.startdate?.substring(0, 10)}</td>
<td>${item.enddate?.substring(0, 10)}</td>
</tr>
`).join('');
const win = window.open('', '_blank');
win.document.write(`
<html>
<head>
<title>未填寫品項活動 - ${followerName}</title>
<style>
body { font-family: "Microsoft JhengHei", Arial, sans-serif; padding: 20px; }
h2 { text-align: center; margin-bottom: 10px; }
.info-header { text-align: center; margin-bottom: 20px; font-size: 16px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #666; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h2>未填寫品項之活動清單</h2>
<div class="info-header">
信眾編號:<strong>${followerNum}</strong> &nbsp;&nbsp;
信眾姓名:<strong>${followerName}</strong>
</div>
<table>
<thead>
<tr>
<th>報名單號</th>
<th>活動分類</th>
<th>活動名稱</th>
<th>開始日期</th>
<th>結束日期</th>
</tr>
</thead>
<tbody>${rows}</tbody>
</table>
</body>
</html>
`);
win.document.close();
win.print();
win.close();
},
syncAddress() {
const sourceAddr = document.getElementById('<%=address.ClientID%>').value;
this.auto_enroll_config.receipt_address = sourceAddr;
},
open_confirm_dialog(auto_enroll) {
if (auto_enroll.num == 0) {
this.doSave(auto_enroll);
return;
}
// 受影響訂單
axios.post(HTTP_HOST + 'api/follower/GetAffectedOrders', auto_enroll)
.then(response => {
this.confirm_dialog.pendingData = auto_enroll;
if (response.data.list.length > 0) {
this.confirm_dialog.orders = response.data.list;
this.confirm_dialog.title = "受影響的已報名活動";
this.confirm_dialog.desc = "修改報名期間後,以下活動將不在新範圍內,是否一併取消?";
this.confirm_dialog.btn_keep_text = "保留現有活動";
this.confirm_dialog.btn_cancel_text = "取消全部活動";
this.confirm_dialog.show = true;
} else {
this.doSave(auto_enroll);
}
})
},
doSave(auto_enroll) {
axios.post(HTTP_HOST + 'api/follower/SaveAutoEnrollList', auto_enroll)
.then(response => {
const savedData = response.data;
const updatedItem = {
...this.auto_enroll.editedItem,
num: Number(savedData.num),
id: Number(savedData.num),
auto_enroll_start_date: savedData.start_date,
auto_enroll_end_date: savedData.end_date,
auto_enroll_receipt_title: savedData.receipt_title,
auto_enroll_receipt_address: savedData.receipt_address,
};
this.$set(this.auto_enroll.items, this.auto_enroll.editedIndex, updatedItem);
this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
this.auto_enroll.editedIndex = -1;
this.confirm_dialog.pendingData = null;
})
},
close_confirm_dialog() {
this.confirm_dialog.show = false;
},
keep_auto_enroll_order() {
this.confirm_dialog.show = false;
if (this.confirm_dialog.pendingData) {
this.doSave(this.confirm_dialog.pendingData);
} else if (this.confirm_dialog.pendingDeleteItem) {
this.doDelete(this.confirm_dialog.pendingDeleteItem);
}
},
delete_auto_enroll_order() {
this.confirm_dialog.show = false;
const orderNos = this.confirm_dialog.orders.map(o => o.order_no);
if (orderNos.length === 0) return;
const numsString = orderNos.join(',')
axios.delete(HTTP_HOST + `api/order/DeleteAll/${numsString}`)
.then(() => {
if (this.confirm_dialog.pendingData) {
this.doSave(this.confirm_dialog.pendingData);
} else if (this.confirm_dialog.pendingDeleteItem) {
this.doDelete(this.confirm_dialog.pendingDeleteItem);
}
})
.catch(error => {
console.log("刪除訂單失敗", error);
this.snackbar.text = "刪除訂單失敗:" + error;
this.snackbar.show = true;
})
},
search_show(curr) { search_show(curr) {
console.log("btn_click:", curr, curr.api_url); console.log("btn_click:", curr, curr.api_url);
this.search_dialog.current = curr; this.search_dialog.current = curr;
@@ -585,7 +968,7 @@
this.search_dialog.list = response.data.list this.search_dialog.list = response.data.list
this.search_dialog.count = response.data.count this.search_dialog.count = response.data.count
this.search_dialog.loading = false this.search_dialog.loading = false
console.log(this.search_dialog.list)
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@@ -1318,13 +1701,32 @@
$('.tab-pane,.edit_Click').removeClass('pe-none'); // 移除 pe-none 類,允許編輯 $('.tab-pane,.edit_Click').removeClass('pe-none'); // 移除 pe-none 類,允許編輯
} }
}); });
let isComposing = false;
const cellphoneInput = document.querySelector('[id$="cellphone"]');
if (cellphoneInput) {
cellphoneInput.addEventListener('compositionstart', () => {
isComposing = true;
});
cellphoneInput.addEventListener('compositionend', (e) => {
isComposing = false;
formatCellphone(e.target);
});
cellphoneInput.addEventListener('input', (e) => {
if (!isComposing) {
formatCellphone(e.target);
}
});
}
</script> </script>
</asp:Content> </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server"> <asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex"> <div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
<template v-if="follower_id !='' "> {{titleword()}} </template> <template v-if="follower_id !='' "> {{titleword()}} </template>
</div> </div>
<div class="d-flex align-items-center"> <div class="">
<div class="form-check me-3 d-none" id="editCheckboxContainer"> <div class="form-check me-3 d-none" id="editCheckboxContainer">
<input class="form-check-input" type="checkbox" id="editCheckbox"> <input class="form-check-input" type="checkbox" id="editCheckbox">
<label class="form-check-label" for="editCheckbox"> <label class="form-check-label" for="editCheckbox">
@@ -1332,8 +1734,8 @@
</label> </label>
</div> </div>
<asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary edit_Click noedit" /> <asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary edit_Click noedit" />
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary edit_Click noedit" /> <asp:Button ID="edit" runat="server" Text="儲存" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary edit_Click noedit" />
<asp:Button ID="goback" runat="server" Text="回列表" Visible="false" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" /> <asp:Button ID="goback" runat="server" Text="取消" Visible="true" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
@@ -1359,8 +1761,11 @@
type="button" role="tab" aria-controls="profile" aria-selected="false" v-if="lists.length > 0"> type="button" role="tab" aria-controls="profile" aria-selected="false" v-if="lists.length > 0">
未付款紀錄 </button> 未付款紀錄 </button>
<button class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4" <button class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4"
type="button" role="tab" aria-controls="profile" aria-selected="false"> type="button" role="tab" aria-controls="profile" aria-selected="false" display="none">
牌位標題 </button> 牌位標題 </button>
<button class="nav-link" id="sec2-tab5" data-bs-toggle="tab" data-bs-target="#sec2-page5"
type="button" role="tab" aria-controls="profile" aria-selected="false">
全年報名 </button>
</div> </div>
</nav> </nav>
</div> </div>
@@ -1412,7 +1817,7 @@
</div> </div>
<label class="col-sm-2 col-lg-1 col-form-label">手機號碼<asp:Literal ID="cellphoneReqStar" runat="server" Text=" *"></asp:Literal></label> <label class="col-sm-2 col-lg-1 col-form-label">手機號碼<asp:Literal ID="cellphoneReqStar" runat="server" Text=" *"></asp:Literal></label>
<div class="col-sm-10 col-lg-3"> <div class="col-sm-10 col-lg-3">
<asp:TextBox ID="cellphone" MaxLength="12" runat="server" CssClass="form-control" data-encrypt="Y" placeholder="聯絡電話與手機號碼請至少填寫一項" oninput="formatCellphone(this)"></asp:TextBox> <asp:TextBox ID="cellphone" MaxLength="12" runat="server" CssClass="form-control" data-encrypt="Y" placeholder="聯絡電話與手機號碼請至少填寫一項"></asp:TextBox>
<asp:RegularExpressionValidator ControlToValidate="cellphone" Display="Dynamic" ErrorMessage="格式有誤" ID="RegularExpressionValidator2" runat="server" SetFocusOnError="true" ValidationExpression="^09\d{2}-?\d{3}-?\d{3}$" /> <asp:RegularExpressionValidator ControlToValidate="cellphone" Display="Dynamic" ErrorMessage="格式有誤" ID="RegularExpressionValidator2" runat="server" SetFocusOnError="true" ValidationExpression="^09\d{2}-?\d{3}-?\d{3}$" />
</div> </div>
</div> </div>
@@ -1570,7 +1975,6 @@
</template> </template>
</div> </div>
</div> </div>
<div class="row mb-1"> <div class="row mb-1">
<label class="col-form-label">備註</label> <label class="col-form-label">備註</label>
@@ -1959,9 +2363,176 @@
</v-data-table> </v-data-table>
</v-card> </v-card>
</div> </div>
<div class="tab-pane fade" id="sec2-page5" role="tabpanel" aria-labelledby="sec2-tab5" >
<v-card class="mx-auto" outlined v-if="follower_id!=''">
<v-data-table class="elevation-1" fixed-header
:headers="auto_enroll.headers"
:items="auto_enroll.items"
:search="auto_enroll.search">
<v-divider inset></v-divider>
<template v-slot:top>
<v-toolbar flat color="transparent" class="row ms-0">
<div class="col-12 col-md-10 d-flex">
<v-text-field
v-model="auto_enroll.search"
append-icon="mdi-magnify"
label="查詢"
dense
outlined
single-line
hide-details>
</v-text-field>
<v-btn
color="primary"
class="ml-2 white--text "
title="新增全年報名"
@click="auto_enroll_add">
<v-icon dark>mdi-plus</v-icon>新增
</v-btn>
</div>
</v-toolbar>
</template>
<!-- 編輯中 -->
<template v-slot:item.auto_enroll_start_date="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_start_date"
type="date"
dense
hide-details
outlined>
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_start_date }}
</template>
</template>
<template v-slot:item.auto_enroll_end_date="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_end_date"
type="date"
dense
hide-details
outlined>
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_end_date }}
</template>
</template>
<template v-slot:item.auto_enroll_receipt_title="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_receipt_title"
dense
hide-details
outlined
placeholder="請輸入收據抬頭">
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_receipt_title }}
</template>
</template>
<template v-slot:item.auto_enroll_receipt_address="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_receipt_address"
dense
hide-details
outlined
placeholder="請輸入收據地址">
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_receipt_address }}
</template>
</template>
<!-- 狀態欄位 -->
<template v-slot:item.auto_enroll_status="{ item }">
<v-chip
small
:color="getEnrollStatus(item).color"
:text-color="getEnrollStatus(item).textColor"
class="font-weight-medium">
{{ getEnrollStatus(item).label }}
</v-chip>
</template>
<!-- 操作欄位 -->
<template v-slot:item.actions="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-icon color="red" class="mr-2" @click="auto_enroll_cancel">
mdi-window-close
</v-icon>
<v-icon color="green" class="mr-2" @click="auto_enroll_save">
mdi-content-save
</v-icon>
</template>
<template v-else>
<v-icon color="green" class="mr-2" @click="auto_enroll_edit(item)">
mdi-pencil
</v-icon>
<v-icon color="red" class="mr-2" @click="auto_enroll_delete(item)">
mdi-delete
</v-icon>
<v-icon color="blue" class="mr-2" @click="unfilled_dialog_show(item)" title="查看未填寫品項活動">
mdi-file-find
</v-icon>
</template>
</template>
</v-data-table>
</v-card>
</div>
</div> </div>
</asp:Panel> </asp:Panel>
</div> </div>
<!-- 顯示沒有品項的活動 -->
<v-dialog v-model="unfilled_dialog.show" max-width="900px">
<v-card>
<v-card-title class="headline grey lighten-2">
未填寫品項的活動
<v-spacer></v-spacer>
<v-btn icon @click="unfilled_dialog.show = false"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title>
<v-card-text>
<v-data-table
:headers="unfilled_dialog.headers"
:items="unfilled_dialog.items"
:footer-props="unfilled_dialog.footer"
:items-per-page="unfilled_dialog.pageSize"
:server-items-length="unfilled_dialog.count"
:page.sync="unfilled_dialog.page"
:loading="unfilled_dialog.loading"
@update:page="unfilled_dialog_load"
>
</v-data-table>
</v-card-text>
<v-card-actions class="justify-center pb-6">
<v-btn
color="primary"
:disabled="unfilled_dialog.items.length == 0"
class="px-4"
@click="exportUnfilledOrders">
<v-icon left>mdi-printer</v-icon>
列印
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- Family Member Dialog --> <!-- Family Member Dialog -->
<v-dialog v-model="family.dialog" max-width="600px"> <v-dialog v-model="family.dialog" max-width="600px">
<v-card> <v-card>
@@ -2104,7 +2675,7 @@
<v-card> <v-card>
<v-card-title class="justify-space-between grey lighten-2"> <v-card-title class="justify-space-between grey lighten-2">
查詢:{{search_dialog.current.title}} 查詢:{{search_dialog.current.title}}
<v-btn icon @click="search_dialog.show=false"><v-icon>mdi-close</v-icon></v-btn> <v-btn icon @click="search_dialog.show=false;"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title> </v-card-title>
<v-card-text > <v-card-text >
<v-row> <v-row>
@@ -2154,5 +2725,47 @@
</v-btn> </v-btn>
</template> </template>
</v-snackbar> </v-snackbar>
<v-dialog v-model="confirm_dialog.show" max-width="500px" persistent>
<v-card>
<v-card-title class="justify-space-between grey lighten-2">
<span>{{ confirm_dialog.title }}</span>
<v-btn icon @click="close_confirm_dialog"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title>
<v-card-text class="pt-4">
<p class="body-1">{{ confirm_dialog.desc }}</p>
<v-data-table
:headers="confirm_dialog.headers"
:items="confirm_dialog.orders"
:items-per-page="10"
class="elevation-1 grey lighten-5"
:footer-props="{
'items-per-page-text': '每頁顯示',
'items-per-page-options': [5, 10]
}"
>
<template v-slot:item.activitydate="{ item }">
<span>{{ item.activitydate }}</span>
</template>
</v-data-table>
</v-card-text>
<v-divider class="pa-0 ma-0"></v-divider>
<v-card-actions class="pa-4 justify-end">
<v-btn color="primary" @click="keep_auto_enroll_order">
{{ confirm_dialog.btn_keep_text }}
</v-btn>
<v-btn color="red" dark @click="delete_auto_enroll_order">
{{ confirm_dialog.btn_cancel_text }}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div> </div>
</asp:Content> </asp:Content>
+123 -38
View File
@@ -1,34 +1,46 @@
using System; using Model;
using Newtonsoft.Json;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.Entity;
using System.Data.OleDb; using System.Data.OleDb;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Configuration; using static Model.activity_check;
using System.IO;
using System.Linq;
using System.Globalization;
using Model;
public partial class admin_follower_reg : MyWeb.config public partial class admin_follower_reg : MyWeb.config
{ {
private Model.ezEntities _db = new Model.ezEntities(); private Model.ezEntities _db = new Model.ezEntities();
public ArrayList _tmp = new ArrayList(); public ArrayList _tmp = new ArrayList();
public bool isDataChanged = false;
public bool isAutoNumbering = ConfigurationManager.AppSettings["IsAutoNumbering"].ToString() == "true" ? true : false;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
CallAjax(); CallAjax();
if (!IsPostBack) if (!IsPostBack)
{ {
InitEnumsOptions<Model.follower.type>(identity_type); //身分別 InitEnumsOptions<Model.follower.type>(identity_type); //身分別
//var qry = _db.followers.AsEnumerable(); //var qry = _db.followers.AsEnumerable();
var qry = _db.followers.AsQueryable(); var qry = _db.followers.AsQueryable();
if (isStrNull(Request["num"])) if (isStrNull(Request["num"]))
{ {
if (!isAutoNumbering)
{
f_number.ReadOnly = false;
}
if (!isStrNull(Request["leader"])) if (!isStrNull(Request["leader"]))
{ {
int _num = Val(Request["leader"]); int _num = Val(Request["leader"]);
@@ -50,9 +62,14 @@ public partial class admin_follower_reg : MyWeb.config
//預設國籍 //預設國籍
country.Value = "158"; country.Value = "158";
country_txt.Value = "中華民國(台灣)"; country_txt.Value = "中華民國(台灣)";
// 預設加入日期
join_date.Text = DateTime.Now.ToString("yyyy-MM-dd");
} }
else else
{ {
f_number.ReadOnly = true;
int _num = Val(Request["num"]); int _num = Val(Request["num"]);
var prod = qry.Where(q => q.num == _num).FirstOrDefault(); var prod = qry.Where(q => q.num == _num).FirstOrDefault();
if (prod != null) if (prod != null)
@@ -127,7 +144,7 @@ public partial class admin_follower_reg : MyWeb.config
country.Value = prod.country.ToString(); country.Value = prod.country.ToString();
} }
if (prod.reg_time.HasValue) if (prod.reg_time.HasValue)
{ {
timePanel1.Visible = true; timePanel1.Visible = true;
reg_time.Text= prod.reg_time.Value.ToString("yyyy/MM/dd HH:mm:ss"); reg_time.Text= prod.reg_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
} }
@@ -138,7 +155,6 @@ public partial class admin_follower_reg : MyWeb.config
modify_time.Text = prod.admin_log; modify_time.Text = prod.admin_log;
} }
edit.Visible = true; edit.Visible = true;
goback.Visible = true; goback.Visible = true;
add.Visible = false; add.Visible = false;
@@ -163,10 +179,39 @@ public partial class admin_follower_reg : MyWeb.config
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"])); Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
} }
#region #region
protected string createOrderNumber()
{
Application.Lock();
string order_no = "AA" + DateTime.Now.ToString("yyMMdd");
var qry = _db.companies.AsQueryable();
//var prod = qry.Where(q => q.last_order_no.Contains(order_no)).FirstOrDefault();
var prod = qry.Where(q => q.num == 1).FirstOrDefault();
if (prod != null)
{
if (!isStrNull(prod.last_order_no) && prod.last_order_no.Contains(order_no))
{
int tmp = Convert.ToInt32(prod.last_order_no.Replace(order_no, "")) + 1;
order_no = order_no + tmp.ToString("0000");
}
else
{
order_no = order_no + "0001";
}
prod.last_order_no = order_no;
_db.SaveChanges();
}
else
order_no = "";
Application.UnLock();
return order_no;
}
protected void add_Click(object sender, EventArgs e) protected void add_Click(object sender, EventArgs e)
{ {
if (Page.IsValid) { if (Page.IsValid) {
@@ -190,7 +235,7 @@ public partial class admin_follower_reg : MyWeb.config
{ {
ObjValue.SetValue(followers, selectDate(textBox)); ObjValue.SetValue(followers, selectDate(textBox));
} }
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"]) else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"])
&& ValString(textBox.Attributes["data-encrypt"]).Equals("Y")) && ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
{ {
ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim())); ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim()));
@@ -206,8 +251,11 @@ public partial class admin_follower_reg : MyWeb.config
} }
} }
} }
// 使用新的 generate_f_number 方法,已內建重號檢查和重試機制 if (isAutoNumbering)
followers.f_number = follower.generate_f_number(sex.SelectedValue); {
// 使用新的 generate_f_number 方法,已內建重號檢查和重試機制
followers.f_number = follower.generate_f_number(sex.SelectedValue);
}
followers.identity_type = Val(identity_type.SelectedValue); followers.identity_type = Val(identity_type.SelectedValue);
if(!isStrNull(leader.Value)) followers.leader = Val(leader.Value); if(!isStrNull(leader.Value)) followers.leader = Val(leader.Value);
if (!isStrNull(country.Value)) followers.country = country.Value; if (!isStrNull(country.Value)) followers.country = country.Value;
@@ -240,6 +288,8 @@ public partial class admin_follower_reg : MyWeb.config
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Insert, f_number.Text + u_name.Text); admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Insert, f_number.Text + u_name.Text);
Session["LastAddedID"] = followers.f_number;
Response.Redirect("index.aspx"); Response.Redirect("index.aspx");
} }
else else
@@ -259,8 +309,8 @@ public partial class admin_follower_reg : MyWeb.config
L_msg.Type = alert_type.danger; L_msg.Type = alert_type.danger;
L_msg.Text = "信眾編號重複"; L_msg.Text = "信眾編號重複";
} }
} }
} }
#endregion #endregion
@@ -282,7 +332,7 @@ public partial class admin_follower_reg : MyWeb.config
try try
{ {
foreach (Control obj in cardBodyPanel.Controls) foreach (Control obj in cardBodyPanel.Controls)
{ {
if (obj is TextBox) if (obj is TextBox)
{ {
var ObjValue = followers.GetType().GetProperty(obj.ID); var ObjValue = followers.GetType().GetProperty(obj.ID);
@@ -298,10 +348,7 @@ public partial class admin_follower_reg : MyWeb.config
} }
else else
ObjValue.SetValue(followers, null); ObjValue.SetValue(followers, null);
} }
} }
followers.identity_type = Val(identity_type.SelectedValue); followers.identity_type = Val(identity_type.SelectedValue);
@@ -310,22 +357,60 @@ public partial class admin_follower_reg : MyWeb.config
followers.sex = sex.SelectedValue; followers.sex = sex.SelectedValue;
followers.blood = blood.SelectedValue; followers.blood = blood.SelectedValue;
followers.tab = tab.Value.Trim(','); followers.tab = tab.Value.Trim(',');
followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
followers.follower_hash = encrypt.followerHash(followers.phone, followers.id_code); followers.follower_hash = encrypt.followerHash(followers.phone, followers.id_code);
// 如果啟用 search_keywords 功能,生成並更新 search_keywords // 如果啟用 search_keywords 功能,生成並更新 search_keywords
if (GlobalVariables.UseSearchKeywords) if (GlobalVariables.UseSearchKeywords)
{ {
followers.search_keywords = encrypt.GenerateSearchKeywords(followers); followers.search_keywords = encrypt.GenerateSearchKeywords(followers);
} }
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log(); // 檢查是否有修改資料
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Update, f_number.Text + u_name.Text); var entry = _db.Entry(followers);
this.isDataChanged = entry.CurrentValues.PropertyNames.Any(name =>
{
if (name == "admin_log" || name == "follower_hash")
return false;
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"])); var originalVal = entry.OriginalValues[name]?.ToString();
var currentVal = entry.CurrentValues[name]?.ToString();
// 針對加密欄位進行特殊處理
bool isEncryptedField = (name == "phone" || name == "id_code");
if (isEncryptedField)
{
string originalPlain = !string.IsNullOrEmpty(originalVal) ? encrypt.DecryptAutoKey(originalVal) : "";
string currentPlain = !string.IsNullOrEmpty(currentVal) ? encrypt.DecryptAutoKey(currentVal) : "";
return originalPlain.Trim() != currentPlain.Trim();
}
return !object.Equals(originalVal, currentVal);
});
if (this.isDataChanged)
{
followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
}
else
{
entry.State = EntityState.Unchanged;
}
int isDataSaved = _db.SaveChanges();
if (isDataSaved > 0)
{
//L_msg.Type = alert_type.success;
//L_msg.Text = "修改成功";
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Update, f_number.Text + u_name.Text);
Response.Redirect("index.aspx?dirty=1&page=" + Convert.ToString(Request["page"]));
}
else
{
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -340,16 +425,16 @@ public partial class admin_follower_reg : MyWeb.config
L_msg.Text = "查無資料"; L_msg.Text = "查無資料";
} }
/* /*
if (chk_pro_num(f_number.Text, Val(Request["num"]))) if (chk_pro_num(f_number.Text, Val(Request["num"])))
{ {
} }
else else
{ {
L_msg.Type = alert_type.danger; L_msg.Type = alert_type.danger;
L_msg.Text = "信眾編號重複"; L_msg.Text = "信眾編號重複";
} }
*/ */
} }
} }
#endregion #endregion
+32 -1
View File
@@ -85,7 +85,7 @@
<label for="u_gauth"><i class="mdi mdi-key-variant"></i> Google Authenticator 驗證碼</label> <label for="u_gauth"><i class="mdi mdi-key-variant"></i> Google Authenticator 驗證碼</label>
</div> </div>
<div class="mt-4 mb-0 d-grid gap-2"> <div class="mt-4 mb-0 d-grid gap-2">
<asp:LinkButton ID="Button1" runat="server" OnClick="Button1_Click" <asp:LinkButton ID="Button1" runat="server" OnClick="Button1_Click"
CssClass="btn btn-primary rounded-pill"> CssClass="btn btn-primary rounded-pill">
<i class="mdi mdi-login"></i> 登入</asp:LinkButton> <i class="mdi mdi-login"></i> 登入</asp:LinkButton>
<asp:LinkButton ID="DesignModeButton" runat="server" OnClick="DesignModeButton_Click" <asp:LinkButton ID="DesignModeButton" runat="server" OnClick="DesignModeButton_Click"
@@ -105,5 +105,36 @@
</div> </div>
</div> </div>
<!-- /.content_box --> <!-- /.content_box -->
<script>
document.addEventListener('DOMContentLoaded', function () {
var accountInput = document.getElementById('<%= u_id.ClientID %>');
var passwordInput = document.getElementById('<%= u_password.ClientID %>');
var chkInput = document.getElementById('<%= chknum.ClientID %>');
var btn = document.getElementById('<%= Button1.ClientID %>');
accountInput.addEventListener('keypress', function (e){
if (e.keyCode === 13) {
$("#<%= u_password.ClientID %>").focus();
return false;
}
})
passwordInput.addEventListener('keypress', function (e) {
if (e.keyCode === 13) {
$("#<%= chknum.ClientID %>").focus();
return false;
}
})
var triggerLogin = function (e) {
if (e.keyCode === 13) {
btn.click();
e.preventDefault();
return false;
}
};
if (chkInput) chkInput.addEventListener('keypress', triggerLogin);
});
</script>
</asp:Content> </asp:Content>
+1 -1
View File
@@ -8,7 +8,7 @@
<ul class="collapsible_item"> <ul class="collapsible_item">
<asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound"> <asp:Repeater ID="Repeater2" runat="server" OnItemDataBound="Repeater2_ItemDataBound">
<ItemTemplate> <ItemTemplate>
<li><a class="menu" href="<%#ResolveUrl(ValString(Eval("url"))) %>" <li><a class="menu" href="<%#ResolveUrl(ValString(Eval("url"))) %>"
target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>"><%#Eval("title") %></a></li> target="<%#(ValString(Eval("target"))=="B"?"_blank":"_self") %>"><%#Eval("title") %></a></li>
</ItemTemplate> </ItemTemplate>
</asp:Repeater> </asp:Repeater>
+233 -61
View File
@@ -14,17 +14,18 @@
<a @click="print_dialog.show=true" class="btn btn-outline-primary btn-print" target="_blank"> <a @click="print_dialog.show=true" class="btn btn-outline-primary btn-print" target="_blank">
<i class="mdi mdi-printer"></i>列印管理報表 <i class="mdi mdi-printer"></i>列印管理報表
</a> </a>
<div :style="data_table.list.length === 0 ? 'pointer-events: none; opacity: 0.5;' : ''" style="display:inline-block;">
<div class="dropdown d-inline-block"> <div class="dropdown d-inline-block">
<a class="btn btn-outline-primary btn-print dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><i class="mdi mdi-printer"></i>列印報名資料</a> <a class="btn btn-outline-primary btn-print dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><i class="mdi mdi-printer"></i>列印查詢資料</a>
<ul class="dropdown-menu ps-0 w-100" aria-labelledby="dropdownPrintLink"> <ul class="dropdown-menu ps-0 w-100" aria-labelledby="dropdownPrintLink">
<li><a @click="search.hasPrice='Y';goPrint()" class="dropdown-item"><i class="mdi mdi-printer me-1"></i>有金額</a></li> <li><a @click="search.hasPrice='Y';goPrint()" class="dropdown-item"><i class="mdi mdi-printer me-1"></i>有金額</a></li>
<li><a @click="search.hasPrice='N';goPrint()" class="dropdown-item"><i class="mdi mdi-printer me-1"></i>無金額</a></li> <li><a @click="search.hasPrice='N';goPrint()" class="dropdown-item"><i class="mdi mdi-printer me-1"></i>無金額</a></li>
</ul> </ul>
</div>
</div>
<div :style="data_table.list.length === 0 ? 'pointer-events: none; opacity: 0.5;' : ''" style="display:inline-block;">
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出查詢資料(Excel</asp:LinkButton>
</div> </div>
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server"> <asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
@@ -39,6 +40,8 @@
vuetify: new Vuetify(vuetify_options), vuetify: new Vuetify(vuetify_options),
data() { data() {
return { return {
print_error_msg: "",
isSearched: false,
this_act : '<%= Request["act_id"]%>', this_act : '<%= Request["act_id"]%>',
options: { multiSort: false }, options: { multiSort: false },
search_options: { multiSort: false }, search_options: { multiSort: false },
@@ -56,6 +59,7 @@
{ text: '報名日期', value: 'up_time' }, { text: '報名日期', value: 'up_time' },
{ text: '報名活動', value: 'subject', align: 'start' }, { text: '報名活動', value: 'subject', align: 'start' },
{ text: '單據狀態', value: 'keyin1_txt' }, { text: '單據狀態', value: 'keyin1_txt' },
{ text: '報到狀態', value: 'status' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' } { text: '', value: 'slot_btn', sortable: false, align: 'end' }
], ],
footer:{ footer:{
@@ -203,6 +207,10 @@
} }
}, },
mounted() { mounted() {
const printResult = document.getElementById('<%= hid_err_msg.ClientID %>').value;
document.getElementById('<%= hid_err_msg.ClientID %>').value = '';
window._printResult = printResult
this.detalKeyinArray(); this.detalKeyinArray();
this.search_dialog.current = this.search_dialog.controls.search1 ///default this.search_dialog.current = this.search_dialog.controls.search1 ///default
if (this.this_act != '') if (this.this_act != '')
@@ -211,20 +219,63 @@
this.initActivity(); this.initActivity();
const navEntries = performance.getEntriesByType("navigation"); const navEntries = performance.getEntriesByType("navigation");
const isReload = navEntries.length > 0 && navEntries[0].type === "reload"; const isReload = navEntries.length > 0 && navEntries[0].type === "reload";
if (isReload) { if (isReload) {
sessionStorage.removeItem("orderpage"); sessionStorage.removeItem("orderpage");
sessionStorage.removeItem("order_list_cache");
sessionStorage.removeItem("order_query_params");
}
else if ("<%=lastAddedNo%>" !== "") {
const newQuery = { order_no: '<%=lastAddedNo%>' };
sessionStorage.setItem('order_query_params', JSON.stringify(newQuery));
this.search = newQuery;
this.isSearched = true;
} }
else { else {
const savedPage = parseInt(sessionStorage.getItem('orderpage')); const savedPage = parseInt(sessionStorage.getItem('orderpage'));
const savedData = sessionStorage.getItem("order_list_cache");
const savedQuery = JSON.parse(sessionStorage.getItem("order_query_params"));
if (savedQuery) {
this.search = savedQuery;
this.isSearched = true;
}
if (savedPage) { if (savedPage) {
this.options.page = savedPage; this.options.page = savedPage;
} }
} if (savedData && savedData !== "undefined") {
this.data_table = JSON.parse(savedData);
this.isSearched = true;
}
}
if (printResult === 'nodata' || printResult === 'success') {
this.$nextTick(() => {
this.print_dialog.show = true;
if (printResult === 'nodata') {
this.print_error_msg = "查無資料,請重新選擇區間";
}
});
}
this.$nextTick(() => {
setTimeout(() => {
// 清空 URL
const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
window.history.replaceState({}, '', cleanUrl);
}, 100);
});
}, },
watch: { watch: {
options: { options: {
handler() { handler() {
this.getDefault() if (this.isSearched) {
this.getDefault()
}
else {
this.data_table.loading = false;
}
}, },
deep: true, deep: true,
}, },
@@ -236,6 +287,57 @@
}, },
}, },
methods: { methods: {
triggerManagementExport(mode) {
this.print_error_msg = "";
if (this.print_search.year == '') {
msgbox('請輸入年份');
return;
}
if (!this.print_search.chk_noact && !this.print_search.chk_hasact) {
msgbox('活動/非活動至少勾選一項');
return;
}
// 將 Vue 狀態同步至 ASP.NET HiddenField,供後端 PostBack 讀取參數
document.getElementById('<%= hid_print_mode.ClientID %>').value = this.print_conditions;
document.getElementById('<%= hid_print_year.ClientID %>').value = this.print_search.year;
if (this.print_conditions == 'mm')
document.getElementById('<%= hid_print_month.ClientID %>').value = this.print_search.month;
else if (this.print_conditions == 'ss')
document.getElementById('<%= hid_print_season.ClientID %>').value = this.print_search.season;
document.getElementById('<%= hid_select_act.ClientID %>').value = this.print_search.select_act;
document.getElementById('<%= hid_select_actitem.ClientID %>').value = this.print_search.select_actitem;
document.getElementById('<%= hid_chk_hasact.ClientID %>').value = this.print_search.chk_hasact;
document.getElementById('<%= hid_chk_noact.ClientID %>').value = this.print_search.chk_noact;
let qry = "";
Object.keys(this.print_search).forEach(key => {
if (this.print_search[key] != undefined && this.print_search[key] != null && this.print_search[key] != '') {
if (key == 'month' ) {
if (this.print_conditions == 'mm') {
qry += "&month=" + this.print_search.month;
}
} else if ( key == 'season')
{
if (this.print_conditions == 'ss') {
qry += "&season=" + this.print_search.season;
}
}
else {
qry += (qry != '' ? '&' : '?') + (key + '=' + this.print_search[key]);
}
}
});
document.getElementById('<%= hid_qry.ClientID %>').value = qry;
if (mode === 'print') {
document.getElementById('<%= print_management.ClientID %>').click();
}
else if (mode === "excel") {
document.getElementById('<%= excel_management.ClientID %>').click();
}
},
search_show(curr) { search_show(curr) {
//console.log("btn_click:", curr, curr.api_url); //console.log("btn_click:", curr, curr.api_url);
this.search_dialog.current = curr; this.search_dialog.current = curr;
@@ -321,19 +423,24 @@
this.data_table.list = response.data.list this.data_table.list = response.data.list
this.data_table.count = response.data.count; this.data_table.count = response.data.count;
this.data_table.loading = false this.data_table.loading = false
const dataToStore = JSON.stringify(this.data_table);
sessionStorage.setItem("order_list_cache", dataToStore);
}) })
.catch(error => console.log(error)) .catch(error => console.log(error))
}, },
detalKeyinArray() { detalKeyinArray() {
var getArray = <%=Newtonsoft.Json.JsonConvert.SerializeObject(_keyin1Item, Newtonsoft.Json.Formatting.Indented) %>; var getArray = <%=Newtonsoft.Json.JsonConvert.SerializeObject(_keyin1Item, Newtonsoft.Json.Formatting.Indented) %>;
var keys = Object.keys(getArray); if (getArray !== null) {
for (let i = 0; i < keys.length; i++) { var keys = Object.keys(getArray);
//console.log(`${keys[i]}:${getArray[keys[i]]}`); //value : text for (let i = 0; i < keys.length; i++) {
var _tmp = { //console.log(`${keys[i]}:${getArray[keys[i]]}`); //value : text
text: getArray[keys[i]], var _tmp = {
val: parseInt(keys[i]), text: getArray[keys[i]],
val: parseInt(keys[i]),
}
this.keyin1_items.push(_tmp);
} }
this.keyin1_items.push(_tmp);
} }
}, },
@@ -368,22 +475,28 @@
//} //}
//this.data_table.selected = []; //this.data_table.selected = [];
//this.data_table.count = this.data_table.list.length //this.data_table.count = this.data_table.list.length
location.reload(); //location.reload();
this.getDefault();
}) })
.catch(error => console.log(error)) .catch(error => console.log(error))
} }
}, },
btn_search() { btn_search() {
this.isSearched = true;
sessionStorage.setItem("order_query_params", JSON.stringify(this.search));
this.this_act = ''; this.this_act = '';
this.search.activity_num = ''; this.search.activity_num = '';
this.getDefault(true) this.getDefault(true)
bootstrap.Offcanvas.getInstance(document.getElementById("offcanvasRight")).hide()
}, },
btn_all() { btn_all() {
this.isSearched = false;
this.this_act = ''; this.this_act = '';
this.search.activity_num = ''; this.search.activity_num = '';
clearObjProps(this.search); clearObjProps(this.search);
this.btn_search() sessionStorage.setItem("order_query_params", JSON.stringify(this.search));
//this.btn_search()
}, },
checkInMsg(item) { checkInMsg(item) {
this.check_data.f_num = item.f_num; this.check_data.f_num = item.f_num;
@@ -392,39 +505,59 @@
this.check_data.activity_name = item.subject; this.check_data.activity_name = item.subject;
this.check_dialog.show = true; this.check_dialog.show = true;
}, },
checkIn() { checkIn(item) {
if (this.check_data.qty > 0 && this.check_data.status.val > 0) { var checkdata =
var chechdata = {
{ f_num: item.f_num,
f_num: this.check_data.f_num, activity_num: item.activity_num,
activity_num: this.check_data.activity_num, status: 1,
status: this.check_data.status.val, qty: 1,
qty: this.check_data.qty,
}
axios
.post(HTTP_HOST + 'api/activity/OrderCheckIn', chechdata)
.then(response => {
//清空
this.check_data.f_num = 0;
this.check_data.u_name = '';
this.check_data.activity_num = 0;
this.check_data.activity_name = '';
this.check_data.qty = 1;
this.check_data.status.text = '';
this.check_data.status.val = 1;
this.check_dialog.show = false;
msgtop('簽到成功')
})
.catch(
error => {
console.log(error)
msgtop('簽到失敗', 'error')
}
)
} else {
msgbox('報到資訊請填寫完整');
} }
console.log(checkdata)
axios
.post(HTTP_HOST + 'api/activity/OrderCheckIn', checkdata)
.then(response => {
msgtop('簽到成功');
this.getDefault();
})
.catch(
error => {
console.log(error)
msgtop('簽到失敗', 'error')
}
)
//if (this.check_data.qty > 0 && this.check_data.status.val > 0) {
// var chechdata =
// {
// f_num: this.check_data.f_num,
// activity_num: this.check_data.activity_num,
// status: this.check_data.status.val,
// qty: this.check_data.qty,
// }
// axios
// .post(HTTP_HOST + 'api/activity/OrderCheckIn', chechdata)
// .then(response => {
// //清空
// this.check_data.f_num = 0;
// this.check_data.u_name = '';
// this.check_data.activity_num = 0;
// this.check_data.activity_name = '';
// this.check_data.qty = 1;
// this.check_data.status.text = '';
// this.check_data.status.val = 1;
// this.check_dialog.show = false;
// msgtop('簽到成功')
// })
// .catch(
// error => {
// console.log(error)
// msgtop('簽到失敗', 'error')
// }
// )
//} else {
// msgbox('報到資訊請填寫完整');
//}
}, goPrint() { }, goPrint() {
let _qry = ""; let _qry = "";
Object.keys(this.search).forEach(key => { Object.keys(this.search).forEach(key => {
@@ -442,6 +575,7 @@
//列印管理報表 //列印管理報表
print_close() { print_close() {
this.print_dialog.show = false; this.print_dialog.show = false;
this.print_error_msg = "";
} }
, ,
initPrintSearch() { initPrintSearch() {
@@ -504,9 +638,9 @@
} }
} }
}); });
console.log(_qry);
this.print_dialog.show = false; this.print_dialog.show = false;
window.open("print.aspx" + _qry, '_blank'); //window.open("print.aspx" + _qry, '_blank');
} else { } else {
msgbox('活動/非活動至少勾選一項'); msgbox('活動/非活動至少勾選一項');
} }
@@ -537,7 +671,7 @@
initActivity() { initActivity() {
axios.get(HTTP_HOST + 'api/activity') axios.get(HTTP_HOST + 'api/activity')
.then(response => { .then(response => {
this.select_act_list = response.data this.select_act_list = response.data
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@@ -556,10 +690,35 @@
$('#country2').val(''); $('#country2').val('');
VueApp.search.country2 = ''; VueApp.search.country2 = '';
}); });
$(document).ready(function () {
// 判斷是否彈出 search dialog
let hasSearchResult = sessionStorage.getItem("order_list_cache") !== null;
if (!hasSearchResult && window._printResult === '') {
let $btn = $("a[data-bs-target='#offcanvasRight'][href='#search_panel']");
$btn.click();
let el = document.getElementById('offcanvasRight');
let offcanvas = bootstrap.Offcanvas.getOrCreateInstance(el);
offcanvas.show();
}
});
</script> </script>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" /> <uc1:alert runat="server" ID="L_msg" Text="" />
<asp:HiddenField ID="hid_err_msg" runat="server" />
<asp:HiddenField ID="hid_print_year" runat="server" />
<asp:HiddenField ID="hid_print_month" runat="server" />
<asp:HiddenField ID="hid_print_season" runat="server" />
<asp:HiddenField ID="hid_print_mode" runat="server" />
<asp:HiddenField ID="hid_chk_hasact" runat="server" />
<asp:HiddenField ID="hid_chk_noact" runat="server" />
<asp:HiddenField ID="hid_select_act" runat="server" />
<asp:HiddenField ID="hid_select_actitem" runat="server" />
<asp:HiddenField ID="hid_qry" runat="server" />
<asp:LinkButton ID="print_management" runat="server" OnClick="export_Click" style="display:none;" />
<asp:LinkButton ID="excel_management" runat="server" OnClick="export_Click" style="display:none;" />
<div id="content" class="container-fluid"> <div id="content" class="container-fluid">
<v-data-table <v-data-table
v-model="data_table.selected" v-model="data_table.selected"
@@ -580,10 +739,13 @@
<template #item.up_time="{ item }" > <template #item.up_time="{ item }" >
{{ item.up_time|timeString('YYYY/MM/DD') }} {{ item.up_time|timeString('YYYY/MM/DD') }}
</template> </template>
<template #item.u_name="{ item }" > <template #item.u_name="{ item }" >
<a v-if="item.f_num != null && item.activity_num != null" @click="checkInMsg(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-account-check"></i>報到</a>
{{ item.u_name }} {{ item.u_name }}
</template> </template>
<template #item.status="{ item }" >
<a v-if="item.f_num != null && item.activity_num != null && item.status == 0" @click="checkIn(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-account"></i>報到</a>
<a v-if="item.f_num != null && item.activity_num != null && item.status == 1" class="btn btn-outline-secondary btn-sm opacity-50" style="pointer-events: none" ><i class="mdi mdi-account-check"></i>已報到</a>
</template>
<template #item.slot_btn="{ item }"> <template #item.slot_btn="{ item }">
<a :href="'reg.aspx?order_no='+item.order_no" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a> <a :href="'reg.aspx?order_no='+item.order_no" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a>
<a @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></i>刪除</a> <a @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></i>刪除</a>
@@ -692,7 +854,8 @@
item-text="text" item-text="text"
item-value="val" item-value="val"
v-model="print_search.month" v-model="print_search.month"
:items="select_items.month" :items="select_items.month"
eager
></v-select> ></v-select>
</v-col> </v-col>
<v-col :cols="2" class="pt-5" v-if="print_conditions=='ss' "> <v-col :cols="2" class="pt-5" v-if="print_conditions=='ss' ">
@@ -703,7 +866,8 @@
item-text="text" item-text="text"
item-value="val" item-value="val"
v-model="print_search.season" v-model="print_search.season"
:items="select_items.season" :items="select_items.season"
eager
></v-select> ></v-select>
</v-col> </v-col>
@@ -764,9 +928,17 @@
</v-row> </v-row>
</v-col>--%> </v-col>--%>
</v-row> </v-row>
<v-row>
<v-col>
<div v-if="print_error_msg" class="red--text mt-2 text-center" style="font-weight: bold;">
{{ print_error_msg }}
</div>
</v-col>
</v-row>
<v-row densee class="pt-3" > <v-row densee class="pt-3" >
<v-col :cols="12" class="pt-3 text-center" > <v-col :cols="12" class="pt-3 text-center" >
<v-btn class="ma-2" color="primary" dark @click="goPrint2" > 列印 </v-btn> <v-btn class="ma-2" color="primary" dark @click="triggerManagementExport('print')" > 列印 </v-btn>
<v-btn class="ma-2" color="primary" dark @click="triggerManagementExport('excel')"> 匯出 Excel </v-btn>
<v-btn class="ma-2" color="green" dark @click="print_close" > 取消 </v-btn> <v-btn class="ma-2" color="green" dark @click="print_close" > 取消 </v-btn>
</v-col> </v-col>
</v-row> </v-row>
+565 -26
View File
@@ -1,22 +1,28 @@
using System; using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using Newtonsoft.Json.Linq;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Configuration; using static Model.admin_log;
using System.IO; using static regionController;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
using System.Linq;
public partial class admin_order_index : MyWeb.config public partial class admin_order_index : MyWeb.config
{ {
private Model.ezEntities _db = new Model.ezEntities(); private Model.ezEntities _db = new Model.ezEntities();
public Dictionary<int, string> _keyin1Item = null; public Dictionary<int, string> _keyin1Item = null;
protected string lastAddedNo;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
@@ -33,6 +39,13 @@ public partial class admin_order_index : MyWeb.config
} }
_keyin1Item = publicFun.enum_desc<Model.activity_check.keyin1>(); //狀態 _keyin1Item = publicFun.enum_desc<Model.activity_check.keyin1>(); //狀態
if (Session["LastAddedNo"] != null)
{
lastAddedNo = Session["LastAddedNo"].ToString();
Session.Remove("LastAddedNo");
}
BuildKind(); BuildKind();
} }
@@ -58,6 +71,452 @@ public partial class admin_order_index : MyWeb.config
#endregion #endregion
#region Excel #region Excel
protected void export_Click(object sender, EventArgs e)
{
LinkButton btn = sender as LinkButton;
if (btn == null) return;
bool isPrintMode = (btn.ID == "print_management");
bool isExcelMode = (btn.ID == "excel_management" || btn.ID == "excel");
//查詢要匯出的資料
string _query = ""; // 紀錄匯出條件
//var list = searchData(ref _query, isManagementMode);
if (isExcelMode)
{
int selYear = !string.IsNullOrEmpty(hid_print_year.Value) ? int.Parse(hid_print_year.Value) : 0;
int selMonth = !string.IsNullOrEmpty(hid_print_month.Value) ? int.Parse(hid_print_month.Value) : 0;
int selSeason = !string.IsNullOrEmpty(hid_print_season.Value) ? int.Parse(hid_print_season.Value) : 0;
string selMode = !string.IsNullOrEmpty(hid_print_mode.Value) ? hid_print_mode.Value : "";
bool chkHasAct = !string.IsNullOrEmpty(hid_chk_hasact.Value) && Convert.ToBoolean(hid_chk_hasact.Value);
bool chkNoAct = !string.IsNullOrEmpty(hid_chk_noact.Value) && Convert.ToBoolean(hid_chk_noact.Value);
int selAct = !string.IsNullOrEmpty(hid_select_act.Value) ? int.Parse(hid_select_act.Value) : 0;
int selActItem = !string.IsNullOrEmpty(hid_select_actitem.Value) ? int.Parse(hid_select_actitem.Value) : 0;
var qry = _db.pro_order.AsQueryable();
if (selYear > 0)
{
qry = qry.Where(o => o.up_time.HasValue && o.up_time.Value.Year == selYear);
_query += "年份:" + selYear + "\n";
}
if (selMode == "mm" && selMonth > 0)
{
qry = qry.Where(o => o.up_time.HasValue && o.up_time.Value.Month == selMonth);
_query += "月份:" + selMonth + "\n";
}
if (selMode == "ss" && selSeason > 0)
{
if (selSeason == 1)
{
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 1 || o.up_time.Value.Month == 2 || o.up_time.Value.Month == 3);
}
else if (selSeason == 2)
{
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 4 || o.up_time.Value.Month == 5 || o.up_time.Value.Month == 6);
}
else if (selSeason == 3)
{
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 7 || o.up_time.Value.Month == 8 || o.up_time.Value.Month == 9);
}
else if (selSeason == 4)
{
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 10 || o.up_time.Value.Month == 11 || o.up_time.Value.Month == 12);
}
_query += "季度:" + selSeason + "\n";
}
if (chkHasAct)
{
if(selAct > 0)
{
var actSubject = _db.activities.Where(a => a.num == selAct).Select(a => a.subject).FirstOrDefault();
_query += $"活動報名: {actSubject}\n";
}
else
{
_query += $"活動報名\n";
}
if (chkNoAct)
{
_query += "非活動報名\n";
if (selAct > 0)
qry = qry.Where(o => o.activity_num.HasValue && o.activity_num.Value == selAct);
}
else
{
qry = qry.Where(o => o.activity_num.HasValue);
if (selAct > 0)
qry = qry.Where(o => o.activity_num.Value == selAct);
}
}
else
{
if (chkNoAct)
{
qry = qry.Where(o => o.activity_num == null);
_query += "非活動報名\n";
}
}
if (selActItem > 0)
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem_num.Value == selActItem).Count() > 0);
if (selYear > 0)
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);
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
var bedDt = _db.bed_order_detail.AsQueryable();//掛單明細
//紀錄匯出條件
//var list = qry.ToList();
var list = qry.GroupJoin(
_db.pro_order_detail, o => o.order_no, p => p.order_no, (o, c) =>
new
{
//訂單資料
order_no = o.order_no,
up_time = o.up_time,
keyin1 = o.keyin1,
f_num = o.follower != null ? o.follower.u_name : "", //姓名/名稱
phone = o.phone,
activity_num = o.activity_num.HasValue ? o.activity.subject : "",
address = o.address,
demo = o.demo,
c
}).SelectMany(o => o.c.DefaultIfEmpty(), (o, d) => //SelectMany 展開
new
{
//訂單資料
order_no = o.order_no,
up_time = o.up_time,
keyin1 = o.keyin1,
f_num = o.f_num, //姓名/名稱
phone = o.phone,
activity_num = o.activity_num,
address = o.address,
demo = o.demo,
//訂單明細
//使用DefaultIfEmpty 因匿名型別無法輸出NULL(無法轉換成強型別),需特別注意Null的處理
d_actItem_num = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.subject : ""), //項目名稱
d_category = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.category.ToString() : ""),
d_f_num = d == null ? "" : (d.f_num.HasValue ? d.follower.u_name : ""), //姓名
d_address = d == null ? "" : d.address,
d_from_id = d == null ? "" : (d.from_id.HasValue ? d.follower1.u_name : ""), //陽上/報恩者
d_f_num_tablet = d == null ? "" : d.f_num_tablet,
d_start_date = d == null ? (DateTime?)null : d.start_date, //開始日期
d_due_date = d == null ? (DateTime?)null : d.due_date, //期滿日期
d_extend_date = d == null ? (DateTime?)null : d.extend_date, //應續約日
d_price = d == null ? (float?)null : d.price, //預設金額
d_qty = d == null ? "" : (d.qty.HasValue ? d.qty.Value.ToString() : "0"), //數量
d_writeBedQty = d == null ? 0 : bedDt.Where(b => (b.bed_order.o_detail_id.Value == d.num) && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量
d_notBedQty = d == null ? 0 : bedDt.Where(b => b.bed_order.o_detail_id.Value == d.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量
d_pay = d == null ? "" : (d.pay.HasValue ? d.pay.Value.ToString() : "0"), //已收金額
d_pay_date = d == null ? (DateTime?)null : d.start_date, //付款期限
d_keyin1 = d == null ? (int?)null : d.keyin1,
d_demo = d == null ? "" : d.demo, //狀態備註
}).ToList();
var memoryStream = new MemoryStream();
if (list.Count > 0)
{
using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
{
var wb = doc.AddWorkbookPart();
wb.Workbook = new Workbook();
var sheets = wb.Workbook.AppendChild(new Sheets());
//建立第一個頁籤
var ws = wb.AddNewPart<WorksheetPart>();
ws.Worksheet = new Worksheet();
sheets.Append(new Sheet()
{
Id = wb.GetIdOfPart(ws),
SheetId = 1,
Name = "報名"
});
//設定欄寬
var cu = new Columns();
cu.Append(
new Column { Min = 1, Max = 1, Width = 15, CustomWidth = true },
new Column { Min = 2, Max = 4, Width = 10, CustomWidth = true },
new Column { Min = 5, Max = 5, Width = 15, CustomWidth = true },
new Column { Min = 6, Max = 8, Width = 25, CustomWidth = true },
new Column { Min = 9, Max = 9, Width = 15, CustomWidth = true },
new Column { Min = 10, Max = 10, Width = 10, CustomWidth = true },
new Column { Min = 11, Max = 11, Width = 25, CustomWidth = true },
new Column { Min = 12, Max = 16, Width = 10, CustomWidth = true },
new Column { Min = 17, Max = 20, Width = 10, CustomWidth = true }
);
ws.Worksheet.Append(cu);
//建立資料頁
var sd = new SheetData();
ws.Worksheet.AppendChild(sd);
//第一列資料
var tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue("單號"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("報名日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("單據狀態"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("姓名/名稱"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("聯絡電話"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("報名活動"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("收件地址"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("備註"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("項目名稱"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("姓名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("代表地址"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("標題"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("陽上/報恩者"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("開始日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("期滿日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("應續約日"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("劃位狀態"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("預設金額"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("數量"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("小計"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("已收金額"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("未收金額"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("付款期限"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("報名狀態"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("狀態備註"), DataType = CellValues.String }
);
sd.AppendChild(tr);
foreach (var item in list)
{
string midNamesResult = "";
string leftNamesResult = "";
string jsonString = item.d_f_num_tablet?.ToString() ?? "";
try
{
var jo = JObject.Parse(jsonString);
// 標題
var midList = jo["mid_items"]?
.Select(i => (string)i["fam_name"])
.Where(name => !string.IsNullOrEmpty(name))
.ToList();
if (midList != null && midList.Any())
{
midNamesResult = string.Join(", ", midList);
}
// 陽上
var leftList = jo["left_items"]?
.Select(i => (string)i["fam_name"])
.Where(name => !string.IsNullOrEmpty(name))
.ToList();
if (leftList != null && leftList.Any())
{
leftNamesResult = string.Join(", ", leftList);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"JSON 解析失敗 (訂單:{item.order_no}): {ex.Message}");
}
//新增資料列
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(item.order_no), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.up_time?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(Model.pro_order.keyin1_value_to_text(item.keyin1)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.f_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.activity_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.address), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.demo), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_actItem_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_f_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_address), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(midNamesResult), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(leftNamesResult), DataType = CellValues.String },
//new Cell() { CellValue = new CellValue(item.d_from_id), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_start_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_due_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_extend_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue((Val(item.d_category) == (int)Model.activity.category.Order) ? (item.d_notBedQty + "/" + item.d_writeBedQty) : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_price)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_qty), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty))), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_pay)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty) - ValFloat(item.d_pay))), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_pay_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_keyin1.HasValue ? tdesc[item.d_keyin1.Value] : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_demo), DataType = CellValues.String }
);
sd.AppendChild(tr);
}
//空一列
tr = new Row();
sd.AppendChild(tr);
//匯出資訊
string _data = "匯出時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
_data += " " + admin.info.u_id;
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
_data = "匯出條件 : " + (!isStrNull(_query) ? _query : "-");
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.order_no).ToList()));
}
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=報名.xlsx");
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
HttpContext.Current.Response.End();
hid_err_msg.Value = "success";
}
else
{
hid_err_msg.Value = "nodata";
}
}
else if (isPrintMode)
{
int selYear = !string.IsNullOrEmpty(hid_print_year.Value) ? int.Parse(hid_print_year.Value) : 0;
int selMonth = !string.IsNullOrEmpty(hid_print_month.Value) ? int.Parse(hid_print_month.Value) : 0;
int selSeason = !string.IsNullOrEmpty(hid_print_season.Value) ? int.Parse(hid_print_season.Value) : 0;
string selMode = !string.IsNullOrEmpty(hid_print_mode.Value) ? hid_print_mode.Value : "";
bool chkHasAct = !string.IsNullOrEmpty(hid_chk_hasact.Value) && Convert.ToBoolean(hid_chk_hasact.Value);
bool chkNoAct = !string.IsNullOrEmpty(hid_chk_noact.Value) && Convert.ToBoolean(hid_chk_noact.Value);
int selAct = !string.IsNullOrEmpty(hid_select_act.Value) ? int.Parse(hid_select_act.Value) : -1;
int selActItem = !string.IsNullOrEmpty(hid_select_actitem.Value) ? int.Parse(hid_select_actitem.Value) : -1;
string urlParams = !string.IsNullOrEmpty(hid_qry.Value) ? hid_qry.Value : "";
var qry = _db.pro_order.AsQueryable();
if (selYear > 0)
qry = qry.Where(o => o.up_time.HasValue && o.up_time.Value.Year == selYear);
if (selMode == "mm" && selMonth > 0)
qry = qry.Where(o => o.up_time.HasValue && o.up_time.Value.Month == selMonth);
else if (selMode == "ss" && selSeason > 0)
{
if (selSeason == 1)
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 1 || o.up_time.Value.Month == 2 || o.up_time.Value.Month == 3);
else if (selSeason == 2)
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 4 || o.up_time.Value.Month == 5 || o.up_time.Value.Month == 6);
else if (selSeason == 3)
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 7 || o.up_time.Value.Month == 8 || o.up_time.Value.Month == 9);
else if (selSeason == 4)
qry = qry.Where(o => o.up_time.HasValue)
.Where(o => o.up_time.Value.Month == 10 || o.up_time.Value.Month == 11 || o.up_time.Value.Month == 12);
}
if (chkHasAct)
{
if (chkNoAct)
{
if (selAct >= 0)
qry = qry.Where(o => o.activity_num.HasValue && o.activity_num.Value == selAct);
}
else
{
qry = qry.Where(o => o.activity_num.HasValue);
if (selAct >= 0)
qry = qry.Where(o => o.activity_num.Value == selAct);
}
}
else
{
if (chkNoAct)
qry = qry.Where(o => o.activity_num == null);
}
if (selActItem >= 0)
{
qry = qry.Where(o => o.pro_order_detail.Where(f2 => f2.actItem_num.HasValue && f2.actItem_num.Value == selActItem).Count() > 0);
}
var count = qry.Count();
if (count > 0)
{
hid_err_msg.Value = "success";
string script = $@"var otherWin = window.open('print.aspx{urlParams}', '列印報名資料', 'noopener,noreferrer');";
ScriptManager.RegisterStartupScript(this, GetType(), "ExecutePrint", script, true);
}
else
{
hid_err_msg.Value = "nodata";
}
//var qry = _db.followers.AsQueryable();
//if (selYear > 0)
//{
// urlParams += "&year=" + selYear;
//}
//if (selMode == "mm" && selMonth > 0)
//{
// urlParams += "&month=" + selMonth;
//}
//else if (selMode == "ss" && selSeason > 0)
//{
// urlParams += "&season=" + selSeason;
//}
//if (list.Count > 0)
//{
// hid_err_msg.Value = "success";
// hid_print_year.Value = selYear.ToString();
// hid_print_month.Value = selMonth.ToString();
// hid_print_season.Value = selSeason.ToString();
// hid_print_mode.Value = selMode;
// string script = $@"window.open('print.aspx?{urlParams}&mode={selMode}', '列印信眾資料');";
// ScriptManager.RegisterStartupScript(this, GetType(), "ExecutePrint", script, true);
//}
//else
//{
// hid_err_msg.Value = "nodata";
// string script = $@"
// var win = window.open('', '列印信眾資料');
// if (win) win.close()";
// ScriptManager.RegisterStartupScript(this, GetType(), "CancelPrint", script, true);
//}
}
}
protected void excel_Click(object sender, EventArgs e) protected void excel_Click(object sender, EventArgs e)
{ {
@@ -111,6 +570,7 @@ public partial class admin_order_index : MyWeb.config
new Cell() { CellValue = new CellValue("項目名稱"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("項目名稱"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("姓名"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("姓名"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("代表地址"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("代表地址"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("標題"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("陽上/報恩者"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("陽上/報恩者"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("開始日期"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("開始日期"), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("期滿日期"), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("期滿日期"), DataType = CellValues.String },
@@ -132,32 +592,57 @@ public partial class admin_order_index : MyWeb.config
// 改為整數陣列,避免後續查詢中使用 .ToString() // 改為整數陣列,避免後續查詢中使用 .ToString()
var aIDt = _db.actItems.Where(f => f.subject.Contains(s_actItemTxt.Value.Trim())).Select(f => f.num).ToArray();//品項 var aIDt = _db.actItems.Where(f => f.subject.Contains(s_actItemTxt.Value.Trim())).Select(f => f.num).ToArray();//品項
var qry = _db.pro_order.AsQueryable(); var qry = _db.pro_order.AsQueryable();
string _query = ""; // 紀錄匯出條件
if (!isStrNull(s_order_no.Value)) if (!isStrNull(s_order_no.Value))
{
_query += "單號:" + s_order_no.Value + "\n";
qry = qry.Where(o => o.order_no.Contains(s_order_no.Value.Trim())); qry = qry.Where(o => o.order_no.Contains(s_order_no.Value.Trim()));
}
if (!isStrNull(s_u_name.Value)) if (!isStrNull(s_u_name.Value))
{
_query += "姓名/名稱:" + s_u_name.Value + "\n";
qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(s_u_name.Value.Trim())); qry = qry.Where(o => o.f_num.HasValue && o.follower.u_name.Contains(s_u_name.Value.Trim()));
}
if (!isStrNull(s_introducerTxt.Value)) if (!isStrNull(s_introducerTxt.Value))
{
_query += "介紹人:" + s_introducerTxt.Value + "\n";
qry = qry.Where(o => o.f_num.HasValue && o.follower1.u_name.Contains(s_introducerTxt.Value.Trim())); qry = qry.Where(o => o.f_num.HasValue && o.follower1.u_name.Contains(s_introducerTxt.Value.Trim()));
}
if (!isStrNull(s_subject.Value)) if (!isStrNull(s_subject.Value))
{
_query += "報名活動:" + s_subject.Value + "\n";
qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(s_subject.Value.Trim())); qry = qry.Where(o => o.activity_num.HasValue && o.activity.subject.Contains(s_subject.Value.Trim()));
}
if (!isStrNull(s_actItemTxt.Value)) if (!isStrNull(s_actItemTxt.Value))
{ {
// ❌ 錯誤寫法: 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.ToArray().Contains(f2.actItem_num.ToString())).Count() > 0);
// ✅ 實際比較:僅在 actItem_num 有值時才與整數陣列比對 // ✅ 實際比較:僅在 actItem_num 有值時才與整數陣列比對
_query += "品項:" + s_actItemTxt.Value + "\n";
qry = qry.Where(o => o.pro_order_detail.Any(f2 => qry = qry.Where(o => o.pro_order_detail.Any(f2 =>
f2.order_no == o.order_no && f2.order_no == o.order_no &&
f2.actItem_num.HasValue && f2.actItem_num.HasValue &&
aIDt.Contains(f2.actItem_num.Value))); aIDt.Contains(f2.actItem_num.Value)));
} }
if (!isStrNull(s_keyin1.SelectedValue)) if (!isStrNull(s_keyin1.SelectedValue))
{
_query += $"單據狀態:{Model.pro_order.keyin1_value_to_text(s_keyin1.SelectedValue)}\n";
qry = qry.Where(o => o.keyin1 == s_keyin1.SelectedValue); qry = qry.Where(o => o.keyin1 == s_keyin1.SelectedValue);
}
if (!isStrNull(s_up_time1.Value) && isDate(s_up_time1.Value)) if (!isStrNull(s_up_time1.Value) && isDate(s_up_time1.Value))
qry = qry.Where(o => o.up_time >= ValDate(s_up_time1.Value)); {
_query += "報名日期(起):" + s_up_time1.Value.Trim() + "\n";
var tmp_s_up_time1 = ValDate(s_up_time1.Value);
qry = qry.Where(o => o.up_time >= tmp_s_up_time1);
}
if (!isStrNull(s_up_time2.Value) && isDate(s_up_time2.Value)) if (!isStrNull(s_up_time2.Value) && isDate(s_up_time2.Value))
qry = qry.Where(o => o.up_time < Convert.ToDateTime(s_up_time2.Value).AddDays(1)); {
_query += "報名日期(訖):" + s_up_time2.Value.Trim() + "\n";
var tmp_s_up_time2 = Convert.ToDateTime(s_up_time2.Value).AddDays(1);
qry = qry.Where(o => o.up_time < tmp_s_up_time2);
}
qry = qry.OrderByDescending(o => o.reg_time); qry = qry.OrderByDescending(o => o.reg_time);
MyWeb.encrypt encrypt = new MyWeb.encrypt(); MyWeb.encrypt encrypt = new MyWeb.encrypt();
@@ -198,20 +683,21 @@ public partial class admin_order_index : MyWeb.config
//訂單明細 //訂單明細
//使用DefaultIfEmpty 因匿名型別無法輸出NULL(無法轉換成強型別),需特別注意Null的處理 //使用DefaultIfEmpty 因匿名型別無法輸出NULL(無法轉換成強型別),需特別注意Null的處理
d_actItem_num = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.subject : ""), //項目名稱 d_actItem_num = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.subject : ""), //項目名稱
d_category = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.category.ToString() : ""), d_category = d == null ? "" : (d.actItem_num.HasValue ? d.actItem.category.ToString() : ""),
d_f_num = d == null ? "" : (d.f_num.HasValue ? d.follower.u_name : ""), //姓名 d_f_num = d == null ? "" : (d.f_num.HasValue ? d.follower.u_name : ""), //姓名
d_address = d == null ? "" : d.address, d_address = d == null ? "" : d.address,
d_from_id = d == null ? "" : (d.from_id.HasValue ? d.follower1.u_name : ""), //陽上/報恩者 d_from_id = d == null ? "" : (d.from_id.HasValue ? d.follower1.u_name : ""), //陽上/報恩者
d_start_date = d == null ? "" : (d.start_date.HasValue ? d.start_date.Value.ToString("yyyy/MM/dd") : ""), //開始日期 d_f_num_tablet = d == null ? "" : d.f_num_tablet,
d_due_date = d == null ? "" : (d.due_date.HasValue ? d.due_date.Value.ToString("yyyy/MM/dd") : ""), //期滿日期 d_start_date = d == null ? (DateTime?)null : d.start_date, //開始日期
d_extend_date = d == null ? "" : (d.extend_date.HasValue ? d.extend_date.Value.ToString("yyyy/MM/dd") : ""), //應續約日 d_due_date = d == null ? (DateTime?)null : d.due_date, //期滿日期
d_price = d == null ? "" : (d.price.HasValue ? d.price.Value.ToString() : "0"), //預設金額 d_extend_date = d == null ? (DateTime?)null : d.extend_date, //應續約日
d_price = d == null ? (float?)null : d.price, //預設金額
d_qty = d == null ? "" : (d.qty.HasValue ? d.qty.Value.ToString() : "0"), //數量 d_qty = d == null ? "" : (d.qty.HasValue ? d.qty.Value.ToString() : "0"), //數量
d_writeBedQty = d == null ? 0 : bedDt.Where(b =>( b.bed_order.o_detail_id.Value == d.num) && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量 d_writeBedQty = d == null ? 0 : bedDt.Where(b => (b.bed_order.o_detail_id.Value == d.num) && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(), //已劃數量
d_notBedQty = d == null ? 0 : bedDt.Where(b => b.bed_order.o_detail_id.Value == d.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量 d_notBedQty = d == null ? 0 : bedDt.Where(b => b.bed_order.o_detail_id.Value == d.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(), //未劃數量
d_pay = d == null ? "" : (d.pay.HasValue ? d.pay.Value.ToString() : "0"), //已收金額 d_pay = d == null ? "" : (d.pay.HasValue ? d.pay.Value.ToString() : "0"), //已收金額
d_pay_date = d == null ? "" : (d.pay_date.HasValue ? d.pay_date.Value.ToString("yyyy/MM/dd") : ""), //付款期限 d_pay_date = d == null ? (DateTime?)null : d.start_date, //付款期限
d_keyin1 = d == null ? "" : (d.keyin1.HasValue&& d.keyin1.Value>0 ? tdesc[d.keyin1 ?? 1] : ""), //報名狀態 d_keyin1 = d == null ? (int?)null : d.keyin1,
d_demo = d == null ? "" : d.demo, //狀態備註 d_demo = d == null ? "" : d.demo, //狀態備註
}).ToList(); }).ToList();
@@ -259,11 +745,43 @@ public partial class admin_order_index : MyWeb.config
{ {
foreach (var item in list) foreach (var item in list)
{ {
string midNamesResult = "";
string leftNamesResult = "";
string jsonString = item.d_f_num_tablet?.ToString() ?? "";
try
{
var jo = JObject.Parse(jsonString);
// 標題
var midList = jo["mid_items"]?
.Select(i => (string)i["fam_name"])
.Where(name => !string.IsNullOrEmpty(name))
.ToList();
if (midList != null && midList.Any())
{
midNamesResult = string.Join(", ", midList);
}
// 陽上
var leftList = jo["left_items"]?
.Select(i => (string)i["fam_name"])
.Where(name => !string.IsNullOrEmpty(name))
.ToList();
if (leftList != null && leftList.Any())
{
leftNamesResult = string.Join(", ", leftList);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"JSON 解析失敗 (訂單:{item.order_no}): {ex.Message}");
}
//新增資料列 //新增資料列
tr = new Row(); tr = new Row();
tr.Append( tr.Append(
new Cell() { CellValue = new CellValue(item.order_no), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.order_no), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.up_time.Value.ToString("yyyy/MM/dd")), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.up_time?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(Model.pro_order.keyin1_value_to_text(item.keyin1)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(Model.pro_order.keyin1_value_to_text(item.keyin1)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.f_num), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.f_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String },
@@ -274,23 +792,44 @@ public partial class admin_order_index : MyWeb.config
new Cell() { CellValue = new CellValue(item.d_actItem_num), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_actItem_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_f_num), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_f_num), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_address), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_address), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_from_id), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(midNamesResult), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_start_date), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(leftNamesResult), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_due_date), DataType = CellValues.String }, //new Cell() { CellValue = new CellValue(item.d_from_id), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_extend_date), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_start_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue((Val(item.d_category) ==(int)Model.activity.category.Order) ?( item.d_notBedQty +"/" + item.d_writeBedQty):""), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_due_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_extend_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue((Val(item.d_category) == (int)Model.activity.category.Order) ? (item.d_notBedQty + "/" + item.d_writeBedQty) : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_price)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_price)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_qty), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_qty), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty))), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty))), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_pay)), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("$" + ValMoney(item.d_pay)), DataType = CellValues.String },
new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty) - ValFloat(item.d_pay))), DataType = CellValues.String }, new Cell() { CellValue = new CellValue("$" + ValMoney(ValFloat(item.d_price) * Val(item.d_qty) - ValFloat(item.d_pay))), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_pay_date), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_pay_date?.ToString("yyyy/MM/dd") ?? ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_keyin1), DataType = CellValues.String }, new Cell() { CellValue = new CellValue(item.d_keyin1.HasValue ? tdesc[item.d_keyin1.Value] : ""), DataType = CellValues.String },
new Cell() { CellValue = new CellValue(item.d_demo), DataType = CellValues.String } new Cell() { CellValue = new CellValue(item.d_demo), DataType = CellValues.String }
); );
sd.AppendChild(tr); sd.AppendChild(tr);
} }
//空一列
tr = new Row();
sd.AppendChild(tr);
//匯出資訊
string _data = "匯出時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
_data += " " + admin.info.u_id;
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
_data = "匯出條件 : " + (!isStrNull(_query) ? _query : "-");
tr = new Row();
tr.Append(
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
);
sd.AppendChild(tr);
Model.admin_log admin_log = new Model.admin_log(); Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.order_no).ToList())); admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.order_no).ToList()));
+2 -2
View File
@@ -41,7 +41,7 @@
{ text: '活動名稱​', value: 'subject', }, { text: '活動名稱​', value: 'subject', },
{ text: '報到日期​', value: 'reg_time_date', }, { text: '報到日期​', value: 'reg_time_date', },
{ text: '報到時間​', value: 'reg_time_time' }, { text: '報到時間​', value: 'reg_time_time' },
{ text: '姓名(人數)', value: 'qty' }, { text: '姓名', value: 'qty' },
{ text: '狀態', value: 'statusTxt' }, { text: '狀態', value: 'statusTxt' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' } { text: '', value: 'slot_btn', sortable: false, align: 'end' }
@@ -199,7 +199,7 @@
{{item.reg_time |timeString('HH:mm:ss') }} {{item.reg_time |timeString('HH:mm:ss') }}
</template> </template>
<template #item.qty="{ item }" > <template #item.qty="{ item }" >
{{item.u_name }}({{item.qty }}) {{item.u_name }}
</template> </template>
+6 -13
View File
@@ -144,13 +144,10 @@
<tbody> <tbody>
<tr> <tr>
<th>項目名稱</th> <th>項目名稱</th>
<th class="nowarp">姓名</th> <th class="nowarp">陽上</th>
<th>代表地址</th> <th class="nowarp">標題</th>
<th class="nowarp">陽上/報恩</th>
<th class="fit">開始日</th> <th class="fit">開始日</th>
<th class="fit">期滿日</th> <th class="fit">期滿日</th>
<th class="fit">延續日</th>
<th class="fit">劃位</th>
<asp:PlaceHolder ID="PlaceHolder2" runat="server"> <asp:PlaceHolder ID="PlaceHolder2" runat="server">
<th class="fit">功德金</th> <th class="fit">功德金</th>
<th class="fit">數量</th> <th class="fit">數量</th>
@@ -167,18 +164,14 @@
<td> <td>
<asp:Literal ID="actitem_numTxt" runat="server"></asp:Literal></td> <asp:Literal ID="actitem_numTxt" runat="server"></asp:Literal></td>
<td class="nowarp"> <td class="nowarp">
<asp:Literal ID="f_numTxt" runat="server"></asp:Literal></td> <asp:Literal ID="left_nameTxt" runat="server"></asp:Literal></td>
<td><%# Eval("address") %></td>
<td class="nowarp"> <td class="nowarp">
<asp:Literal ID="from_idTxt" runat="server"></asp:Literal></td> <asp:Literal ID="mid_nameTxt" runat="server"></asp:Literal></td>
<td class="fit"><%# Eval("start_date") != null? Convert.ToDateTime( Eval("start_date")).ToString("yyyy/MM/dd") : "" %></td> <td class="fit"><%# Eval("start_date") != null? Convert.ToDateTime( Eval("start_date")).ToString("yyyy/MM/dd") : "" %></td>
<td class="fit"> <td class="fit">
<asp:Literal ID="due_date" runat="server"></asp:Literal></td> <asp:Literal ID="due_date" runat="server"></asp:Literal></td>
<td class="fit">
<asp:Literal ID="extend_date" runat="server"></asp:Literal></td>
<td class="fit">
<asp:Literal ID="BedQty" runat="server"></asp:Literal></td>
<asp:PlaceHolder ID="PlaceHolder2" runat="server"> <asp:PlaceHolder ID="PlaceHolder2" runat="server">
<td class="fit text-end"> <td class="fit text-end">
<asp:Literal ID="item_price" runat="server" Text='<%# Eval("price") %>'></asp:Literal></td> <asp:Literal ID="item_price" runat="server" Text='<%# Eval("price") %>'></asp:Literal></td>
+83 -25
View File
@@ -1,9 +1,15 @@
using DocumentFormat.OpenXml.Drawing.Charts; using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Vml.Office; using DocumentFormat.OpenXml.Vml.Office;
using Microsoft.Ajax.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Helpers;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
@@ -182,8 +188,20 @@ public partial class admin_follower_print_ : System.Web.UI.Page
if (!string.IsNullOrEmpty(_chkHasAct) && Convert.ToBoolean(_chkHasAct)) if (!string.IsNullOrEmpty(_chkHasAct) && Convert.ToBoolean(_chkHasAct))
{ {
_query += "活動報名\n"; if (!string.IsNullOrEmpty(_selectAct))
{
int selectAct = Convert.ToInt32(_selectAct);
if (selectAct > 0)
{
var actSubject = _db.activities.Where(a => a.num == selectAct).Select(a => a.subject).FirstOrDefault();
_query += $"活動報名: {actSubject}\n";
}
}
else
{
_query += $"活動報名\n";
}
if (!string.IsNullOrEmpty(_chkNoAct) && Convert.ToBoolean(_chkNoAct)) if (!string.IsNullOrEmpty(_chkNoAct) && Convert.ToBoolean(_chkNoAct))
{ {
_query += "非活動報名\n"; _query += "非活動報名\n";
@@ -200,7 +218,7 @@ public partial class admin_follower_print_ : System.Web.UI.Page
else else
{ {
qry = qry.Where(o => o.activity_num.HasValue); qry = qry.Where(o => o.activity_num.HasValue);
if (!string.IsNullOrEmpty(_selectAct)) if (!string.IsNullOrEmpty(_selectAct))
{ {
int selectAct = Convert.ToInt32(_selectAct); int selectAct = Convert.ToInt32(_selectAct);
@@ -404,16 +422,56 @@ public partial class admin_follower_print_ : System.Web.UI.Page
actitem_numTxt.Text = row.actItem_num.HasValue && row.actItem != null ? row.actItem.subject : ""; actitem_numTxt.Text = row.actItem_num.HasValue && row.actItem != null ? row.actItem.subject : "";
} }
Literal fNumTxtLit = (Literal)e.Item.FindControl("f_numTxt"); //Literal fNumTxtLit = (Literal)e.Item.FindControl("f_numTxt");
if (fNumTxtLit != null) //if (fNumTxtLit != null)
{ //{
fNumTxtLit.Text = row.f_num.HasValue && row.follower != null ? row.follower.u_name : ""; // fNumTxtLit.Text = row.f_num.HasValue && row.follower != null ? row.follower.u_name : "";
} //}
Literal fromIdTxtLit = (Literal)e.Item.FindControl("from_idTxt"); string jsonString = row.f_num_tablet?.ToString() ?? "";
if (fromIdTxtLit != null) if (!string.IsNullOrWhiteSpace(jsonString))
{ {
fromIdTxtLit.Text = row.from_id.HasValue && row.follower1 != null ? row.follower1.u_name : ""; var jo = JObject.Parse(jsonString);
List<string> allMidNames = new List<string>();
List<string> allLeftNames = new List<string>();
// 標題
var midNames = jo["mid_items"]?
.Select(item => (string)item["fam_name"])
.ToList();
if (midNames != null && midNames.Any())
{
allMidNames.AddRange(midNames);
}
if (allMidNames.Any())
{
Literal midNameTextLit = (Literal)e.Item.FindControl("mid_nameTxt");
if (midNameTextLit != null)
{
midNameTextLit.Text = string.Join(", ", allMidNames);
}
}
// 陽上
var leftNames = jo["left_items"]?
.Select(item => (string)item["fam_name"])
.ToList();
if (leftNames != null && leftNames.Any())
{
allLeftNames.AddRange(leftNames);
}
if (allLeftNames.Any())
{
Literal leftNameTextLit = (Literal)e.Item.FindControl("left_nameTxt");
if (leftNameTextLit != null)
{
leftNameTextLit.Text = string.Join(", ", allLeftNames);
}
}
} }
Literal dueDateLit = (Literal)e.Item.FindControl("due_date"); Literal dueDateLit = (Literal)e.Item.FindControl("due_date");
@@ -422,21 +480,21 @@ public partial class admin_follower_print_ : System.Web.UI.Page
dueDateLit.Text = row.due_date.HasValue ? row.due_date.Value.ToString("yyyy-MM-dd") : ""; dueDateLit.Text = row.due_date.HasValue ? row.due_date.Value.ToString("yyyy-MM-dd") : "";
} }
Literal extendDateLit = (Literal)e.Item.FindControl("extend_date"); //Literal extendDateLit = (Literal)e.Item.FindControl("extend_date");
if (extendDateLit != null) //if (extendDateLit != null)
{ //{
extendDateLit.Text = row.extend_date.HasValue ? row.extend_date.Value.ToString("yyyy-MM-dd") : ""; // extendDateLit.Text = row.extend_date.HasValue ? row.extend_date.Value.ToString("yyyy-MM-dd") : "";
} //}
//劃位狀態 ////劃位狀態
int writeBedQty = _bedDt.Where(b => b.bed_order != null && b.bed_order.o_detail_id == row.num && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count(); //int writeBedQty = _bedDt.Where(b => b.bed_order != null && b.bed_order.o_detail_id == row.num && b.checkIn_date.HasValue && b.bed_kind_detail_id.HasValue).Count();
int notBedQty = _bedDt.Where(b => b.bed_order != null && b.bed_order.o_detail_id == row.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count(); //int notBedQty = _bedDt.Where(b => b.bed_order != null && b.bed_order.o_detail_id == row.num && (!b.checkIn_date.HasValue || !b.bed_kind_detail_id.HasValue)).Count();
Literal bedQtyLit = (Literal)e.Item.FindControl("BedQty"); //Literal bedQtyLit = (Literal)e.Item.FindControl("BedQty");
if (bedQtyLit != null) //if (bedQtyLit != null)
{ //{
bedQtyLit.Text = (row.actItem != null && row.actItem.category.HasValue && Convert.ToInt32(row.actItem.category.Value) == (int)Model.activity.category.Order) ? (notBedQty + "/" + writeBedQty) : ""; // bedQtyLit.Text = (row.actItem != null && row.actItem.category.HasValue && Convert.ToInt32(row.actItem.category.Value) == (int)Model.activity.category.Order) ? (notBedQty + "/" + writeBedQty) : "";
} //}
Literal keyin1Lit = (Literal)e.Item.FindControl("keyin1"); Literal keyin1Lit = (Literal)e.Item.FindControl("keyin1");
if (keyin1Lit != null) if (keyin1Lit != null)
+9 -7
View File
@@ -526,7 +526,7 @@
window.addEventListener('message', async (event) => { window.addEventListener('message', async (event) => {
if (event.data.source === 'editor.btn.click') { if (event.data.source === 'editor.btn.click') {
const receivedData = event.data.data; const receivedData = event.data.data;
// 更新編輯中的項目 // 更新編輯中的項目
//if (receivedData.tabletItem && this.editedIndex > -1) { //if (receivedData.tabletItem && this.editedIndex > -1) {
if (receivedData.tabletItem) { if (receivedData.tabletItem) {
@@ -703,6 +703,7 @@
curr.select(this.editedItem, row); curr.select(this.editedItem, row);
} }
this.search_dialog.show = false; this.search_dialog.show = false;
this.search_dialog.page = 1;
//console.log(row, row["u_name"], row["f_number"], curr.id, target); //console.log(row, row["u_name"], row["f_number"], curr.id, target);
}, },
//報名詳細資料 //報名詳細資料
@@ -782,7 +783,6 @@
this.desserts_count = response.data.list !== undefined ? response.data.count : 0 this.desserts_count = response.data.list !== undefined ? response.data.count : 0
this.calutotalPrice(); this.calutotalPrice();
this.disableButton = false; this.disableButton = false;
}) })
.catch( .catch(
error => console.log(error) error => console.log(error)
@@ -807,7 +807,7 @@
isValidDate = Date.parse(item.pay_date); isValidDate = Date.parse(item.pay_date);
if (!isNaN(isValidDate)) if (!isNaN(isValidDate))
item.pay_date = new Date(item.pay_date).format("yyyy-MM-dd") item.pay_date = new Date(item.pay_date).format("yyyy-MM-dd")
console.log(item);
this.editedItem = $.extend(true, {}, item); this.editedItem = $.extend(true, {}, item);
this.data_dialog.show = true; this.data_dialog.show = true;
this.data_dialog.isAddNew = false; this.data_dialog.isAddNew = false;
@@ -839,7 +839,7 @@
// 顯示對話框 // 顯示對話框
this.tablet_edit.show = true; this.tablet_edit.show = true;
// 立即恢復數據 // 立即恢復數據
this.editedItem = $.extend(true, {}, currentData); this.editedItem = $.extend(true, {}, currentData);
} catch (error) { } catch (error) {
console.error('Error in editTablet:', error); console.error('Error in editTablet:', error);
} }
@@ -971,9 +971,11 @@
/* (this.editedItem.category=="1"? this.editedItem.from_id_selected.val != 0 : true) &&*/ /* (this.editedItem.category=="1"? this.editedItem.from_id_selected.val != 0 : true) &&*/
this.requireData(this.editedItem.qty, (this.editedItem.num == 0 ? false : true)) ) /* qty為0視為不需要此項目,不儲存此筆資料*/ this.requireData(this.editedItem.qty, (this.editedItem.num == 0 ? false : true)) ) /* qty為0視為不需要此項目,不儲存此筆資料*/
{ {
console.log(this.editedItem);
//check price //check price
if (this.editedItem.pay <= this.editedItem.price * this.editedItem.qty) { if (this.editedItem.pay <= this.editedItem.price * this.editedItem.qty) {
console.log(this.editedItem.f_num_selected.val);
console.log(this.editedItem.from_id_selected.val);
//check qty //check qty
//數量不可小於掛單明細的數量 //數量不可小於掛單明細的數量
if (this.editedItem.qty >= this.editedItem.writeBedQty + this.editedItem.notBedQty) { if (this.editedItem.qty >= this.editedItem.writeBedQty + this.editedItem.notBedQty) {
@@ -1727,7 +1729,7 @@
<div class=""> <div class="">
<asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary" /> <asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary" />
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" /> <asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
<asp:Button ID="goback" runat="server" Text="回列表" Visible="false" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" /> <asp:Button ID="goback" runat="server" Text="取消" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
</div> </div>
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
@@ -2353,7 +2355,7 @@
<v-card> <v-card>
<v-card-title class="justify-space-between grey lighten-2"> <v-card-title class="justify-space-between grey lighten-2">
查詢:{{search_dialog.current.title}} 查詢:{{search_dialog.current.title}}
<v-btn icon @click="search_dialog.show=false"><v-icon>mdi-close</v-icon></v-btn> <v-btn icon @click="search_dialog.show=false; search_dialog.page = 1;"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title> </v-card-title>
<v-card-text > <v-card-text >
<v-row> <v-row>
+26 -12
View File
@@ -1,15 +1,16 @@
using System; using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.Entity.Infrastructure;
using System.Data.OleDb; using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Web; using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Data.Entity.Infrastructure;
public partial class admin_order_reg : MyWeb.config public partial class admin_order_reg : MyWeb.config
{ {
@@ -187,16 +188,29 @@ public partial class admin_order_reg : MyWeb.config
{ {
if (!isStrNull(pro_order.order_no)) if (!isStrNull(pro_order.order_no))
{ {
_db.pro_order.Add(pro_order); bool isRegistered = _db.pro_order.Any(x => x.f_num == pro_order.f_num && x.activity_num == pro_order.activity_num);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log(); if (isRegistered) // 重複報名
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no); {
L_msg.Type = alert_type.warning;
L_msg.Text = "此信眾已報名過本活動";
}
else
{
_db.pro_order.Add(pro_order);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
string url = "index.aspx"; string url = "index.aspx";
url = "reg.aspx?order_no=" + pro_order.order_no; url = "reg.aspx?order_no=" + pro_order.order_no;
Response.Redirect(url);
Session["LastAddedNo"] = pro_order.order_no;
Response.Redirect(url);
}
} }
else else
{ {
+25
View File
@@ -147,6 +147,14 @@
</v-col> </v-col>
<v-col cols="auto" class="ml-4"> <v-col cols="auto" class="ml-4">
<span class="subtitle-2 grey--text text--darken-1">超渡-已選</span> <span class="subtitle-2 grey--text text--darken-1">超渡-已選</span>
<v-chip v-if="tabletItem.has_chao_limit"
x-small
class="ml-2 px-2"
:color="family_deceased_Y_selected.length > tabletItem.chao_limit_count ? 'error' : 'grey lighten-1'"
:dark="family_deceased_Y_selected.length > tabletItem.chao_limit_count"
label>
{{ family_deceased_Y_selected.length }} / {{ tabletItem.chao_limit_count }}
</v-chip>
</v-col> </v-col>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-col cols="auto"> <v-col cols="auto">
@@ -237,6 +245,14 @@
</v-col> </v-col>
<v-col cols="auto" :class="{'ml-4': item_type==='A'}"> <v-col cols="auto" :class="{'ml-4': item_type==='A'}">
<span class="subtitle-2 grey--text text--darken-1">陽上/祈福-已選</span> <span class="subtitle-2 grey--text text--darken-1">陽上/祈福-已選</span>
<v-chip v-if="tabletItem.has_yang_limit"
x-small
class="ml-2 px-2"
:color="family_deceased_N_selected.length > tabletItem.yang_limit_count ? 'error' : 'grey lighten-1'"
:dark="family_deceased_N_selected.length > tabletItem.yang_limit_count"
label>
{{ family_deceased_N_selected.length }} / {{ tabletItem.yang_limit_count }}
</v-chip>
</v-col> </v-col>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-col cols="auto"> <v-col cols="auto">
@@ -700,6 +716,15 @@
saveData() { saveData() {
// 其它資料欄位, 不應在這裡修改 // 其它資料欄位, 不應在這裡修改
// 應該在進來的時候, 就已經修改(insert)好了 // 應該在進來的時候, 就已經修改(insert)好了
if (this.tabletItem.has_chao_limit && this.family_deceased_Y_selected.length > this.tabletItem.chao_limit_count) {
alert(`超渡人數超過限制!(上限 ${this.tabletItem.chao_limit_count} 人)`);
return; // 阻斷存檔
}
if (this.tabletItem.has_yang_limit && this.family_deceased_N_selected.length > this.tabletItem.yang_limit_count) {
alert(`陽上人數超過限制!(上限 ${this.tabletItem.yang_limit_count} 人)`);
return; // 阻斷存檔
}
let tablet_data = {}; let tablet_data = {};
if (this.item_type === 'B') {// B:超渡, 超薦..... if (this.item_type === 'B') {// B:超渡, 超薦.....
tablet_data = { tablet_data = {
+4 -2
View File
@@ -42,11 +42,13 @@
<add key="UseSearchKeywords" value="true" /> <add key="UseSearchKeywords" value="true" />
<!--網站的簡稱,用來區別session和cookie--> <!--網站的簡稱,用來區別session和cookie-->
<add key="SC" value="erp17168" /> <add key="SC" value="erp17168" />
<!--是否啟用信眾自動編號 (true=啟用, false=停用)-->
<add key="IsAutoNumbering" value="true" />
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<!--SQL用--> <!--SQL用-->
<add name="shopConn" providerName="System.Data.SqlClient" connectionString="Data Source=192.168.5.21;Initial Catalog=17168erp_t;User ID=sa;Password=linux@mssql1234;Encrypt=False;TrustServerCertificate=True;Provider=SQLOLEDB;Connection Timeout=10;" /> <add name="shopConn" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=17168erp_t;User ID=sa;Password=778611;Encrypt=False;TrustServerCertificate=True;Provider=SQLOLEDB;Connection Timeout=10;" />
<add name="ezEntities" providerName="System.Data.EntityClient" connectionString="metadata=res://*/App_Code.Model.Model.csdl|res://*/App_Code.Model.Model.ssdl|res://*/App_Code.Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=192.168.5.21;Initial Catalog=17168erp_t;User ID=sa;Password=linux@mssql1234;Encrypt=False;TrustServerCertificate=True;Connection Timeout=10;&quot;" /> <add name="ezEntities" providerName="System.Data.EntityClient" connectionString="metadata=res://*/App_Code.Model.Model.csdl|res://*/App_Code.Model.Model.ssdl|res://*/App_Code.Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=17168erp_t;User ID=sa;Password=778611;Encrypt=False;TrustServerCertificate=True;Connection Timeout=10;&quot;" />
<!-- <!--
--> -->
<!--SQL用--> <!--SQL用-->
+102
View File
@@ -0,0 +1,102 @@
## FK 規則更新
| FK 名稱 | 更新內容 |
| - | - |
| FK_act_bom_actItem1| 刪除規則設為 cascade |
| FK_pro_order_followers | 刪除規則設為 cascade |
| FK_pro_order_activity | 刪除規則設為 cascade |
| FK_pro_order_detail_pro_order | 刪除規則設為 cascade |
| FK_pro_order_detail_followers | 刪除規則設為 沒有動作 |
| FK_activity_relating_activity | 刪除規則設為 cascade |
| FK_pro_order_auto_enroll | 刪除規則設為 NULL |
## 資料表欄位更新
| 資料表 | 新增欄位 | 備註 |
| - | - | - |
| actitem | 加上 sort_order (int) 欄位位 | |
| activity_relating | 加上 has_yang_limit(bit) 欄位 | |
| activity_relating | 加上 has_chao_limit(bit) 欄位 | |
| activity_relating | 加上 yang_limit_count (int) 欄位 | |
| activity_relating | 加上 chao_limit_count (int) 欄位 | |
| company | 加上 last_auto_order_no (nvarchar(20)) 欄位 | |
| pro_order | 加上 au_num (int) 欄位 | 需建立 FK 限制 (見下方 SQL) |
- 更新 actitem 資料表
```language
ALTER TABLE actitem
ADD sort_order int NULL;
```
- 更新 activity_relating 資料表
```language
ALTER TABLE activity_relating
ADD has_yang_limit bit NULL,
has_chao_limit bit NULL,
yang_limit_count int NULL,
chao_limit_count int NULL;
```
- 更新 company 資料表
```language
ALTER TABLE company
ADD last_auto_order_no nvarchar(20) NULL;
```
- 更新 pro_order 資料表及外鍵限制
```language
-- 新增欄位
ALTER TABLE pro_order
ADD au_num int NULL;
-- 建立外鍵限制 (FK_pro_order_auto_enroll)
ALTER TABLE pro_order
ADD CONSTRAINT FK_pro_order_auto_enroll
FOREIGN KEY (au_num) REFERENCES auto_enroll(num);
```
## 新增資料表 auto_enroll
| 欄位名稱 | 資料類型 | 允許 Null | 備註 |
| - | - | - | - |
| num | int | 否 | PK, 識別規格 (Identity) |
| f_num | int | 否 | FK (連至 followers.num) |
| start_date | date | 是 | |
| end_date | date | 是 | |
| receipt_title | nvarchar(MAX) | 是 | |
| receipt_address | nchar(200) | 否 | |
- 建立資料表 auto_enroll
```language
CREATE TABLE [dbo].[auto_enroll] (
[num] int IDENTITY(1,1) NOT NULL,
[f_num] int NOT NULL,
[start_date] date NULL,
[end_date] date NULL,
[receipt_title] nvarchar(MAX) NULL,
[receipt_address] nchar(200) NOT NULL,
CONSTRAINT [PK_auto_enroll] PRIMARY KEY CLUSTERED ([num] ASC)
);
```
- 設定外鍵限制
```language
ALTER TABLE [dbo].[auto_enroll]
ADD CONSTRAINT FK_auto_enroll_followers
FOREIGN KEY (f_num) REFERENCES followers(num);
```
### 資料表相關設定 (SQL)
- 設定主鍵
```language
ALTER TABLE [dbo].[auto_enroll]
ADD CONSTRAINT PK_auto_enroll PRIMARY KEY (num);
```
- 設定外鍵
```language
ALTER TABLE auto_enroll
ADD CONSTRAINT FK_auto_enroll_followers
FOREIGN KEY (f_num) REFERENCES followers(num);
```
- Model.edmx 設定
- num 識別規格設為 是
- Model.edmx auto_enroll.num 屬性 StoreGeneratedPattern 設為 Identity
+41
View File
@@ -0,0 +1,41 @@
FK 規則更新
FK_act_bom_actItem1 刪除規則設為 cascade
FK_pro_order_followers 刪除規則設為 cascade
FK_pro_order_activity 刪除規則設為 cascade
FK_pro_order_detail_pro_order 刪除規則設為 cascade
FK_pro_order_detail_followers 刪除規則設為 沒有動作
FK_activity_relating_activity 刪除規則設為 cascade
FK_pro_order_auto_enroll 刪除規則設為 NULL
------------------------------------------------------------
資料表欄位更新
actitem 加上 sort_order(int) 欄位
activity_relating 加上 has_yang_limit(bit) 欄位
activity_relating 加上 has_chao_limit(bit) 欄位
activity_relating 加上 yang_limit_count(int) 欄位
activity_relating 加上 chao_limit_count(int) 欄位
company 加上 last_auto_order_no(nvarchar(20)) 欄位
pro_order 加上 au_num(int) 欄位 並加上 constraint
ALTER TABLE pro_order
ADD CONSTRAINT FK_pro_order_auto_enroll
FOREIGN KEY (au_num) REFERENCES auto_enroll(num);
------------------------------------------------------------
新增資料表 auto_enroll
num int 不允許 Null
f_num int 不允許 Null
start_date date 允許 Null
end_date date 允許 Null
receipt_title nvarchar(MAX) 允許 Null
receipt_address nchar(200) 不允許 Null
設定主鍵
ALTER TABLE [dbo].[auto_enroll]
ADD CONSTRAINT PK_auto_enroll PRIMARY KEY (num);
設定外鍵
ALTER TABLE auto_enroll
ADD CONSTRAINT FK_auto_enroll_followers
FOREIGN KEY (f_num) REFERENCES followers(num);
Model.edmx 設定
1. num 識別規格設為 是
2. Model.edmx auto_enroll.num 屬性 StoreGeneratedPattern 設為 Identity