7644df57d0
2. 新增報名頁面加上取消鍵 3. 優化登入頁面:按下 enter 自動換格/送出 4. 修復新增報名頁面中,不同 search_dialog 中的 page 參數相互連動之異常 5. 修改報名頁面列印格式 6. 修復報名頁面匯出功能 7. 優化報到功能 8. 報名頁面中,無查詢資料時不可點選匯出/列印按鈕 9. 匯出/列印報名管理報表時,若無資料則顯示提示 10. 修復列印管理報表後父視窗 UI 不能點擊的問題 11. 新增報名管理表單匯出 excel 功能 12. 於新增信眾、新增活動頁面加上取消鍵 13. 優化報名管理匯出功能:若篩選條件包含特定活動,自動於「匯出條件」欄位標註活動名稱 14. 優化報名查詢匯出功能:匯出之文件中加上「匯出條件」欄位 15. 修復信眾資料頁面中,使用「生日」作為篩選基準時,後續執行「列印查詢資料」與「匯出查詢資料」會報錯 16. 修復「列印信眾查詢」功能中,電話搜尋欄位未正確帶入查詢條件之異常 17. 解決中文輸入法輸入電話號碼的跳字問題 18. 新增品項管理介面排序功能
185 lines
8.1 KiB
C#
185 lines
8.1 KiB
C#
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
using DocumentFormat.OpenXml.Vml.Office;
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
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.AsQueryable();
|
|
|
|
// ❌ 錯誤寫法: qry = qry.Where(o => o.f_number.Contains(Request["f_number"].Trim()));
|
|
// LINQ to Entities 無法轉換 Request[] 方法,必須先轉換為變數再使用
|
|
string fNumberParam = Request["f_number"]?.Trim();
|
|
if (!string.IsNullOrEmpty(fNumberParam))
|
|
{
|
|
qry = qry.Where(o => o.f_number.Contains(fNumberParam));
|
|
_query += "信眾編號:" + fNumberParam + "\n";
|
|
}
|
|
|
|
string uNameParam = Request["u_name"]?.Trim();
|
|
if (!string.IsNullOrEmpty(uNameParam))
|
|
{
|
|
qry = qry.Where(o => o.u_name.Contains(uNameParam));
|
|
_query += "信眾姓名:" + uNameParam + "\n";
|
|
}
|
|
|
|
string addressParam = Request["address"]?.Trim();
|
|
if (!string.IsNullOrEmpty(addressParam))
|
|
{
|
|
qry = qry.Where(o => o.address.Contains(addressParam));
|
|
_query += "地址:" + addressParam + "\n";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["birthday"]))
|
|
{
|
|
DateTime birthdayParam = Convert.ToDateTime(Request["birthday"].Trim());
|
|
qry = qry.Where(o => o.birthday >= birthdayParam);
|
|
_query += "生日(起):" + birthdayParam.ToString("yyyy/MM/dd") + "\n";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["birthday2"]))
|
|
{
|
|
DateTime birthday2Param = Convert.ToDateTime(Request["birthday2"].Trim());
|
|
var tmpBirthday2Param = birthday2Param.AddDays(1);
|
|
qry = qry.Where(o => o.birthday < tmpBirthday2Param);
|
|
_query += "生日(訖):" + birthday2Param.ToString("yyyy/MM/dd") + "\n";
|
|
}
|
|
// ❌ 錯誤寫法: _db.countries.Where(x => x.ID == Request["country"].ToString())
|
|
// LINQ to Entities 無法轉換 Request[].ToString(),必須先轉換為變數再使用
|
|
string countryId = Request["country"]?.ToString();
|
|
if (!string.IsNullOrEmpty(countryId))
|
|
{
|
|
qry = qry.Where(o => o.country == countryId);
|
|
_query += "國家:" + (_db.countries.Where(x => x.ID == countryId).Select(x => x.name_zh).FirstOrDefault() ?? "") + "\n";
|
|
}
|
|
|
|
string country2Id = Request["country2"]?.ToString();
|
|
if (!string.IsNullOrEmpty(country2Id))
|
|
{
|
|
if (country2Id == "1")
|
|
{
|
|
qry = qry.Where(o => o.country == "158");
|
|
}
|
|
else if (country2Id == "2")
|
|
{
|
|
qry = qry.Where(o => o.country != "158");
|
|
}
|
|
_query += "國家:" + (_db.countries.Where(x => x.ID == country2Id).Select(x => x.name_zh).FirstOrDefault() ?? "") + "\n";
|
|
}
|
|
|
|
string phone_ipcode = Request["phone_idcode"]?.ToString();
|
|
if (!string.IsNullOrEmpty(phone_ipcode) && GlobalVariables.UseSearchKeywords)
|
|
{
|
|
MyWeb.encrypt encrypt = new MyWeb.encrypt();
|
|
string hexSearch = encrypt.ConvertToHex(phone_ipcode.Trim());
|
|
if (!string.IsNullOrEmpty(hexSearch))
|
|
{
|
|
qry = qry.Where(o => o.search_keywords != null && o.search_keywords.Contains(hexSearch));
|
|
_query += "電話/證號:" + phone_ipcode.Trim() + "\n";
|
|
}
|
|
}
|
|
|
|
//管理報表
|
|
if (!string.IsNullOrEmpty(Request["year"]))
|
|
{
|
|
//title.Text = "信眾管理報表";
|
|
int yearParam = Convert.ToInt32(Request["year"]);
|
|
qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Year == yearParam);
|
|
_query += "年份:" + Request["year"] + "\n";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["month"]))
|
|
{
|
|
int monthParam = Convert.ToInt32(Request["month"]);
|
|
qry = qry.Where(o => o.join_date.HasValue && o.join_date.Value.Month == monthParam);
|
|
_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();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
} |