migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

273
web/admin/news/index.aspx Normal file
View File

@@ -0,0 +1,273 @@
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_news_index" %>
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<div class="mb-2 mb-sm-0">
<a href="news_reg.aspx" class="btn btn-primary">
<i class="mdi mdi-plus"></i>新增
</a>
<a @click="deleteAll" class="btn btn-outline-danger" title="刪除勾選的資料" ><i class="mdi mdi-trash-can"></i> 刪除勾選</a>
</div>
<div class="">
<a href="javascript:PrintTagRWD('content');" class="btn btn-outline-primary btn-print">
<i class="mdi mdi-printer"></i>列印本頁
</a>
<asp:LinkButton ID="excel" runat="server" Visible="false" CssClass="btn btn-outline-primary" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
</div>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
<%--<link href="<%=ResolveUrl("~/js/vuetify_ez.css")%>" rel="stylesheet" />--%>
<script>
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
let VueApp=new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
options: { multiSort: false },
data_table: {
loading: true,
list: [],
selected: [],
singleSelect: false,
count: 0,
page: 1,
pageSize: 10,
header: [
{ text: '標題', value: 'subject', align: 'start' },
{ text: '分類', value: 'kindsTxt'},
{ text: '狀態', value: 'status' },
{ text: '作者', value: 'author' },
{ text: '上架日期', value: 'selltime1' },
{ text: '下架日期', value: 'selltime2' },
{ text: '發佈日期', value: 'uptime' },
{ text: '是否置頂', value: 'topping' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end', class:'hidden-print' },
],
footer:{
showFirstLastPage: true,
itemsPerPageOptions:[5,10,20,30],
},
},
search: {
kind: '',
subject: '',
selltime1:'',
selltime2: '',
uptime1: '',
uptime2: '',
activity_num: '',
activity_numTxt: '',
}
}
},
watch: {
options: {
handler() {
this.getDefault()
},
deep: true,
},
},
methods: {
getDefault(clearpage = false) {
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/news/GetList', 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))
},
editItem(item) {
console.log("edit", item);
},
deleteItem(item) {
if (confirm('是否確定刪除此筆資料?')) {
const index = this.data_table.list.indexOf(item)
if (index != -1) {
axios
.delete(HTTP_HOST + 'api/news/' + item.num)
.then(response => {
console.log("del", item);
this.data_table.list.splice(index, 1);
this.data_table.count = this.data_table.list.length
})
.catch(error => console.log(error))
}
}
},
deleteAll() {
if (confirm('是否確定刪除已勾選的資料?')) {
axios
.delete(HTTP_HOST + 'api/news/Delete/' + this.data_table.selected.map(x => x.num))
.then(response => {
//console.log("delAll");
//for (var i = 0; i < this.data_table.selected.length; i++) {
// const index = this.data_table.list.indexOf(this.data_table.selected[i]);
// this.data_table.list.splice(index, 1);
//}
//this.data_table.selected = [];
//this.data_table.count = this.data_table.list.length
location.reload();
})
.catch(error => console.log(error))
}
},
btn_search() {
this.getDefault(true)
},
btn_all() {
clearObjProps(this.search);
this.btn_search()
},
},
computed: {
pageCount() {
return Math.ceil(this.data_table.count / this.data_table.pageSize)
},
},
})
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid">
<v-data-table
v-model="data_table.selected"
:items="data_table.list"
:search-props="search"
item-key="num"
:options.sync="options"
:headers="data_table.header"
:footer-props="data_table.footer"
:server-items-length="data_table.count"
:loading="data_table.loading"
:single-select="data_table.singleSelect"
show-select
hide-default-footer
:page.sync="data_table.page"
:items-per-page.sync="data_table.pageSize"
class="elevation-1">
<template #item.status="{ item }" >
{{ item.status=='Y'?"顯示":"隱藏" }}
</template>
<template #item.author="{ item }" >
{{ item.authorName }}
</template>
<template #item.selltime1="{ item }" >
{{ item.selltime1|timeString('YYYY/MM/DD') }}
</template>
<template #item.selltime2="{ item }" >
{{ item.selltime2|timeString('YYYY/MM/DD') }}
</template>
<template #item.uptime="{ item }" >
{{ item.uptime|timeString('YYYY/MM/DD') }}
</template>
<template #item.topping="{ item }" >
<span v-if="item.topping=='Y'"><i class='mdi mdi-check'></i></span>
</template>
<template #item.slot_btn="{ item }" :class="hidden-print">
<a :href="'news_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>
</template>
</v-data-table>
<v-container>
<v-row class="align-baseline" wrap>
<v-col cols="12" md="9">
<v-pagination
v-model="data_table.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ data_table.count }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="data_table.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="data_table.page = parseInt($event, 10)"
></v-text-field>
</v-col>
</v-row>
</v-container>
</div>
<div id="print_data">
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" runat="Server">
<div id="search_panel" alt="查詢公告資料">
<div class="mb-3">
<label class="form-label">分類</label>
<asp:DropDownList ID="s_kind" runat="server" CssClass="form-select" v-model="search.kind" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">標題 </label>
<input type="text" v-model="search.subject" class="form-control" placeholder="可輸入關鍵字查詢">
</div>
<div class="mb-3">
<label class="form-label">發佈日期</label>
<div class="input-group">
<input type="date" v-model="search.uptime1" class="form-control" autocomplete="off">
<span class="input-group-text" >~</span>
<input type="date" v-model="search.uptime2" class="form-control" autocomplete="off">
</div>
</div>
<div class="mb-3">
<label class="form-label">上下架日期</label>
<div class="input-group">
<input type="date" v-model="search.selltime1" class="form-control" autocomplete="off">
<span class="input-group-text">~</span>
<input type="date" v-model="search.selltime2" class="form-control" autocomplete="off">
</div>
</div>
<div class="mb-3">
<label class="form-label">相關活動</label>
<asp:DropDownList ID="s_activity_num" runat="server" CssClass="form-select" v-model="search.activity_num" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">相關活動 </label>
<input type="text" v-model="search.activity_numTxt" class="form-control" placeholder="可輸入關鍵字查詢">
</div>
<div class="mb-3 p-2 border-top">
<a @click="btn_search" class="btn btn-outline-primary"><i class="mdi mdi-filter"></i> 搜尋</a>
<a class="btn btn-outline-secondary" @click="btn_all"><i class="mdi mdi-filter-remove"></i> 所有資料</a>
</div>
</div>
</asp:Content>

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Linq;
using static TreeView;
public partial class admin_news_index : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BuildKind();
}
}
#region
public void BuildKind()
{
s_kind.Items.Clear();
s_kind.Items.Add(new ListItem("請選擇", ""));
//buildMultiKind(s_kind, "news_kind", 0, "", 1, Model.news.KindLevelMax);
var qry1 = new TreeView().get_data2(_db.news_kind.Select(o => new TreeItem()
{
kind = o.kind,
num = o.num,
root = o.root,
range = o.range,
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
if (qry1.Count() > 0)
foreach (var qq in qry1)
s_kind.Items.Add(new ListItem(new TreeView().RptDash(qq.Level) + qq.kind, qq.num.ToString()));
//活動
s_activity_num.Items.Clear();
s_activity_num.Items.Add(new ListItem("請選擇", ""));
var qry2 = _db.activities.AsEnumerable();
qry2 = qry2.OrderByDescending(o => o.num).ToList();
if (qry2.Count() > 0)
foreach (var qq in qry2)
s_activity_num.Items.Add(new ListItem(qq.subject, qq.num.ToString()));
}
#endregion
#region Excel
protected void excel_Click(object sender, EventArgs e)
{
//請參考訂單系統的匯出
}
#endregion
}

View File

@@ -0,0 +1,92 @@
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="kind_reg.aspx.cs" Inherits="admin_news_kind_reg" %>
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="footer_script" runat="Server">
<link href="../../App_Script/bootstrap_toggle/css/bootstrap-toggle.min.css" rel="stylesheet" />
<script src="../../App_Script/bootstrap_toggle/js/bootstrap-toggle.min.js"></script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<nav class="mb-1">
<asp:LinkButton ID="ImageButton4" runat="server" CausesValidation="False" OnClick="ImageButton4_Click" CssClass="btn btn-primary"><i class="mdi mdi-plus"></i> 新增主分類</asp:LinkButton>
<asp:LinkButton ID="sortButton" runat="server" Visible="false" CssClass="btn btn-primary" OnClick="sortButton_Click">
<i class="mdi mdi-sort"></i> 排序選項</asp:LinkButton>
</nav>
<nav class="mb-1">
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
<asp:Button ID="add" runat="server" Text="新增" Visible="false" OnClick="add_Click" CssClass="btn btn-primary" />
<asp:PlaceHolder ID="down_table" runat="server">
<asp:LinkButton ID="ImageButton5" runat="server" OnClick="ImageButton5_Click" CssClass="btn btn-outline-secondary" CausesValidation="False"><i class="mdi mdi-arrow-down-right"></i> 建立下一層選項</asp:LinkButton>
<asp:LinkButton ID="ImageButton6" runat="server" OnClientClick="return msgconfirm('是否確定刪除這筆資料?<br>注意!資料刪除後將一併刪除此資料的子選項!',this);" OnClick="ImageButton6_Click" CssClass="btn btn-outline-secondary"><i class="mdi mdi-trash-can"></i> 刪除</asp:LinkButton>
</asp:PlaceHolder>
</nav>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid pb-4">
<div class="row">
<div class="col-sm-4">
<div class="card shadow-sm my-2" id="sec1">
<div class="card-header">選擇分類</div>
<div class="card-body">
<asp:TreeView ID="TreeView2" runat="server" CssClass="aspxTree" ImageSet="Arrows"
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
</asp:TreeView>
</div>
</div>
</div>
<div class="col-sm-8">
<asp:Panel ID="table" runat="server" CssClass="card shadow-sm my-2">
<div class="card-header">
<div>
<asp:Label ID="start" runat="server" CssClass="text-danger" Display="Dynamic"></asp:Label>
</div>
<div>
<asp:Label ID="title_msg" runat="server" CssClass="" ForeColor=""></asp:Label>
</div>
</div>
<div class="card-body form-horizontal label-sm-right " role="form">
<div>
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
</div>
<div class="row mb-1">
<label class="col-sm-2 col-lg-3 col-form-label">* 分類名稱</label>
<div class="col-sm-10 col-lg-9">
<asp:TextBox ID="item_name" runat="server" CssClass="form-control" MaxLength="100" placeholder="請輸入分類名稱"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="item_name" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</div>
</div>
<div class="row mb-1">
<label class="col-sm-2 col-lg-3 col-form-label">備註</label>
<div class="col-sm-10 col-lg-9">
<asp:TextBox ID="demo" runat="server" CssClass="form-control" TextMode="MultiLine" Rows="3" placeholder="請輸入備註"></asp:TextBox>
</div>
</div>
<div class="row mb-1">
<label class="col-sm-2 col-lg-3 col-form-label">* 狀態</label>
<div class="col-sm-10 col-lg-9">
<label class="col-form-control">
<input type="checkbox" id="status" runat="server"
data-toggle="toggle" data-on="啟用" data-off="停用" data-onstyle="success" />
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-md-offset-2 col-sm-9 col-md-10">
<asp:HiddenField ID="HiddenField1" runat="server" />
</div>
</div>
</div>
</asp:Panel>
</div>
</div>
</div>
</asp:Content>

View File

@@ -0,0 +1,340 @@
using System;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Data.Entity.Infrastructure;
public partial class admin_news_kind_reg : MyWeb.config
{
DataTable treeDt = new DataTable();
const int LevelMax = Model.news.KindLevelMax; //分類層數
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
BuildTreeView();
if (!isStrNull(Request["num"]))
{
int _num = Val(Request["num"]);
var prod = _db.news_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
if (prod != null)
{
title_msg.Text = "修改<span class=\"text-primary\">【" + prod.kind + "】</span>的分類名稱";
item_name.Text = prod.kind;
demo.Text = prod.demo;
status.Checked = ValString(prod.status).Equals("Y");
HiddenField1.Value = prod.kind;
}
else
{
Response.Redirect(Request.Url.AbsolutePath );
}
edit.Visible = true;
add.Visible = false;
down_table.Visible = true;
start.Visible = false;
}
else
{
status.Checked = true;
table.Visible = false;
down_table.Visible = false;
if (Convert.ToString(Request["msg"]) == "A") { start.Text = "【資料修改成功】"; }
else if (Convert.ToString(Request["msg"]) == "B") { start.Text = "【資料新增成功】"; }
else if (Convert.ToString(Request["msg"]) == "C") { start.Text = "【資料刪除成功】"; }
else { start.Text = "【請點選下方欲新增、修改或刪除的分類】"; }
}
}
}
#region
protected void TreeTopology()
{
MyWeb.sql sql = new MyWeb.sql();
OleDbConnection sqlConn = sql.conn(db, p_name);
try
{
sqlConn.Open();
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
sqlCmd.CommandText = "SELECT num,kind,root FROM news_kind ORDER BY kind,root, range";
treeDt = sql.dataTable(sqlCmd);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
sqlConn.Close();
sqlConn.Dispose();
}
}
public void BuildTreeView()
{
TreeView2.Nodes.Clear();
TreeTopology();
BuildChild(0, TreeView2.Nodes);
treeDt.Dispose();
}
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
{
DataTable dt = treeDt;
foreach (DataRow row in dt.Rows)
{
if (row["root"].ToString() == RootUid.ToString())
{
TreeNode NewNode = new TreeNode();
if (Convert.ToString(Request["num"]) == row["num"].ToString() & HiddenField1.Value != "AddMainItem")
{
NewNode.Text = "<b><span style=\"color:blue\">" + row["kind"].ToString() + "</span></b>";
if (Level +1 > LevelMax)
{
ImageButton5.Visible = false;
}
}
else
{
NewNode.Text = row["kind"].ToString();
}
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString() ;
NewNode.Expand();
Nodes.Add(NewNode);
if (Level + 1 <= LevelMax)
{
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
}
}
}
}
#endregion
#region
protected void ImageButton5_Click(object sender, EventArgs e)
{
title_msg.Text = "於<span class=\"text-primary\">【" + HiddenField1.Value + "】</span>分類下,新增次分類";
item_name.Text = "";
demo.Text = "";
add.Visible = true;
edit.Visible = false;
down_table.Visible = false;
start.Visible = false;
}
protected void ImageButton4_Click(object sender, EventArgs e)
{
title_msg.Text = "<span class=\"text-primary\">於根目錄下,新增主分類</span>";
table.Visible = true;
item_name.Text = "";
demo.Text = "";
add.Visible = true;
edit.Visible = false;
down_table.Visible = false;
start.Visible = false;
status.Checked = true;
HiddenField1.Value = "AddMainItem";
BuildTreeView();
}
#endregion
#region
protected void edit_Click(object sender, EventArgs e)
{
L_msg.Text = "";
int _num = Val(Request["num"]);
try
{
Model.news_kind news_kind = _db.news_kind.Where(q => q.num == _num).FirstOrDefault();//修改
if (news_kind != null)
{
news_kind.kind = item_name.Text;
news_kind.demo = demo.Text;
news_kind.status = status.Checked ? "Y" : "N";
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.News, (int)Model.admin_log.Status.Update, "分類:" + item_name.Text);
L_msg.Type = alert_type.success;
L_msg.Text = "操作成功";
}
else
{
L_msg.Type = alert_type.danger;
L_msg.Text = "無此資料";
}
}
catch (DbUpdateConcurrencyException)
{
L_msg.Type = alert_type.danger;
L_msg.Text = "Error";
throw;
}
BuildTreeView();
}
#endregion
#region
protected void add_Click(object sender, EventArgs e)
{
L_msg.Text = "";
int range = 1;
int root = 0;
if (HiddenField1.Value != "AddMainItem")
{
root = Convert.ToInt32(Request["num"]);
}
try
{
var prod = _db.news_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
if (prod != null)
if (prod.range.HasValue)
range = prod.range.Value + 1;
Model.news_kind news_kind = new Model.news_kind();//新增
news_kind.kind = item_name.Text;
news_kind.root = root;
news_kind.range = range;
news_kind.demo = demo.Text;
news_kind.status = status.Checked ? "Y" : "N";
_db.news_kind.Add(news_kind);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.News, (int)Model.admin_log.Status.Insert, "分類:"+item_name.Text);
L_msg.Type = alert_type.success;
L_msg.Text = "操作成功";
}
catch (DbUpdateConcurrencyException)
{
throw;
}
BuildTreeView();
}
#endregion
#region
protected void ImageButton6_Click(object sender, EventArgs e)
{
int num = Val(Request["num"]);
del_product(num);
var prod = _db.news_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
if (prod != null)
{
_db.news_kind.Remove(prod);
_db.SaveChanges(); //執行
}
Del_Ohter_Items(Val(Request["num"]));
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.News, (int)Model.admin_log.Status.Delete, "分類:" + item_name.Text);
Response.Redirect(Request.Url.AbsolutePath + "?msg=C");
}
public void Del_Ohter_Items(int d_num)
{
var prod = _db.news_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
if (prod.Count > 0)
{
foreach (var row in prod)
{
del_product(row.num);
Del_Ohter_Items(row.num);
}
//查詢結果全部刪除
_db.news_kind.RemoveRange(prod);
_db.SaveChanges();
}
}
public void del_product(int num) //刪除訊息
{
//EF Model 資料庫拉關聯 , 故刪除分類前,一定要先刪除訊息,否則關聯會出錯
var prod = _db.news.AsEnumerable().Where(q => q.kind == num).ToList();
if (prod.Count > 0)
{
////刪除檔案
//foreach (var item in prod)
//{
// var prod2 = _db.news_files.AsEnumerable().Where(q => q.news_id == item.num).ToList();
// if (prod2.Count > 0)
// {
// foreach (var item2 in prod2)
// {
// if (!isStrNull(item2.pic1))
// {
// MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
// fileSystem.Delete(Model.news.Dir + "/" + item2.pic1);
// }
// }
// //查詢結果全部刪除
// _db.news_files.RemoveRange(prod2);
// _db.SaveChanges();
// }
//}
////查詢結果全部刪除
//_db.news.RemoveRange(prod);
//_db.SaveChanges();
//改為清空訊息分類
foreach (var item in prod)
item.kind = null;
_db.SaveChanges();
}
}
#endregion
protected void sortButton_Click(object sender, EventArgs e)
{
Response.Redirect("range.aspx");
}
}

217
web/admin/news/list.aspx Normal file
View File

@@ -0,0 +1,217 @@
<%@ Page Title="後端管理系統" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="list.aspx.cs" Inherits="admin_news_list" %>
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
<%--<link href="<%=ResolveUrl("~/js/vuetify_ez.css")%>" rel="stylesheet" />--%>
<script>
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
let VueApp = new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
options: { multiSort: false },
data_table: {
loading: true,
list: [],//dataRows
selected: [],
singleSelect: false,
count: 0,//totalCount
page: 1,
pageSize: 10,//itemsPerPage
header: [
{ text: '分類', value: 'kindsTxt' },
{ text: '標題', value: 'subject', align: 'start' },
{ text: '發佈日期', value: 'uptime' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' }
],//headerItems
footer: {
showFirstLastPage: true,
itemsPerPageOptions: [5, 10, 20, 30],
},//footerItems
},
search: {
kind: '',
subject: '',
selltime1: '',
selltime2: '',
uptime1: '',
uptime2: '',
activity_num: '',
activity_numTxt: '',
status: 'Y',
},
}
},
watch: {
options: {
handler() {
this.getDefault()
},
deep: true,
},
},
methods: {
getDefault() {
const { sortBy, sortDesc, page, itemsPerPage } = this.options
const params = {
sortBy: sortBy[0], sortDesc: sortDesc[0],
page: page, pageSize: itemsPerPage,
top : true
};
this.data_table.loading = true
axios
.post(HTTP_HOST + 'api/news/GetList', 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))
},
btn_search() {
this.page = 1;
this.getDefault()
},
btn_all() {
clearObjProps(this.search);
this.btn_search()
},
},
computed: {
pageCount() {
return Math.ceil(this.data_table.count / this.data_table.pageSize)
},
},
})
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid">
<v-data-table
v-model="data_table.selected"
:items="data_table.list"
:search-props="search"
item-key="num"
:options.sync="options"
:headers="data_table.header"
:footer-props="data_table.footer"
:server-items-length="data_table.count"
:loading="data_table.loading"
:single-select="data_table.singleSelect"
<%-- show-select--%>
hide-default-footer
:page.sync="data_table.page"
:items-per-page.sync="data_table.pageSize"
class="elevation-1">
<template #item.uptime="{ item }" >
{{ item.uptime|timeString('YYYY/MM/DD') }}
<span v-if="item.topping=='Y'" class="badge bg-secondary">置頂</span>
</template>
<template #item.slot_btn="{ item }">
<a :href="'reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm">
<i class='mdi mdi-magnify'></i>查看</a>
</template>
</v-data-table>
<v-container>
<v-row class="align-baseline" wrap>
<v-col cols="12" md="9">
<v-pagination
v-model="data_table.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ data_table.totalCount }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="data_table.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="data_table.page = parseInt($event, 10)"
></v-text-field>
</v-col>
<%--
<v-col cols="6" md="2">
<v-select
dense
hide-details
:value="itemsPerPage"
label="每頁筆數"
@change="itemsPerPage = parseInt($event, 10)"
:items="footerItems.itemsPerPageOptions">
</v-select>
</v-col>--%>
</v-row>
</v-container>
</div>
<div id="print_data">
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" runat="Server">
<div id="search_panel" alt="查詢公告資料">
<div class="mb-3">
<label class="form-label">分類</label>
<asp:DropDownList ID="s_kind" runat="server" CssClass="form-select" v-model="search.kind" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">標題 </label>
<input type="text" v-model="search.subject" class="form-control" placeholder="可輸入關鍵字查詢">
</div>
<div class="mb-3">
<label class="form-label">發佈日期</label>
<div class="input-group">
<input type="date" v-model="search.uptime1" class="form-control" autocomplete="off">
<span class="input-group-text" >~</span>
<input type="date" v-model="search.uptime2" class="form-control" autocomplete="off">
</div>
</div>
<div class="mb-3">
<label class="form-label">上下架日期</label>
<div class="input-group">
<input type="date" v-model="search.selltime1" class="form-control" autocomplete="off">
<span class="input-group-text">~</span>
<input type="date" v-model="search.selltime2" class="form-control" autocomplete="off">
</div>
</div>
<div class="mb-3">
<label class="form-label">相關活動</label>
<asp:DropDownList ID="s_activity_num" runat="server" CssClass="form-select" v-model="search.activity_num" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">相關活動 </label>
<input type="text" v-model="search.activity_numTxt" class="form-control" placeholder="可輸入關鍵字查詢">
</div>
<div class="mb-3 p-2 border-top">
<a @click="btn_search" class="btn btn-outline-primary"><i class="mdi mdi-filter"></i> 搜尋</a>
<a class="btn btn-outline-secondary" @click="btn_all"><i class="mdi mdi-filter-remove"></i> 所有資料</a>
</div>
</div>
</asp:Content>

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Linq;
using static TreeView;
public partial class admin_news_list : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BuildKind();
}
}
#region
public void BuildKind()
{
s_kind.Items.Clear();
s_kind.Items.Add(new ListItem("請選擇", ""));
// buildMultiKind(s_kind, "news_kind", 0, "", 1, Model.news.KindLevelMax);
var qry1 = new TreeView().get_data2(_db.news_kind.Select(o => new TreeItem()
{
kind = o.kind,
num = o.num,
root = o.root,
range = o.range,
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
if (qry1.Count() > 0)
foreach (var qq in qry1)
s_kind.Items.Add(new ListItem(new TreeView().RptDash(qq.Level) + qq.kind, qq.num.ToString()));
//活動
s_activity_num.Items.Clear();
s_activity_num.Items.Add(new ListItem("請選擇", ""));
var qry2 = _db.activities.AsEnumerable();
qry2 = qry2.OrderByDescending(o => o.num).ToList();
if (qry2.Count() > 0)
foreach (var qq in qry2)
s_activity_num.Items.Add(new ListItem(qq.subject, qq.num.ToString()));
}
#endregion
}

View File

@@ -0,0 +1,482 @@
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="news_reg.aspx.cs" Inherits="admin_news_news_reg" ValidateRequest="false" %>
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="footer_script" runat="Server">
<link href="../../App_Script/bootstrap_toggle/css/bootstrap-toggle.min.css" rel="stylesheet" />
<script src="../../App_Script/bootstrap_toggle/js/bootstrap-toggle.min.js"></script>
<!--編緝器-->
<script type="text/javascript" src="<%=ResolveUrl("~/admin/ckeditor/ckeditor.js") %>"></script>
<script type="text/javascript">
CKEDITOR.config.toolbar = 'Default';
</script>
<!--編緝器-->
<script>
//圖片
$(document).ready(function () {
$('#<%=AddBtn.ClientID%>').addClass('d-none');
var obj = $('a.picPath');
if (obj.length > 0) {
for (i = 0; i < obj.length; i++) {
$('#pics').append('<input type="file" data-id="' + $(obj[i]).attr('data-id') + '" name="picUpload' + $(obj[i]).attr('data-id') + '" id="picUpload' + $(obj[i]).attr('data-id') + '" />');
}
bindPics();
}
});
function bindPics(add =true) {
$('.giftItems input[type=file]').unbind();
$('.giftItems input[type=file]').change(function () {
InitPIcs(this, add);
});
$('.picPath').click(function () {
var id = $(this).attr('data-id');
$('#picUpload' + id).click();
});
if ($('.giftItems input[type=file]').length > 0) {
var obj = $('.giftItems input[type=file]');
for (i = 0; i < obj.length; i++) {
InitPIcs(obj[i], add);
}
}
}
function InitPIcs(obj, add) {
var id = $(obj).attr('data-id');
$('#picPath' + id).html("<i class=\"fas fa-image\"></i> 選擇檔案");
readURL(obj, add);
}
function readURL(input, add) {
var id = $(input).attr('data-id');
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#picShow' + id).attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]); // convert to base64 string
//$('#picShow' + id).show();
$('#fileName' + id).text(input.files[0].name);
var _type = input.files[0].name.split('.');
//$('#fileType' + id).text(input.files[0].type);
$('#fileType' + id).text(_type[_type.length-1]);
var _len = $('input[type="file"]').length;
var _index = $('#txt' + id).text();
console.log(_index);
console.log($('input[type="file"]').length);
console.log('--------');
if (_len - _index == 1 && add)
__doPostBack('<%= AddBtn.UniqueID %>', '');
} else if ($('#picShow' + id).attr('data-path') != "") {
//$('#picShow' + id).show();
//$('#picShow' + id).attr('src', $('#picShow' + id).attr('data-path'));
} else {
$('#picShow' + id).hide();
}
}
</script>
<script>
let VueApp = new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
news_id: '<%= Request["num"] %>',
options: {},
search_dialog: {
controls: {
search1: {
id: 'search1',
title: '公告分類',
text_prop: 'kind',
value_prop: 'num',
keys: [
{ id: 'kind', title: '分類名稱', value: '' },
],
api_url: HTTP_HOST + 'api/news/GetKindList',
columns: [
{ id: 'kind', title: '分類名稱', value: '' },
],
selected: {},
select(t) {
console.log("select search1", t);
}
},
search2: {
id: 'search2',
title: '相關活動',
text_prop: 'subject',
value_prop: 'num',
keys: [
{ id: 'subject', title: '活動名稱', value: '' },
{ id: 'kindTxt', title: '活動分類' },
],
api_url: HTTP_HOST + 'api/activity/GetList',
columns: [
{ id: 'subject', title: '活動名稱' },
{ id: 'kindTxt', title: '活動分類' },
],
selected: {},
select(t) {
console.log("select search2", t);
//帶出明細
if (t != null) {
}
}
},
},
show: false,
current: {},
list: [],
count: 0,
page: 1,
loading: false,
footer: {
showFirstLastPage: true,
disableItemsPerPage: true,
itemsPerPageAllText: '',
itemsPerPageText: '',
},
},
snackbar: {
show: false,
text: "",
}
}
},
mounted() {
this.search_dialog.current = this.search_dialog.controls.search1
//console.log("mounted");
},
watch: {
options: {
handler() {
//console.log("watch1", this.search_dialog, this.search_dialog.page);
this.search_get()
console.log("watch2", this.search_dialog, this.search_dialog.page);
},
deep: true,
},
},
methods: {
search_show(curr) {
//console.log("btn_click:", curr, curr.api_url);
this.search_dialog.current = curr;
this.search_clear()
//this.search_get()//清除完自動會重抓, 故取消
this.search_dialog.show = true;
},
search_clear() {
if (!this.search_dialog.current.keys) return;
this.search_dialog.current.keys.forEach((t, i) => { t.value = '' })
this.search_get()
},
search_get() {
if (!this.search_dialog.current.keys) return;
let api_url = this.search_dialog.current.api_url;
let keys = this.search_dialog.current.keys;
//const { page, itemsPerPage } = this.options
//const { sortBy, sortDesc, page, itemsPerPage } = this.options
this.search_dialog.page = this.options.page ?? 1
let params = { page: this.search_dialog.page, pageSize: 10 };//url params
var search = {};//post body
keys.forEach((t, i) => {
search[t.id] = t.value;
});
//necessary parameter===
if (this.search_dialog.current.id == 'search1') {
search['inTime'] = (this.news_id != '' ? false : true);
}
console.log("search_get", api_url, search, params, this.options);
this.search_dialog.loading = true
axios.post(api_url, search, { params: params })
.then(response => {
this.search_dialog.list = response.data.list
this.search_dialog.count = response.data.count
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,
})
})
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.search_dialog.show = false;
console.log(row, row["u_name"], row["f_number"], curr.id, target);
},
},
computed: {
},
})
</script>
</asp:Content>
<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>
<div class="">
<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="goback" runat="server" Text="回列表" Visible="false" CausesValidation ="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
</div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid">
<div class="card shadow-sm my-2" id="sec2">
<div class="card-header py-0">
<nav class="navbar py-0">
<div class="nav nav-tabs">
<button class="nav-link active" id="sec2-tab1" data-bs-toggle="tab" data-bs-target="#sec2-page1"
type="button" role="tab" aria-controls="home" aria-selected="true">
基本資料</button>
<button class="nav-link" id="sec2-tab2" data-bs-toggle="tab" data-bs-target="#sec2-page2"
type="button" role="tab" aria-controls="profile" aria-selected="false">
檔案管理</button>
</div>
</nav>
</div>
<div class="card-body">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="sec2-page1" role="tabpanel" aria-labelledby="sec2-tab1">
<div>
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
</div>
<div class="row mb-1 label-sm-right ">
<label class="col-sm-2 col-lg-1 col-form-label">標題 *</label>
<div class="col-sm-10 col-lg-7">
<asp:TextBox ID="subject" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入標題"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="subject" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</div>
<label class="col-sm-2 col-lg-1 col-form-label">作者</label>
<div class="col-sm-10 col-lg-3 pt-2">
<asp:Literal ID="author" runat="server"></asp:Literal>
</div>
</div>
<div class="row mb-1 label-sm-right ">
<label class="col-sm-2 col-lg-1 col-form-label">分類 *</label>
<div class="col-sm-4 col-lg-3">
<%-- <asp:DropDownList ID="kind" runat="server" CssClass="form-select">
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>--%>
<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
id="kind_txt" runat="server" placeholder="分類" value="">
<asp:HiddenField ID="kind" runat="server" Value="" />
<button class="btn btn-outline-secondary" type="button">
<i class="mdi mdi-view-list-outline"></i>
</button>
</div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="kind_txt" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</div>
<label class="col-sm-2 col-lg-1 col-form-label">狀態 *</label>
<div class="col-sm-4 col-lg-3">
<asp:DropDownList ID="status" CssClass="form-select" runat="server">
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
<asp:ListItem Value="Y" Text="顯示"></asp:ListItem>
<asp:ListItem Value="N" Text="隱藏"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="status" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</div>
<label class="col-sm-2 col-lg-1 col-form-label mt-1 mt-lg-0">置頂</label>
<div class="col-sm-4 col-lg-3 mt-1 mt-lg-0">
<label class="col-form-control">
<input type="checkbox" id="topping" runat="server"
data-toggle="toggle" data-on="是" data-off="否" data-onstyle="success" />
</label>
</div>
</div>
<div class="row mb-1 label-sm-right ">
<label class="col-sm-2 col-lg-1 col-form-label">發佈日 *</label>
<div class="col-sm-10 col-lg-3">
<asp:TextBox ID="uptime" runat="server" CssClass="form-control " TextMode="Date" autocomplete="off" data-date-format="yyyy-mm-dd"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="uptime" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
</div>
<label class="col-sm-2 col-lg-1 col-form-label mt-1 mt-lg-0">上架期間</label>
<div class="col-sm-10 col-lg-7 mt-1 mt-lg-0">
<div class="input-group">
<asp:TextBox ID="start_day" CssClass="form-control " autocomplete="off" TextMode="Date" data-date-format="yyyy-mm-dd" runat="server"></asp:TextBox>
<span class="input-group-text">~</span>
<asp:TextBox ID="end_day" CssClass="form-control " autocomplete="off" TextMode="Date" data-date-format="yyyy-mm-dd" runat="server"></asp:TextBox>
</div>
<div>
<span class="form-text text-muted">(若不設定,則不限時永久開放)</span>
</div>
</div>
</div>
<div class="row mb-1 label-sm-right ">
<label class="col-sm-2 col-lg-1 col-form-label">相關活動</label>
<div class="col-sm-4 col-lg-3">
<div class="input-group mb-3" data-search-control="search2" @click="search_show(search_dialog.controls.search2)">
<input class="form-control search-text" type="text" readonly
id="activity_num_txt" runat="server" placeholder="相關活動" value="">
<asp:HiddenField ID="activity_num" runat="server" Value="" />
<button class="btn btn-outline-secondary" type="button">
<i class="mdi mdi-view-list-outline"></i>
</button>
</div>
</div>
</div>
<hr />
<div class="row mb-1">
<label class="col-form-label">備註</label>
<div class="">
<asp:TextBox ID="demo" runat="server" Rows="5" TextMode="MultiLine" CssClass="form-control" placeholder="請輸入備註"></asp:TextBox>
</div>
</div>
<div class="row mb-1">
<label class="col-form-label">* 內容</label>
<div class="">
<asp:TextBox ID="word" runat="server" CssClass="ckeditor" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="v_word" ControlToValidate="word" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true" EnableClientScript="False"></asp:RequiredFieldValidator>
</div>
</div>
</div>
<div class="tab-pane fade giftItems" id="sec2-page2" role="tabpanel" aria-labelledby="sec2-tab2">
<asp:Panel ID="Panel1" runat="server" CssClass="form-group d-none">
<asp:FileUpload ID="FileUpload1" runat="server" />
</asp:Panel>
<div class="form-text text-muted">檔案限制容量4MB僅接受 jpg,jpeg,png,pdf,doc,docx,xls,xlsx,ppt,pptx 格式</div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table class="table table-hover">
<thead>
<tr>
<th><span class="w-1">序</span></th>
<th><span class="w-2">名稱</span></th>
<th><span class="w-2">類型</span></th>
<th><span class="w-1"></span></th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="fileRepeater" runat="server" OnItemDataBound="fileRepeater_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<span id="txt<%#Eval("num") %>"><asp:Literal ID="index" runat="server" Text='<%# Container.ItemIndex+1 %>' ></asp:Literal></span>
</td>
<td>
<asp:HiddenField ID="id" runat="server" />
<img id="picShow<%#Eval("num") %>" style="display: none" data-path="<%#!isStrNull(Eval("pic1"))?"../.."+ Model.news.Dir.Replace("~","") +"/"+ValString(Eval("pic1")):"" %>" />
<asp:HiddenField ID="pic" runat="server" />
<span id="fileName<%#Eval("num") %>"><asp:Literal ID="pic_name" runat="server"></asp:Literal></span>
</td>
<td><span id="fileType<%#Eval("num") %>"><asp:Literal ID="pic_type" runat="server"></asp:Literal></span></td>
<td class="d-print-none text-end">
<a id="picPath<%#Eval("num") %>" data-id="<%#Eval("num") %>" class="btn btn-outline-secondary btn-sm picPath" href="javascript:void(0)">選擇檔案</a>
<asp:LinkButton ID="DelBtn" CssClass="btn btn-outline-secondary btn-sm" runat="server" CausesValidation="false" OnClick="DelBtn_Click">
<i class="mdi mdi-close-circle"></i> 刪除</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td></td>
<td></td>
<td></td>
<td>
<asp:LinkButton ID="AddBtn" CssClass="btn" runat="server" CausesValidation="false" OnClick="AddBtn_Click">
<i class="mdi mdi-plus-circle"></i> 新增</asp:LinkButton>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<div id="pics" class="d-none"></div>
</div>
</div>
</div>
</div>
<v-dialog v-model="search_dialog.show" max-width="500px">
<v-card>
<v-card-title class="justify-space-between grey lighten-2">
查詢:{{search_dialog.current.title}}
<v-btn icon @click="search_dialog.show=false"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title>
<v-card-text >
<v-row>
<v-col v-for="item in search_dialog.current.keys"
:cols="search_dialog.current.keys.length>1?6:12" >
<v-text-field v-model="item.value" :label="item.title"></v-text-field>
</v-col>
<v-col cols="12" class="text-end">
<v-btn color="primary" elevation="0" @click="search_get()">查詢</v-btn>
<v-btn elevation="0" @click="search_clear()">清除條件</v-btn>
</v-col>
</v-row>
<v-data-table
:headers="search_headers()"
:items="search_dialog.list"
:footer-props="search_dialog.footer"
:items-per-page="10"
:server-items-length="search_dialog.count"
:page.sync="search_dialog.page"
:options.sync="options"
@click:row="search_select"
></v-data-table>
</v-card-text>
<v-card-actions>
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
v-model="snackbar.show"
timeout="2000"
>
{{ snackbar.text }}
<template v-slot:action="{ attrs }">
<v-btn
text
v-bind="attrs"
@click="snackbar.show = false"
>
關閉
</v-btn>
</template>
</v-snackbar>
</div>
</asp:Content>

View File

@@ -0,0 +1,511 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Globalization;
public partial class admin_news_news_reg : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (isStrNull(Request["num"]))
{
uptime.Text = DateTime.Now.ToString("yyyy-MM-dd");
addNewRow();
}
else
{
int _num = Val(Request["num"]);
var qry = _db.news.AsEnumerable();
//var prod = _db.news.Where(q => q.num == _num).ToList();
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
subject.Text = prod.subject;
if (prod.kind.HasValue)
{
kind_txt.Value = prod.news_kind.kind.ToString();
kind.Value = prod.kind.ToString();
}
status.SelectedValue = prod.status;
topping.Checked = ValString(prod.topping).Equals("Y");
if (prod.selltime1.HasValue)
{
start_day.Text = prod.selltime1.Value.ToString("yyyy-MM-dd");
}
if (prod.selltime2.HasValue)
{
end_day.Text = prod.selltime2.Value.ToString("yyyy-MM-dd");
}
if (prod.uptime.HasValue)
{
uptime.Text = prod.uptime.Value.ToString("yyyy-MM-dd");
}
if (prod.author.HasValue)
author.Text = prod.admin.u_name;
if (prod.activity_num.HasValue)
{
activity_num_txt.Value = prod.activity.subject.ToString();
activity_num.Value = prod.activity_num.ToString();
}
word.Text = prod.word;
demo.Text = prod.demo;
initNewsFiles(_num);
addNewRow();
edit.Visible = true;
goback.Visible = true;
add.Visible = false;
}
else
{
Response.Redirect("index.aspx");
}
}
}
}
protected void goback_Click(object sender, EventArgs e)
{
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
}
#region
protected void add_Click(object sender, EventArgs e)
{
if (Page.IsValid) {
L_msg.Text = "";
MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
string[] pic_name2 = { };
string[] pic_type = { };
string[] pic_name = fileSystem.UploadNewsFile(Model.news.Dir, 800, admin.info.num, ref pic_name2, ref pic_type); //縮圖的寬高不得超過800象素如果不是圖片也會傳
Model.news news = new Model.news();//新增
news.subject = subject.Text;
if (!isStrNull(kind.Value)) { news.kind = Val(kind.Value); }
if (!isStrNull(start_day.Text)) { news.selltime1 = ValDate(start_day.Text); } else { news.selltime1 = null; }
if (!isStrNull(end_day.Text)) { news.selltime2 = ValDate(end_day.Text); } else { news.selltime2 = null; }
news.word = word.Text;
news.demo = demo.Text;
if (!isStrNull(uptime.Text)) { news.uptime = ValDate(uptime.Text); }
if (admin.info.num > 0) { news.author = admin.info.num; } else { news.author =null; }
if (!isStrNull(status.SelectedValue)) { news.status = status.SelectedValue; }
news.topping = topping.Checked ? "Y" : "N";
if (!isStrNull(activity_num.Value)) { news.activity_num = Val(activity_num.Value); }
_db.news.Add(news);
_db.SaveChanges();
int _id = news.num;
if( _id > 0)
{
//檔案上傳
if( SaveFiles(_id, pic_name, pic_name2, pic_type))
{
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.News, (int)Model.admin_log.Status.Insert, subject.Text);
Response.Redirect("index.aspx");
}
}
else
{
L_msg.Type = alert_type.danger;
L_msg.Text = "Error";
}
//using (Model.ezEntities _db = new Model.ezEntities())
//{
//}
}
}
#endregion
#region
protected void edit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
L_msg.Text = "";
MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
string[] pic_name2 = { };
string[] pic_type = { };
string[] pic_name = fileSystem.UploadNewsFile(Model.news.Dir, 800,admin.info.num, ref pic_name2, ref pic_type); //縮圖的寬高不得超過800象素如果不是圖片也會傳
int _num = Val(Request["num"]);
Model.news news = _db.news.Where(q => q.num == _num).FirstOrDefault();//修改
if (news != null)
{
news.subject = subject.Text;
if (!isStrNull(kind.Value)) { news.kind = Val(kind.Value); }
if (!isStrNull(start_day.Text)) { news.selltime1 = ValDate(start_day.Text); } else { news.selltime1 = null; }
if (!isStrNull(end_day.Text)) { news.selltime2 = ValDate(end_day.Text); } else { news.selltime2 = null; }
news.word = word.Text;
news.demo = demo.Text;
if (!isStrNull(uptime.Text)) { news.uptime = ValDate(uptime.Text); }
if (admin.info.num > 0) { news.author = admin.info.num; }
if (!isStrNull(status.SelectedValue)) { news.status = status.SelectedValue; }
if (admin.info.num > 0) { news.author = admin.info.num; } else { news.author = null; }
news.topping = topping.Checked ? "Y" : "N";
if (!isStrNull(activity_num.Value)) { news.activity_num = Val(activity_num.Value); }
_db.SaveChanges();
//檔案
if (SaveFiles(Val(Request["num"]), pic_name, pic_name2, pic_type))
{
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.News, (int)Model.admin_log.Status.Update, subject.Text);
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
}
}
else
{
L_msg.Type = alert_type.danger;
L_msg.Text = "查無資料";
}
}
}
#endregion
#region
#region
//public void SaveFiles(int news_id, string[] pic_name , string[] _pic_name2 , string[] _pic_type)
//{
// DataTable picDt = new DataTable();
// IEnumerable<DataRow> queryFiles = (IEnumerable<DataRow>)from dTc in _db.news_files.AsEnumerable() where dTc.news_id == news_id select dTc;
// // int aa = queryTeacher.Count<DataRow>(); //Count=1
// if (queryFiles.Count<DataRow>() > 0) { picDt = queryFiles.CopyToDataTable<DataRow>(); }
// if (picDt.Rows.Count > 0)
// {
// }
// //處理本次更新的檔案
// MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
// List<string> nums = new List<string>();
// DataTable dt = GetFileRows();
// if (dt.Rows.Count > 0)
// {
// int p = 1;
// foreach (DataRow row in dt.Rows)
// {
// bool _change = false;
// string orgPic = GiftOrgPic(ValString(row["num"]), ref picDt);
// if (!isStrNull(pic_name[p]))
// {
// if (!isStrNull(orgPic)) { fileSystem.Delete(MyWeb.news.Dir + "/" + orgPic); }
// _change = true;
// }
// else
// {
// pic_name[p] = orgPic;
// }
// Model.news_files ff = _db.news_files.Where(q => q.news_id == news_id && q.num == ValString(row["num"]) ).FirstOrDefault();//修改
// if (ff != null)
// {
// ff.pic1 = pic_name[p];
// if (_change)
// {
// ff.reg_time = DateTime.Now;
// ff.pic_name = _pic_name2[p];
// ff.pic_type = _pic_type[p];
// }
// _db.SaveChanges();
// }
// else
// {
// if (!isStrNull(pic_name[p]))
// {
// Model.news_files ffNew = new Model.news_files();
// ffNew.num= ValString(row["num"]);
// ffNew.pic1 = pic_name[p];
// ffNew.news_id = news_id;
// ffNew.pic_name = _pic_name2[p];
// ffNew.pic_type = _pic_type[p];
// _db.news_files.Add(ffNew);
// _db.SaveChanges();
// }
// }
// p++;
// }
// }
// if (picDt.Rows.Count > 0)
// {
// foreach (DataRow row in picDt.Rows)
// {
// //刪掉不要的檔案
// var prod = _db.news_files.AsEnumerable().Where(q => q.news_id == news_id && q.num == ValString(row["num"])).FirstOrDefault(); //刪除該筆資料
// if (prod != null)
// {
// _db.news_files.Remove(prod);
// _db.SaveChanges(); //執行
// }
// if (!isStrNull(row["pic1"])) { fileSystem.Delete(MyWeb.news.Dir + "/" + ValString(row["pic1"])); }
// }
// }
//}
public bool SaveFiles(int news_id, string[] pic_name, string[] _pic_name2, string[] _pic_type)
{
bool success = true;
MyWeb.sql sql = new MyWeb.sql();
OleDbConnection sqlConn = sql.conn(db, p_name);
try
{
sqlConn.Open();
//載入原有的檔案
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
sqlCmd.CommandText = "select [num],pic1 from [news_files] where news_id=? order by [num]";
sqlCmd.Parameters.Add(new OleDbParameter("news_id", news_id));
DataTable picDt = sql.dataTable(sqlCmd);
//處理本次更新的檔案
MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
List<string> nums = new List<string>();
DataTable dt = GetFileRows();
if (dt.Rows.Count > 0)
{
int p = 1;
foreach (DataRow row in dt.Rows)
{
bool _change = false;
string orgPic = GiftOrgPic(ValString(row["num"]), ref picDt);
if (!isStrNull(pic_name[p]))
{
if (!isStrNull(orgPic)) { fileSystem.Delete(Model.news.Dir + "/" + orgPic); }
_change = true;
}
else
{
pic_name[p] = orgPic;
}
sqlCmd = new OleDbCommand("", sqlConn);
sqlCmd.CommandText = "UPDATE [news_files] SET pic1=?" + (_change ? ",reg_time=?,pic_name=?,pic_type=?" : "") + " WHERE news_id=? and num=? ";
if (!isStrNull(pic_name[p]))
{
sqlCmd.CommandText += " IF @@ROWCOUNT = 0 ";
sqlCmd.CommandText += "INSERT INTO [news_files] (num,pic1,news_id,pic_name,pic_type) VALUES (?,?,?,?,?)";
}
sqlCmd.Parameters.Add(new OleDbParameter("pic1", pic_name[p]));
if (_change)
{
sqlCmd.Parameters.Add(new OleDbParameter("reg_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
sqlCmd.Parameters.Add(new OleDbParameter("pic_name", _pic_name2[p]));
sqlCmd.Parameters.Add(new OleDbParameter("pic_type", _pic_type[p]));
}
sqlCmd.Parameters.Add(new OleDbParameter("news_id", news_id));
sqlCmd.Parameters.Add(new OleDbParameter("num", ValString(row["num"])));
if (!isStrNull(pic_name[p]))
{
sqlCmd.Parameters.Add(new OleDbParameter("num", ValString(row["num"])));
sqlCmd.Parameters.Add(new OleDbParameter("pic1", pic_name[p]));
sqlCmd.Parameters.Add(new OleDbParameter("news_id", news_id));
sqlCmd.Parameters.Add(new OleDbParameter("pic_name", _pic_name2[p]));
sqlCmd.Parameters.Add(new OleDbParameter("pic_type", _pic_type[p]));
}
sqlCmd.ExecuteNonQuery();
p++;
}
}
if (picDt.Rows.Count > 0)
{
foreach (DataRow row in picDt.Rows)
{
//刪掉不要的檔案
OleDbCommand sqlCmd2 = new OleDbCommand("", sqlConn);
sqlCmd2.CommandText = "delete from [news_files] where news_id=? and num=?";
sqlCmd2.Parameters.Add(new OleDbParameter("news_id", news_id));
sqlCmd2.Parameters.Add(new OleDbParameter("num", ValString(row["num"])));
sqlCmd2.ExecuteNonQuery();
if (!isStrNull(row["pic1"])) { fileSystem.Delete(Model.news.Dir + "/" + ValString(row["pic1"])); }
}
}
}
catch (Exception ex)
{
//Response.Write(ex.Message);
success = false;
L_msg.Type = alert_type.danger;
L_msg.Text = ex.Message;
}
finally
{
sqlConn.Close(); sqlConn.Dispose();
}
return success;
}
protected string GiftOrgPic(string id, ref DataTable dt)
{
if (dt.Rows.Count > 0)
foreach (DataRow row in dt.Rows)
if (row["num"].ToString() == id)
{
string pic = row["pic1"].ToString();
dt.Rows.Remove(row);
return pic;
}
return "";
}
#endregion
#region
protected void initNewsFiles(int num = 0)
{
var qry = _db.news_files.AsEnumerable();
if (num > 0)
qry = qry.Where(q => q.news_id == num).ToList();
else
qry = qry.ToList();
fileRepeater.DataSource = qry;
fileRepeater.DataBind();
}
protected void fileRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//DataRowView row = (DataRowView)e.Item.DataItem;
((HiddenField)e.Item.FindControl("id")).Value = DataBinder.Eval(e.Item.DataItem, "num").ToString();
((HiddenField)e.Item.FindControl("pic")).Value = DataBinder.Eval(e.Item.DataItem, "pic1").ToString();
((Literal)e.Item.FindControl("pic_name")).Text = DataBinder.Eval(e.Item.DataItem, "pic_name").ToString();
((Literal)e.Item.FindControl("pic_type")).Text = DataBinder.Eval(e.Item.DataItem, "pic_type").ToString();
}
#endregion
protected DataTable GetFileRows()
{
DataTable dt = new DataTable();
dt.Columns.Add("num");
dt.Columns.Add("pic1");
dt.Columns.Add("pic_name");
dt.Columns.Add("pic_type");
if (fileRepeater.Items.Count > 0)
{
foreach (RepeaterItem item in fileRepeater.Items)
{
DataRow row = dt.NewRow();
row["pic1"] = ((HiddenField)item.FindControl("pic")).Value;
row["num"] = ((HiddenField)item.FindControl("id")).Value;
row["pic_name"] = ((Literal)item.FindControl("pic_name")).Text;
row["pic_type"] = ((Literal)item.FindControl("pic_type")).Text;
dt.Rows.Add(row);
}
}
return dt;
}
#region
protected void addNewRow()
{
string id = DateTime.Now.ToString("yyyyMMddHHmmss"); ;
DataTable dt = GetFileRows();
DataRow row = dt.NewRow();
row["num"] = id;
row["pic1"] = "";
row["pic_name"] = "";
row["pic_type"] = "";
dt.Rows.Add(row);
fileRepeater.DataSource = dt;
fileRepeater.DataBind();
ScriptJS("$('#pics').append('<input type=\"file\" data-id=\"" + id + "\" name=\"picUpload" + id + "\" id=\"picUpload" + id + "\">');bindPics();");
}
protected void AddBtn_Click(object sender, EventArgs e)
{
addNewRow();
}
#endregion
#region
protected void DelBtn_Click(object sender, EventArgs e)
{
RepeaterItem rItem = (RepeaterItem)((LinkButton)sender).NamingContainer;
string id = ((HiddenField)rItem.FindControl("id")).Value;
DataTable dt = GetFileRows();
foreach (DataRow row in dt.Rows)
{
if (ValString(row["num"]) == id)
{
dt.Rows.Remove(row);
break;
}
}
fileRepeater.DataSource = dt;
fileRepeater.DataBind();
ScriptJS("$('#picUpload" + id + "').remove();bindPics(false);");
}
#endregion
#endregion
}

42
web/admin/news/range.aspx Normal file
View File

@@ -0,0 +1,42 @@
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="range.aspx.cs" Inherits="admin_news_range" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<nav class="mb-1">
<a href="kind_reg.aspx" class="btn btn-outline-primary">
<i class="mdi mdi-arrow-left"></i> 回選項編輯</a>
<a href="range.aspx" class="btn btn-primary">
<i class="mdi mdi-arrow-up-right"></i> 顯示主選項</a>
</nav>
<nav class="mb-1">
</nav>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="content" class="container-fluid pb-4">
<div class="row">
<div class="col-sm-4">
<div class="card shadow-sm my-2" id="sec1">
<div class="card-header">選擇分類</div>
<div class="card-body">
<asp:TreeView ID="TreeView2" runat="server" cssClass="aspxTree" ImageSet="Arrows"
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
</asp:TreeView>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="card shadow-sm my-2" id="sec2">
<div class="card-header">請直接拖曳調整以下的順序</div>
<div class="card-body">
<iframe src="range2.aspx?num=<%= Convert.ToString(Request["num"]) %>" class="sort-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
</asp:Content>

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public partial class admin_news_range : MyWeb.config
{
DataTable treeDt = new DataTable();
const int LevelMax = Model.news.KindLevelMax; //分類層數
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
TreeTopology();
BuildChild(0, TreeView2.Nodes);
}
}
protected void TreeTopology()
{
MyWeb.sql sql = new MyWeb.sql();
OleDbConnection sqlConn = sql.conn(db, p_name);
try
{
sqlConn.Open();
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
sqlCmd.CommandText = "SELECT num,kind,root FROM news_kind ORDER BY root, range";
treeDt = sql.dataTable(sqlCmd);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
sqlConn.Close();
sqlConn.Dispose();
}
}
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
{
DataTable dt = treeDt;
foreach (DataRow row in dt.Rows)
{
if (row["root"].ToString() == RootUid.ToString())
{
TreeNode NewNode = new TreeNode();
if (Convert.ToString(Request["num"]) == row["num"].ToString())
{
NewNode.Text = "<b><font color=blue>" + row["kind"].ToString() + "</font></b>";
}
else
{
NewNode.Text = row["kind"].ToString();
}
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString();
//NewNode.Target = "f_range";
NewNode.Expand();
Nodes.Add(NewNode);
if (Level + 1<= LevelMax)
{
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
}
}
}
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
public partial class admin_news_range : MyWeb.config
{
DataTable treeDt = new DataTable();
const int LevelMax = MyWeb.news.KindLevelMax; //分類層數
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
TreeTopology();
BuildChild(0, TreeView2.Nodes);
}
}
protected void TreeTopology()
{
MyWeb.sql sql = new MyWeb.sql();
OleDbConnection sqlConn = sql.conn(db, p_name);
try
{
sqlConn.Open();
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
sqlCmd.CommandText = "SELECT num,kind,root FROM news_kind ORDER BY root, range";
treeDt = sql.dataTable(sqlCmd);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
sqlConn.Close();
sqlConn.Dispose();
}
}
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
{
DataTable dt = treeDt;
foreach (DataRow row in dt.Rows)
{
if (row["root"].ToString() == RootUid.ToString())
{
TreeNode NewNode = new TreeNode();
if (Convert.ToString(Request["num"]) == row["num"].ToString())
{
NewNode.Text = "<b><font color=blue>" + row["kind"].ToString() + "</font></b>";
}
else
{
NewNode.Text = row["kind"].ToString();
}
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString();
//NewNode.Target = "f_range";
NewNode.Expand();
Nodes.Add(NewNode);
if (Level + 1<= LevelMax)
{
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
}
}
}
}
}

View File

@@ -0,0 +1,42 @@
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="range.aspx.cs" Inherits="admin_news_range" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<nav class="mb-1">
<a href="kind_reg.aspx" class="btn btn-outline-primary">
<i class="mdi mdi-arrow-left"></i> 回選項編輯</a>
<a href="range.aspx" class="btn btn-primary">
<i class="mdi mdi-arrow-up-right"></i> 顯示主選項</a>
</nav>
<nav class="mb-1">
</nav>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="content" class="container-md pb-4">
<div class="row">
<div class="col-sm-4">
<div class="card shadow-sm my-2" id="sec1">
<div class="card-header">選擇分類</div>
<div class="card-body">
<asp:TreeView ID="TreeView2" runat="server" cssClass="aspxTree" ImageSet="Arrows"
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
</asp:TreeView>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="card shadow-sm my-2" id="sec2">
<div class="card-header">請直接拖曳調整以下的順序</div>
<div class="card-body">
<iframe src="range2.aspx?num=<%= Convert.ToString(Request["num"]) %>" class="sort-iframe"></iframe>
</div>
</div>
</div>
</div>
</div>
</asp:Content>

View File

@@ -0,0 +1,55 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="range2.aspx.cs" Inherits="admin_news_range2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="~/js/bootstrap5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style>
.list-group-item.bg-light:hover{
cursor:pointer;
background-color: rgba(var(--bs-light-rgb),0)!important
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<asp:sqlDataSource ID="sqlDataSource1" runat="server"
updateCommand="UPDATE [news_kind] SET [kind] = @kind, [root] = @root, [range] = @range WHERE [num] = @num"
ProviderName="<%$ ConnectionStrings:shopConn.providerName%>">
<UpdateParameters>
<asp:Parameter Name="kind" Type="String" />
<asp:Parameter Name="root" Type="Int32" />
<asp:Parameter Name="range" Type="Int32" />
<asp:Parameter Name="num" Type="Int32" />
</UpdateParameters>
</asp:sqlDataSource>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<cc1:reorderlist id="ReorderList1" runat="server" cssClass="list-group"
allowreorder="True" datakeyfield="num" datasourceid="sqlDataSource1" postbackonreorder="False" sortorderfield="range">
<ItemTemplate>
<%#Eval("kind")%>
</ItemTemplate>
</cc1:reorderlist>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
<script>
document.querySelectorAll("ul").forEach((t, i) => {
t.className = "list-group";
});
document.querySelectorAll("li").forEach((t, i) => {
t.className = "list-group-item bg-light";
});
</script>
</body>
</html>

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_news_range2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
sqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["shopConn"].ConnectionString;
sqlDataSource1.ConnectionString = sqlDataSource1.ConnectionString.Replace("Provider=SQLNCLI11", "");
string root = "0";
if (Convert.ToString(Request["num"]) != "" & Request["num"]!=null)
{
root = Request["num"];
}
sqlDataSource1.SelectCommand = "SELECT [num], [kind], [root], [range] FROM [news_kind] WHERE [root]=" + root + " ORDER BY [range]";
}
}

59
web/admin/news/reg.aspx Normal file
View File

@@ -0,0 +1,59 @@
<%@ Page Title="後端管理系統" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="reg.aspx.cs" Inherits="admin_news__reg" ValidateRequest="false" %>
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="footer_script" runat="Server">
</asp:Content>
<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>
<div class="">
<asp:Button ID="goback" runat="server" Text="回公告檢視" CausesValidation ="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
</div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-fluid">
<div class="card shadow-sm my-3">
<div class="card-body">
<div class="row align-items-center mb-sm-3 mb-1">
<div class="col">
由 <asp:Literal ID="author" runat="server"></asp:Literal> 發佈
</div>
<div class="col text-muted text-end">
<asp:Literal ID="uptime" runat="server"></asp:Literal>
</div>
</div>
<h6>
<asp:Literal ID="kind" runat="server"></asp:Literal></h6>
<hr >
<h5 class="card-title bg-primary bg-gradient bg-opacity-25 p-3">
<asp:Literal ID="subject" runat="server"></asp:Literal></h5>
<p><asp:Literal ID="word" runat="server"></asp:Literal></p>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:LinkButton ID="file" runat="server" CssClass="btn btn-outline-secondary shadow-sm me-3" OnClick="file_Click" CommandName='<%# Eval("pic1") %>' CommandArgument='<%# Eval("pic_name") %>'><%# ValString(Eval("pic_name")).Split('.')[0] %></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</div>
</asp:Content>

108
web/admin/news/reg.aspx.cs Normal file
View File

@@ -0,0 +1,108 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Globalization;
using static TreeView;
public partial class admin_news__reg : MyWeb.config
{
private Model.ezEntities _db = new Model.ezEntities();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (isStrNull(Request["num"]))
{
Response.Redirect("list.aspx" + rtnQueryString("num"));
}
else
{
int _num = Val(Request["num"]);
var qry = _db.news.AsEnumerable();
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
if (prod != null)
{
if (prod.author.HasValue)
author.Text = prod.admin.u_name;
if (prod.uptime.HasValue)
uptime.Text = prod.uptime.Value.ToString("yyyy-MM-dd");
if (prod.kind.HasValue)
{
kind.Text = prod.news_kind.kind;
kind.Text = new TreeView().kindText(_db.news_kind.Select(o => new TreeItem()
{
kind = o.kind,
num = o.num,
root = o.root,
}).ToList(), prod.kind);
}
subject.Text = prod.subject;
word.Text = prod.word;
//檔案
var qry2 = _db.news_files.AsEnumerable();
var prod2 = qry2.Where(q => q.news_id == _num).ToList();
Repeater1.DataSource = prod2;
Repeater1.DataBind();
}
else
{
Response.Redirect("list.aspx");
}
}
}
}
protected void goback_Click(object sender, EventArgs e)
{
Response.Redirect("list.aspx?page=" + Convert.ToString(Request["page"]));
}
#region
protected void file_Click(object sender, EventArgs e)
{
FileInfo FileInfo = new FileInfo(HttpContext.Current.Server.MapPath(Model. news.Dir + "/" + ((LinkButton)sender).CommandName));
if (FileInfo.Exists)
{
Response.ContentType = "application/octet-stream";
//指定輸出類型
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", ((LinkButton)sender).CommandArgument));
Response.HeaderEncoding = System.Text.Encoding.GetEncoding("big5");
// 若要支援中文檔名,要加這個。
Response.WriteFile(FileInfo.FullName);
// 輸出檔案內容
Response.End();
}
else
{
Response.ContentType = "text/plain";
//Response.Write("資料不存在");
ScriptMsg("資料不存在", "", msgIcon.error);
}
}
#endregion
}