update from old git
This commit is contained in:
48
web/admin/region/bed/bedstatus/create.aspx
Normal file
48
web/admin/region/bed/bedstatus/create.aspx
Normal file
@@ -0,0 +1,48 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="create.aspx.cs" Inherits="admin_region_bed_bedstatus_create" %>
|
||||
|
||||
<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_Code">代碼</label>
|
||||
<asp:TextBox ID="TB_Code" runat="server" CssClass="form-control" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="TB_Category">状态所属分类(挂单,房间,床位)</label>
|
||||
<asp:DropDownList ID="TB_Category" runat="server" CssClass="form-control"></asp:DropDownList>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label for="Description">說明</label>
|
||||
<asp:TextBox ID="Description" runat="server" CssClass="form-control" TextMode="MultiLine" Rows="3" />
|
||||
</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>
|
||||
|
||||
103
web/admin/region/bed/bedstatus/create.aspx.cs
Normal file
103
web/admin/region/bed/bedstatus/create.aspx.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
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_region_bed_bedstatus_create : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) // 加這行
|
||||
{
|
||||
if (Guid.TryParse(Request.QueryString["statusid"], out Guid id))
|
||||
{
|
||||
LoadData(id);
|
||||
L_title.Text = "編輯區域類型";
|
||||
}
|
||||
var categoryList = RegionRoomBedStatus.GetCategoryList();
|
||||
// 假设你的下拉控件ID叫 ddlCategory
|
||||
TB_Category.DataSource = categoryList;
|
||||
TB_Category.DataTextField = "Text"; // 显示文字
|
||||
TB_Category.DataValueField = "Value"; // 选项值
|
||||
TB_Category.DataBind();
|
||||
TB_Category.Items.Insert(0, new ListItem("--请选择分类--", ""));
|
||||
}
|
||||
}
|
||||
private void LoadData(Guid id)
|
||||
{
|
||||
var rt = _db.RegionRoomBedStatus.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;
|
||||
TB_Category.SelectedValue = rt.Category?.ToString();
|
||||
Description.Text = rt.Description;
|
||||
|
||||
}
|
||||
protected void BTN_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegionRoomBedStatus rt;
|
||||
if (Guid.TryParse(HF_Id.Value, out Guid id))
|
||||
{
|
||||
// 更新
|
||||
rt = _db.RegionRoomBedStatus.FirstOrDefault(r => r.Uuid == id);
|
||||
if (rt == null)
|
||||
{
|
||||
L_msg.Text = "<div class='alert alert-danger'>資料不存在</div>";
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 新增
|
||||
rt = new RegionRoomBedStatus();
|
||||
rt.Uuid = Guid.NewGuid();
|
||||
_db.RegionRoomBedStatus.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.Description = Description.Text.Trim();
|
||||
if(int.TryParse(TB_Category.SelectedValue, out int category))
|
||||
{
|
||||
rt.Category = category;
|
||||
}
|
||||
else
|
||||
{
|
||||
rt.Category = null;
|
||||
}
|
||||
_db.SaveChanges();
|
||||
|
||||
L_msg.Text = "<div class='alert alert-success'>儲存成功</div>";
|
||||
|
||||
// 如果是新增,更新隱藏欄位並切換標題為編輯
|
||||
if (HF_Id.Value == "")
|
||||
{
|
||||
HF_Id.Value = rt.Uuid.ToString();
|
||||
L_title.Text = "編輯區域類型";
|
||||
}
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Text = $"<div class='alert alert-danger'>錯誤:{ex.Message}</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
99
web/admin/region/bed/bedstatus/index.aspx
Normal file
99
web/admin/region/bed/bedstatus/index.aspx
Normal file
@@ -0,0 +1,99 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_region_bed_bedstatus_index" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
||||
<a href="create.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"
|
||||
:loading="loading"
|
||||
>
|
||||
<template #item.actions="{item}">
|
||||
<a :href="'create.aspx?statusid='+item.uuid" class="btn btn-primary"><i class="mdi mdi-pencil"></i>修改</a>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-danger"
|
||||
@click="confirmDeleteStatus(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: 'Id', value: 'id' },
|
||||
{ text: '狀態名稱', value: 'name' },
|
||||
{ text: '狀態代碼', value: 'code' },
|
||||
{ text: '描述', value: 'description' },
|
||||
{ text: '状态分类', value: 'categoryName'},
|
||||
{ text: '', value: 'actions' }
|
||||
],
|
||||
items: [],
|
||||
loading: true, // 初始時顯示動畫
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getStatusList() {
|
||||
axios.get('/api/region/bed/status/list')
|
||||
.then((res) => {
|
||||
this.items = res.data
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
confirmDeleteStatus(item) {
|
||||
this.$refs.confirmModal.open({
|
||||
message: '是否確認刪除給床位狀態',
|
||||
onConfirm: () => {
|
||||
this.deleteStatus(item);
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteStatus(item) {
|
||||
axios.post('/api/region/bed/status/delete', null, {
|
||||
params: { id: item.uuid }
|
||||
})
|
||||
.then(() => {
|
||||
this.items = this.items.filter(i => i.uuid != item.uuid);
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作成功',
|
||||
message: '刪除成功!',
|
||||
status: 'success'
|
||||
});
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.getStatusList();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
14
web/admin/region/bed/bedstatus/index.aspx.cs
Normal file
14
web/admin/region/bed/bedstatus/index.aspx.cs
Normal 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_region_bed_bedstatus_index : MyWeb.config
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user