This commit is contained in:
2026-07-22 18:04:17 +08:00
parent 07c5027ad8
commit da58dc92d0
19 changed files with 2105 additions and 148 deletions
+4
View File
@@ -95,6 +95,10 @@ namespace Model
public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; }
public virtual DbSet<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
public virtual DbSet<auto_enroll> auto_enroll { get; set; }
public virtual DbSet<receipt_detail> receipt_detail { get; set; }
public virtual DbSet<receipt_master> receipt_master { get; set; }
public virtual DbSet<receipt_style> receipt_style { get; set; }
public virtual DbSet<receipt_style_d> receipt_style_d { get; set; }
public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount)
{
+81 -2
View File
@@ -694,8 +694,8 @@ namespace Model
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 Nullable<System.DateTime> start_date { get; set; }
public Nullable<System.DateTime> end_date { get; set; }
public string receipt_title { get; set; }
public string receipt_address { get; set; }
@@ -1539,6 +1539,85 @@ namespace Model
using System;
using System.Collections.Generic;
public partial class receipt_detail
{
public int num { get; set; }
public Nullable<int> receipt_num { get; set; }
public string title { get; set; }
public Nullable<int> amt { get; set; }
public string receipt_no { get; set; }
public string caseofficer { get; set; }
public string c_user { get; set; }
public string c_date { get; set; }
public string c_time { get; set; }
public string u_user { get; set; }
public string u_date { get; set; }
public string u_time { get; set; }
public string addr { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class receipt_master
{
public int num { get; set; }
public string order_no { get; set; }
public Nullable<int> total_amt { get; set; }
public string receipt_date { get; set; }
public Nullable<int> style_num { get; set; }
public string c_user { get; set; }
public string c_date { get; set; }
public string c_time { get; set; }
public string u_user { get; set; }
public string u_date { get; set; }
public string u_time { get; set; }
public string source { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class receipt_style
{
public int num { get; set; }
public string name { get; set; }
public string c_user { get; set; }
public string c_date { get; set; }
public string c_time { get; set; }
public string u_user { get; set; }
public string u_date { get; set; }
public string u_time { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class receipt_style_d
{
public int num { get; set; }
public Nullable<int> style_num { get; set; }
public string item_name { get; set; }
public string item_value { get; set; }
public string c_user { get; set; }
public string c_date { get; set; }
public string c_time { get; set; }
public string u_user { get; set; }
public string u_date { get; set; }
public string u_time { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class Region
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+215 -14
View File
@@ -343,10 +343,10 @@
</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="start_date" Type="date" />
<Property Name="end_date" Type="date" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="receipt_address" Type="nchar" MaxLength="200" />
<Property Name="receipt_address" Type="nvarchar" MaxLength="200" />
</EntityType>
<EntityType Name="bed_kind">
<Key>
@@ -419,7 +419,7 @@
<Property Name="smtp_def" Type="nvarchar" MaxLength="1" />
<Property Name="use_sender" Type="nvarchar" MaxLength="1" />
<Property Name="bed_order_no" Type="nvarchar" MaxLength="20" />
<Property Name="last_auto_order_no" Type="nvarchar" MaxLength="20" />
<Property Name="last_auto_order_no" Type="varchar" MaxLength="20" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -795,6 +795,69 @@
<Property Name="pic1" Type="nvarchar" MaxLength="50" />
<Property Name="pro_id" Type="int" />
</EntityType>
<EntityType Name="receipt_detail">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="receipt_num" Type="int" />
<Property Name="title" Type="nvarchar(max)" />
<Property Name="amt" Type="int" />
<Property Name="receipt_no" Type="varchar" MaxLength="50" />
<Property Name="caseofficer" Type="nvarchar" MaxLength="50" />
<Property Name="c_user" Type="varchar" MaxLength="30" />
<Property Name="c_date" Type="varchar" MaxLength="10" />
<Property Name="c_time" Type="varchar" MaxLength="6" />
<Property Name="u_user" Type="varchar" MaxLength="30" />
<Property Name="u_date" Type="varchar" MaxLength="10" />
<Property Name="u_time" Type="varchar" MaxLength="6" />
<Property Name="addr" Type="nvarchar" MaxLength="255" />
</EntityType>
<EntityType Name="receipt_master">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="order_no" Type="varchar" MaxLength="50" />
<Property Name="total_amt" Type="int" />
<Property Name="receipt_date" Type="varchar" MaxLength="10" />
<Property Name="style_num" Type="int" />
<Property Name="c_user" Type="varchar" MaxLength="30" />
<Property Name="c_date" Type="varchar" MaxLength="10" />
<Property Name="c_time" Type="varchar" MaxLength="6" />
<Property Name="u_user" Type="varchar" MaxLength="30" />
<Property Name="u_date" Type="varchar" MaxLength="10" />
<Property Name="u_time" Type="varchar" MaxLength="6" />
<Property Name="source" Type="varchar" MaxLength="8" />
</EntityType>
<EntityType Name="receipt_style">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="name" Type="nvarchar" MaxLength="50" />
<Property Name="c_user" Type="varchar" MaxLength="30" />
<Property Name="c_date" Type="varchar" MaxLength="10" />
<Property Name="c_time" Type="varchar" MaxLength="6" />
<Property Name="u_user" Type="varchar" MaxLength="30" />
<Property Name="u_date" Type="varchar" MaxLength="10" />
<Property Name="u_time" Type="varchar" MaxLength="6" />
</EntityType>
<EntityType Name="receipt_style_d">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="style_num" Type="int" />
<Property Name="item_name" Type="varchar" MaxLength="50" />
<Property Name="item_value" Type="nvarchar" MaxLength="50" />
<Property Name="c_user" Type="varchar" MaxLength="30" />
<Property Name="c_date" Type="varchar" MaxLength="10" />
<Property Name="c_time" Type="varchar" MaxLength="6" />
<Property Name="u_user" Type="varchar" MaxLength="30" />
<Property Name="u_date" Type="varchar" MaxLength="10" />
<Property Name="u_time" Type="varchar" MaxLength="6" />
</EntityType>
<EntityType Name="Region">
<Key>
<PropertyRef Name="Uuid" />
@@ -1140,15 +1203,15 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_activity_activity_category_kind">
<End Role="activity_category_kind" Type="Self.activity_category_kind" Multiplicity="0..1" />
<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_category_kind">
<Principal Role="activity_kind">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="activity">
<PropertyRef Name="category_kind" />
<PropertyRef Name="kind" />
</Dependent>
</ReferentialConstraint>
</Association>
@@ -2188,6 +2251,10 @@
<EntitySet Name="project" EntityType="Self.project" Schema="dbo" store:Type="Tables" />
<EntitySet Name="project_kind" EntityType="Self.project_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="project_sub" EntityType="Self.project_sub" Schema="dbo" store:Type="Tables" />
<EntitySet Name="receipt_detail" EntityType="Self.receipt_detail" Schema="dbo" store:Type="Tables" />
<EntitySet Name="receipt_master" EntityType="Self.receipt_master" Schema="dbo" store:Type="Tables" />
<EntitySet Name="receipt_style" EntityType="Self.receipt_style" Schema="dbo" store:Type="Tables" />
<EntitySet Name="receipt_style_d" EntityType="Self.receipt_style_d" Schema="dbo" store:Type="Tables" />
<EntitySet Name="Region" EntityType="Self.Region" Schema="dbo" store:Type="Tables" />
<EntitySet Name="RegionAndRoomAndBedSchedule" EntityType="Self.RegionAndRoomAndBedSchedule" Schema="dbo" store:Type="Tables" />
<EntitySet Name="RegionRoomBed" EntityType="Self.RegionRoomBed" Schema="dbo" store:Type="Tables" />
@@ -2246,8 +2313,8 @@
<End Role="actItem" EntitySet="actItem" />
<End Role="actItem_files" EntitySet="actItem_files" />
</AssociationSet>
<AssociationSet Name="FK_activity_activity_category_kind" Association="Self.FK_activity_activity_category_kind">
<End Role="activity_category_kind" EntitySet="activity_category_kind" />
<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">
@@ -2953,7 +3020,7 @@
<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="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" />
<Property Name="last_auto_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -4620,6 +4687,10 @@
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<EntitySet Name="receipt_detail" EntityType="Model.receipt_detail" />
<EntitySet Name="receipt_master" EntityType="Model.receipt_master" />
<EntitySet Name="receipt_style" EntityType="Model.receipt_style" />
<EntitySet Name="receipt_style_d" EntityType="Model.receipt_style_d" />
</EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" />
@@ -5343,10 +5414,10 @@
</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="start_date" Type="DateTime" Precision="0" />
<Property Name="end_date" Type="DateTime" Precision="0" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<Property Name="receipt_address" Type="String" MaxLength="200" FixedLength="false" 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>
@@ -5376,6 +5447,69 @@
</Dependent>
</ReferentialConstraint>
</Association>
<EntityType Name="receipt_detail">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="receipt_num" Type="Int32" />
<Property Name="title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="amt" Type="Int32" />
<Property Name="receipt_no" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="caseofficer" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="c_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="c_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="c_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="u_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="u_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="u_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="addr" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="receipt_master">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="order_no" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="total_amt" Type="Int32" />
<Property Name="receipt_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="style_num" Type="Int32" />
<Property Name="c_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="c_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="c_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="u_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="u_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="u_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="source" Type="String" MaxLength="8" FixedLength="false" Unicode="false" />
</EntityType>
<EntityType Name="receipt_style">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="c_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="c_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="c_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="u_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="u_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="u_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
</EntityType>
<EntityType Name="receipt_style_d">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="style_num" Type="Int32" />
<Property Name="item_name" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="item_value" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="c_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="c_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="c_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
<Property Name="u_user" Type="String" MaxLength="30" FixedLength="false" Unicode="false" />
<Property Name="u_date" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="u_time" Type="String" MaxLength="6" FixedLength="false" Unicode="false" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
@@ -6447,6 +6581,73 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="receipt_detail">
<EntityTypeMapping TypeName="Model.receipt_detail">
<MappingFragment StoreEntitySet="receipt_detail">
<ScalarProperty Name="addr" ColumnName="addr" />
<ScalarProperty Name="u_time" ColumnName="u_time" />
<ScalarProperty Name="u_date" ColumnName="u_date" />
<ScalarProperty Name="u_user" ColumnName="u_user" />
<ScalarProperty Name="c_time" ColumnName="c_time" />
<ScalarProperty Name="c_date" ColumnName="c_date" />
<ScalarProperty Name="c_user" ColumnName="c_user" />
<ScalarProperty Name="caseofficer" ColumnName="caseofficer" />
<ScalarProperty Name="receipt_no" ColumnName="receipt_no" />
<ScalarProperty Name="amt" ColumnName="amt" />
<ScalarProperty Name="title" ColumnName="title" />
<ScalarProperty Name="receipt_num" ColumnName="receipt_num" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="receipt_master">
<EntityTypeMapping TypeName="Model.receipt_master">
<MappingFragment StoreEntitySet="receipt_master">
<ScalarProperty Name="source" ColumnName="source" />
<ScalarProperty Name="u_time" ColumnName="u_time" />
<ScalarProperty Name="u_date" ColumnName="u_date" />
<ScalarProperty Name="u_user" ColumnName="u_user" />
<ScalarProperty Name="c_time" ColumnName="c_time" />
<ScalarProperty Name="c_date" ColumnName="c_date" />
<ScalarProperty Name="c_user" ColumnName="c_user" />
<ScalarProperty Name="style_num" ColumnName="style_num" />
<ScalarProperty Name="receipt_date" ColumnName="receipt_date" />
<ScalarProperty Name="total_amt" ColumnName="total_amt" />
<ScalarProperty Name="order_no" ColumnName="order_no" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="receipt_style">
<EntityTypeMapping TypeName="Model.receipt_style">
<MappingFragment StoreEntitySet="receipt_style">
<ScalarProperty Name="u_time" ColumnName="u_time" />
<ScalarProperty Name="u_date" ColumnName="u_date" />
<ScalarProperty Name="u_user" ColumnName="u_user" />
<ScalarProperty Name="c_time" ColumnName="c_time" />
<ScalarProperty Name="c_date" ColumnName="c_date" />
<ScalarProperty Name="c_user" ColumnName="c_user" />
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="receipt_style_d">
<EntityTypeMapping TypeName="Model.receipt_style_d">
<MappingFragment StoreEntitySet="receipt_style_d">
<ScalarProperty Name="u_time" ColumnName="u_time" />
<ScalarProperty Name="u_date" ColumnName="u_date" />
<ScalarProperty Name="u_user" ColumnName="u_user" />
<ScalarProperty Name="c_time" ColumnName="c_time" />
<ScalarProperty Name="c_date" ColumnName="c_date" />
<ScalarProperty Name="c_user" ColumnName="c_user" />
<ScalarProperty Name="item_value" ColumnName="item_value" />
<ScalarProperty Name="item_name" ColumnName="item_name" />
<ScalarProperty Name="style_num" ColumnName="style_num" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
+4
View File
@@ -165,6 +165,10 @@
<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" />
<EntityTypeShape EntityType="Model.receipt_detail" Width="1.5" PointX="23.375" PointY="7.75" />
<EntityTypeShape EntityType="Model.receipt_master" Width="1.5" PointX="25.375" PointY="7.75" />
<EntityTypeShape EntityType="Model.receipt_style" Width="1.5" PointX="19.375" PointY="25.75" />
<EntityTypeShape EntityType="Model.receipt_style_d" Width="1.5" PointX="26.375" PointY="0.75" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
+42
View File
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Model.ViewModel
{
/// <summary>
/// receipt 的摘要描述
/// </summary>
public class receipt_master
{
public receipt_master()
{
//
// TODO: 在這裡新增建構函式邏輯
//
}
public int? num { get; set; }
public string order_no { get; set; }
public int? total_amt { get; set; }
public int? style_num { get; set; }
public string source { get; set; }
public string receipt_date { get; set; }
public List<receipt_detail> list { get;set ; }
}
public class receipt_detail
{
public receipt_detail()
{
}
public int? num { get; set; }
public int? receipt_num { get; set; }
public string title { get; set; }
public string receipt_no { get; set; }
public int? amt { get; set; }
public string caseofficer { get; set; }
public string addr { get; set; }
}
}
+6 -6
View File
@@ -738,8 +738,8 @@ public class FollowerController : ApiController
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_start_date = x.start_date.Value.ToString("yyyy-MM-dd"),
auto_enroll_end_date = x.end_date.Value.ToString("yyyy-MM-dd"),
auto_enroll_receipt_title = x.receipt_title?? "",
auto_enroll_receipt_address = x.receipt_address?? "",
}),
@@ -768,7 +768,7 @@ public class FollowerController : ApiController
;
_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);
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date.Value, item.end_date.Value, item.receipt_title, item.receipt_address);
}
else
{
@@ -781,7 +781,7 @@ public class FollowerController : ApiController
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);
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date.Value, item.end_date.Value, item.receipt_title, item.receipt_address);
}
try
@@ -789,8 +789,8 @@ public class FollowerController : ApiController
var ret = new
{
num = autoEnroll.num,
start_date = autoEnroll.start_date.ToString("yyyy-MM-dd"),
end_date = autoEnroll.end_date.ToString("yyyy-MM-dd"),
start_date = autoEnroll.start_date.Value.ToString("yyyy-MM-dd"),
end_date = autoEnroll.end_date.Value.ToString("yyyy-MM-dd"),
receipt_title = autoEnroll.receipt_title,
receipt_address = autoEnroll.receipt_address,
};
+4
View File
@@ -391,6 +391,7 @@ public class orderController : ApiController
o_detail.qty = detail.qty;
o_detail.printed_files = detail.printed_files;
o_detail.style = detail.style;
o_detail.print_id = GenerateSequentialId(o_detail, order);
Newtonsoft.Json.Linq.JArray mid_items = new Newtonsoft.Json.Linq.JArray();
foreach (var data in detail.mid_items)
{
@@ -514,6 +515,8 @@ public class orderController : ApiController
qry = qry.Where(o => o.f_num != null && o.follower != null && encrypt.DecryptAutoKey(o.follower.id_code) == q.f_user.id_code);
}
sortBy = sortBy ?? string.Empty;
if (sortBy.Equals("order_no"))
{
if (sortDesc)
@@ -580,6 +583,7 @@ public class orderController : ApiController
uptime=x.up_time?.ToString("yyyy-MM-dd"),
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,
amt = _db.pro_order_detail.Where(y => y.order_no == x.order_no).Select(y => new {y.price,y.qty}).Sum(y => y.price*y.qty),
}),
count = count
};
+481
View File
@@ -0,0 +1,481 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Vml;
using DocumentFormat.OpenXml.Wordprocessing;
using Model;
using NPOI.OpenXmlFormats.Wordprocessing;
using NPOI.Util;
using PagedList;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using System.Web.Http;
using System.Web.UI.WebControls;
using Break = DocumentFormat.OpenXml.Wordprocessing.Break;
using Paragraph = DocumentFormat.OpenXml.Wordprocessing.Paragraph;
using Run = DocumentFormat.OpenXml.Wordprocessing.Run;
using Table = DocumentFormat.OpenXml.Wordprocessing.Table;
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
/// <summary>
/// receiptController 的摘要描述
/// </summary>
[ezAuthorize]
public class receiptController: ApiController
{
private Model.ezEntities _db = new Model.ezEntities();
public receiptController()
{
//
// TODO: 在這裡新增建構函式邏輯
//
}
public string generend_receiptNo(string source)
{
string start = source + "A";
string no = start + DateTime.Now.ToString("yyyyMMdd");
var qry = _db.receipt_detail.Where(x => x.receipt_no.StartsWith(no));
var receipt_no=qry.Select(x => x.receipt_no).Max();
if (!string.IsNullOrEmpty(receipt_no))
{
receipt_no= receipt_no.Remove(0,(start + DateTime.Now.ToString("yyyyMMdd")).Length);
return start + DateTime.Now.ToString("yyyyMMdd")+string.Format("{0:D4}", Int32.Parse(receipt_no)+1);
}
else
{
return start + DateTime.Now.ToString("yyyyMMdd") + "0001";
}
}
[HttpPost]
[Route("api/receipt/UpdateReceiptWithDetail")]
public IHttpActionResult UpdateReceiptWithDetail([FromBody] Model.ViewModel.receipt_master receipt)
{
int master_no = 0;
try
{
//Model.receipt_master m = new Model.receipt_master();
List<Model.receipt_detail> list = new List<Model.receipt_detail>();
var master = _db.receipt_master.Where(x => x.num == receipt.num).FirstOrDefault();
if (master != null)
{
master.u_time = DateTime.Now.ToString("HHmmss");
master.u_date = DateTime.Now.ToString("yyyyMMdd");
}
master_no=master.num;
//m.receipt_date = receipt.receipt_date;
//m.order_no = receipt.order_no;
//m.total_amt = receipt.total_amt;
//m.style_num = receipt.style_num;
//m.source = receipt.source;
//m.num=(int)receipt.num;
//m.c_date = DateTime.Now.ToString("yyyyMMdd");
//m.c_time = DateTime.Now.ToString("HHmmss");
//m.u_time = DateTime.Now.ToString("HHmmss");
//m.u_date = DateTime.Now.ToString("yyyyMMdd");
//_db.receipt_master.Add(m);
//_db.SaveChanges();
//master_no = m.num;
string pre_no = string.Empty;
foreach (var d in receipt.list)
{
if (d.num == 0)
{
receipt_detail dd = new receipt_detail();
if (string.IsNullOrEmpty(pre_no))
{
dd.receipt_no = generend_receiptNo(master.source);
}
else
{
string new_no = pre_no.Remove(0, 10);
dd.receipt_no = master.source + "A" + DateTime.Now.ToString("yyyyMMdd") + string.Format("{0:D4}", Int32.Parse(new_no) + 1);
}
dd.addr = d.addr;
dd.title = d.title;
dd.amt = d.amt;
dd.caseofficer = d.caseofficer;
dd.receipt_num = master.num;
dd.c_date = DateTime.Now.ToString("yyyyMMdd");
dd.c_time = DateTime.Now.ToString("HHmmss");
dd.u_time = DateTime.Now.ToString("HHmmss");
dd.u_date = DateTime.Now.ToString("yyyyMMdd");
pre_no = dd.receipt_no;
list.Add(dd);
}
else
{
var dd=_db.receipt_detail.Where(x=>x.num==d.num).FirstOrDefault();
dd.title=d.title;
dd.amt=d.amt;
dd.caseofficer=d.caseofficer;
dd.u_time = DateTime.Now.ToString("HHmmss");
dd.u_date = DateTime.Now.ToString("yyyyMMdd");
}
}
_db.receipt_detail.AddRange(list);
_db.SaveChanges();
return Ok(new { result = "Y", message = "存檔成功" });
}
catch (Exception ex)
{
var s = _db.receipt_master.Where(x => x.num == master_no).FirstOrDefault();
if (s != null)
{
_db.receipt_master.Remove(s);
_db.SaveChanges();
}
return Ok(new { result = "N", message = $"存檔失敗,{ex.Message} {ex.StackTrace}" });
}
}
[HttpPost]
[Route("api/receipt/SaveReceiptWithDetail")]
public IHttpActionResult SaveReceiptWithDetail([FromBody] Model.ViewModel.receipt_master receipt)
{
int master_no = 0;
try
{
Model.receipt_master m = new Model.receipt_master();
List<Model.receipt_detail> list = new List<Model.receipt_detail>();
m.receipt_date = receipt.receipt_date;
m.order_no = receipt.order_no;
m.total_amt = receipt.total_amt;
m.style_num = receipt.style_num;
m.source = receipt.source;
m.c_date = DateTime.Now.ToString("yyyyMMdd");
m.c_time = DateTime.Now.ToString("HHmmss");
m.u_time= DateTime.Now.ToString("HHmmss");
m.u_date = DateTime.Now.ToString("yyyyMMdd");
_db.receipt_master.Add(m);
_db.SaveChanges();
master_no = m.num;
string pre_no = string.Empty;
foreach (var d in receipt.list)
{
receipt_detail dd = new receipt_detail();
if (string.IsNullOrEmpty(pre_no))
{
dd.receipt_no = generend_receiptNo(m.source);
}
else
{
string new_no = pre_no.Remove(0,10);
dd.receipt_no = m.source + "A" + DateTime.Now.ToString("yyyyMMdd") + string.Format("{0:D4}", Int32.Parse(new_no)+1);
}
dd.addr = d.addr;
dd.title = d.title;
dd.amt = d.amt;
dd.caseofficer = d.caseofficer;
dd.receipt_num = m.num;
dd.c_date = DateTime.Now.ToString("yyyyMMdd");
dd.c_time = DateTime.Now.ToString("HHmmss");
dd.u_time = DateTime.Now.ToString("HHmmss");
dd.u_date = DateTime.Now.ToString("yyyyMMdd");
pre_no = dd.receipt_no;
list.Add(dd);
}
_db.receipt_detail.AddRange(list);
_db.SaveChanges();
return Ok(new {result="Y",message="存檔成功"});
}
catch (Exception ex)
{
var s=_db.receipt_master.Where(x=>x.num==master_no).FirstOrDefault();
if (s != null)
{
_db.receipt_master.Remove(s);
_db.SaveChanges();
}
return Ok(new { result = "N", message = $"存檔失敗,{ex.Message} {ex.StackTrace}" });
}
}
[HttpPost]
[Route("api/receipt/GetList")]
public IHttpActionResult GetList([FromBody] Model.ViewModel.receipt_master r,
int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
var qry = _db.receipt_master.AsQueryable();
if (r.num.HasValue)
qry = qry.Where(x => x.num == r.num.Value);
if (!string.IsNullOrEmpty(r.receipt_date))
qry = qry.Where(x=>x.receipt_date==r.receipt_date);
if (!string.IsNullOrEmpty(r.source))
qry = qry.Where(x => x.source == r.source);
if (!string.IsNullOrEmpty(r.order_no))
qry = qry.Where(x => x.order_no == r.order_no);
qry=qry.OrderBy(x => x.num);
var count = qry.Count();
var qryList = (pageSize > 0) ? qry.ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qryList.Select(x => new
{
x.num,x.source,x.order_no,x.total_amt,x.receipt_date,x.style_num,
follower=_db.pro_order.Where(y=>y.order_no==x.order_no).Select(y=>new {
u_name=_db.followers.Where(z=>z.num==y.f_num).Select(z=>z.u_name).FirstOrDefault(),
}).FirstOrDefault(),
receipt_count=_db.receipt_detail.Where(w=>w.receipt_num==x.num).Count()
}),
count=count
};
if (ret.list == null) throw new HttpResponseException(HttpStatusCode.NotFound);
return Ok(ret);
}
[HttpPost]
[Route("api/receipt/GetData")]
public IHttpActionResult GetData([FromBody] Model.ViewModel.receipt_master r)
{
var qry = _db.receipt_master.AsQueryable();
if (r.num.HasValue)
qry = qry.Where(x => x.num == r.num.Value);
if (!string.IsNullOrEmpty(r.receipt_date))
qry = qry.Where(x => x.receipt_date == r.receipt_date);
if (!string.IsNullOrEmpty(r.source))
qry = qry.Where(x => x.source == r.source);
if (!string.IsNullOrEmpty(r.order_no))
qry = qry.Where(x => x.order_no == r.order_no);
qry = qry.OrderBy(x => x.num);
var ret = new
{
data = qry.Select(x => new
{
x.num,
x.source,
x.order_no,
x.total_amt,
x.receipt_date,
x.style_num,
follower = _db.pro_order.Where(y => y.order_no == x.order_no).Select(y => new {
u_name = _db.followers.Where(z => z.num == y.f_num).Select(z => z.u_name).FirstOrDefault(),
}).FirstOrDefault(),
receipt_detail = _db.receipt_detail.Where(w => w.receipt_num == x.num).ToList(),
orderdetails=_db.pro_order_detail.Where(q=>q.order_no==x.order_no).Select(q=>new
{
records=_db.pro_order_record.Where(rc=>rc.detail_num==q.num).Select(rc=>rc.price).ToList(),
}).ToList()
}).FirstOrDefault(),
};
if (ret.data == null) throw new HttpResponseException(HttpStatusCode.NotFound);
return Ok(ret);
}
[HttpPost]
[Route("api/receipt/GetAllStyle")]
public IHttpActionResult GetAllStyle()
{
var qry = _db.receipt_style.AsQueryable();
return Ok(new { result = "Y", list = qry.ToList() });
}
[HttpPost]
[Route("api/receipt/PrintReceipt")]
public HttpResponseMessage PrintReceipt([FromBody] Model.receipt_master r)
{
var qry=_db.receipt_master.AsQueryable();
qry = qry.Where(x=>x.num==r.num);
var data = qry.Select(x=>new
{
x.num,x.receipt_date,x.source,x.order_no,x.style_num,
details=_db.receipt_detail.Where(y=>y.receipt_num==x.num).ToList(),
styleDetail=_db.receipt_style_d.Where(z=>z.style_num==x.style_num).ToList(),
}).FirstOrDefault();
try
{
string templatePath = HttpContext.Current.Server.MapPath("~/rpt/sample/receipt_sample01.docx");
if (!File.Exists(templatePath))
{
return Request.CreateResponse(HttpStatusCode.NotFound, "Template file not found.");
}
byte[] templateBytes = File.ReadAllBytes(templatePath);
// 2. 建立記憶體串流
MemoryStream outputStream = new MemoryStream();
outputStream.Write(templateBytes, 0, templateBytes.Length);
// 3. 使用 Open XML 處理記憶體中的資料
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(outputStream, true))
{
var body = wordDoc.MainDocumentPart.Document.Body;
var templateTable = body.Elements<Table>().FirstOrDefault();
if (templateTable != null && data.details != null && data.details.Count > 0)
{
OpenXmlElement currentAnchor = templateTable;
// 建立全域計數器 (請實作於迴圈外部,避免歸零)
int docPrIdCounter = 1000;
int vmlIdCounter = 2000;
for (int i = 0; i < data.details.Count; i++)
{
Table newTable = (Table)templateTable.CloneNode(true);
// --- 步驟 A:修復 DrawingML 的 docPr ID ---
foreach (var docPr in newTable.Descendants<DocumentFormat.OpenXml.Drawing.Wordprocessing.DocProperties>())
{
docPr.Id = (uint)docPrIdCounter++;
// 順便變更 Name,避免如 "直線接點 2" 的名稱重複
docPr.Name = $"直線接點_{docPrIdCounter}";
}
// --- 步驟 B:修復 VML 的 id 與 o:spid ---
foreach (var line in newTable.Descendants<Line>())
{
string newSpid = $"_x0000_s{vmlIdCounter++}";
// 更新原本的 v:line id
line.Id = $"直線接點_{vmlIdCounter}";
// o:spid 屬於 Office 擴充屬性,透過 SetAttribute 強制覆寫
var oNamespace = "urn:schemas-microsoft-com:office:office";
line.SetAttribute(new OpenXmlAttribute("spid", "o", oNamespace, newSpid));
}
// 移除複製出來的書籤標籤,保持結構乾淨
var bookmarksStarts = newTable.Descendants<BookmarkStart>().ToList();
var bookmarksEnds = newTable.Descendants<BookmarkEnd>().ToList();
foreach (var bm in bookmarksStarts) bm.Remove();
foreach (var bm in bookmarksEnds) bm.Remove();
foreach (var p in newTable.Descendants<Paragraph>())
{
p.RsidParagraphAddition = null;
p.RsidParagraphDeletion = null;
p.RsidParagraphProperties = null;
p.RsidRunAdditionDefault = null;
}
var textElements = newTable.Descendants<Text>().ToList();
foreach (var textNode in textElements)
{
// 檢查文字節點是否包含指定的關鍵字,並進行置換
if (textNode.Text.Contains("$CompanyTitle"))
{
var companyTitle = data.styleDetail.Where(x => x.item_name == "CompanyTitle").Select(x => x.item_value).FirstOrDefault();
textNode.Text = textNode.Text.Replace("$CompanyTitle", companyTitle ?? "");
}
if (textNode.Text.Contains("$ApproveNo"))
{
var approveNo = data.styleDetail.Where(x => x.item_name == "ApproveNo").Select(x => x.item_value).FirstOrDefault();
textNode.Text = textNode.Text.Replace("$ApproveNo", approveNo ?? "");
}
if (textNode.Text.Contains("$CompanyTaxNo"))
{
var companyTaxNo = data.styleDetail.Where(x => x.item_name == "CompanyTaxNo").Select(x => x.item_value).FirstOrDefault();
textNode.Text = textNode.Text.Replace("$CompanyTaxNo", companyTaxNo ?? "");
}
if (textNode.Text.Contains("$CompanyAddr"))
{
var companyAddr = data.styleDetail.Where(x => x.item_name == "CompanyAddr").Select(x => x.item_value).FirstOrDefault();
textNode.Text = textNode.Text.Replace("$CompanyAddr", companyAddr ?? "");
}
if (textNode.Text.Contains("$CompanyTel"))
{
var companyTel = data.styleDetail.Where(x => x.item_name == "CompanyTel").Select(x => x.item_value).FirstOrDefault();
textNode.Text = textNode.Text.Replace("$CompanyTel", companyTel ?? "");
}
if (textNode.Text.Contains("$ReceiptNo"))
{
textNode.Text = textNode.Text.Replace("$ReceiptNo", data.details[i].receipt_no ?? "");
}
if (textNode.Text.Contains("$ReceiptDate"))
{
textNode.Text = textNode.Text.Replace("$ReceiptDate", data.receipt_date ?? "");
}
if (textNode.Text.Contains("$ReceiptTitle"))
{
textNode.Text = textNode.Text.Replace("$ReceiptTitle", data.details[i].title ?? "");
}
if (textNode.Text.Contains("$ReceiptAmt"))
{
textNode.Text = textNode.Text.Replace("$ReceiptAmt", data.details[i].amt.ToString() ?? "");
}
if (textNode.Text.Contains("$Charge"))
{
textNode.Text = textNode.Text.Replace("$Charge", "" ?? "");
}
if (textNode.Text.Contains("$Caseofficer"))
{
textNode.Text = textNode.Text.Replace("$Caseofficer", data.details[i].caseofficer ?? "");
}
}
currentAnchor= body.InsertAfter(newTable, currentAnchor);
//currentAnchor = newTable;
if (i < data.details.Count - 1)
{
Paragraph pageBreakParagraph = new Paragraph(
new Run(
new Break() { Type = BreakValues.Page }
)
);
// 🔥【關鍵修正】將分頁段落插入到剛才產生的新表格後方
currentAnchor = body.InsertAfter(pageBreakParagraph, currentAnchor);
}
}
body.RemoveChild(templateTable);
wordDoc.MainDocumentPart.Document.Save();
}
} // wordDoc 關閉,確認資料完全寫入 outputStream
// 🔥 關鍵步驟:重設記憶體串流指標到起點
outputStream.Position = 0;
// 4. 建立 HttpResponseMessage
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
// 將記憶體流包裝成 StreamContent
response.Content = new StreamContent(outputStream);
// 設定 Content-Type 標頭(Word 專用 MIME Type
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
// 設定 Content-Disposition 標頭,指定為附件並提供預設檔名
string fileName = $"Report_{DateTime.Now:yyyyMMddHHmmss}.docx";
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = fileName
};
return response;
}
catch (Exception ex)
{
// Log exception details appropriately here
return Request.CreateResponse(HttpStatusCode.InternalServerError, $"Generation failed: {ex.Message}");
}
}
}