將全年報名移至獨立頁籤,並新增未報名品項名單列印功能
This commit is contained in:
+15
-397
@@ -155,31 +155,6 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
modify_time.Text = prod.admin_log;
|
||||
}
|
||||
|
||||
if (!isStrNull(prod.is_auto_enroll))
|
||||
{
|
||||
hid_is_auto_enroll.Value = prod.is_auto_enroll.ToString();
|
||||
}
|
||||
|
||||
if (prod.auto_enroll_start_date.HasValue)
|
||||
{
|
||||
hid_auto_enroll_start_date.Value = prod.auto_enroll_start_date.Value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
if (prod.auto_enroll_is_receipt.HasValue)
|
||||
{
|
||||
hid_auto_enroll_is_receipt.Value = prod.auto_enroll_is_receipt.ToString();
|
||||
}
|
||||
|
||||
if (!isStrNull(prod.auto_enroll_receipt_title))
|
||||
{
|
||||
hid_auto_enroll_receipt_title.Value = prod.auto_enroll_receipt_title.ToString();
|
||||
}
|
||||
|
||||
if (!isStrNull(prod.auto_enroll_receipt_address))
|
||||
{
|
||||
hid_auto_enroll_receipt_address.Value = prod.auto_enroll_receipt_address.ToString();
|
||||
}
|
||||
|
||||
edit.Visible = true;
|
||||
goback.Visible = true;
|
||||
add.Visible = false;
|
||||
@@ -260,7 +235,7 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
{
|
||||
ObjValue.SetValue(followers, selectDate(textBox));
|
||||
}
|
||||
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"])
|
||||
else if (!isStrNull(((TextBox)obj).Attributes["data-encrypt"])
|
||||
&& ValString(textBox.Attributes["data-encrypt"]).Equals("Y"))
|
||||
{
|
||||
ObjValue.SetValue(followers, encrypt.EncryptAutoKey(textBox.Text.Trim()));
|
||||
@@ -292,77 +267,12 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
//tab
|
||||
followers.tab = tab.Value.Trim(',');
|
||||
|
||||
if (!isStrNull(hid_is_auto_enroll.Value)) followers.is_auto_enroll = hid_is_auto_enroll.Value == "true";
|
||||
if (!isStrNull(hid_auto_enroll_start_date.Value)) followers.auto_enroll_start_date = Convert.ToDateTime(hid_auto_enroll_start_date.Value);
|
||||
if (!isStrNull(hid_auto_enroll_is_receipt.Value)) followers.auto_enroll_is_receipt = hid_auto_enroll_is_receipt.Value == "true";
|
||||
if (!isStrNull(hid_auto_enroll_receipt_title.Value)) followers.auto_enroll_receipt_title = hid_auto_enroll_receipt_title.Value;
|
||||
if (!isStrNull(hid_auto_enroll_receipt_address.Value)) followers.auto_enroll_receipt_address = hid_auto_enroll_receipt_address.Value;
|
||||
|
||||
string ChkNewMsg = Model.follower.ChkNewFollower(followers);
|
||||
|
||||
if(string.IsNullOrEmpty(ChkNewMsg))
|
||||
{
|
||||
_db.followers.Add(followers);
|
||||
_db.SaveChanges();
|
||||
|
||||
if (hid_is_auto_enroll.Value == "true")
|
||||
{
|
||||
// 信眾自動報名
|
||||
var qry = _db.activities.Where(a => a.startDate_solar >= followers.auto_enroll_start_date).AsQueryable();
|
||||
var activities = qry.ToList();
|
||||
if (activities != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var activity in activities)
|
||||
{
|
||||
Model.pro_order pro_order = new Model.pro_order(); //新增
|
||||
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
|
||||
if (isRegistered) continue; // 重複報名
|
||||
|
||||
pro_order.order_no = createOrderNumber();
|
||||
pro_order.up_time = DateTime.Now;
|
||||
pro_order.reg_time = DateTime.Now;
|
||||
pro_order.keyin1 = "A01";
|
||||
pro_order.f_num = followers.num;
|
||||
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
|
||||
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
|
||||
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
|
||||
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
|
||||
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
|
||||
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
|
||||
pro_order.demo = "";
|
||||
pro_order.customize_data = "";
|
||||
|
||||
try
|
||||
{
|
||||
if (!isStrNull(pro_order.order_no))
|
||||
{
|
||||
_db.pro_order.Add(pro_order);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (prod.Count > 0)
|
||||
//{
|
||||
// var orderNumbers = prod.Select(x => x.order_no).ToList();
|
||||
// var qry = _db.pro_order_detail
|
||||
// .Where(o => orderNumbers.Contains(o.order_no))
|
||||
// }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int _id = followers.num;
|
||||
|
||||
@@ -377,9 +287,9 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Session["LastAddedID"] = followers.f_number;
|
||||
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
else
|
||||
@@ -399,8 +309,8 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "信眾編號重複";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -421,10 +331,6 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
{
|
||||
try
|
||||
{
|
||||
// 記錄修改前的舊值,供後續流程判斷
|
||||
bool old_is_auto_enroll = followers.is_auto_enroll ?? false;
|
||||
DateTime? old_auto_enroll_start_date = followers.auto_enroll_start_date;
|
||||
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
@@ -454,294 +360,6 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
//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);
|
||||
|
||||
if (!isStrNull(hid_is_auto_enroll.Value)) followers.is_auto_enroll = hid_is_auto_enroll.Value == "true";
|
||||
if (!isStrNull(hid_auto_enroll_start_date.Value)) followers.auto_enroll_start_date = Convert.ToDateTime(hid_auto_enroll_start_date.Value);
|
||||
if (!isStrNull(hid_auto_enroll_is_receipt.Value)) followers.auto_enroll_is_receipt = hid_auto_enroll_is_receipt.Value == "true";
|
||||
if (!isStrNull(hid_auto_enroll_receipt_title.Value)) followers.auto_enroll_receipt_title = hid_auto_enroll_receipt_title.Value;
|
||||
if (!isStrNull(hid_auto_enroll_receipt_address.Value)) followers.auto_enroll_receipt_address = hid_auto_enroll_receipt_address.Value;
|
||||
|
||||
// is_auto_enroll 從關 → 開,執行自動報名
|
||||
bool new_is_auto_enroll = followers.is_auto_enroll ?? false;
|
||||
bool isAutoEnrollTurnedOn = !old_is_auto_enroll && new_is_auto_enroll;
|
||||
bool isAutoEnrollTurnedOff = old_is_auto_enroll && !new_is_auto_enroll;
|
||||
|
||||
// auto_enroll_start_date 有變更,確認是否刪除已有訂單
|
||||
bool isStartDateChanged = followers.auto_enroll_start_date != old_auto_enroll_start_date;
|
||||
|
||||
// 關 → 開,執行自動報名
|
||||
if (isAutoEnrollTurnedOn)
|
||||
{
|
||||
var qry = _db.activities.Where(a => a.startDate_solar >= followers.auto_enroll_start_date).AsQueryable();
|
||||
var latestOrder = _db.pro_order.Where(o => o.f_num == followers.num).OrderByDescending(o => o.order_no).FirstOrDefault(); // 最近一次訂單
|
||||
var activities = qry.ToList();
|
||||
if (activities != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var activity in activities)
|
||||
{
|
||||
Model.pro_order pro_order = new Model.pro_order(); //新增
|
||||
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
|
||||
if (isRegistered) continue; // 重複報名
|
||||
|
||||
pro_order.order_no = createOrderNumber();
|
||||
pro_order.up_time = DateTime.Now;
|
||||
pro_order.reg_time = DateTime.Now;
|
||||
pro_order.keyin1 = "A01";
|
||||
pro_order.f_num = followers.num;
|
||||
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
|
||||
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
|
||||
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
|
||||
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
|
||||
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
|
||||
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
|
||||
pro_order.demo = "";
|
||||
pro_order.customize_data = "";
|
||||
|
||||
try
|
||||
{
|
||||
if (!isStrNull(pro_order.order_no))
|
||||
{
|
||||
_db.pro_order.Add(pro_order);
|
||||
_db.SaveChanges();
|
||||
|
||||
// 報名品項(最近一次訂單內容)
|
||||
if (latestOrder != null)
|
||||
{
|
||||
var last_order_details = _db.pro_order_detail.Where(o => o.order_no == latestOrder.order_no).ToList();
|
||||
foreach (var last_order_detail in last_order_details)
|
||||
{
|
||||
|
||||
Model.pro_order_detail order_detail = new Model.pro_order_detail();
|
||||
order_detail.order_no = pro_order.order_no;
|
||||
order_detail.actItem = last_order_detail.actItem;
|
||||
order_detail.parent_num = last_order_detail.parent_num;
|
||||
order_detail.print_id = last_order_detail.print_id;
|
||||
order_detail.f_num = last_order_detail.f_num;
|
||||
order_detail.f_num_tablet = last_order_detail.f_num_tablet;
|
||||
order_detail.address = last_order_detail.address;
|
||||
order_detail.from_id = last_order_detail.from_id;
|
||||
order_detail.from_id_tablet = last_order_detail.from_id_tablet;
|
||||
order_detail.bed_type = last_order_detail.bed_type;
|
||||
order_detail.qty = last_order_detail.qty;
|
||||
order_detail.price = last_order_detail.price;
|
||||
order_detail.start_date = DateTime.Today;
|
||||
order_detail.pay = last_order_detail.pay;
|
||||
order_detail.bed_type = last_order_detail.bed_type;
|
||||
order_detail.keyin1 = last_order_detail.keyin1;
|
||||
order_detail.demo = last_order_detail.demo;
|
||||
order_detail.customize_data = last_order_detail.customize_data;
|
||||
order_detail.printed_files = last_order_detail.printed_files;
|
||||
order_detail.UpdateTime = DateTime.Now;
|
||||
_db.pro_order_detail.Add(order_detail);
|
||||
}
|
||||
}
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 開 → 關,刪除自動報名訂單
|
||||
if (isAutoEnrollTurnedOff && hid_is_delete_all_order.Value == "true")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hid_delete_order_list.Value))
|
||||
{
|
||||
var ids = hid_delete_order_list.Value.TrimEnd(',').Split(',');
|
||||
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
|
||||
if (prod.Count() > 0)
|
||||
{
|
||||
var prod2 = _db.pro_order_detail.Where(q => ids.Contains(q.order_no)).ToList();
|
||||
if (prod2.Count > 0)
|
||||
{
|
||||
foreach (var item2 in prod2)
|
||||
{
|
||||
var prod3 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
|
||||
if (prod3.Count > 0)
|
||||
{
|
||||
foreach (var item3 in prod3)
|
||||
{
|
||||
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
|
||||
if (prod4.Count > 0)
|
||||
{
|
||||
_db.bed_order_detail.RemoveRange(prod4);
|
||||
}
|
||||
}
|
||||
|
||||
_db.bed_order.RemoveRange(prod3);
|
||||
}
|
||||
}
|
||||
|
||||
_db.pro_order_detail.RemoveRange(prod2);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
_db.pro_order.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
if (admin.isLoign())
|
||||
{
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Delete, admin_log.LogViewBtn(prod.Select(x => x.order_no).ToList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isStartDateChanged && old_auto_enroll_start_date.HasValue && !isAutoEnrollTurnedOff)
|
||||
{
|
||||
bool isDateMovedLater = followers.auto_enroll_start_date > old_auto_enroll_start_date; // 變晚
|
||||
bool isDateMovedEarlier = followers.auto_enroll_start_date < old_auto_enroll_start_date; // 變早
|
||||
|
||||
// 日期變晚,刪除指定訂單
|
||||
if (isDateMovedLater && hid_is_delete_all_order.Value == "true")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hid_delete_order_list.Value))
|
||||
{
|
||||
var ids = hid_delete_order_list.Value.TrimEnd(',').Split(',');
|
||||
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
|
||||
if (prod.Count() > 0)
|
||||
{
|
||||
//var prod2 = _db.pro_order_detail.ToList().Where(q => ids.Contains(Convert.ToString(q.order_no))).ToList();
|
||||
var prod2 = _db.pro_order_detail.Where(q => ids.Contains(q.order_no)).ToList();
|
||||
if (prod2.Count > 0)
|
||||
{
|
||||
foreach (var item2 in prod2)
|
||||
{
|
||||
var prod3 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
|
||||
if (prod3.Count > 0)
|
||||
{
|
||||
foreach (var item3 in prod3)
|
||||
{
|
||||
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
|
||||
if (prod4.Count > 0)
|
||||
{
|
||||
_db.bed_order_detail.RemoveRange(prod4);
|
||||
}
|
||||
}
|
||||
|
||||
_db.bed_order.RemoveRange(prod3);
|
||||
}
|
||||
}
|
||||
|
||||
_db.pro_order_detail.RemoveRange(prod2);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
_db.pro_order.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
if (admin.isLoign())
|
||||
{
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Delete, admin_log.LogViewBtn(prod.Select(x => x.order_no).ToList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 日期變早,補報名
|
||||
else if (isDateMovedEarlier && !isAutoEnrollTurnedOn)
|
||||
{
|
||||
var qry = _db.activities.Where(a =>
|
||||
a.startDate_solar >= followers.auto_enroll_start_date &&
|
||||
a.startDate_solar < old_auto_enroll_start_date);
|
||||
var latestOrder = _db.pro_order.Where(o => o.f_num == followers.num).OrderByDescending(o => o.order_no).FirstOrDefault(); // 最近一次訂單
|
||||
var activities = qry.ToList();
|
||||
if (activities != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var activity in activities)
|
||||
{
|
||||
Model.pro_order pro_order = new Model.pro_order(); //新增
|
||||
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
|
||||
if (isRegistered) continue; // 重複報名
|
||||
|
||||
pro_order.order_no = createOrderNumber();
|
||||
pro_order.up_time = DateTime.Now;
|
||||
pro_order.reg_time = DateTime.Now;
|
||||
pro_order.keyin1 = "A01";
|
||||
pro_order.f_num = followers.num;
|
||||
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
|
||||
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
|
||||
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
|
||||
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
|
||||
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
|
||||
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
|
||||
pro_order.demo = "";
|
||||
pro_order.customize_data = "";
|
||||
|
||||
try
|
||||
{
|
||||
if (!isStrNull(pro_order.order_no))
|
||||
{
|
||||
_db.pro_order.Add(pro_order);
|
||||
_db.SaveChanges();
|
||||
|
||||
// 報名品項(最近一次訂單內容)
|
||||
if (latestOrder != null)
|
||||
{
|
||||
var last_order_details = _db.pro_order_detail.Where(o => o.order_no == latestOrder.order_no).ToList();
|
||||
foreach (var last_order_detail in last_order_details)
|
||||
{
|
||||
|
||||
Model.pro_order_detail order_detail = new Model.pro_order_detail();
|
||||
order_detail.order_no = pro_order.order_no;
|
||||
order_detail.actItem = last_order_detail.actItem;
|
||||
order_detail.parent_num = last_order_detail.parent_num;
|
||||
order_detail.print_id = last_order_detail.print_id;
|
||||
order_detail.f_num = last_order_detail.f_num;
|
||||
order_detail.f_num_tablet = last_order_detail.f_num_tablet;
|
||||
order_detail.address = last_order_detail.address;
|
||||
order_detail.from_id = last_order_detail.from_id;
|
||||
order_detail.from_id_tablet = last_order_detail.from_id_tablet;
|
||||
order_detail.bed_type = last_order_detail.bed_type;
|
||||
order_detail.qty = last_order_detail.qty;
|
||||
order_detail.price = last_order_detail.price;
|
||||
order_detail.start_date = DateTime.Today;
|
||||
order_detail.pay = last_order_detail.pay;
|
||||
order_detail.bed_type = last_order_detail.bed_type;
|
||||
order_detail.keyin1 = last_order_detail.keyin1;
|
||||
order_detail.demo = last_order_detail.demo;
|
||||
order_detail.customize_data = last_order_detail.customize_data;
|
||||
order_detail.printed_files = last_order_detail.printed_files;
|
||||
order_detail.UpdateTime = DateTime.Now;
|
||||
_db.pro_order_detail.Add(order_detail);
|
||||
}
|
||||
}
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果啟用 search_keywords 功能,生成並更新 search_keywords
|
||||
if (GlobalVariables.UseSearchKeywords)
|
||||
{
|
||||
@@ -806,16 +424,16 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
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 = "信眾編號重複";
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (chk_pro_num(f_number.Text, Val(Request["num"])))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "信眾編號重複";
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user