update from old git

This commit is contained in:
2025-09-04 18:30:54 +08:00
parent af2c152ef6
commit 61502cb3bd
46 changed files with 6420 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_regiontype_index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<a href="reg.aspx" class="btn btn-primary">
<i class="mdi mdi-plus"></i>新增區域類型
</a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container">
<div class="card shadow-sm">
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
<h5 class="mb-0">區域類型管理</h5>
</div>
<div class="card-body">
<v-data-table
:headers="headers"
:items="items"
>
<template #item.isactive =" {item} ">
<v-icon small :color="item.isactive ? 'success' : 'grey'">
{{ item.isactive ? 'mdi-check-circle' : 'mdi-close-circle' }}
</v-icon>
{{ item.isactive ? '已啟用' : '已停用' }}
</template>
<template #item.actions="{item}">
<a :href="'reg.aspx?regiontypeid='+item.uuid" class="btn btn-primary"><i class="mdi mdi-pencil"></i>修改</a>
<button
type="button"
class="btn btn-outline-danger"
@click="regiontypeDelete(item)"
>
<i class="mdi mdi-delete"></i> 刪除
</button>
</template>
</v-data-table>
</div>
</div>
</div>
<message-modal ref="messageModal"></message-modal>
<confirm-modal ref="confirmModal"></confirm-modal>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
headers: [
{ text: '區域類型名稱', value: 'name' },
{ text: '區域代碼', value: 'code' },
{ text: '啟用', value: 'isactive' },
{ text: '操作', value: 'actions', sortable: false }
],
items: []
}
},
methods: {
getRegionTypeList() {
axios.post('/api/regiontype/getreiontypelist')
.then((res) => {
this.items = res.data;
})
},
regiontypeDelete(item) {
this.$refs.confirmModal.open({
'title': '刪除提示',
'message': `確定要刪除 ${item.name} ?`,
onConfirm: () => {
axios.post('/api/regiontype/delete',null, {
params: { uuid: item.uuid }
})
.then(() => {
this.items = this.items.filter(i => i.uuid != item.uuid);
this.$refs.messageModal.open({
title: '操作成功',
message: '刪除成功!',
status: 'success'
});
})
}
});
}
},
mounted() {
this.getRegionTypeList();
}
})
</script>
</asp:Content>

View File

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

View File

@@ -0,0 +1,46 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="reg.aspx.cs" Inherits="admin_regiontype_reg" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
<div></div>
<div>
<a href="index.aspx" class="btn btn-primary">回列表</a>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="container">
<div class="card shadow-sm my-3">
<div class="card-header">
<asp:Literal ID="L_title" runat="server" Text="新增區域類型" />
</div>
<div class="card-body">
<asp:Literal ID="L_msg" runat="server" />
<asp:HiddenField ID="HF_Id" runat="server" />
<div class="form-group mb-3">
<label for="TB_Name">名稱</label>
<asp:TextBox ID="TB_Name" runat="server" CssClass="form-control" />
</div>
<div class="form-group mb-3">
<label for="TB_Name">代碼</label>
<asp:TextBox ID="TB_Code" runat="server" CssClass="form-control" />
</div>
<div class="form-check form-switch mb-3">
<input type="checkbox" class="form-check-input" id="CB_IsActive" name="CB_IsActive" checked runat="server"/>
<label class="form-check-label" for="CB_IsActive">是否啟用</label>
</div>
<asp:Button ID="BTN_Save" runat="server" Text="儲存" CssClass="btn btn-primary" OnClick="BTN_Save_Click" />
</div>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
</asp:Content>

View File

@@ -0,0 +1,87 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_regiontype_reg : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Guid.TryParse(Request.QueryString["regiontypeid"], out Guid id))
{
LoadData(id);
L_title.Text = "編輯區域類型";
}
}
}
private void LoadData(Guid id)
{
var rt = _db.RegionType.FirstOrDefault(r => r.Uuid == id);
if (rt == null)
{
L_msg.Text = "<div class='alert alert-danger'>找不到資料</div>";
BTN_Save.Enabled = false;
return;
}
HF_Id.Value = rt.Uuid.ToString();
TB_Name.Text = rt.Name;
TB_Code.Text = rt.Code;
CB_IsActive.Checked = rt.IsActive;
}
protected void BTN_Save_Click(object sender, EventArgs e)
{
try
{
RegionType rt;
if (Guid.TryParse(HF_Id.Value, out Guid id))
{
// 更新
rt = _db.RegionType.FirstOrDefault(r => r.Uuid == id);
if (rt == null)
{
L_msg.Text = "<div class='alert alert-danger'>資料不存在</div>";
return;
}
}
else
{
// 新增
rt = new RegionType();
rt.Uuid = Guid.NewGuid();
_db.RegionType.Add(rt);
}
rt.Name = TB_Name.Text.Trim();
if(rt.Name.Length == 0)
{
L_msg.Text = "<div class='alert alert-danger'>名稱不能为空</div>";
return;
}
rt.Code = TB_Code.Text.Trim();
rt.IsActive = CB_IsActive.Checked;
_db.SaveChanges();
L_msg.Text = "<div class='alert alert-success'>儲存成功</div>";
// 如果是新增,更新隱藏欄位並切換標題為編輯
if (HF_Id.Value == "")
{
HF_Id.Value = rt.Uuid.ToString();
L_title.Text = "編輯區域類型";
}
}
catch (Exception ex)
{
L_msg.Text = $"<div class='alert alert-danger'>錯誤:{ex.Message}</div>";
}
}
}