155 lines
6.7 KiB
C#
155 lines
6.7 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.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();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
} |