migrate to new git
This commit is contained in:
399
web/admin/project/index.aspx
Normal file
399
web/admin/project/index.aspx
Normal file
@@ -0,0 +1,399 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_project_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="">
|
||||
|
||||
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
|
||||
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<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' },
|
||||
{ text: '類別', value: 'kindsTxt'},
|
||||
{ text: '品項', value: 'actItem_Txt' },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' },
|
||||
],
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
subject: '',
|
||||
kind: '',
|
||||
actItem_num: '',
|
||||
|
||||
}
|
||||
,
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '專案類別',
|
||||
text_prop: 'kind',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'kind', title: '類別名稱', value: '' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/project/GetKindList',
|
||||
columns: [
|
||||
{ id: 'kind', title: '類別名稱', value: '' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
console.log("select search1", t);
|
||||
}
|
||||
}, search3: {
|
||||
id: 'search3',
|
||||
title: '品項',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/activity/GetItemList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '項目名稱' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
console.log("select search3", t);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
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
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getDefault()
|
||||
this.search_get()
|
||||
console.log("watch2", this.search_dialog, this.search_dialog.page);
|
||||
},
|
||||
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/project/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/project/' + 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/project/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()
|
||||
},//===
|
||||
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;
|
||||
});
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
},
|
||||
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.slot_btn="{ item }">
|
||||
<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>
|
||||
<input type="text" v-model="search.subject" class="form-control" id="subject" runat="server" placeholder="可輸入關鍵字查詢">
|
||||
</div>
|
||||
<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>
|
||||
<asp:DropDownList ID="s_actItem_num" runat="server" CssClass="form-select" v-model="search.actItem_num" >
|
||||
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
160
web/admin/project/index.aspx.cs
Normal file
160
web/admin/project/index.aspx.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
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 DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using static TreeView;
|
||||
|
||||
public partial class admin_project_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, "project_kind", 0, "", 1, Model.project.KindLevelMax);
|
||||
var qry1 = new TreeView().get_data2(_db.project_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_actItem_num.Items.Clear();
|
||||
s_actItem_num.Items.Add(new ListItem("請選擇", ""));
|
||||
var qry = _db.actItems.AsEnumerable();
|
||||
qry = qry.Where(o => (int?)o.category==(int)Model.activity.category.Patronize);//贊助項目
|
||||
qry = qry.OrderByDescending(o => o.num).ToList();
|
||||
if(qry.Count() > 0)
|
||||
foreach(var qq in qry)
|
||||
s_actItem_num.Items.Add(new ListItem(qq.subject, qq.num.ToString()));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 匯出Excel
|
||||
|
||||
protected void excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
|
||||
{
|
||||
var wb = doc.AddWorkbookPart();
|
||||
wb.Workbook = new Workbook();
|
||||
var sheets = wb.Workbook.AppendChild(new Sheets());
|
||||
|
||||
//建立第一個頁籤
|
||||
var ws = wb.AddNewPart<WorksheetPart>();
|
||||
ws.Worksheet = new Worksheet();
|
||||
sheets.Append(new Sheet()
|
||||
{
|
||||
Id = wb.GetIdOfPart(ws),
|
||||
SheetId = 1,
|
||||
Name = "專案管理"
|
||||
});
|
||||
|
||||
//設定欄寬
|
||||
var cu = new Columns();
|
||||
cu.Append(
|
||||
new Column { Min = 1, Max = 2, Width = 15, CustomWidth = true },
|
||||
new Column { Min = 3, Max = 3, Width = 25, CustomWidth = true }
|
||||
);
|
||||
ws.Worksheet.Append(cu);
|
||||
|
||||
//建立資料頁
|
||||
var sd = new SheetData();
|
||||
ws.Worksheet.AppendChild(sd);
|
||||
|
||||
//第一列資料
|
||||
var tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue("名稱"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("類別"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("品項"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//查詢要匯出的資料
|
||||
var qry = _db.projects.AsEnumerable();
|
||||
|
||||
if (!string.IsNullOrEmpty(subject.Value))
|
||||
qry = qry.Where(o => o.subject.Contains(subject.Value.Trim()));
|
||||
if (!string.IsNullOrEmpty(s_kind.SelectedValue))
|
||||
qry = qry.Where(o => o.kind == Convert.ToInt32( s_kind.SelectedValue));
|
||||
if (!string.IsNullOrEmpty(s_actItem_num.SelectedValue))
|
||||
qry = qry.Where(o => o.actItem_num == Convert.ToInt32(s_actItem_num.SelectedValue));
|
||||
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
var list = qry.ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
//新增資料列
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(item.subject), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.kind.HasValue? item.project_kind.kind:""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.actItem_num.HasValue? item.actItem.subject:""), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
}
|
||||
|
||||
}
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.subject).ToList()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=專案管理.xlsx");
|
||||
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
|
||||
HttpContext.Current.Response.End();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
83
web/admin/project/kind_reg.aspx
Normal file
83
web/admin/project/kind_reg.aspx
Normal file
@@ -0,0 +1,83 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="kind_reg.aspx.cs" Inherits="admin_project_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>
|
||||
|
||||
</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="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>
|
||||
|
||||
303
web/admin/project/kind_reg.aspx.cs
Normal file
303
web/admin/project/kind_reg.aspx.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
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_project_kind_reg : MyWeb.config
|
||||
{
|
||||
DataTable treeDt = new DataTable();
|
||||
const int LevelMax = Model.project.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.project_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;
|
||||
HiddenField1.Value = prod.kind;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect(Request.Url.AbsolutePath );
|
||||
|
||||
}
|
||||
|
||||
edit.Visible = true;
|
||||
add.Visible = false;
|
||||
down_table.Visible = true;
|
||||
start.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 project_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;
|
||||
HiddenField1.Value = "AddMainItem";
|
||||
BuildTreeView();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
try
|
||||
{
|
||||
Model.project_kind project_kind = _db.project_kind.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (project_kind != null)
|
||||
{
|
||||
project_kind.kind = item_name.Text;
|
||||
project_kind.demo = demo.Text;
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (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.project_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.project_kind project_kind = new Model.project_kind();//新增
|
||||
project_kind.kind = item_name.Text;
|
||||
project_kind.root = root;
|
||||
project_kind.range = range;
|
||||
project_kind.demo = demo.Text;
|
||||
_db.project_kind.Add(project_kind);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (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.project_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
_db.project_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.Project, (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.project_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.project_kind.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void del_product(int num)
|
||||
{
|
||||
var prod = _db.projects.AsEnumerable().Where(q => q.kind == num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
////查詢結果全部刪除
|
||||
//_db.projects.RemoveRange(prod);
|
||||
//_db.SaveChanges();
|
||||
|
||||
//清空分類
|
||||
foreach (var item in prod)
|
||||
item.kind = null;
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
398
web/admin/project/list.aspx
Normal file
398
web/admin/project/list.aspx
Normal file
@@ -0,0 +1,398 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="list.aspx.cs" Inherits="admin_project_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">
|
||||
<div class="mb-2 mb-sm-0">
|
||||
|
||||
</div>
|
||||
<div class="">
|
||||
|
||||
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
|
||||
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<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: 'actItem_Txt' },
|
||||
{ text: '贊助人 ', value: 'f_num_Txt' },
|
||||
{ text: '金額', value: 'total' },
|
||||
{ text: '專案活動 ', value: 'projects' },
|
||||
],
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
actItem_num: '',
|
||||
f_num_txt:'',
|
||||
}
|
||||
,
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '專案類別',
|
||||
text_prop: 'kind',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'kind', title: '類別名稱', value: '' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/project/GetKindList',
|
||||
columns: [
|
||||
{ id: 'kind', title: '類別名稱', value: '' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
console.log("select search1", t);
|
||||
}
|
||||
}, search3: {
|
||||
id: 'search3',
|
||||
title: '品項',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/activity/GetItemList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '項目名稱' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
console.log("select search3", t);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
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
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getDefault()
|
||||
this.search_get()
|
||||
console.log("watch2", this.search_dialog, this.search_dialog.page);
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDefault() {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: page, pageSize: itemsPerPage
|
||||
};
|
||||
this.data_table.loading = true
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/project/GetPatronizeList', 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/project/' + 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/project/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
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
},
|
||||
btn_search() {
|
||||
this.page = 1;
|
||||
this.getDefault()
|
||||
},
|
||||
btn_all() {
|
||||
clearObjProps(this.search);
|
||||
this.btn_search()
|
||||
},//===
|
||||
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;
|
||||
});
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.data_table.count / this.data_table.pageSize)
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
currency: function (value) {
|
||||
return value == null || value === "" ? "" :
|
||||
('$' + parseFloat(value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").replace(".00", ""));
|
||||
},
|
||||
}
|
||||
})
|
||||
</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"
|
||||
|
||||
hide-default-footer
|
||||
:page.sync="data_table.page"
|
||||
:items-per-page.sync="data_table.pageSize"
|
||||
class="elevation-1">
|
||||
|
||||
<template v-slot:item.total="{ item }">
|
||||
{{item.price * item.qty | currency }}
|
||||
</template>
|
||||
<template v-slot:item.projects="{ item }">
|
||||
<div v-for="data in item.projects">
|
||||
<a :href="'news_reg.aspx?num='+data.num" >{{data.subject }}</a>
|
||||
</div>
|
||||
</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>
|
||||
<input type="text" v-model="search.f_num_txt" class="form-control" placeholder="可輸入關鍵字查詢" id="s_f_num" runat="server">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">品項</label>
|
||||
<asp:DropDownList ID="s_actItem_num" runat="server" CssClass="form-select" v-model="search.actItem_num" >
|
||||
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
153
web/admin/project/list.aspx.cs
Normal file
153
web/admin/project/list.aspx.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
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 DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
|
||||
public partial class admin_project_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_actItem_num.Items.Clear();
|
||||
s_actItem_num.Items.Add(new ListItem("請選擇", ""));
|
||||
var qry = _db.actItems.AsEnumerable();
|
||||
qry = qry.Where(o => (int?)o.category==(int)Model.activity.category.Patronize);//贊助項目
|
||||
qry = qry.OrderByDescending(o => o.num).ToList();
|
||||
if(qry.Count() > 0)
|
||||
foreach(var qq in qry)
|
||||
s_actItem_num.Items.Add(new ListItem(qq.subject, qq.num.ToString()));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 匯出Excel
|
||||
|
||||
protected void excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
|
||||
{
|
||||
var wb = doc.AddWorkbookPart();
|
||||
wb.Workbook = new Workbook();
|
||||
var sheets = wb.Workbook.AppendChild(new Sheets());
|
||||
|
||||
//建立第一個頁籤
|
||||
var ws = wb.AddNewPart<WorksheetPart>();
|
||||
ws.Worksheet = new Worksheet();
|
||||
sheets.Append(new Sheet()
|
||||
{
|
||||
Id = wb.GetIdOfPart(ws),
|
||||
SheetId = 1,
|
||||
Name = "贊助報告"
|
||||
});
|
||||
|
||||
//設定欄寬
|
||||
var cu = new Columns();
|
||||
cu.Append(
|
||||
new Column { Min = 1, Max = 3, Width = 15, CustomWidth = true },
|
||||
new Column { Min = 4, Max = 4, Width = 30, CustomWidth = true }
|
||||
);
|
||||
ws.Worksheet.Append(cu);
|
||||
|
||||
//建立資料頁
|
||||
var sd = new SheetData();
|
||||
ws.Worksheet.AppendChild(sd);
|
||||
|
||||
//第一列資料
|
||||
var tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue("品項"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("贊助人 "), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("金額"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("專案活動"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//查詢要匯出的資料
|
||||
var qry = _db.pro_order_detail.AsEnumerable();
|
||||
qry = qry.Where(o => (int?)o.actItem.category == (int)Model.activity.category.Patronize);
|
||||
|
||||
if (!string.IsNullOrEmpty(s_f_num.Value))
|
||||
qry = qry.Where(o => o.f_num == Convert.ToInt32(s_f_num.Value));
|
||||
if (!string.IsNullOrEmpty(s_actItem_num.SelectedValue))
|
||||
qry = qry.Where(o => o.actItem_num == Convert.ToInt32(s_actItem_num.SelectedValue));
|
||||
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
var list = qry.ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
var projectDt = _db.projects.AsEnumerable(); //專案
|
||||
foreach (var item in list)
|
||||
{
|
||||
var projects = from s in projectDt
|
||||
where s.actItem_num == item.actItem_num
|
||||
select new
|
||||
{
|
||||
subject = s.subject,
|
||||
num = s.num,
|
||||
};
|
||||
|
||||
|
||||
//新增資料列
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(item.f_num.HasValue ? item.follower.u_name : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.actItem_num.HasValue ? item.actItem.subject : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.price.HasValue ? ValMoney(item.price.Value) : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(string.Join(",", projects.Select(x => x.subject).ToList())), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=贊助報告.xlsx");
|
||||
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
651
web/admin/project/news_reg.aspx
Normal file
651
web/admin/project/news_reg.aspx
Normal file
@@ -0,0 +1,651 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="news_reg.aspx.cs" Inherits="admin_project_new_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">
|
||||
<!--編緝器-->
|
||||
<script type="text/javascript" src="<%=ResolveUrl("~/admin/ckeditor/ckeditor.js") %>"></script>
|
||||
<script type="text/javascript">
|
||||
CKEDITOR.config.toolbar = 'Default';
|
||||
</script>
|
||||
<!--編緝器-->
|
||||
<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 {
|
||||
pid: '<%= 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/project/GetKindList',
|
||||
columns: [
|
||||
{ id: 'kind', title: '類別名稱', value: '' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
//console.log("select search1", t);
|
||||
}
|
||||
}, search3: {
|
||||
id: 'search3',
|
||||
title: '品項',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/activity/GetItemList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '項目名稱' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
selected: {},
|
||||
select(t) {
|
||||
//console.log("select search3", t);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
show: false,
|
||||
current: {},
|
||||
list: [],
|
||||
count: 0,
|
||||
page:1,
|
||||
loading: false,
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
disableItemsPerPage: true,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText:'',
|
||||
},
|
||||
},
|
||||
snackbar: {
|
||||
show: false,
|
||||
text: "",
|
||||
},
|
||||
//
|
||||
optionsDetail: { multiSort: false },
|
||||
searchDetail: '',
|
||||
headersDetail: [
|
||||
{ text: '* 標題', value: 'subject', sortable: false },
|
||||
{ text: '* 日期', value: 'uptime', sortable: false },
|
||||
{ text: '', value: 'actions', sortable: false, width: "150px" },
|
||||
],
|
||||
desserts: [],
|
||||
desserts_count: 0,
|
||||
editedIndex: -1,
|
||||
editedItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
subject: "",
|
||||
uptime: new Date().format("yyyy-MM-dd"),
|
||||
word: "",
|
||||
pic1: [],
|
||||
pro_id: 0,
|
||||
formData: new FormData(),
|
||||
},
|
||||
defaultItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
subject: "",
|
||||
uptime: new Date().format("yyyy-MM-dd"),
|
||||
word: "",
|
||||
pic1: [],
|
||||
pro_id: 0,
|
||||
formData: new FormData(),
|
||||
},
|
||||
data_dialog: {
|
||||
show: false,
|
||||
isAddNew: false,
|
||||
}
|
||||
}
|
||||
},
|
||||
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,
|
||||
},
|
||||
optionsDetail: {
|
||||
handler() {
|
||||
this.initialize();
|
||||
},
|
||||
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 == 'search3') {
|
||||
search['category'] = "4"; //贊助
|
||||
}
|
||||
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;
|
||||
},
|
||||
initialize() {
|
||||
if (this.pid != '') {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.optionsDetail
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: page, pageSize: itemsPerPage,
|
||||
};
|
||||
var searchItemDetail = {
|
||||
num: this.pid,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/project/GetItemList', searchItemDetail, { params: params })
|
||||
.then(response => {
|
||||
this.desserts = response.data.list
|
||||
this.desserts_count = response.data.count
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
}
|
||||
},
|
||||
addNew() {
|
||||
|
||||
window.location = 'update.aspx?pro_id=' + this.pid;
|
||||
|
||||
//var keysArr = [];
|
||||
|
||||
//for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
// //console.log(this.desserts[i].id)
|
||||
// keysArr.push(parseInt(this.desserts[i].id));
|
||||
//}
|
||||
|
||||
//var _c = Math.max.apply(null, keysArr);
|
||||
//const addObj = Object.assign({}, this.defaultItem);
|
||||
//addObj.id = (isFinite(_c) ? _c : 0) + 1;
|
||||
//this.desserts.unshift(addObj);
|
||||
//this.editItem(addObj);
|
||||
//this.data_dialog.show = true;
|
||||
//this.data_dialog.isAddNew = true;
|
||||
|
||||
},
|
||||
editItem(item) {
|
||||
|
||||
window.location = 'update.aspx?pro_id=' + this.pid + "&pnum=" + item.num;
|
||||
|
||||
//=====
|
||||
//this.editedIndex = this.desserts.indexOf(item);
|
||||
////日期處理
|
||||
//let isValidDate = Date.parse(item.uptime);
|
||||
//if (!isNaN(isValidDate))
|
||||
// item.uptime = new Date(item.uptime).format("yyyy-MM-dd")
|
||||
////編輯器
|
||||
//CKEDITOR.instances.word.setData(item.word);
|
||||
|
||||
//this.editedItem = Object.assign({}, item);
|
||||
//this.data_dialog.show = true;
|
||||
//this.data_dialog.isAddNew = false;
|
||||
},
|
||||
cancel() {
|
||||
|
||||
//if new data , splice it
|
||||
//if (this.data_dialog.isAddNew && this.editedItem.num == 0) {
|
||||
|
||||
// for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
// if (this.desserts[i].id == this.editedItem.id) {
|
||||
// this.desserts.splice(i, 1); break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
this.close();
|
||||
},
|
||||
close() {
|
||||
setTimeout(() => {
|
||||
this.editedItem = Object.assign({}, this.defaultItem);
|
||||
this.editedIndex = -1;
|
||||
}, 300)
|
||||
},
|
||||
save() {
|
||||
if (this.editedIndex > -1) {
|
||||
if (this.pid != '') {
|
||||
|
||||
|
||||
//axios
|
||||
// .post(HTTP_HOST + 'api/fileSys/upload', this.editedItem.formData)
|
||||
// .then(response => {
|
||||
// if (response.data != "") {}
|
||||
// })
|
||||
// .catch(
|
||||
// error => console.log(error)
|
||||
// )
|
||||
|
||||
//chcck necessary params
|
||||
if (this.editedItem.subject != "" && this.editedItem.uptime != "" ) {
|
||||
//insert or update data
|
||||
var project_sub =
|
||||
{
|
||||
num: this.editedItem.num,
|
||||
pro_id: this.pid,
|
||||
subject: this.editedItem.subject,
|
||||
uptime: this.editedItem.uptime,
|
||||
//word: this.editedItem.word, //?????
|
||||
word: CKEDITOR.instances.word.getData(), //?????
|
||||
//pic1: this.editedItem.pic1.name !== undefined ? this.editedItem.pic1.name : "" ,
|
||||
//pic1: this.editedItem.pic1.length>0 ?
|
||||
pic1: "",
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/project/SaveDetailData', project_sub)
|
||||
.then(response => {
|
||||
this.editedItem.num = response.data;
|
||||
Object.assign(this.desserts[this.editedIndex], this.editedItem)
|
||||
this.close();
|
||||
this.data_dialog.show = false;
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
|
||||
} else {
|
||||
this.snackbar.text = "必填項目未填寫完整";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
} else {
|
||||
this.snackbar.text = "請先新增專案";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
}
|
||||
},
|
||||
fileChange(e) {
|
||||
for (var i = 0; i < e.length; i++) {
|
||||
this.editedItem.formData.append('file', e[i]) //用迴圈抓出多少筆再append回來
|
||||
}
|
||||
}, deleteItem(item) {
|
||||
//confirm('確定要刪除此筆資料嗎?') && this.desserts.splice(index, 1);
|
||||
if (confirm('確定要刪除此筆資料嗎?')) {
|
||||
const index = this.desserts.indexOf(item);
|
||||
if (item.num > 0) {
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/project/DeleteItem/' + item.num)
|
||||
.then(response => {
|
||||
console.log("del", item);
|
||||
this.desserts.splice(index, 1)
|
||||
this.desserts_count = this.desserts_count - 1;
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
} else {
|
||||
this.desserts.splice(index, 1)
|
||||
this.close();
|
||||
this.data_dialog.show = false;
|
||||
}
|
||||
}
|
||||
}, magnifyItem(item) {
|
||||
window.open('reg.aspx?num=' + item.num, '_blank');
|
||||
}
|
||||
},
|
||||
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-xl">
|
||||
<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="label-sm-right">
|
||||
<div class="row mb-1 ">
|
||||
<label class="col-sm-2 col-lg-1 col-form-label">名稱 *</label>
|
||||
<div class="col-sm-4 col-lg-3">
|
||||
<asp:TextBox ID="subject" MaxLength="50" runat="server" CssClass="form-control" placeholder="請輸入專案名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" 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-4 col-lg-3">
|
||||
<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="RequiredFieldValidator7" 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">
|
||||
<div class="input-group mb-3" data-search-control="search3" @click="search_show(search_dialog.controls.search3)">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
id="actItem_num_txt" runat="server" placeholder="品項" value="">
|
||||
<asp:HiddenField ID="actItem_num" 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="actItem_num_txt" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
|
||||
</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>
|
||||
<div class="tab-pane fade" id="sec2-page2" role="tabpanel" aria-labelledby="sec2-tab2">
|
||||
|
||||
<%-- <v-dialog v-model="data_dialog.show" max-width="900px">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
活動資料
|
||||
<v-btn icon @click="data_dialog.show=false;cancel()"><v-icon>mdi-close</v-icon></v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-row dense class="pt-2">
|
||||
<v-col :cols="2" class="pt-3" >
|
||||
<span class="fs-6 text text-dark">標題 *</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" >
|
||||
<v-text-field v-model="editedItem.subject" :hide-details="true" dense single-line></v-text-field>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row dense class="pt-2">
|
||||
<v-col :cols="2" class="pt-3" >
|
||||
<span class="fs-6 text text-dark">日期 *</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" :md="4" >
|
||||
<v-text-field v-model="editedItem.uptime" :hide-details="true" dense single-line type="date" ></v-text-field>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row dense class="pt-2">
|
||||
<v-col :cols="2" class="pt-3" >
|
||||
<span class="fs-6 text text-dark">照片上傳</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" :md="4" >
|
||||
<v-file-input
|
||||
v-model="editedItem.pic1"
|
||||
accept="image/png, image/jpeg, image/bmp"
|
||||
placeholder="請選擇圖片"
|
||||
prepend-icon="mdi-camera"
|
||||
></v-file-input>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row dense class="pt-2">
|
||||
<v-col :cols="2" class="pt-3" >
|
||||
<span class="fs-6 text text-dark">內容 *</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" :md="4" >
|
||||
<textarea name="word" rows="2" cols="20" class="ckeditor" v-model="editedItem.word" ></textarea>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div class="row mb-1">
|
||||
<label class="col-form-label">內容 *</label>
|
||||
<div class="">
|
||||
<textarea name="word" rows="2" cols="20" class="ckeditor" v-model="editedItem.word" ></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>--%>
|
||||
|
||||
<div v-show="data_dialog.show">
|
||||
<div>
|
||||
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
|
||||
</div>
|
||||
<div class="label-sm-right">
|
||||
<div class="row mb-1 ">
|
||||
<label class="col-sm-2 col-lg-1 col-form-label">標題 *</label>
|
||||
<div class="col-sm-4 col-lg-3">
|
||||
<input type="text" maxlength="50" class="form-control" v-model="editedItem.subject">
|
||||
</div>
|
||||
<label class="col-sm-2 col-lg-1 col-form-label">日期 *</label>
|
||||
<div class="col-sm-4 col-lg-3">
|
||||
<input type="date" class="form-control" v-model="editedItem.uptime" autocomplete="off" data-date-format="yyyy-mm-dd">
|
||||
</div>
|
||||
<label class="col-sm-2 col-lg-1 col-form-label">照片上傳</label>
|
||||
<div class="col-sm-4 col-lg-3">
|
||||
<%-- <img id="picShow" style="display: none" data-path="" class="picShow" />
|
||||
<a id="picPath" class="btn btn-default picPath" href="javascript:void(0)">請選擇圖片</a>
|
||||
<div id="pics" class="d-none"><input type="file" name="picUpload" id="picUpload" /></div> --%>
|
||||
<v-file-input
|
||||
<%--v-model="editedItem.pic1" --%>
|
||||
accept="image/png, image/jpeg, image/bmp"
|
||||
placeholder="請選擇圖片"
|
||||
prepend-icon="mdi-camera"
|
||||
@change="fileChange"
|
||||
multiple>
|
||||
</v-file-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row mb-1">
|
||||
<label class="col-form-label">內容 *</label>
|
||||
<div class="">
|
||||
<textarea rows="5" class="ckeditor" name="word" ></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<%-- <v-btn class="ma-2" color="red lighten-2" dark @click="save()" > 新增 <v-icon dark right > mdi-new-box </v-icon> </v-btn>--%>
|
||||
<v-btn class="ma-2" color="primary" dark @click="save()" > 儲存 <v-icon dark right > mdi-content-save </v-icon> </v-btn>
|
||||
</div>
|
||||
|
||||
<v-card class="mx-auto mt-10" outlined v-if="pid!=''">
|
||||
<v-data-table
|
||||
:headers="headersDetail"
|
||||
:items="desserts"
|
||||
:search="searchDetail"
|
||||
:options.sync="optionsDetail" class="elevation-1" fixed-header height="350px"
|
||||
:server-items-length="desserts_count">
|
||||
<v-divider inset></v-divider>
|
||||
<template v-slot:top>
|
||||
<v-toolbar flat color="white">
|
||||
<div class="d-flex w-100">
|
||||
<v-text-field v-model="searchDetail" append-icon="mdi-magnify" label="查詢" dense outlined single-line hide-details></v-text-field>
|
||||
<v-btn
|
||||
color="primary"
|
||||
class="ml-2 white--text"
|
||||
@click="addNew">
|
||||
<v-icon dark>mdi-plus</v-icon>新增
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
|
||||
<template v-slot:item.uptime="{ item }">
|
||||
{{item.uptime|timeString('YYYY/MM/DD')}}
|
||||
</template>
|
||||
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<div >
|
||||
<v-icon color="blue" class="mr-3" @click="magnifyItem(item)" >
|
||||
mdi-magnify
|
||||
</v-icon>
|
||||
<v-icon color="green" class="mr-3" @click="editItem(item);">
|
||||
mdi-pencil
|
||||
</v-icon>
|
||||
<v-icon color="red" @click="deleteItem(item)">
|
||||
mdi-delete
|
||||
</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
</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>
|
||||
|
||||
145
web/admin/project/news_reg.aspx.cs
Normal file
145
web/admin/project/news_reg.aspx.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
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_project_new_reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var qry = _db.projects.AsEnumerable();
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
if (prod != null)
|
||||
{
|
||||
|
||||
subject.Text = prod.subject;
|
||||
if (prod.kind.HasValue)
|
||||
{
|
||||
kind_txt.Value = prod.project_kind.kind.ToString();
|
||||
kind.Value = prod.kind.ToString();
|
||||
}
|
||||
|
||||
if (prod.actItem_num.HasValue)
|
||||
{
|
||||
actItem_num_txt.Value = prod.actItem.subject.ToString();
|
||||
actItem_num.Value = prod.actItem_num.ToString();
|
||||
}
|
||||
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 = "";
|
||||
|
||||
Model.project project = new Model.project();
|
||||
project.subject = subject.Text;
|
||||
if (!isStrNull(kind.Value)) { project.kind = Val(kind.Value); }
|
||||
if (!isStrNull(actItem_num.Value)) { project.actItem_num = Val(actItem_num.Value); }
|
||||
|
||||
project.demo = demo.Text;
|
||||
project.reg_time = DateTime.Now;
|
||||
|
||||
try
|
||||
{
|
||||
_db.projects.Add(project);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (int)Model.admin_log.Status.Insert, subject.Text);
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Text = ex.Message;
|
||||
L_msg.Type = alert_type.danger;
|
||||
//L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
int _num = Val(Request["num"]);
|
||||
Model.project project = _db.projects.Where(q => q.num == _num).FirstOrDefault();
|
||||
if (project != null)
|
||||
{
|
||||
project.subject = subject.Text;
|
||||
if (!isStrNull(kind.Value)) { project.kind = Val(kind.Value); }
|
||||
if (!isStrNull(actItem_num.Value)) { project.actItem_num = Val(actItem_num.Value); }
|
||||
project.demo = demo.Text;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Project, (int)Model.admin_log.Status.Update, subject.Text);
|
||||
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
//L_msg.Text = ex.InnerException.Message;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
45
web/admin/project/reg.aspx
Normal file
45
web/admin/project/reg.aspx
Normal file
@@ -0,0 +1,45 @@
|
||||
<%@ Page Title="後端管理系統" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="reg.aspx.cs" Inherits="admin_project__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">
|
||||
|
||||
|
||||
</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="project_name" 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>
|
||||
<asp:Image ID="Image1" runat="server" Visible="false" />
|
||||
<p><asp:Literal ID="word" runat="server"></asp:Literal></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
68
web/admin/project/reg.aspx.cs
Normal file
68
web/admin/project/reg.aspx.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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_project__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("index.aspx" + rtnQueryString("num"));
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var qry = _db.project_sub.AsEnumerable();
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty( prod.pic1))
|
||||
{
|
||||
Image1.Visible = true;
|
||||
Image1.ImageUrl = Model.project.Dir + "/" + prod.pic1;
|
||||
}
|
||||
if (prod.pro_id.HasValue)
|
||||
project_name.Text = prod.project.subject;
|
||||
if (prod.uptime.HasValue)
|
||||
uptime.Text = prod.uptime.Value.ToString("yyyy-MM-dd");
|
||||
|
||||
|
||||
subject.Text = prod.subject;
|
||||
word.Text = prod.word;
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void goback_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
79
web/admin/project/update.aspx
Normal file
79
web/admin/project/update.aspx
Normal file
@@ -0,0 +1,79 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="update.aspx.cs" Inherits="admin_project_update" 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>
|
||||
<!--編緝器-->
|
||||
|
||||
</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="回列表" 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-header">
|
||||
專案活動管理
|
||||
</div>
|
||||
<asp:Panel ID="cardBodyPanel" runat="server" CssClass="card-body">
|
||||
<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="50" 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">
|
||||
<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>
|
||||
|
||||
|
||||
</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-11">
|
||||
<asp:FileUpload ID="FileUpload1" runat="server" />
|
||||
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="FileUpload1" ErrorMessage="請上傳JPG或PNG格式"
|
||||
ValidationExpression="^.+(.jpg|.JPG|.jpeg|.JPEG|.png|.PNG)$" Display="Dynamic"></asp:RegularExpressionValidator>
|
||||
<asp:CheckBox ID="CheckBox1" Text="刪除" runat="server" Visible="false" />
|
||||
<asp:Image ID="Image1" runat="server" Visible="false" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<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>
|
||||
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
189
web/admin/project/update.aspx.cs
Normal file
189
web/admin/project/update.aspx.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
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_project_update : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
if (!isStrNull(Request["pro_id"]))
|
||||
{
|
||||
|
||||
if (isStrNull(Request["pnum"]))
|
||||
{
|
||||
uptime.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["pnum"]);
|
||||
var qry = _db.project_sub.AsEnumerable();
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
subject.Text = prod.subject;
|
||||
word.Text = prod.word;
|
||||
|
||||
if (prod.uptime.HasValue)
|
||||
{
|
||||
uptime.Text = prod.uptime.Value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(prod.pic1))
|
||||
{
|
||||
CheckBox1.Visible = true;
|
||||
ViewState["pic1"] = prod.pic1;
|
||||
Image1.Visible = true;
|
||||
Image1.ImageUrl = "../../App_Script/DisplayCut.ashx?file=" + Model.project.Dir.Replace("~/upload/", "") + "/" + prod.pic1 + "&w=150&h=150";
|
||||
|
||||
}
|
||||
|
||||
|
||||
edit.Visible = true;
|
||||
|
||||
add.Visible = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("news_reg.aspx?num=" + Request["pro_id"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void goback_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("news_reg.aspx?num="+ Request["pro_id"] );
|
||||
}
|
||||
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid) {
|
||||
L_msg.Text = "";
|
||||
|
||||
MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
|
||||
string[] pic_name = fileSystem.UploadPhoto(Model.project.Dir, 1200); //縮圖的寬高不得超過800象素,如果不是圖片也會傳
|
||||
|
||||
|
||||
Model.project_sub project_sub = new Model.project_sub();//新增
|
||||
project_sub.subject = subject.Text;
|
||||
project_sub.word = word.Text;
|
||||
project_sub.pro_id =Convert.ToInt32(Request["pro_id"]);
|
||||
if (!isStrNull(uptime.Text)) { project_sub.uptime = ValDate(uptime.Text); }
|
||||
|
||||
|
||||
if (pic_name.Length > 0 && !isStrNull(pic_name[0]))
|
||||
project_sub.pic1 = pic_name[0];
|
||||
|
||||
project_sub.reg_time = DateTime.Now;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
_db.project_sub.Add(project_sub);
|
||||
_db.SaveChanges();
|
||||
Response.Redirect("news_reg.aspx?num=" + Request["pro_id"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Text = ex.Message;
|
||||
L_msg.Type = alert_type.danger;
|
||||
//L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
MyWeb.fileSystem fileSystem = new MyWeb.fileSystem();
|
||||
string[] pic_name = fileSystem.UploadPhoto(Model.project.Dir, 1200); //縮圖的寬高不得超過800象素,如果不是圖片也會傳
|
||||
|
||||
|
||||
int _num = Val(Request["pnum"]);
|
||||
Model.project_sub project_sub = _db.project_sub.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (project_sub != null)
|
||||
{
|
||||
project_sub.subject = subject.Text;
|
||||
project_sub.word = word.Text;
|
||||
if (!isStrNull(uptime.Text)) { project_sub.uptime = ValDate(uptime.Text); }
|
||||
project_sub.pro_id = Convert.ToInt32(Request["pro_id"]);
|
||||
|
||||
if (pic_name[0] != "" | CheckBox1.Checked)
|
||||
{
|
||||
if (pic_name.Length > 0 && !isStrNull(pic_name[0]))
|
||||
project_sub.pic1 = pic_name[0];
|
||||
else
|
||||
project_sub.pic1 = null;
|
||||
|
||||
|
||||
if (!isStrNull(ViewState["pic1"])) // '刪除舊圖
|
||||
{
|
||||
fileSystem.Delete(Model.project.Dir + "/" + Convert.ToString(ViewState["pic1"]));
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_db.SaveChanges();
|
||||
Response.Redirect("news_reg.aspx?num=" + Request["pro_id"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
//L_msg.Text = ex.InnerException.Message;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "查無資料";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user