migrate to new git
This commit is contained in:
BIN
web/admin/follower/example.xlsx
Normal file
BIN
web/admin/follower/example.xlsx
Normal file
Binary file not shown.
64
web/admin/follower/import.aspx
Normal file
64
web/admin/follower/import.aspx
Normal file
@@ -0,0 +1,64 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="import.aspx.cs" Inherits="admin_follower_import" 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-header">
|
||||
人員匯入
|
||||
</div>
|
||||
<asp:Panel ID="cardBodyPanel" runat="server" CssClass="card-body">
|
||||
<div class="row g-1 gx-lg-2 label-sm-right">
|
||||
<label class="col-sm-3 col-form-label">步驟 1</label>
|
||||
<div class="col-sm-9 pt-1">
|
||||
請先下載 EXCEL 表格,
|
||||
<asp:LinkButton ID="databaseExport" runat="server" CssClass="btn btn-default" CausesValidation="false" OnClick="databaseExport_Click"><i class="mdi mdi-content-save"></i> 點擊此處下載</asp:LinkButton>。
|
||||
</div>
|
||||
|
||||
<label class="col-sm-3 col-form-label">步驟 2</label>
|
||||
<div class="col-sm-9 pt-2">
|
||||
選擇已編輯好的 EXCEL 表格
|
||||
<div>
|
||||
<asp:FileUpload ID="FileUpload1" runat="server" />
|
||||
</div>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="FileUpload1" runat="server" ValidationGroup="Required"
|
||||
ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
|
||||
<label class="col-sm-3 col-form-label">步驟 3</label>
|
||||
<div class="col-sm-9 pt-1">
|
||||
匯入資料
|
||||
<asp:LinkButton ID="submitButton" runat="server" Text="匯入資料" CssClass="btn btn-outline-success" ValidationGroup="Required" OnClick="submitButton_Click"></asp:LinkButton>
|
||||
</div>
|
||||
|
||||
<label class="col-sm-3 col-form-label">注意事項</label>
|
||||
<div class="col-sm-9 pt-2">
|
||||
如有大量資料,建議分批匯入,以免造成執行時間過久而導致網頁逾時。<br />
|
||||
Excel匯入只做新增,不提供刪除或修改欄位的功能。<br />
|
||||
<span class="text-danger">不做「信眾編號」重複的檢查</span>,使用者轉檔時需自行過濾。<br />
|
||||
<span class="text-danger">「國籍」欄位請務必輸入代碼</span>,代碼資料可參考工作表2「國籍資料參考」。<br />
|
||||
匯入資料範例參考 <a href="example.xlsx" class="btn btn-outline-primary">觀看範例</a>
|
||||
</div>
|
||||
|
||||
<label class="col-sm-3 col-form-label"></label>
|
||||
<div class="col-sm-9 pt-2">
|
||||
<asp:Label ID="msg" runat="server" ForeColor="Red"></asp:Label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Panel>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
348
web/admin/follower/import.aspx.cs
Normal file
348
web/admin/follower/import.aspx.cs
Normal file
@@ -0,0 +1,348 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.IO;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
|
||||
using System.Collections.Generic;
|
||||
using DocumentFormat.OpenXml.Office2013.PowerPoint.Roaming;
|
||||
|
||||
public partial class admin_follower_import : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 下載空excel
|
||||
|
||||
|
||||
protected void databaseExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
excelEPPlus();
|
||||
}
|
||||
protected void excelEPPlus() //下載空excel
|
||||
{
|
||||
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 = 10, CustomWidth = true },
|
||||
new Column { Min = 4 , Max = 17, Width = 15, CustomWidth = true },
|
||||
new Column { Min = 18, Max = 18, Width = 8, CustomWidth = true },
|
||||
new Column { Min = 19, Max = 19, Width = 30, CustomWidth = true },
|
||||
new Column { Min = 20, Max = 20, Width = 8, CustomWidth = true },
|
||||
new Column { Min = 21, Max = 30, Width = 15, 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 },//4
|
||||
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 },
|
||||
new Cell() { CellValue = new CellValue("電子信箱"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("生日"), DataType = CellValues.String }, //10
|
||||
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 }, //14
|
||||
new Cell() { CellValue = new CellValue("LINE帳號"), 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 },//18
|
||||
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 },
|
||||
new Cell() { CellValue = new CellValue("備註"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//國籍
|
||||
ws = wb.AddNewPart<WorksheetPart>();
|
||||
ws.Worksheet = new Worksheet();
|
||||
sheets.Append(new Sheet()
|
||||
{
|
||||
Id = wb.GetIdOfPart(ws),
|
||||
SheetId = 2,
|
||||
Name = "國籍資料參考"
|
||||
});
|
||||
|
||||
//設定欄寬
|
||||
cu = new Columns();
|
||||
cu.Append(
|
||||
new Column { Min = 1, Max = 1, Width = 10, CustomWidth = true },
|
||||
new Column { Min = 2, Max = 2, Width = 30, CustomWidth = true }
|
||||
);
|
||||
ws.Worksheet.Append(cu);
|
||||
|
||||
//建立資料頁
|
||||
sd = new SheetData();
|
||||
ws.Worksheet.AppendChild(sd);
|
||||
|
||||
//第一列資料
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue("代碼"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("中文名稱"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
var qry = _db.countries.AsEnumerable()
|
||||
.OrderBy(o => o.range).ThenBy(o => o.name_en).ToList();
|
||||
|
||||
//國籍資料
|
||||
if (qry.Count > 0)
|
||||
{
|
||||
foreach(var item in qry)
|
||||
{
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(item.ID), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.name_zh), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=follower_import.xlsx");
|
||||
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
|
||||
HttpContext.Current.Response.End();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 匯入資料
|
||||
protected void submitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (FileUpload1.HasFile)
|
||||
{
|
||||
string errorLog = "";
|
||||
string jumpLog = "";
|
||||
msg.Text = "";
|
||||
//開檔
|
||||
//載入Excel檔案
|
||||
using (ExcelPackage ep = new ExcelPackage(FileUpload1.PostedFile.InputStream))
|
||||
{
|
||||
|
||||
ExcelWorksheet sheet = ep.Workbook.Worksheets[1];//取得Sheet1
|
||||
int startRowNumber = sheet.Dimension.Start.Row;//起始列編號,從1算起
|
||||
int endRowNumber = sheet.Dimension.End.Row;//結束列編號,從1算起
|
||||
int startColumn = sheet.Dimension.Start.Column;//開始欄編號,從1算起
|
||||
int endColumn = sheet.Dimension.End.Column;//結束欄編號,從1算起
|
||||
|
||||
|
||||
bool isHeader = true;
|
||||
if (isHeader)//有包含標題
|
||||
{
|
||||
startRowNumber += 1;
|
||||
}
|
||||
|
||||
List<Model.country> _country = _db.countries.ToList();
|
||||
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
List<string> addList = new List<string>();
|
||||
for (int currentRow = startRowNumber; currentRow <= endRowNumber; currentRow++)
|
||||
{
|
||||
ExcelRange range = sheet.Cells[currentRow, startColumn, currentRow, endColumn];//抓出目前的Excel列
|
||||
if (range.Any(c => !string.IsNullOrEmpty(c.Text)) == false)//這是一個完全空白列(使用者用Delete鍵刪除動作)
|
||||
{
|
||||
continue;//略過此列
|
||||
}
|
||||
|
||||
|
||||
if (!isStrNull(sheet.Cells[currentRow, 1].Text) &&
|
||||
!isStrNull(sheet.Cells[currentRow, 2].Text) &&
|
||||
!isStrNull(sheet.Cells[currentRow, 3].Text) &&
|
||||
!isStrNull(sheet.Cells[currentRow, 4].Text) &&
|
||||
!isStrNull(sheet.Cells[currentRow, 18].Text) )
|
||||
{
|
||||
|
||||
//定義日期欄位格式
|
||||
sheet.Cells[currentRow, 10].Style.Numberformat.Format = "yyyy-MM-dd";
|
||||
sheet.Cells[currentRow, 11].Style.Numberformat.Format = "yyyy-MM-dd";
|
||||
sheet.Cells[currentRow, 14].Style.Numberformat.Format = "yyyy-MM-dd";
|
||||
|
||||
//寫值---
|
||||
//新增
|
||||
|
||||
string _sex = ValString(sheet.Cells[currentRow, 3].Text.Trim()).Replace("眾", "").Trim() + "眾";
|
||||
|
||||
int _identity_type = (int)Model.follower.type.Personal; //身分別預設
|
||||
switch (ValString(sheet.Cells[currentRow, 4].Text.Trim()))
|
||||
{
|
||||
case "出家眾":
|
||||
_identity_type = (int)Model.follower.type.Monk;
|
||||
break;
|
||||
case "個人":
|
||||
_identity_type = (int)Model.follower.type.Personal;
|
||||
break;
|
||||
case "法人":
|
||||
_identity_type = (int)Model.follower.type.Legal;
|
||||
break;
|
||||
case "往生菩薩":
|
||||
_identity_type = (int)Model.follower.type.Bodhisattva;
|
||||
break;
|
||||
case "蓮友":
|
||||
_identity_type = (int)Model.follower.type.Seeker;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Model.follower follower = new Model.follower();
|
||||
follower.f_number = ValString(sheet.Cells[currentRow, 1].Text.Trim());
|
||||
follower.u_name = ValString(sheet.Cells[currentRow, 2].Text.Trim());
|
||||
follower.sex = _sex;
|
||||
follower.identity_type = _identity_type;//身分別 4
|
||||
follower.phone = encrypt.EncryptAutoKey(ValString(sheet.Cells[currentRow, 5].Text.Trim()));
|
||||
follower.cellphone = encrypt.EncryptAutoKey(ValString(sheet.Cells[currentRow, 6].Text.Trim()));
|
||||
follower.id_code = encrypt.EncryptAutoKey(ValString(sheet.Cells[currentRow, 7].Text.Trim()));
|
||||
follower.passport = encrypt.EncryptAutoKey(ValString(sheet.Cells[currentRow, 8].Text.Trim()));
|
||||
follower.email = ValString(sheet.Cells[currentRow, 9].Text.Trim());
|
||||
if (isDate(sheet.Cells[currentRow, 10].Text.Trim())) { follower.birthday = ValDate(sheet.Cells[currentRow, 10].Text.Trim()); }
|
||||
if (isDate(sheet.Cells[currentRow, 11].Text.Trim())) { follower.refugedate = ValDate(sheet.Cells[currentRow, 11].Text.Trim()); }
|
||||
follower.refuge_name = ValString(sheet.Cells[currentRow, 12].Text.Trim());
|
||||
follower.refuge_area = ValString(sheet.Cells[currentRow, 13].Text.Trim());
|
||||
|
||||
if (isDate(sheet.Cells[currentRow, 14].Text.Trim())) { follower.join_date = ValDate(sheet.Cells[currentRow, 14].Text.Trim()); }
|
||||
|
||||
follower.socialid1 = ValString(sheet.Cells[currentRow, 15].Text.Trim());
|
||||
follower.socialid2 = ValString(sheet.Cells[currentRow, 16].Text.Trim());
|
||||
follower.introducer = ValString(sheet.Cells[currentRow, 17].Text.Trim());
|
||||
|
||||
//檢查國籍代碼是否存在
|
||||
var country = _country.Where(x => x.name_zh == ValString(sheet.Cells[currentRow, 18].Text.Trim())).FirstOrDefault();
|
||||
if(country != null)
|
||||
{
|
||||
//follower.country = ValString(sheet.Cells[currentRow, 18].Text.Trim());
|
||||
follower.country = country.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
follower.country = null;
|
||||
}
|
||||
|
||||
follower.address = ValString(sheet.Cells[currentRow, 19].Text.Trim());
|
||||
follower.blood = ValString(sheet.Cells[currentRow, 20].Text.Trim()).Replace("型", "").ToUpper();
|
||||
follower.contactor = ValString(sheet.Cells[currentRow, 21].Text.Trim());
|
||||
follower.contactor_phone = encrypt.EncryptAutoKey(ValString(sheet.Cells[currentRow, 22].Text.Trim()));
|
||||
follower.demo = ValString(sheet.Cells[currentRow, 23].Text.Trim());
|
||||
follower.reg_time = DateTime.Now;
|
||||
//follower.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
string ChkNewMsg = Model.follower.ChkNewFollower(follower);
|
||||
if (string.IsNullOrEmpty(ChkNewMsg))
|
||||
{
|
||||
_db.followers.Add(follower);
|
||||
addList.Add(follower.f_number + follower.u_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
jumpLog += "第" + currentRow + "行: "
|
||||
+ follower.u_name + " : "
|
||||
+ ChkNewMsg + "<br>";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jumpLog += "第" + currentRow + "行:欄位輸入不完整<br>";
|
||||
}
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
_db.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
errorLog = ex.InnerException.Message;
|
||||
}
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Insert, "Excel匯入:" + admin_log.LogViewBtn(addList));
|
||||
|
||||
if (!isStrNull(errorLog))
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "匯入失敗";
|
||||
msg.Text = errorLog;
|
||||
if (!isStrNull(jumpLog))
|
||||
{
|
||||
msg.Text += "<br>部份或全部資料未匯入:<br>" + jumpLog;
|
||||
}
|
||||
}
|
||||
else if (!isStrNull(jumpLog))
|
||||
{
|
||||
L_msg.Type = alert_type.warning;
|
||||
L_msg.Text = "部份或全部資料未匯入";
|
||||
msg.Text = "未匯入的資料列:<br>" + jumpLog;
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "匯入成功";
|
||||
}
|
||||
|
||||
|
||||
}//end using
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptMsg("請上傳excel檔", "", msgIcon.error);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
599
web/admin/follower/index.aspx
Normal file
599
web/admin/follower/index.aspx
Normal file
@@ -0,0 +1,599 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_follower_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="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 @click="print_dialog.show=true" class="btn btn-outline-primary btn-print" target="_blank">
|
||||
<i class="mdi mdi-printer"></i>列印管理報表
|
||||
</a>
|
||||
<a @click="goPrint" class="btn btn-outline-primary btn-print" target="_blank">
|
||||
<i class="mdi mdi-printer"></i>列印查詢資料
|
||||
</a>
|
||||
<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 },
|
||||
search_options: { multiSort: false },
|
||||
data_table: {
|
||||
loading: true,
|
||||
list: [],
|
||||
selected: [],
|
||||
singleSelect: false,
|
||||
count: 0,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
header: [
|
||||
{ text: '信眾編號', value: 'f_number', align: 'start' },
|
||||
{ text: '信眾姓名', value: 'u_name'},
|
||||
{ text: '身分別', value: 'identity_type_desc' },
|
||||
{ text: '性別', value: 'sex' },
|
||||
{ text: '生日', value: 'birthday' },
|
||||
{ text: '生肖/干支', value: 'sign', sortable: false },
|
||||
{ text: '報名記錄', value: 'order_record' },
|
||||
{ text: '', value: 'slot', sortable: false },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' },
|
||||
],
|
||||
footer:{
|
||||
showFirstLastPage: true,
|
||||
pageSizeOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
f_number: '',
|
||||
u_name: '',
|
||||
sex: '',
|
||||
//birthday: new Date().toISOString().split('T')[0],
|
||||
//birthday2: new Date().toISOString().split('T')[0]
|
||||
birthday:'',
|
||||
birthday2: '',
|
||||
address: '',
|
||||
country: '',
|
||||
country2: '',
|
||||
/*注意這邊的參數不能跟下方print_search重複*/
|
||||
},
|
||||
//列印管理報表
|
||||
print_conditions:'yy',
|
||||
print_search: {
|
||||
year: '',
|
||||
month: '',
|
||||
season: '',
|
||||
},
|
||||
select_items: {
|
||||
month: [{
|
||||
text: "請選擇",
|
||||
val: 0
|
||||
},],
|
||||
season: [{
|
||||
text: "請選擇",
|
||||
val: 0
|
||||
},],
|
||||
},
|
||||
print_dialog: {
|
||||
show: false,
|
||||
},
|
||||
//國籍
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '國籍',
|
||||
text_prop: 'name_zh',
|
||||
value_prop: 'id',
|
||||
keys: [
|
||||
{ id: 'keyword', title: '關鍵字' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/country/GetList',
|
||||
columns: [
|
||||
{ id: 'id', title: '代碼' },
|
||||
{ id: 'name_en', title: '英文短名稱' },
|
||||
{ id: 'name_zh', title: '中文名稱' },
|
||||
],
|
||||
selected: {},
|
||||
select(item, t) {
|
||||
//console.log("select search1", t);
|
||||
t.search.country = item.id;
|
||||
t.search.country2 = '';
|
||||
}
|
||||
},
|
||||
|
||||
}, show: false,
|
||||
current: {},
|
||||
list: [],
|
||||
count: 0,
|
||||
page: 1,
|
||||
loading: false,
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
disableItemsPerPage: true,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getList()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
search_options: {
|
||||
handler() {
|
||||
this.search_get()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
}, mounted() {
|
||||
this.search_dialog.current = this.search_dialog.controls.search1 ///default
|
||||
this.initPrintSearch();
|
||||
const navEntries = performance.getEntriesByType("navigation");
|
||||
const isReload = navEntries.length > 0 && navEntries[0].type === "reload";
|
||||
if (isReload) {
|
||||
sessionStorage.removeItem("followerpage");
|
||||
}
|
||||
else {
|
||||
const savedPage = parseInt(sessionStorage.getItem('followerpage'));
|
||||
if (savedPage) {
|
||||
this.options.page = savedPage;
|
||||
}
|
||||
}
|
||||
},
|
||||
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.search_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===
|
||||
|
||||
|
||||
console.log("search_get", api_url, search, params, this.search_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);
|
||||
}
|
||||
this.search_dialog.show = false;
|
||||
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
||||
},
|
||||
getList(clearpage = false) {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: clearpage ? '1' : page, pageSize: itemsPerPage
|
||||
};
|
||||
sessionStorage.setItem('followerpage', page);
|
||||
this.data_table.loading = true
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/follower/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)
|
||||
)
|
||||
},
|
||||
getDataFromApi() {
|
||||
},
|
||||
editItem(item) {
|
||||
console.log("edit", item);
|
||||
//this.editedIndex = this.desserts.indexOf(item)
|
||||
//this.editedItem = Object.assign({}, item)
|
||||
//this.dialog = true
|
||||
},
|
||||
deleteItem(item) {
|
||||
//this.editedIndex = this.list.indexOf(item)
|
||||
//this.editedItem = Object.assign({}, item)
|
||||
//this.dialogDelete = true
|
||||
if (confirm('是否確定刪除此筆資料?')) {
|
||||
const index = this.data_table.list.indexOf(item)
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/follower/' + item.num)
|
||||
.then(response => {
|
||||
this.getList();
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteAll() {
|
||||
if (confirm('是否確定刪除已勾選的資料?')) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/follower/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.getList(true)
|
||||
bootstrap.Offcanvas.getInstance(document.getElementById("offcanvasRight")).hide()
|
||||
},
|
||||
btn_all() {
|
||||
clearObjProps(this.search);
|
||||
this.btn_search()
|
||||
},
|
||||
goPrint() {
|
||||
//debugger;
|
||||
let _qry = "";
|
||||
Object.keys(this.search).forEach(key => {
|
||||
//console.log(`${key}: ${this.search[key]}`);
|
||||
if (this.search[key] != undefined && this.search[key] != null && this.search[key] != '') {
|
||||
_qry += (_qry != '' ? '&' : '?') + (key + '=' + this.search[key]);
|
||||
}
|
||||
});
|
||||
window.open("print.aspx" + _qry, '_blank');
|
||||
},
|
||||
//列印管理報表
|
||||
print_close() {
|
||||
this.print_dialog.show = false;
|
||||
}
|
||||
,
|
||||
initPrintSearch() {
|
||||
//下拉選單
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
var _tmp = {
|
||||
text: i,
|
||||
val:i,
|
||||
}
|
||||
this.select_items.month.push(_tmp);
|
||||
}
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
var _tmp = {
|
||||
text: i,
|
||||
val: i,
|
||||
}
|
||||
this.select_items.season.push(_tmp);
|
||||
}
|
||||
|
||||
//預設值
|
||||
const Today = new Date();//現在日期時間
|
||||
const first_date = new Date(Today.getFullYear(), Today.getMonth(), 1); //本月第一天
|
||||
const last_month_date = new Date(first_date - 1); //上個月最後一天
|
||||
|
||||
this.print_search.year = last_month_date.getFullYear();
|
||||
this.print_search.month = last_month_date.getMonth() + 1 //預設上個月的年份
|
||||
|
||||
let _season = 1;
|
||||
const _month = first_date.getMonth() + 1; //本月
|
||||
if (_month >= 1 && _month <= 3) {
|
||||
_season = 4;
|
||||
} else if (_month >= 4 && _month <= 6) {
|
||||
_season = 1;
|
||||
} else if (_month >= 7 && _month <= 9) {
|
||||
_season = 2;
|
||||
} else if (_month >= 10 && _month <= 12) {
|
||||
_season = 3;
|
||||
}
|
||||
this.print_search.season = _season; //預設上一季
|
||||
//this.print_search.season = 0;
|
||||
},
|
||||
goPrint2() {
|
||||
if (this.print_search.year != '') {
|
||||
//let _qry = "";
|
||||
//Object.keys(this.print_search).forEach(key => {
|
||||
// if (this.print_search[key] != undefined && this.print_search[key] != null && this.print_search[key] != '') {
|
||||
// _qry += (_qry != '' ? '&' : '?') + (key + '=' + this.print_search[key]);
|
||||
// }
|
||||
//});
|
||||
|
||||
let _qry = "?year=" + this.print_search.year;
|
||||
if (this.print_conditions == 'mm') {
|
||||
_qry += "&month=" + this.print_search.month;
|
||||
} else if (this.print_conditions == 'ss') {
|
||||
_qry += "&season=" + this.print_search.season;
|
||||
}
|
||||
|
||||
this.print_dialog.show = false;
|
||||
window.open("print.aspx" + _qry, '_blank');
|
||||
}else{
|
||||
msgbox('請輸入年份');
|
||||
}
|
||||
|
||||
},
|
||||
//
|
||||
countryChange() {
|
||||
this.search.country = '';
|
||||
$('#country_txt').val('')
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.data_table.count / this.data_table.pageSize)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
document.getElementById("<%= s_country.ClientID %>").addEventListener("click", function () {
|
||||
$('#country2').val('');
|
||||
VueApp.search.country2 = '';
|
||||
});
|
||||
</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.birthday="{ item }" >
|
||||
<div><span class="badge bg-secondary">西元</span> {{ item.birthday|timeString('YYYY/MM/DD') }} </div>
|
||||
<div><span class="badge bg-secondary">農曆</span> {{ item.birthday2 }} </div>
|
||||
</template>
|
||||
<template #item.sign="{ item }" >
|
||||
{{ item.sign }}/{{ item.sexagenary }}
|
||||
</template>
|
||||
<template #item.slot_btn="{ item }">
|
||||
<a :href="'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>
|
||||
<template #item.order_record="{item}">
|
||||
<a :href="'order_record.aspx?userid='+item.num" class="btn btn-outline-secondary btn-sm">報名記錄</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>
|
||||
<v-dialog v-model="print_dialog.show" max-width="400px">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
信眾加入日期管理報表
|
||||
<v-btn icon @click="print_close"><v-icon>mdi-close</v-icon></v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text >
|
||||
<v-row densee class="pt-3" >
|
||||
<v-col :cols="4" >
|
||||
<span class="fs-6 text text-dark">查詢條件</span>
|
||||
</v-col>
|
||||
<v-col :cols="8" >
|
||||
<select class="form-select" v-model="print_conditions" >
|
||||
<option value="yy">年</option>
|
||||
<option value="mm">月</option>
|
||||
<option value="ss">季</option>
|
||||
</select>
|
||||
</v-col>
|
||||
<v-col :cols="2" class="pt-5" >
|
||||
<span class="fs-6 text text-dark">年 *</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" >
|
||||
<v-text-field v-model.number="print_search.year" min="1911" type="number" placeholder="年份必填" />
|
||||
|
||||
</v-col>
|
||||
<v-col :cols="2" class="pt-5" v-if="print_conditions=='mm' ">
|
||||
<span class="fs-6 text text-dark">月</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" v-if="print_conditions=='mm' ">
|
||||
<v-select
|
||||
item-text="text"
|
||||
item-value="val"
|
||||
v-model="print_search.month"
|
||||
:items="select_items.month"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col :cols="2" class="pt-5" v-if="print_conditions=='ss' ">
|
||||
<span class="fs-6 text text-dark">季</span>
|
||||
</v-col>
|
||||
<v-col :cols="10" v-if="print_conditions=='ss' ">
|
||||
<v-select
|
||||
item-text="text"
|
||||
item-value="val"
|
||||
v-model="print_search.season"
|
||||
:items="select_items.season"
|
||||
></v-select>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
<v-row densee class="pt-3" >
|
||||
<v-col :cols="12" class="pt-3 text-center" >
|
||||
<v-btn class="ma-2" color="primary" dark @click="goPrint2" > 列印 </v-btn>
|
||||
<v-btn class="ma-2" color="green" dark @click="print_close" > 取消 </v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<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-if="item.visible===undefined || item.visible==true "></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="search_options"
|
||||
@click:row="search_select"
|
||||
></v-data-table>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</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_number" class="form-control" placeholder="可輸入關鍵字查詢" id="s_f_number" runat="server">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">信眾姓名 </label>
|
||||
<input type="text" v-model="search.u_name" class="form-control" placeholder="可輸入關鍵字查詢" id="s_u_name" runat="server">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">地址 </label>
|
||||
<input type="text" v-model="search.address" class="form-control" placeholder="可輸入關鍵字查詢" id="s_address" runat="server">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">生日</label>
|
||||
<div class="input-group">
|
||||
<input type="date" v-model="search.birthday" class="form-control" id="s_birthday" runat="server">
|
||||
<span class="input-group-text">~</span>
|
||||
<input type="date" v-model="search.birthday2" class="form-control" id="s_birthday2" runat="server" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">國籍</label>
|
||||
<div class="input-group mb-3 d-none" data-search-control="search1" @click="search_show(search_dialog.controls.search1)">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
placeholder="請選擇國籍" value="" id="country_txt">
|
||||
<input type="hidden" v-model="search.country" >
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>
|
||||
<asp:DropDownList ID="s_country" runat="server" CssClass="form-select" v-model="search.country" >
|
||||
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
<select class="form-select" v-model="search.country2" @change="countryChange" id="country2">
|
||||
<option value="">請選擇</option>
|
||||
<option value="0">全部</option>
|
||||
<option value="1">台灣</option>
|
||||
<option value="2">境外(非台灣)</option>
|
||||
</select>
|
||||
</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>
|
||||
267
web/admin/follower/index.aspx.cs
Normal file
267
web/admin/follower/index.aspx.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
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 DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using System.Linq;
|
||||
using static TreeView;
|
||||
|
||||
|
||||
public partial class admin_follower_index : MyWeb.config
|
||||
{
|
||||
public int page = 1;
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
BuildKind();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 分類
|
||||
|
||||
|
||||
|
||||
public void BuildKind()
|
||||
{
|
||||
//國籍
|
||||
s_country.Items.Clear();
|
||||
s_country.Items.Add(new ListItem("請選擇", ""));
|
||||
var qry =_db.countries.AsEnumerable().OrderBy(x => x.range).ThenBy(x => x.name_en).ToList();
|
||||
if (qry.Count > 0)
|
||||
{
|
||||
foreach(var x in qry)
|
||||
s_country.Items.Add(new ListItem(x.name_zh, x.ID));
|
||||
}
|
||||
|
||||
//var qry1 = new TreeView().get_data2(_db.countries.AsEnumerable().Select(o => new TreeItem()
|
||||
//{
|
||||
// kind = o.name_zh,
|
||||
// num = Convert.ToInt32( o.ID),
|
||||
// root = 0,
|
||||
// range = o.range,
|
||||
//}).OrderBy(x => x.range).ThenBy(x => x.kind).ToList(), 0, 0);
|
||||
//if (qry1.Count() > 0)
|
||||
// foreach (var qq in qry1)
|
||||
// s_country.Items.Add(new ListItem(new TreeView().RptDash(qq.Level) + qq.kind, 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 = 10, CustomWidth = true },
|
||||
new Column { Min = 4, Max = 11, Width = 15, CustomWidth = true },
|
||||
new Column { Min = 12, Max = 12, Width = 25, CustomWidth = true },
|
||||
new Column { Min = 13, Max = 13, Width = 8, CustomWidth = true },
|
||||
new Column { Min = 14, Max = 14, Width = 35, CustomWidth = true },
|
||||
new Column { Min = 15, Max = 16, Width = 15, 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 },
|
||||
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 },
|
||||
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 },
|
||||
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 },
|
||||
new Cell() { CellValue = new CellValue("介紹人"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("LINE帳號"), 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 }
|
||||
//,new Cell() { CellValue = new CellValue("SHA"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//查詢要匯出的資料
|
||||
|
||||
//紀錄匯出條件
|
||||
string _query = "";
|
||||
|
||||
var list = searchData(ref _query);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
Model.country country = new Model.country();
|
||||
var tdesc = publicFun.enum_desc<Model.follower.type>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
//新增資料列
|
||||
tr = new Row();
|
||||
string s1, s2, sha;
|
||||
s1= encrypt.DecryptAutoKey(item.phone);
|
||||
s2= encrypt.DecryptAutoKey(item.id_code);
|
||||
sha = encrypt.followerHash(s1, s2);
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(item.f_number), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.u_name), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.sex), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(!isStrNull(item.identity_type)? tdesc[item.identity_type ?? 1] :""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.birthday.HasValue ? ValDate(item.birthday.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.phone)), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.cellphone)), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.refuge_area), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.refuge_name), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.refugedate.HasValue ? ValDate(item.refugedate.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.join_date.HasValue ? ValDate(item.join_date.Value).ToString("yyyy/MM/dd") : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.contactor), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.contactor_phone)), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.blood), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(!isStrNull(item.country) ? item.country1.name_zh : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.address), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.introducer), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.socialid1), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.socialid2), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.reg_time.HasValue ? ValDate(item.reg_time.Value).ToString("yyyy/MM/dd HH:mm:ss") : ""), DataType = CellValues.String }
|
||||
,new Cell() { CellValue = new CellValue(encrypt.DecryptAutoKey(item.id_code)), DataType = CellValues.String }
|
||||
//, new Cell() { CellValue = new CellValue(sha), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
}
|
||||
|
||||
//空一列
|
||||
tr = new Row();
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//匯出資訊
|
||||
string _data = "匯出時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
_data += " " + admin.info.u_id;
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(_data), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
_data = "匯出條件 : " + (!isStrNull(_query) ? _query : "-");
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(_data), 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.Follower, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.f_number + x.u_name).ToList()));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptMsg2("查無資料");
|
||||
}
|
||||
}
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=信眾_data.xlsx");
|
||||
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
}
|
||||
protected List<Model.follower> searchData(ref string _query)
|
||||
{
|
||||
|
||||
//查詢要匯出的資料
|
||||
var qry = _db.followers.AsEnumerable();
|
||||
|
||||
//紀錄匯出條件
|
||||
if (!isStrNull(s_f_number.Value))
|
||||
{
|
||||
qry = qry.Where(o => o.f_number.Contains(s_f_number.Value.Trim()));
|
||||
|
||||
_query += "信眾編號:" + s_f_number.Value.Trim() + "\n";
|
||||
|
||||
}
|
||||
|
||||
if (!isStrNull(s_u_name.Value))
|
||||
{
|
||||
qry = qry.Where(o => o.u_name.Contains(s_u_name.Value.Trim()));
|
||||
|
||||
_query += "信眾姓名:" + s_u_name.Value.Trim() + "\n";
|
||||
|
||||
}
|
||||
if (!isStrNull(s_address.Value))
|
||||
{
|
||||
qry = qry.Where(o => o.address.Contains(s_address.Value.Trim()));
|
||||
_query += "地址:" + s_u_name.Value.Trim() + "\n";
|
||||
}
|
||||
if (!isStrNull(s_birthday.Value) && isDate(s_birthday.Value))
|
||||
{
|
||||
qry = qry.Where(o => o.birthday >= ValDate(s_birthday.Value));
|
||||
_query += "生日(起):" + s_birthday.Value.Trim() + "\n";
|
||||
}
|
||||
if (!isStrNull(s_birthday2.Value) && isDate(s_birthday2.Value))
|
||||
{
|
||||
qry = qry.Where(o => o.birthday < Convert.ToDateTime(s_birthday2.Value).AddDays(1));
|
||||
_query += "生日(訖):" + s_birthday2.Value.Trim() + "\n";
|
||||
}
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
return qry.ToList();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
112
web/admin/follower/order_record.aspx
Normal file
112
web/admin/follower/order_record.aspx
Normal file
@@ -0,0 +1,112 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="order_record.aspx.cs" Inherits="admin_follower_order_record" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
||||
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
|
||||
<div class="ms-3">
|
||||
<span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<div class="container-fluid">
|
||||
<v-data-table
|
||||
:headers="total_record.headers"
|
||||
:items="total_record.items"
|
||||
item-key="id"
|
||||
class="elvation-1">
|
||||
|
||||
</v-data-table>
|
||||
</div>
|
||||
<v-divider class="my-4"></v-divider>
|
||||
<div class="container-fluid">
|
||||
<v-data-table
|
||||
:headers="activity_record.headers"
|
||||
:items="activity_record.items"
|
||||
item-key="id"
|
||||
class="elvation-1">
|
||||
<template #item.slot_detail_btn="{item}">
|
||||
<a :href="'order_record_detail.aspx?orderno='+item.orderno+'&userid='+current_userid" class="btn btn-outline-secondary btn-sm">詳細記錄</a>
|
||||
</template>
|
||||
<template #item.startdate="{item}">
|
||||
{{item.startdate | timeString('YYYY/MM/DD')}}
|
||||
</template>
|
||||
|
||||
<template #item.enddate="{item}">
|
||||
{{item.enddate | timeString('YYYY/MM/DD')}}
|
||||
</template>
|
||||
<template #item.order_item="{item}">
|
||||
{{item.order_item.join(',')}}
|
||||
</template>
|
||||
</v-data-table>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
|
||||
</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 {
|
||||
current_userid: <%= Request["userid"] %>,
|
||||
total_record: {
|
||||
options: { multiSort: false },
|
||||
headers: [
|
||||
{ text: '參加活動次數', value: 'activity_times' },
|
||||
{ text: '總功德金', value: 'total_amount' }
|
||||
],
|
||||
items: [{ activity_times: 0, total_amount: 0}]
|
||||
},
|
||||
activity_record: {
|
||||
options: { multiSort: false },
|
||||
headers: [
|
||||
{ text: '報名單號', value: 'orderno'},
|
||||
{ text: '活動分類', value: 'category' },
|
||||
{ text: '活動名稱', value: 'activityname' },
|
||||
{ text: '開始日期', value: 'startdate' },
|
||||
{ text: '結束日期', value: 'enddate' },
|
||||
{ text: '功德金', value: 'amount' },
|
||||
{ text: '報名項目', value: 'order_item' },
|
||||
{ text: '牌位數量', value: 'pwcount' },
|
||||
{ text: '', value: 'slot_detail_btn' }
|
||||
],
|
||||
items: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getDefault() {
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/follower/totalorderamount?id=' + this.current_userid)
|
||||
.then(res => {
|
||||
this.total_record.items[0].total_amount = res.data.totalamount
|
||||
this.total_record.items[0].activity_times = res.data.activity_times
|
||||
})
|
||||
.catch(error => console.log())
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/follower/orderrecord?id=' + this.current_userid)
|
||||
.then(res => {
|
||||
this.activity_record.items = res.data.list
|
||||
})
|
||||
.catch(error => console.log())
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'total_record.options':{
|
||||
handler() {
|
||||
this.getDefault()
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
26
web/admin/follower/order_record.aspx.cs
Normal file
26
web/admin/follower/order_record.aspx.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using static publicFun;
|
||||
|
||||
public partial class admin_follower_order_record : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
var userid = Request["userid"];
|
||||
if(!string.IsNullOrEmpty(userid))
|
||||
{
|
||||
int _num = Val(userid);
|
||||
var qry = _db.followers.Where(x => x.num == _num).FirstOrDefault();
|
||||
if (qry != null)
|
||||
{
|
||||
username.Text = qry.u_name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
65
web/admin/follower/order_record_detail.aspx
Normal file
65
web/admin/follower/order_record_detail.aspx
Normal file
@@ -0,0 +1,65 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="order_record_detail.aspx.cs" Inherits="admin_follower_order_record_detail" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
||||
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
|
||||
<div class="ms-3">
|
||||
<span>信眾姓名:</span><asp:Literal runat="server" ID="username"></asp:Literal>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<div class="container-fluid">
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="items"
|
||||
item-key="id"
|
||||
class="elevation-1">
|
||||
|
||||
</v-data-table>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
|
||||
</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 {
|
||||
orderno: '<%=Request["orderno"] %>',
|
||||
headers: [
|
||||
{ text: '報名單號', value: 'orderno'},
|
||||
{ text: '牌位名稱', value: 'pwname' },
|
||||
{ text: '牌位編號', value: 'printid' },
|
||||
{ text: '功德金', value: 'price'}
|
||||
],
|
||||
items: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getPwList() {
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/follower/orderreordpwlist?orderno=' + this.orderno)
|
||||
.then(res => {
|
||||
this.items = res.data.list
|
||||
console.log(this.orderno)
|
||||
})
|
||||
.catch(res => console.log())
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.getPwList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
24
web/admin/follower/order_record_detail.aspx.cs
Normal file
24
web/admin/follower/order_record_detail.aspx.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class admin_follower_order_record_detail : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
var userid = Request["userid"];
|
||||
if (!string.IsNullOrEmpty(userid))
|
||||
{
|
||||
int _num = Val(userid);
|
||||
var qry = _db.followers.Where(x => x.num == _num).FirstOrDefault();
|
||||
if (qry != null)
|
||||
{
|
||||
username.Text = qry.u_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
170
web/admin/follower/print.aspx
Normal file
170
web/admin/follower/print.aspx
Normal file
@@ -0,0 +1,170 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="print.aspx.cs" Inherits="admin_follower_print_" %>
|
||||
|
||||
<!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>
|
||||
<script src="https://code.jquery.com/jquery-3.6.2.min.js"></script>
|
||||
<link href="~/js/bootstrap5/bootstrap.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
.fit {
|
||||
width: 1%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table td {
|
||||
padding: 4px 3px;
|
||||
}
|
||||
|
||||
table thead tr th {
|
||||
font-size: 11pt;
|
||||
font-weight: 300;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
table thead tr td {
|
||||
font-size: 11pt;
|
||||
font-weight: 700;
|
||||
border-bottom: 2px solid #333;
|
||||
}
|
||||
|
||||
table tbody tr td {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: A4 landscape
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 5mm 4mm;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
body {
|
||||
padding: 3.5mm 2.5mm;
|
||||
}
|
||||
|
||||
.docs {
|
||||
max-width: 297mm;
|
||||
margin: 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div class="docs">
|
||||
<h1><asp:Literal ID="title" runat="server" Text="信眾查詢列表"></asp:Literal></h1>
|
||||
<table style="repeat-header: yes; repeat-footer: yes; width: 100%;" id="content">
|
||||
<thead>
|
||||
<tr>
|
||||
<asp:Literal ID="footer" runat="server"></asp:Literal>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>信眾姓名</td>
|
||||
<td class="fit">信眾編號</td>
|
||||
<td class="fit">性別</td>
|
||||
<td class="fit">血型</td>
|
||||
<td class="fit">生日</td>
|
||||
<td class="fit">聯絡電話</td>
|
||||
<td class="fit">手機號碼</td>
|
||||
<td>緊急連絡人</td>
|
||||
<td class="fit">緊急連絡電話</td>
|
||||
<td class="fit">身分別</td>
|
||||
<td>皈依道場</td>
|
||||
<td>皈依法名</td>
|
||||
<td class="fit">皈依日期</td>
|
||||
<td class="fit">加入日期</td>
|
||||
<td class="fit">建檔日期</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<asp:Repeater ID="Repeater1" runat="server">
|
||||
<ItemTemplate>
|
||||
<tr>
|
||||
<td>
|
||||
<%# Eval("u_name") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("f_number") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("sex") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("blood") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("birthday") != null? Convert.ToDateTime( Eval("birthday")).ToString("yyyy/MM/dd") : "" %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# encrypt.DecryptAutoKey( Eval("phone")?.ToString()) %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# encrypt.DecryptAutoKey( Eval("cellphone")?.ToString()) %>
|
||||
</td>
|
||||
<td>
|
||||
<%# Eval("contactor") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# encrypt.DecryptAutoKey( Eval("contactor_phone")?.ToString()) %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("u_name") %>
|
||||
</td>
|
||||
<td>
|
||||
<%# Eval("refuge_area") %>
|
||||
</td>
|
||||
<td>
|
||||
<%# Eval("refuge_name") %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("refugedate") != null? Convert.ToDateTime( Eval("refugedate")).ToString("yyyy/MM/dd") : "" %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("join_date") != null? Convert.ToDateTime( Eval("join_date")).ToString("yyyy/MM/dd") : "" %>
|
||||
</td>
|
||||
<td class="fit">
|
||||
<%# Eval("reg_time") != null? Convert.ToDateTime( Eval("reg_time")).ToString("yyyy/MM/dd HH:mm:ss") : "" %>
|
||||
</td>
|
||||
</tr>
|
||||
<%--<tr>
|
||||
<td>
|
||||
<div style="page-break-after: always;"></div>
|
||||
</td>
|
||||
</tr>--%>
|
||||
</ItemTemplate>
|
||||
</asp:Repeater>
|
||||
|
||||
<asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="false">
|
||||
<tr>
|
||||
<td colspan="15" >查無資料</td>
|
||||
</tr>
|
||||
</asp:PlaceHolder>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
<script src="print.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload = function () {
|
||||
window.print();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
155
web/admin/follower/print.aspx.cs
Normal file
155
web/admin/follower/print.aspx.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml.Vml.Office;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class admin_follower_print_ : System.Web.UI.Page
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
MyWeb.admin admin = new MyWeb.admin();
|
||||
|
||||
if ( admin.isLoign())
|
||||
{
|
||||
//var getDelItem = Request["num"].TrimEnd(',').Split(',').Select(s => int.Parse(s));
|
||||
//var prod = _db.followers.AsEnumerable().Where(s => getDelItem.Contains(s.num)).ToList();
|
||||
|
||||
//紀錄匯出條件
|
||||
string _query = "";
|
||||
var qry = _db.followers.AsEnumerable();
|
||||
if (!string.IsNullOrEmpty(Request["f_number"]))
|
||||
{
|
||||
qry = qry.Where(o => o.f_number.Contains(Request["f_number"].Trim()));
|
||||
_query += "信眾編號:" + Request["f_number"].Trim() + "\n";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Request["u_name"]))
|
||||
{
|
||||
qry = qry.Where(o => o.u_name.Contains(Request["u_name"].Trim()));
|
||||
|
||||
_query += "信眾姓名:" + Request["u_name"].Trim() + "\n";
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["address"]))
|
||||
{
|
||||
qry = qry.Where(o => o.address.Contains(Request["address"].Trim()));
|
||||
_query += "地址:" + Request["address"].Trim() + "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["birthday"]))
|
||||
{
|
||||
qry = qry.Where(o => o.birthday >= Convert.ToDateTime(Request["birthday"].Trim()));
|
||||
_query += "生日(起):" + Convert.ToDateTime(Request["birthday"].Trim()).ToString("yyyy/MM/dd") + "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["birthday2"]) )
|
||||
{
|
||||
qry = qry.Where(o => o.birthday < Convert.ToDateTime(Request["birthday2"]).AddDays(1));
|
||||
_query += "生日(訖):" + Convert.ToDateTime(Request["birthday2"].Trim()).ToString("yyyy/MM/dd") + "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["country"]))
|
||||
{
|
||||
qry = qry.Where(o => o.country == Request["country"]);
|
||||
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"" )+ "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["country2"]))
|
||||
{
|
||||
if (Request["country2"] == "1")
|
||||
{
|
||||
qry = qry.Where(o => o.country == "158");
|
||||
}
|
||||
else if (Request["country2"] == "2")
|
||||
{
|
||||
qry = qry.Where(o => o.country != "158");
|
||||
|
||||
}
|
||||
_query += "國家:" + (_db.countries.AsEnumerable().Where(x => x.ID == Request["country2"].ToString()).Select(x => x.name_zh).FirstOrDefault()??"") + "\n";
|
||||
}
|
||||
|
||||
//管理報表
|
||||
if (!string.IsNullOrEmpty(Request["year"]))
|
||||
{
|
||||
//title.Text = "信眾管理報表";
|
||||
qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Year == Convert.ToInt32(Request["year"]) );
|
||||
_query += "年份:" + Request["year"] + "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["month"]))
|
||||
{
|
||||
qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Month == Convert.ToInt32(Request["month"]));
|
||||
_query += "月份:" + Request["month"] + "\n";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Request["season"]) )
|
||||
{
|
||||
|
||||
if (Request["season"] == "1")
|
||||
{
|
||||
qry = qry.Where(o => o.join_date.HasValue)
|
||||
.Where(o => o.join_date.Value.Month == 1 || o.join_date.Value.Month == 2 || o.join_date.Value.Month == 3);
|
||||
}
|
||||
else if (Request["season"] == "2")
|
||||
{
|
||||
qry = qry.Where(o => o.join_date.HasValue)
|
||||
.Where(o => o.join_date.Value.Month == 4 || o.join_date.Value.Month == 5 || o.join_date.Value.Month == 6);
|
||||
}
|
||||
else if (Request["season"] == "3")
|
||||
{
|
||||
qry = qry.Where(o => o.join_date.HasValue)
|
||||
.Where(o => o.join_date.Value.Month == 7 || o.join_date.Value.Month == 8 || o.join_date.Value.Month == 9);
|
||||
}
|
||||
else if (Request["season"] == "4")
|
||||
{
|
||||
qry = qry.Where(o => o.join_date.HasValue)
|
||||
.Where(o => o.join_date.Value.Month == 10 || o.join_date.Value.Month == 11 || o.join_date.Value.Month == 12);
|
||||
}
|
||||
|
||||
|
||||
_query += "季度:" + Request["season"] + "\n";
|
||||
}
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
|
||||
//紀錄匯出條件
|
||||
var prod= qry.ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
Repeater1.DataSource = prod;
|
||||
Repeater1.DataBind();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Print, admin_log.LogViewBtn(prod.Select(x => x.f_number + x.u_name).ToList()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//PlaceHolder1.Visible = true;
|
||||
//Response.Clear();
|
||||
//Response.StatusCode = 404;
|
||||
//Response.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
string _data = "列印時間 : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
_data += "<br>列印帳號 : " + admin.info.u_id;
|
||||
_data += "<br>列印條件 : " + (!string.IsNullOrEmpty(_query) ? _query : "-");
|
||||
footer.Text = _data;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Clear();
|
||||
Response.StatusCode = 404;
|
||||
Response.End();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
134
web/admin/follower/print_bk.aspx
Normal file
134
web/admin/follower/print_bk.aspx
Normal file
@@ -0,0 +1,134 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="print.aspx.cs" Inherits="admin_follower_print_" %>
|
||||
|
||||
<!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>
|
||||
<script src="https://code.jquery.com/jquery-3.6.2.min.js"></script>
|
||||
<link href="~/js/bootstrap5/bootstrap.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
padding: 5mm;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: landscape
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div class="docs">
|
||||
<div class="container-fluid">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<table style="repeat-header: yes; repeat-footer: yes;" id="content">
|
||||
<thead>
|
||||
<tr>
|
||||
<asp:Literal ID="footer" runat="server"></asp:Literal>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<asp:Repeater ID="Repeater1" runat="server">
|
||||
<ItemTemplate>
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">信眾姓名:</label></td>
|
||||
<td colspan="5">
|
||||
<%# Eval("u_name") %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputEmail1" class="form-label mb-0">信眾編號:</label></td>
|
||||
<td>
|
||||
<%# Eval("f_number") %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">性別:</label></td>
|
||||
<td>
|
||||
<%# Eval("sex") %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">血型:</label></td>
|
||||
<td>
|
||||
<%# Eval("blood") %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">生日:</label></td>
|
||||
<td>
|
||||
<%# Eval("birthday") != null? Convert.ToDateTime( Eval("birthday")).ToString("yyyy/MM/dd") : "" %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">聯絡電話:</label></td>
|
||||
<td>
|
||||
<%# encrypt.DecryptAutoKey( Eval("phone")?.ToString()) %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">手機號碼:</label></td>
|
||||
<td>
|
||||
<%# encrypt.DecryptAutoKey( Eval("cellphone")?.ToString()) %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">緊急連絡人:</label></td>
|
||||
<td>
|
||||
<%# Eval("contactor") %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">緊急連絡電話:</label></td>
|
||||
<td>
|
||||
<%# encrypt.DecryptAutoKey( Eval("contactor_phone")?.ToString()) %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">身分別:</label></td>
|
||||
<td>
|
||||
<%# Eval("u_name") %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">皈依道場:</label></td>
|
||||
<td>
|
||||
<%# Eval("refuge_area") %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">皈依法名:</label></td>
|
||||
<td>
|
||||
<%# Eval("refuge_name") %>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<label for="exampleInputPassword1" class="form-label mb-0">皈依日期:</label></td>
|
||||
<td>
|
||||
<%# Eval("refugedate") != null? Convert.ToDateTime( Eval("refugedate")).ToString("yyyy/MM/dd") : "" %>
|
||||
</td>
|
||||
</tr>
|
||||
<%--<tr>
|
||||
<td>
|
||||
<div style="page-break-after: always;"></div>
|
||||
</td>
|
||||
</tr>--%>
|
||||
</ItemTemplate>
|
||||
</asp:Repeater>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="print.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload = function () {
|
||||
//window.print();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
2141
web/admin/follower/reg.aspx
Normal file
2141
web/admin/follower/reg.aspx
Normal file
File diff suppressed because it is too large
Load Diff
441
web/admin/follower/reg.aspx.cs
Normal file
441
web/admin/follower/reg.aspx.cs
Normal file
@@ -0,0 +1,441 @@
|
||||
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 Model;
|
||||
|
||||
public partial class admin_follower_reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public ArrayList _tmp = new ArrayList();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
CallAjax();
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
InitEnumsOptions<Model.follower.type>(identity_type); //身分別
|
||||
//var qry = _db.followers.AsEnumerable();
|
||||
var qry = _db.followers.AsQueryable();
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
if (!isStrNull(Request["leader"]))
|
||||
{
|
||||
int _num = Val(Request["leader"]);
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault(); //家長的資訊
|
||||
if (prod != null)
|
||||
{
|
||||
leader_txt.Value = prod.u_name;
|
||||
leader.Value = prod.num.ToString();
|
||||
address.Text = prod.address;
|
||||
contactor.Text = prod.u_name;
|
||||
if (!isStrNull(prod.phone))
|
||||
{
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
contactor_phone.Text = encrypt.DecryptAutoKey(prod.phone.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//預設國籍
|
||||
country.Value = "158";
|
||||
country_txt.Value = "中華民國(台灣)";
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
if (prod != null)
|
||||
{
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = prod.GetType().GetProperty(obj.ID).GetValue(prod, null);
|
||||
if (!isStrNull(ObjValue))
|
||||
{
|
||||
var textBox = (TextBox)obj;
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
{
|
||||
textBox.Text = Convert.ToDateTime(ObjValue).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else if (!isStrNull(textBox.Attributes["data-encrypt"]) &&
|
||||
ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
|
||||
{
|
||||
textBox.Text = !isStrNull(ObjValue)?
|
||||
encrypt.DecryptAutoKey(ObjValue.ToString()) :"";
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox.Text = ObjValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj is DropDownList && ((DropDownList)obj).SelectedIndex == 0)
|
||||
{
|
||||
var ObjValue = prod.GetType().GetProperty(obj.ID).GetValue(prod, null);
|
||||
if (!isStrNull(ObjValue))
|
||||
{
|
||||
var dropDown = (DropDownList)obj;
|
||||
dropDown.SelectedValue = ObjValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = ex.Message;
|
||||
}
|
||||
|
||||
if (prod.birthday.HasValue)
|
||||
{
|
||||
Literal1.Text = publicFun.chagenDate(prod.birthday.Value);
|
||||
Literal2.Text = Model.follower.chagenSign(prod.birthday.Value);
|
||||
|
||||
}
|
||||
if (prod.leader.HasValue)
|
||||
{
|
||||
leader_txt.Value = prod.follower1.u_name.ToString();
|
||||
leader.Value = prod.leader.ToString();
|
||||
}
|
||||
|
||||
if (!isStrNull(prod.tab))
|
||||
{
|
||||
string[] k = prod.tab.Split(',');
|
||||
for (int i = 0; i < k.Length; i++)
|
||||
{
|
||||
_tmp.Add(k[i].ToString());
|
||||
}
|
||||
tab.Value = prod.tab.ToString();
|
||||
}
|
||||
if (!isStrNull(prod.country))
|
||||
{
|
||||
country_txt.Value = prod.country1.name_zh.ToString();
|
||||
country.Value = prod.country.ToString();
|
||||
}
|
||||
if (prod.reg_time.HasValue)
|
||||
{
|
||||
timePanel1.Visible = true;
|
||||
reg_time.Text= prod.reg_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
|
||||
if ( !isStrNull( prod.admin_log))
|
||||
{
|
||||
timePanel2.Visible = true;
|
||||
modify_time.Text = prod.admin_log;
|
||||
}
|
||||
|
||||
|
||||
edit.Visible = true;
|
||||
goback.Visible = true;
|
||||
add.Visible = false;
|
||||
|
||||
phoneReqStar.Visible = false;
|
||||
cellphoneReqStar.Visible = false;
|
||||
addrReqStar.Visible = false;
|
||||
addressRFV.Visible = false;
|
||||
f_numberReqStar.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 = "";
|
||||
|
||||
if (chk_pro_num(f_number.Text))
|
||||
{
|
||||
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
||||
Model.follower followers = new Model.follower();
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = followers.GetType().GetProperty(obj.ID);
|
||||
var textBox = (TextBox)obj;
|
||||
if (!isStrNull(textBox.Text))
|
||||
{
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
{
|
||||
ObjValue.SetValue(followers, selectDate(textBox));
|
||||
}
|
||||
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"])
|
||||
&& ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
|
||||
{
|
||||
ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjValue.SetValue(followers, ((TextBox)obj).Text.Trim());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjValue.SetValue(followers, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
followers.f_number = follower.generate_f_number(sex.SelectedValue);
|
||||
if (chk_pro_num(followers.f_number))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
followers.f_number = follower.generate_f_number(sex.SelectedValue);
|
||||
if (chk_pro_num(followers.f_number))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "信眾編號重複";
|
||||
return;
|
||||
}
|
||||
}
|
||||
followers.identity_type = Val(identity_type.SelectedValue);
|
||||
if(!isStrNull(leader.Value)) followers.leader = Val(leader.Value);
|
||||
if (!isStrNull(country.Value)) followers.country = country.Value;
|
||||
followers.sex = sex.SelectedValue;
|
||||
|
||||
followers.blood = blood.SelectedValue;
|
||||
followers.reg_time = DateTime.Now;
|
||||
|
||||
//tab
|
||||
followers.tab = tab.Value.Trim(',');
|
||||
|
||||
string ChkNewMsg = Model.follower.ChkNewFollower(followers);
|
||||
|
||||
if(string.IsNullOrEmpty(ChkNewMsg))
|
||||
{
|
||||
_db.followers.Add(followers);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
int _id = followers.num;
|
||||
|
||||
if (_id > 0)
|
||||
{
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Insert, f_number.Text + u_name.Text);
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "錯誤:" + ChkNewMsg;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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.encrypt encrypt = new MyWeb.encrypt();
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
Model.follower followers = _db.followers.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (followers != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = followers.GetType().GetProperty(obj.ID);
|
||||
var textBox = (TextBox)obj;
|
||||
if (!isStrNull(textBox.Text))
|
||||
{
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
ObjValue.SetValue(followers, selectDate(textBox));
|
||||
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"]) && ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
|
||||
ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim()));
|
||||
else
|
||||
ObjValue.SetValue(followers, ((TextBox)obj).Text.Trim());
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(followers, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
followers.identity_type = Val(identity_type.SelectedValue);
|
||||
if (!isStrNull(leader.Value)) followers.leader = Val(leader.Value);
|
||||
if (!isStrNull(country.Value)) followers.country = country.Value;
|
||||
followers.sex = sex.SelectedValue;
|
||||
followers.blood = blood.SelectedValue;
|
||||
followers.tab = tab.Value.Trim(',');
|
||||
followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
followers.follower_hash = encrypt.followerHash(followers.phone, followers.id_code);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Follower, (int)Model.admin_log.Status.Update, f_number.Text + u_name.Text);
|
||||
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "操作失敗";
|
||||
L_msg.Text = ex.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "查無資料";
|
||||
}
|
||||
/*
|
||||
if (chk_pro_num(f_number.Text, Val(Request["num"])))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "信眾編號重複";
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ajax
|
||||
protected void CallAjax()
|
||||
{
|
||||
if (!isStrNull(Request["type"]))
|
||||
{
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/json";
|
||||
AjaxInfo info = new AjaxInfo();
|
||||
info.isOk = false;
|
||||
info.cDate = "";
|
||||
info.sign = "";
|
||||
info.msg = "";
|
||||
|
||||
if (ValString(Request["type"]) == "getTxt")
|
||||
{
|
||||
if (!isStrNull(Request["date"]) && isDate(Request["date"]))
|
||||
{
|
||||
DateTime date = ValDate(Request["date"]);
|
||||
info.isOk = true;
|
||||
|
||||
info.cDate = publicFun.chagenDate(date);
|
||||
info.sign = Model.follower.chagenSign(date);
|
||||
}
|
||||
else
|
||||
info.msg = "參數不正確";
|
||||
|
||||
}
|
||||
else if (ValString(Request["type"]) == "chkNo")
|
||||
{
|
||||
if (!isStrNull(Request["txt"]))
|
||||
{
|
||||
info.isOk = chk_pro_num(ValString(Request["txt"]), !isStrNull(Request["id"]) ? Val(Request["id"]) : 0);
|
||||
if (!info.isOk)
|
||||
info.msg = "信眾編號重複";
|
||||
}
|
||||
else
|
||||
{
|
||||
info.isOk = true;
|
||||
info.msg = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.msg = "參數不正確";
|
||||
}
|
||||
|
||||
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(info));
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
public class AjaxInfo
|
||||
{
|
||||
public bool isOk { get; set; }
|
||||
public string msg { get; set; }
|
||||
public string cDate { get; set; }
|
||||
public string cYear { get; set; }
|
||||
public string sign { get; set; }
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 信眾編號
|
||||
protected bool chk_pro_num(string txt, int num = 0)
|
||||
{
|
||||
bool success = false;
|
||||
var qry = _db.followers.AsEnumerable();
|
||||
qry = qry.Where(q => q.f_number == txt);
|
||||
if (num > 0)
|
||||
qry = qry.Where(q => q.num != num);
|
||||
|
||||
var prod = qry.FirstOrDefault();
|
||||
|
||||
success = (prod == null);
|
||||
|
||||
return success;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user