private void GetActivityDefault() { try { InitQueryBlock(ActivityID.ToString()); //取得活動資訊 ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); ACMS.VO.ActivatyVO myActivatyVO = myActivatyDAO.SelectActivatyByID(ActivityID); //報名截止日後要唯讀 if (myActivatyVO.regist_deadline < DateTime.Today) { MyFormMode = FormViewMode.ReadOnly; //GridView_RegisterPeoplinfo.Enabled = false; PanelCustomFieldA1.Enabled = false; } if (MyFormMode == FormViewMode.Edit) { Wizard1.FindControl("FinishNavigationTemplateContainerID$btnHome").Visible = true; ((Button)Wizard1.FindControl("FinishNavigationTemplateContainerID$FinishButton")).Text = "儲存並發送確認信"; } //活動海報訊息 Literal1.Text = myActivatyVO.activity_info; //活動相關訊息 ObjectDataSource_ActivatyDetails.SelectParameters["id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_UpFiles.SelectParameters["dirName"].DefaultValue = Server.MapPath(Path.Combine("~/UpFiles", ActivityID.ToString())); //報名者資訊 ObjectDataSource_RegisterPersonInfo.SelectParameters["emp_id"].DefaultValue = clsAuth.ID;//預設登入者 //所有報名者資訊 ObjectDataSource_RegisterPeoplenfo.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_RegisterPeoplenfo.SelectParameters["emp_id"].DefaultValue = RegistBy;//由登入者所報名(含登入者本人) //注意事項 Literal_notice.Text = myActivatyVO.notice.Replace("\r\n", "<br />"); FormView_fixA.DataBind(); ACMS.BO.CustomFieldBO myCustFieldBo = new ACMS.BO.CustomFieldBO(); if (myCustFieldBo.SelectByActivity_id(ActivityID).Count > 0) { Session["ShowPanel"] = true; } } catch (Exception ex) { WriteErrorLog("GetDefault", ex.Message, "0"); } //FormView_fixA.FindControl("tr_person_fix1").Visible = (myActivatyVO.is_showperson_fix1 == "Y"); //FormView_fixA.FindControl("tr_person_fix2").Visible = (myActivatyVO.is_showperson_fix2 == "Y"); //(FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2Start") as Label).Text = myActivatyVO.personextcount_min.ToString(); //(FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2End") as Label).Text = myActivatyVO.personextcount_max.ToString(); //RangeValidator myRangeValidator = (FormView_fixA.FindControl("tr_person_fix2").FindControl("chk_txtperson_fix2_3") as RangeValidator); //myRangeValidator.MinimumValue = myActivatyVO.personextcount_min.ToString(); //myRangeValidator.MaximumValue = myActivatyVO.personextcount_max.ToString(); }
protected void GridView_Employee_DataBound(object sender, EventArgs e) { foreach (GridViewRow gr in GridView_Employee.Rows) { if (((LinkButton)gr.FindControl("lbtnSelect")).Enabled==false) { gr.ToolTip = "已經報名"; } } ACMS.BO.ActivatyBO Bo = new ACMS.BO.ActivatyBO(); ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); vo = Bo.SelectActivatyByActivatyID(new Guid(ActivityID)); if (GridView_Employee.Rows.Count == 0) { if (vo.is_grouplimit == "Y") { clsMyObj.ShowMessage("『此活動有限定參加人員,您查詢的部門/人員未在名單內』"); } } }
protected void GridView_Employee_DataBound(object sender, EventArgs e) { foreach (GridViewRow gr in GridView_Employee.Rows) { if (((LinkButton)gr.FindControl("lbtnSelect")).Enabled == false) { gr.ToolTip = "已經報名"; } } ACMS.BO.ActivatyBO Bo = new ACMS.BO.ActivatyBO(); ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); vo = Bo.SelectActivatyByActivatyID(new Guid(ActivityID)); if (GridView_Employee.Rows.Count == 0) { if (vo.is_grouplimit == "Y") { clsMyObj.ShowMessage("『此活動有限定參加人員,您查詢的部門/人員未在名單內』"); } } }
protected void FormView_fixA_DataBound(object sender, EventArgs e) { ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); ACMS.VO.ActivatyVO myActivatyVO = myActivatyDAO.SelectActivatyByID(ActivityID); FormView_fixA.FindControl("tr_person_fix1").Visible = (myActivatyVO.is_showperson_fix1 == "Y"); FormView_fixA.FindControl("lblID").Visible = (myActivatyVO.is_showperson_fix1 == "Y"); FormView_fixA.FindControl("tr_person_fix2").Visible = (myActivatyVO.is_showperson_fix2 == "Y"); FormView_fixA.FindControl("tr_person_fix21").Visible = (myActivatyVO.is_showperson_fix2 == "Y"); (FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2Start") as Label).Text = myActivatyVO.personextcount_min.ToString(); (FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2End") as Label).Text = myActivatyVO.personextcount_max.ToString(); RangeValidator myRangeValidator = (FormView_fixA.FindControl("tr_person_fix2").FindControl("chk_txtperson_fix2_3") as RangeValidator); myRangeValidator.MinimumValue = myActivatyVO.personextcount_min.ToString(); myRangeValidator.MaximumValue = myActivatyVO.personextcount_max.ToString(); if (myActivatyVO.is_showperson_fix1 == "Y" || myActivatyVO.is_showperson_fix2 == "Y") { Session["ShowPanel"] = true; } }
protected void btnOK_Click(object sender, EventArgs e) { string emp_id1 = ""; string emp_id2 = ""; string path = Server.MapPath("~/UpFiles"); // 先檢查是否低於下限 int membersInt = 0; foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == false) { membersInt += 1; } } ACMS.BO.ActivatyBO aBO = new ACMS.BO.ActivatyBO(); ACMS.VO.ActivatyVO aVO = aBO.SelectActivatyByActivatyID(new Guid(activity_id)); if (membersInt < aVO.team_member_min) { // string sdoPostScript = " __doPostBack('" + btnCancelAll1.ClientID + "','1'); "; // string ScriptAll = " if (confirm('取消報名則團隊人數將低於下限,是否要全隊取消報名?')==true) { alert ('1232456'); window.open('http://www.google.com.tw');" + sdoPostScript + "} "; // string ScriptAll = " if (confirm('取消報名則團隊人數將低於下限,是否要全隊取消報名?')==true) { alert ('1232456')} "; //BasePage.RunClientScript (this.Page , ScriptAll); //clsMyObj.ShowMessage("若您取消報名則團隊人數將低於下限,因此系統將取消整個團隊的報名資格,若確定要取消報名,請點選「確定」按鈕後於下個視窗點選「確定取消報名」按鈕!"); btnOK.Visible = false; btnCancelAll.Visible = false; btnOK0.Visible = true; lblMessage.Visible = true; GridView1.Visible = false; mpSearch.Show(); return; } //已換隊長 if (newBoss != "") { foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == true) { if (GridView1.DataKeys[gvr.RowIndex].Value.ToString() == newBoss) { clsMyObj.ShowMessage("您為此隊隊長,請更換隊長,再進行取消!"); this.mpSearch.Show(); return; } } } ACMS.DAO.ActivityTeamMemberDAO myActivityTeamMemberDAO = new ACMS.DAO.ActivityTeamMemberDAO(); myActivityTeamMemberDAO.ChangeBoss(new Guid(activity_id), newBoss, emp_id); } foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == true && (gvr.FindControl("RadioButton1") as RadioButton).Checked == true) { clsMyObj.ShowMessage("您為此隊隊長,請更換隊長,再進行取消!"); this.mpSearch.Show(); return; } } foreach (GridViewRow gvr in GridView1.Rows) { if ((gvr.FindControl("CheckBox1") as CheckBox).Checked == true) { emp_id1 += string.Format("{0},", GridView1.DataKeys[gvr.RowIndex].Value.ToString()); } emp_id2 += string.Format("{0},", GridView1.DataKeys[gvr.RowIndex].Value.ToString()); } if (emp_id1.EndsWith(",")) { emp_id1 = emp_id1.Substring(0, emp_id1.Length - 1); } if (emp_id1 == "" && newBoss == "") { clsMyObj.ShowMessage("您未取消報名也未更換隊長,程式沒有修改任資料!"); return; } MySingleton.AlterRegistResult MyResult = MySingleton.AlterRegistResult.CancelRegistSucess; if (!string.IsNullOrEmpty(emp_id1)) { string aa = string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath).TrimEnd('/'); //MySingleton.AlterRegistResult MyResult = MySingleton.GetMySingleton().AlterRegist_Team(null, null, null, MySingleton.AlterRegistType.CancelRegist, new Guid(activity_id), emp_id1, regist_deadline, cancelregist_deadline, ((Button)sender).Page.Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf('/', 7)) + "/ACMS/WebForm/RegistActivity/RegistedActivityQuery.aspx", path); MyResult = MySingleton.GetMySingleton().AlterRegist_Team(null, null, null, MySingleton.AlterRegistType.CancelRegist, new Guid(activity_id), emp_id1, regist_deadline, cancelregist_deadline, aa + "/Default.aspx", path, "", aa + "/Default.aspx"); //.ResolveUrl("~/WebForm/RegistActivity/RegistedActivityQuery.aspx")); GridView1.DataBind(); } if (CancelTeamRegistClick != null) { this.Visible = false; CancelTeamRegistClick(this, e); } ACMS.DAO.ActivityRegistDAO regDao = new ACMS.DAO.ActivityRegistDAO(); emp_id2 = emp_id2.TrimEnd(','); string members = regDao.AllTeamMemberByMembers(new Guid(activity_id), emp_id2); if (members == "") { clsMyObj.ShowMessage("已達人數下限,目前已取消該隊的報名資格"); return; } if (MyResult == MySingleton.AlterRegistResult.CancelRegistSucess) { if (newBoss == "" && emp_id1 != "") { clsMyObj.ShowMessage("取消報名完成。"); } if (newBoss != "" && emp_id1 != "") { clsMyObj.ShowMessage("更換隊長及取消報名完成。"); } if (newBoss != "" && emp_id1 == "") { clsMyObj.ShowMessage("更換隊長完成。"); } } else if (MyResult == MySingleton.AlterRegistResult.CancelRegistFail_DayOver) { clsMyObj.ShowMessage("取消報名截止日之後無法取消報名!。"); } else if (MyResult == MySingleton.AlterRegistResult.CancelRegistFail) { clsMyObj.ShowMessage("取消報名失敗!。"); } }
//存檔 protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { if (MyFormMode == FormViewMode.ReadOnly) { //ACMS.DAO.LoginDAO myLoginDAO = new ACMS.DAO.LoginDAO(); //string UserData; //string userName = Context.User.Identity.Name; //userName = userName.Substring(userName.IndexOf("\\") + 1); //myLoginDAO.CheckLogin(userName, out UserData); //if (UserData.IndexOf("1") == -1 && UserData.IndexOf("2") == -1)//是活動管理者導回報名狀態查詢 //{ // Response.Redirect("ActivityQuery.aspx"); //} if (Session["History"] == null) { Response.Redirect("ActivityQuery.aspx"); } else { Response.Redirect("HistoryActivityQuery.aspx?type=off"); } } if (txtnotice.Text.Trim() == "") { clsMyObj.ShowMessage("注意事項不可空白"); return; } ACMS.VO.ActivatyVO myActivatyVO = new ACMS.VO.ActivatyVO(); myActivatyVO.id = ActivityID; myActivatyVO.activity_type = ActivityType; myActivatyVO.activity_info = FCKeditor1.Value ; myActivatyVO.org_id = ((DropDownList)FormView1.FindControl("ddlorg_id")).SelectedValue; myActivatyVO.activity_name = ((TextBox)FormView1.FindControl("txtactivity_name")).Text; myActivatyVO.people_type = ((TextBox)FormView1.FindControl("txtpeople_type")).Text; myActivatyVO.activity_startdate = ((WebForm_DatetimePicker)FormView1.FindControl("txtactivity_startdate")).DateTimeValue; myActivatyVO.activity_enddate = ((WebForm_DatetimePicker)FormView1.FindControl("txtactivity_enddate")).DateTimeValue; if (((TextBox)FormView1.FindControl("txtlimit_count")).Text == "" || ((TextBox)FormView1.FindControl("txtlimit_count")).Text == "無上限") { ((TextBox)FormView1.FindControl("txtlimit_count")).Text = "999999"; ((TextBox)FormView1.FindControl("txtlimit2_count")).Text = "0"; } if (((TextBox)FormView1.FindControl("txtlimit2_count")).Text == "" || ((TextBox)FormView1.FindControl("txtlimit2_count")).Text == "無") { ((TextBox)FormView1.FindControl("txtlimit2_count")).Text = "0"; } myActivatyVO.limit_count = Convert.ToInt32(((TextBox)FormView1.FindControl("txtlimit_count")).Text); myActivatyVO.limit2_count = Convert.ToInt32(((TextBox)FormView1.FindControl("txtlimit2_count")).Text); if (((TextBox)FormView1.FindControl("txtteam_member_max")).Text == "") { ((TextBox)FormView1.FindControl("txtteam_member_max")).Text = "0"; } if (((TextBox)FormView1.FindControl("txtteam_member_min")).Text == "") { ((TextBox)FormView1.FindControl("txtteam_member_min")).Text = "0"; } if (ActivityType == "2") { myActivatyVO.team_member_max = Convert.ToInt32(((TextBox)FormView1.FindControl("txtteam_member_max")).Text); myActivatyVO.team_member_min = Convert.ToInt32(((TextBox)FormView1.FindControl("txtteam_member_min")).Text); } myActivatyVO.regist_startdate = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtregist_startdate")).Text); myActivatyVO.regist_deadline = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtregist_deadline")).Text); myActivatyVO.cancelregist_deadline = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtcancelregist_deadline")).Text); myActivatyVO.is_showfile = "Y"; myActivatyVO.is_showprogress = ((CheckBox)FormView1.FindControl("chkis_showprogres")).Checked == true ? "Y" : "N"; myActivatyVO.is_showperson_fix1 = ((CheckBox)FormView2.FindControl("chkis_showperson_fix1")).Checked == true ? "Y" : "N"; myActivatyVO.is_showperson_fix2 = ((CheckBox)FormView2.FindControl("chkis_showperson_fix2")).Checked == true ? "Y" : "N"; if (((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text == "") { ((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text = "0"; } if (((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text == "") { ((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text = "0"; } if (ActivityType == "1") { myActivatyVO.personextcount_max = Convert.ToInt32(((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text); myActivatyVO.personextcount_min = Convert.ToInt32(((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text); } myActivatyVO.is_showidno = ((CheckBox)FormView2.FindControl("chkis_showidno")).Checked == true ? "Y" : "N"; myActivatyVO.is_showremark = ((CheckBox)FormView2.FindControl("chkis_showremark")).Checked == true ? "Y" : "N"; myActivatyVO.remark_name = ((TextBox)FormView2.FindControl("txtremark_name")).Text; myActivatyVO.is_showteam_fix1 = ((CheckBox)FormView2.FindControl("chkis_showteam_fix1")).Checked == true ? "Y" : "N"; myActivatyVO.is_showteam_fix2 = ((CheckBox)FormView2.FindControl("chkis_showteam_fix2")).Checked == true ? "Y" : "N"; if (((TextBox)FormView2.FindControl("txtteamextcount_max")).Text == "") { ((TextBox)FormView2.FindControl("txtteamextcount_max")).Text = "0"; } if (((TextBox)FormView2.FindControl("txtteamextcount_min")).Text == "") { ((TextBox)FormView2.FindControl("txtteamextcount_min")).Text = "0"; } if (ActivityType == "2" && chkis_showteam_fix2.Checked==true) { myActivatyVO.teamextcount_max = Convert.ToInt32(((TextBox)FormView2.FindControl("txtteamextcount_max")).Text); myActivatyVO.teamextcount_min = Convert.ToInt32(((TextBox)FormView2.FindControl("txtteamextcount_min")).Text); } myActivatyVO.is_grouplimit = rblgrouplimit.SelectedValue; myActivatyVO.notice = txtnotice.Text; myActivatyVO.active = "Y"; myActivatyVO.Send1DayMail = ((CheckBox)FormView1.FindControl("cbSend1DayMail")).Checked; myActivatyVO.Send3DayMail = ((CheckBox)FormView1.FindControl("cbSend3DayMail")).Checked; myActivatyVO.SendUnregist = ((CheckBox)FormView1.FindControl("cbSendUnregist")).Checked; try { ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); myActivatyDAO.UpdateActivaty(myActivatyVO); } catch (Exception ex) { clsMyObj.ShowMessage("存檔失敗!"); WriteErrorLog("SaveData", ex.Message, "0"); } Response.Redirect("ActivityEditQuery.aspx"); }
protected void Page_Load(object sender, EventArgs e) { //族群限定的上傳與匯出 (this.Master.Master.FindControl("ScriptManager1") as ScriptManager).RegisterPostBackControl(btnUpload_GroupLimit); (this.Master.Master.FindControl("ScriptManager1") as ScriptManager).RegisterPostBackControl(btnExport_GroupLimit); if (!IsPostBack) { Wizard1.ActiveStepIndex = 0; //取得必要的Session if (Session["form_mode"] == null) { Response.Redirect("ActivityEditQuery.aspx"); } //編輯時須帶入activity_id if (Session["form_mode"].ToString() != "new" && Session["activity_id"] == null) { Response.Redirect("ActivityEditQuery.aspx"); } //取得FormView外的欄位初始值 ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); ACMS.VO.ActivatyVO myActivatyVO = new ACMS.VO.ActivatyVO(); if (Session["form_mode"].ToString() == "new") { //新增模式 MyFormMode = FormViewMode.Insert; ActivityType= Session["activity_type"].ToString(); //新增一筆活動 myActivatyVO.id = ActivityID; myActivatyVO.emp_id = clsAuth.WORK_ID + clsAuth.NATIVE_NAME; myActivatyVO.activity_type = ActivityType; myActivatyDAO.INSERT_NewOne(myActivatyVO); myActivatyVO = myActivatyDAO.SelectActivatyByID(ActivityID); } else { ActivityID= new Guid(Session["activity_id"].ToString()); myActivatyVO = myActivatyDAO.SelectActivatyByID(ActivityID); ActivityType = myActivatyVO.activity_type; if (Session["form_mode"].ToString() == "edit") { //編輯模式 MyFormMode = FormViewMode.Edit; } if (Session["form_mode"].ToString() == "readonly" || myActivatyVO.activity_enddate< DateTime.Now) { //唯讀模式:活動已結束也要是唯讀 MyFormMode = FormViewMode.ReadOnly; //FCKeditor1.Visible = false; FCKeditor1.Visible = false; liactivity_info.Visible = true; rblgrouplimit.Enabled = false; Panel_GroupLimit.Enabled = false; FormView2.Enabled = false; FormView1.Enabled = false; txtnotice.Enabled = false; PanelCustomFieldC.Enabled = false; plCoompanyLimit.Enabled = false; } } if (Session["History"] != null) { FCKeditor1.Visible = false; liactivity_info.Visible = true; } Session["form_mode"] = null; Session["activity_type"] = null; Session["activity_id"] = null; //取得FormView外的欄位初始值 FCKeditor1.Value = myActivatyVO.activity_info; liactivity_info.Text = myActivatyVO.activity_info; rblgrouplimit.SelectedValue = myActivatyVO.is_grouplimit; //if (rblgrouplimit.SelectedValue == "Y")//檢查是否可以運作 //{ // FileUpload_GroupLimit.Enabled = true; // btnUpload_GroupLimit.Enabled = true; // HyperLink1.Enabled = true; // btnAdd_GroupLimit.Enabled = true; // btnExport_GroupLimit.Enabled = true; //} //else //{ // FileUpload_GroupLimit.Enabled = false; // btnUpload_GroupLimit.Enabled = false; // HyperLink1.Enabled = false; // btnAdd_GroupLimit.Enabled = false; // btnExport_GroupLimit.Enabled = false; //} if (rblgrouplimit.SelectedValue == "Y") { FileUpload_GroupLimit.Enabled = true; HyperLink1.Enabled = true; btnAdd_GroupLimit.Enabled = true; btnExport_GroupLimit.Enabled = true; btnUpload_GroupLimit.Enabled = true; Panel_GroupLimit.Visible = true; GridView_GroupLimit .Visible = true; plCoompanyLimit.Visible = true; } else { GridView_GroupLimit.Visible = false; plCoompanyLimit.Visible = false ; } //如果已經過了活動開始報名日,則某些功能需唯讀 if (myActivatyVO.regist_startdate <= DateTime.Now) { FormView1.Enabled = false; FormView2.Enabled = false; PanelCustomFieldC.Enabled = false; rblgrouplimit.Enabled = false; Panel_GroupLimit.Enabled = false; plCoompanyLimit.Enabled = false; } else { if (rblgrouplimit.SelectedValue == "Y")//檢查是否可以運作 { FileUpload_GroupLimit.Enabled = true; HyperLink1.Enabled = true; btnAdd_GroupLimit.Enabled = true; btnExport_GroupLimit.Enabled = true; btnUpload_GroupLimit.Enabled = true; Panel_GroupLimit.Visible = true; plCoompanyLimit.Enabled = true; } else { FileUpload_GroupLimit.Enabled = false; HyperLink1.Enabled = false; btnAdd_GroupLimit.Enabled = false; btnExport_GroupLimit.Enabled = false; btnUpload_GroupLimit.Enabled = false; Panel_GroupLimit.Visible = false; plCoompanyLimit.Enabled = false; } } txtnotice.Text = myActivatyVO.notice; //活動資訊-活動內容 ObjectDataSource_Activaty.SelectParameters["id"].DefaultValue = ActivityID.ToString(); //活動資訊-上傳檔 ObjectDataSource_UpFiles.SelectParameters["dirName"].DefaultValue = Server.MapPath(Path.Combine("~/UpFiles", ActivityID.ToString())); //個人固定欄位 ObjectDataSource_Activaty2.SelectParameters["id"].DefaultValue = ActivityID.ToString(); //自訂欄位 ObjectDataSource_CustomField.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); //族群限定 ObjectDataSource_GroupLimit.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); if (ActivityType == "1") { (this.Master as MyMasterPage).PanelMainGroupingText = "新增個人活動"; (FormView1.FindControl("lbllimit_count") as Literal).Visible = true; (FormView1.FindControl("lbllimit2_count") as Literal).Visible = true; //(FormView1.FindControl("chk_txtlimit_count") as RequiredFieldValidator).ErrorMessage = "活動人數上限必填"; // (FormView1.FindControl("chk_txtlimit_count2") as CompareValidator).ErrorMessage = "活動人數上限必填數字"; //(FormView1.FindControl("chk_txtlimit2_count") as RequiredFieldValidator).ErrorMessage = "活動備取人數必填"; // (FormView1.FindControl("chk_txtlimit2_count2") as CompareValidator).ErrorMessage = "活動備取人數必填數字"; (FormView1.FindControl("trteam_member_max") as System.Web.UI.HtmlControls.HtmlTableRow).Visible = false; (FormView1.FindControl("trteam_member_min") as System.Web.UI.HtmlControls.HtmlTableRow).Visible = false; (FormView2.FindControl("PanelCustomFieldA1") as Panel).Visible = true; (FormView2.FindControl("PanelCustomFieldB1") as Panel).Visible = false; (FormView2.FindControl("PanelCustomFieldB2") as Panel).Visible = false; //PanelCustomFieldC.GroupingText = "個人自訂欄位"; } else { (this.Master as MyMasterPage).PanelMainGroupingText = "新增團隊活動"; (FormView1.FindControl("lbllimit_count_team") as Literal).Visible = true; (FormView1.FindControl("lbllimit2_count_team") as Literal).Visible = true; //(FormView1.FindControl("chk_txtlimit_count") as RequiredFieldValidator).ErrorMessage = "活動隊數上限必填"; // (FormView1.FindControl("chk_txtlimit_count2") as CompareValidator).ErrorMessage = "活動隊數上限必填數字"; //(FormView1.FindControl("chk_txtlimit2_count") as RequiredFieldValidator).ErrorMessage = "活動備取隊數必填"; // (FormView1.FindControl("chk_txtlimit2_count2") as CompareValidator).ErrorMessage = "活動備取隊數必填數字"; (FormView1.FindControl("trteam_member_max") as System.Web.UI.HtmlControls.HtmlTableRow).Visible = true; (FormView1.FindControl("trteam_member_min") as System.Web.UI.HtmlControls.HtmlTableRow).Visible = true; (FormView2.FindControl("PanelCustomFieldA1") as Panel).Visible = false; (FormView2.FindControl("PanelCustomFieldB1") as Panel).Visible = true; (FormView2.FindControl("PanelCustomFieldB2") as Panel).Visible = true; //PanelCustomFieldC.GroupingText = "團隊自訂欄位"; } //andy 從報名狀況查詢進來的即使已經開始報名也要新增限制人員群組//原來活動是要有限制族群的才需要打開限制人群的管制 if (MyFormMode == FormViewMode.ReadOnly && (myActivatyVO.activity_enddate > DateTime.Now) && myActivatyVO.is_grouplimit == "Y" ) { //GridView_GroupLimit.Enabled = false; rblgrouplimit.Enabled = true; Panel_GroupLimit.Enabled = true; GridView_GroupLimit.Columns[3].Visible = false; GridView_GroupLimit.DataBind(); plCoompanyLimit.Enabled = true; } if (myActivatyVO.regist_deadline < DateTime.Today) { // GridView_GroupLimit.Enabled = false; rblgrouplimit.Enabled = false ; Panel_GroupLimit.Enabled = false ; GridView_GroupLimit.Columns[3].Visible = false; GridView_GroupLimit.DataBind(); plCoompanyLimit.Enabled = false ; } } }
//步驟存檔 private void saveStep() { if (MyFormMode == FormViewMode.ReadOnly) { return; } ACMS.VO.ActivatyVO myActivatyVO = new ACMS.VO.ActivatyVO(); myActivatyVO.id = ActivityID; myActivatyVO.activity_type = ActivityType; myActivatyVO.activity_info = FCKeditor1.Value; myActivatyVO.org_id = ((DropDownList)FormView1.FindControl("ddlorg_id")).SelectedValue; myActivatyVO.activity_name = ((TextBox)FormView1.FindControl("txtactivity_name")).Text; myActivatyVO.people_type = ((TextBox)FormView1.FindControl("txtpeople_type")).Text; myActivatyVO.activity_startdate = ((WebForm_DatetimePicker)FormView1.FindControl("txtactivity_startdate")).DateTimeValue; myActivatyVO.activity_enddate = ((WebForm_DatetimePicker)FormView1.FindControl("txtactivity_enddate")).DateTimeValue; if (((TextBox)FormView1.FindControl("txtlimit_count")).Text == "" || ((TextBox)FormView1.FindControl("txtlimit_count")).Text == "無上限") { myActivatyVO.limit_count =999999; myActivatyVO.limit2_count = 0; } if (((TextBox)FormView1.FindControl("txtlimit2_count")).Text == "" || ((TextBox)FormView1.FindControl("txtlimit2_count")).Text == "無") { myActivatyVO.limit2_count = 0; } try { myActivatyVO.limit_count = Convert.ToInt32(((TextBox)FormView1.FindControl("txtlimit_count")).Text); myActivatyVO.limit2_count = Convert.ToInt32(((TextBox)FormView1.FindControl("txtlimit2_count")).Text); } catch {} if (((TextBox)FormView1.FindControl("txtteam_member_max")).Text == "") { ((TextBox)FormView1.FindControl("txtteam_member_max")).Text = "0"; } if (((TextBox)FormView1.FindControl("txtteam_member_min")).Text == "") { ((TextBox)FormView1.FindControl("txtteam_member_min")).Text = "0"; } if (ActivityType == "2") { myActivatyVO.team_member_max = Convert.ToInt32(((TextBox)FormView1.FindControl("txtteam_member_max")).Text); myActivatyVO.team_member_min = Convert.ToInt32(((TextBox)FormView1.FindControl("txtteam_member_min")).Text); } try { myActivatyVO.regist_startdate = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtregist_startdate")).Text); myActivatyVO.regist_deadline = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtregist_deadline")).Text); myActivatyVO.cancelregist_deadline = Convert.ToDateTime(((TextBox)FormView1.FindControl("txtcancelregist_deadline")).Text); } catch { } myActivatyVO.is_showfile = "Y"; myActivatyVO.is_showprogress = ((CheckBox)FormView1.FindControl("chkis_showprogres")).Checked == true ? "Y" : "N"; myActivatyVO.is_showperson_fix1 = ((CheckBox)FormView2.FindControl("chkis_showperson_fix1")).Checked == true ? "Y" : "N"; myActivatyVO.is_showperson_fix2 = ((CheckBox)FormView2.FindControl("chkis_showperson_fix2")).Checked == true ? "Y" : "N"; if (((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text == "") { ((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text = "0"; } if (((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text == "") { ((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text = "0"; } if (ActivityType == "1") { myActivatyVO.personextcount_max = Convert.ToInt32(((TextBox)FormView2.FindControl("txtpersonextcount_max")).Text); myActivatyVO.personextcount_min = Convert.ToInt32(((TextBox)FormView2.FindControl("txtpersonextcount_min")).Text); } myActivatyVO.is_showidno = ((CheckBox)FormView2.FindControl("chkis_showidno")).Checked == true ? "Y" : "N"; myActivatyVO.is_showremark = ((CheckBox)FormView2.FindControl("chkis_showremark")).Checked == true ? "Y" : "N"; myActivatyVO.remark_name = ((TextBox)FormView2.FindControl("txtremark_name")).Text; myActivatyVO.is_showteam_fix1 = ((CheckBox)FormView2.FindControl("chkis_showteam_fix1")).Checked == true ? "Y" : "N"; myActivatyVO.is_showteam_fix2 = ((CheckBox)FormView2.FindControl("chkis_showteam_fix2")).Checked == true ? "Y" : "N"; if (((TextBox)FormView2.FindControl("txtteamextcount_max")).Text == "") { ((TextBox)FormView2.FindControl("txtteamextcount_max")).Text = "0"; } if (((TextBox)FormView2.FindControl("txtteamextcount_min")).Text == "") { ((TextBox)FormView2.FindControl("txtteamextcount_min")).Text = "0"; } if (ActivityType == "2" && chkis_showteam_fix2.Checked == true) { myActivatyVO.teamextcount_max = Convert.ToInt32(((TextBox)FormView2.FindControl("txtteamextcount_max")).Text); myActivatyVO.teamextcount_min = Convert.ToInt32(((TextBox)FormView2.FindControl("txtteamextcount_min")).Text); } myActivatyVO.is_grouplimit = rblgrouplimit.SelectedValue; myActivatyVO.notice = txtnotice.Text; myActivatyVO.active = ""; try { myActivatyVO.Send1DayMail = ((CheckBox)FormView1.FindControl("cbSend1DayMail")).Checked; myActivatyVO.Send3DayMail = ((CheckBox)FormView1.FindControl("cbSend3DayMail")).Checked; myActivatyVO.SendUnregist = ((CheckBox)FormView1.FindControl("cbSendUnregist")).Checked; } catch { } try { ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); myActivatyDAO.UpdateActivaty(myActivatyVO); } catch (Exception ex) { clsMyObj.ShowMessage("存檔失敗!"); WriteErrorLog("SaveData", ex.Message, "0"); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { //======2011/3/30 分為個人及團隊 if (Request.QueryString["Type"] != null) { Session["Type"] = Request.QueryString["Type"]; } if (Session["Type"] == null) { Session["Type"] = "1"; } else { if (Session["Type"].ToString() == "2") { // GridView1.Columns[5].HeaderText = "已報名隊數"; GridView1.Columns[4].HeaderText = "可報名隊數"; GridView1.Columns[5].HeaderText = "已報名隊數"; } } if (Session["EmpID"] != null) { btnQuery.Visible = false; OpenRegisedTeammemberSelector1.Visible = true; OpenRegisedTeammemberSelector1.activity_id = Session["ActID"].ToString(); OpenRegisedTeammemberSelector1.emp_id = Session["EmpID"].ToString(); ACMS.VO.ActivatyVO vo1 = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo1 = new ACMS.BO.ActivatyBO(); Guid id1 = new Guid(Session["ActID"].ToString()); vo1 = bo1.SelectActivatyByActivatyID(id1); OpenRegisedTeammemberSelector1.regist_deadline = vo1.regist_deadline.ToString(); OpenRegisedTeammemberSelector1.cancelregist_deadline = vo1.cancelregist_deadline.ToString(); OpenRegisedTeammemberSelector1.InitDataAndShow(); Session.Remove("ActID"); Session.Remove("EmpID"); return; } //andy if (!(string.IsNullOrEmpty(Request.QueryString["ActID"]))) { ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO(); Guid id = new Guid(Request.QueryString["ActID"]); vo = bo.SelectActivatyByActivatyID(id); txtactivity_name.Text = vo.activity_name; } if (Session["ActID"] != null) { if (!(string.IsNullOrEmpty(Session["ActID"].ToString()))) { ACMS.VO.ActivatyVO vo1 = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo1 = new ACMS.BO.ActivatyBO(); Guid id1 = new Guid(Session["ActID"].ToString()); vo1 = bo1.SelectActivatyByActivatyID(id1); txtactivity_name.Text = vo1.activity_name; } Session.Remove("ActID"); } //=========================================== (this.Master as MyMasterPage).PanelMainGroupingText = "已報名活動查詢"; ObjectDataSource1.SelectParameters["emp_id"].DefaultValue = clsAuth.ID; btnQuery_Click(null, null); } } catch (Exception ex) { WriteErrorLog("PageLoad", ex.Message, "0"); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["EmpID"] != null) { rblActivity_type.SelectedValue = "2"; //btnQuery.Visible = false; OpenRegisedTeammemberSelector1.activity_id = Session["ActID"].ToString(); OpenRegisedTeammemberSelector1.emp_id = Session["EmpID"].ToString(); ACMS.VO.ActivatyVO vo1 = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo1 = new ACMS.BO.ActivatyBO(); Guid id1 = new Guid(Session["ActID"].ToString()); vo1 = bo1.SelectActivatyByActivatyID(id1); OpenRegisedTeammemberSelector1.Visible = true; OpenRegisedTeammemberSelector1.regist_deadline = vo1.regist_deadline.ToString(); OpenRegisedTeammemberSelector1.cancelregist_deadline = vo1.cancelregist_deadline.ToString(); OpenRegisedTeammemberSelector1.InitDataAndShow(); OpenRegisedTeammemberSelector1.IsManager = "1"; Session.Remove("ActID"); Session.Remove("EmpID"); for (int i = 2010; i <= DateTime.Now.Year + 1; i++) { ddlYear.Items.Add(i.ToString()); } ddlYear.SelectedValue = Session["YearNo"].ToString(); ddlMonth.SelectedValue = Session["MonthNo"].ToString(); ddlUnit.SelectedValue = Session["Unit"].ToString(); if (Request["type"] != null && Request["type"] == "off") { (this.Master as MyMasterPage).PanelMainGroupingText = "歷史資料查詢"; GridView1.Columns[7].Visible = false; ObjectDataSource1.SelectParameters["querytype"].DefaultValue = "off"; } else { (this.Master as MyMasterPage).PanelMainGroupingText = "報名狀態查詢"; ObjectDataSource1.SelectParameters["querytype"].DefaultValue = ""; } btnQuery_Click(null, null); return; } if (!IsPostBack) { Session.Remove("History"); for (int i = 2010; i <= DateTime.Now.Year + 1; i++) { ddlYear.Items.Add(i.ToString()); } ddlYear.SelectedValue = DateTime.Now.Year.ToString(); ddlMonth.SelectedValue = DateTime.Now.Month.ToString(); if (Request["type"] != null && Request["type"] == "off") { (this.Master as MyMasterPage).PanelMainGroupingText = "歷史資料查詢"; GridView1.Columns[7].Visible = false; ObjectDataSource1.SelectParameters["querytype"].DefaultValue = "off"; } else { (this.Master as MyMasterPage).PanelMainGroupingText = "報名狀態查詢"; ObjectDataSource1.SelectParameters["querytype"].DefaultValue = ""; } btnQuery_Click(null, null); } } catch (Exception ex) { WriteErrorLog("PageLoad", ex.Message, "0"); } }
//個人報名成功寄信 public static void RegistSuccess(string activity_id, string emp_id, string regist_by, string webPath, string path) { //andy ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO(); string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(','); Guid id = new Guid(activity_id); vo = bo.SelectActivatyByActivatyID(id); MailMessage mail = new MailMessage(); //收件者 string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower(); EmployeeVO empVO = new EmployeeVO(); EMPloyeeDAO empDAO = new EMPloyeeDAO(); empVO = empDAO.getEmployee(emp_id); ACMS.BO.ActivityRegistBO regBO = new ACMS.BO.ActivityRegistBO(); ACMS.VO.ActivityRegistVO regVO = regBO.SelectActivityRegistByPK(id, emp_id); if ((string.Compare(mailtype, "online") != 0)) { foreach (string st1 in smtpto) { mail.To.Add(st1); } } else { mail.To.Add(empVO.OFFICE_MAIL); if (emp_id != regist_by) { empVO = empDAO.getEmployee(regist_by); mail.To.Add(empVO.OFFICE_MAIL); } } //取得附加檔案 ACMS.DAO.UpFilestDAO uDAO = new ACMS.DAO.UpFilestDAO(); List<ACMS.VO.UpFileVO> listUpfileVo = uDAO.SELECT(path + "\\" + activity_id); Attachment data; foreach (ACMS.VO.UpFileVO UFvo in listUpfileVo) { data = new Attachment(UFvo.path); mail.Attachments.Add(data); } mail.Subject = vo.activity_name + ":個人報名成功通知"; //寄件者 mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知"); mail.IsBodyHtml = true; ACMS.DAO.CustomFieldValueDAO myCustFieldValueDAO = new ACMS.DAO.CustomFieldValueDAO(); List<ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = myCustFieldValueDAO.SelectCustomFieldValue(id, emp_id); ACMS.BO.CustomFieldItemBO myCustFieldItemBO = new ACMS.BO.CustomFieldItemBO(); List<ACMS.VO.CustomFieldItemVO> custFieldItemList; string custFieldSt = ""; decimal ttl = 0; string[] FieldIDs; #region "自訂欄位" foreach (CustomFieldValueVO custFieldVO in myCustomFieldValueVOList) { if (custFieldVO.field_control.ToLower() == "textbox") { custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font><br/>" + "<font color='black'> " + custFieldVO.field_value.Trim() + "</font></td></tr>"; } if (custFieldVO.field_control.ToLower() == "textboxlist") { ttl = 0; custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font></td></tr>"; FieldIDs = custFieldVO.field_value.Split(','); custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id); custFieldSt += "<tr><td><table>"; foreach (string fieldID in FieldIDs) { foreach (CustomFieldItemVO custFieldItem in custFieldItemList) if (int.Parse(fieldID) == custFieldItem.field_item_id) { custFieldSt += "<tr><td>" + " " + "<font color='black'>" + custFieldItem.field_item_name + "</font></td><td><font color='black'>$" + custFieldItem.field_item_text + "</font></td></tr>"; ttl += decimal.Parse(custFieldItem.field_item_text); } } custFieldSt += "<tr><td>" + "" + "<font color='Red'> 合計:</font></td><td><font color='Red'>$" + ttl.ToString() + "</font></td></tr>"; custFieldSt += "</table></td></tr>"; } if (custFieldVO.field_control.ToLower() == "checkboxlist") { custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + ":</b></font></td></tr>"; FieldIDs = custFieldVO.field_value.Split(','); custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id); bool doIt = false; foreach (string fieldID in FieldIDs) { foreach (CustomFieldItemVO custFieldItem in custFieldItemList) if (int.Parse(fieldID) == custFieldItem.field_item_id) { if (!doIt) { custFieldSt += ""; } custFieldSt += "<tr><td><font color='black'> " + custFieldItem.field_item_name + custFieldItem.field_item_text + "</font></td></tr>"; doIt = true; } } //' custFieldSt = custFieldSt.Substring(0, custFieldSt.Length - 1); //custFieldSt += "<br/>"; } if (custFieldVO.field_control.ToLower() == "radiobuttonlist") { custFieldSt += "<tr><td>" + "<font color='Blue'><b>." + custFieldVO.field_name + "</b>:</font></td></tr>"; //custFieldSt += "" + "<font color='black'>" + custFieldVO.field_value + "</font>"; FieldIDs = custFieldVO.field_value.Split(','); custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id); foreach (string fieldID in FieldIDs) { foreach (CustomFieldItemVO custFieldItem in custFieldItemList) if (int.Parse(fieldID) == custFieldItem.field_item_id) { custFieldSt += "<tr><td> " + "<font color='black'>" + custFieldItem.field_item_name + custFieldItem.field_item_text + "</font></td></tr>"; } } // custFieldSt += "<br/>"; } } #endregion ACMS.VO.EmployeeVO regByEmpVO = empDAO.getEmployee(regist_by); empVO = empDAO.getEmployee(emp_id); if (custFieldSt != "")//有自訂欄位 { mail.Body = "<table border='1' width='400px'><tr><td style='background:#548DD4;Color:White' align='center' ><b>個人報名成功通知</b></td> </tr><tr><td style ='padding-right :50px;padding-left :50px'>" + "<table style='background:White;Color:Black'><tr><td> </td></tr><tr><td> </td></tr><tr><td>" + "<font color='Blue'><b>.姓名:</b></font><font color='black'>" + empVO.NATIVE_NAME + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.工號:</b></font><font color='black'>" + empVO.WORK_ID + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.活動名稱:</b></font><font color='black'>" + vo.activity_name + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.報名日期:</b></font><font color='black'>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "</font></td></tr><tr><td>"; // + "" + "<font color='Blue'><b>.工號:</b></font>" + empVO.WORK_ID + "<br/>"; if (vo.is_showperson_fix2.ToString().ToUpper() == "Y") { mail.Body += "" + "<font color='Blue'><b>.攜眷人數:</b></font><font color='black'>" + regVO.ext_people.ToString() + "</td></tr><tr><td>"; } mail.Body += "" + "<font color='Blue'><b>" + @"------------------------------------------------------</b></font></td></tr><tr><td> </td></tr><tr><td>"; mail.Body += "" + "<font color='Blue'><b>以下為此次您報名登入資料,敬請確認:</b></font><br/></td></tr>"; mail.Body += "" + custFieldSt; //如果是他人代理報名,則顯示以下文字 if (regist_by != emp_id) { mail.Body += "<tr><td>" + "<font color='Blue'><b>.此活動由</b></font><font color='Black'><u>" + regByEmpVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成報名</b></font></td></tr>"; } mail.Body += "<tr><td>" + "<font color='Blue'><b>.編號:</b></font><Font color='Red'>" + regBO.getSNByActivity(id, emp_id) + "<br/><br/></font></td></tr></table>" + "<tr><td align='center'> <a href='" + webPath + "?Type=1&ActID=" + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by) + "'>" + "報名系統連結</a></td></tr>" + "<tr><td style='background:#548DD4' align='center' > </td> </tr></table>"; } else { mail.Body = "<table border='1' width='400px'><tr><td style='background:#548DD4;Color:White' align='center' ><b>個人報名成功通知</b></td> </tr><tr><td style ='padding-right :50px;padding-left :50px'>" + "<table style='background:White;Color:Black'><tr><td> </td></tr><tr><td> </td></tr><tr><td>" + "<font color='Blue'><b>.姓名:</b></font><font color='black'>" + empVO.NATIVE_NAME + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.工號:</b></font><font color='black'>" + empVO.WORK_ID + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.活動名稱:</b></font><font color='black'>" + vo.activity_name + "</font></td></tr><tr><td>" + "" + "<font color='Blue'><b>.報名日期:</b></font><font color='black'>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "</font></td></tr>"; // + "" + "<font color='Blue'><b>.工號:</b></font>" + empVO.WORK_ID + "<br/>"; if (vo.is_showperson_fix2.ToString().ToUpper() == "Y") { mail.Body += "<tr><td>" + "<font color='Blue'><b>.攜眷人數:</b></font><font color='black'>" + regVO.ext_people.ToString() + "</font></td></tr>"; } mail.Body += "<tr><td>" + "<font color='Blue'><b>" + @"--------------------------------------------</b></font></td></tr><tr><td> </td></tr><tr><td>"; mail.Body += "" + "<font color='Blue'><b>以下為此次您報名登入資料,敬請確認:</b></font><br/></td></tr>"; //如果是他人代理報名,則顯示以下文字 if (regist_by != emp_id) { mail.Body += "<tr><td>" + "<font color='Blue'><b>.此活動由</b></font><font color='Black'><u>" + regByEmpVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成報名</b></font></td></tr>"; } mail.Body += "<tr><td>" + "<font color='Blue'><b>.編號:</b></font><Font color='Red'>" + regBO.getSNByActivity(id, emp_id) + "<br/><br/></font></td></tr></table>" + "<tr><td align='center'> <a href='" + webPath + "?Type=1&ActID=" + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by) + "'>" + "報名系統連結</a></td></tr>" + "<tr><td style='background:#548DD4' align='center' > </td> </tr></table>"; } SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]); string emailAddr = ""; foreach (MailAddress ma in mail.To) { emailAddr += ma.Address + ","; } string ccAddr = ""; foreach (MailAddress ma1 in mail.CC) { ccAddr += ma1.Address + ","; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Insert into MailItems( MailFrom, MailTo, MailServer, MailCC, MailSubject, MailBody, Status, Description) values( @MailFrom, @MailTo, @MailServer, @MailCC, @MailSubject, @MailBody, 0,'')"); SqlParameter[] sqlParams = new SqlParameter[6]; sqlParams[0] = new SqlParameter("@MailServer", SqlDbType.NVarChar); sqlParams[0].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]; sqlParams[1] = new SqlParameter("@MailTo", SqlDbType.NVarChar); sqlParams[1].Value = emailAddr.TrimEnd(','); sqlParams[2] = new SqlParameter("@MailCC", SqlDbType.NVarChar); sqlParams[2].Value = ccAddr.TrimEnd(','); sqlParams[3] = new SqlParameter("@MailSubject", SqlDbType.NVarChar); sqlParams[3].Value = mail.Subject; sqlParams[4] = new SqlParameter("@MailBody", SqlDbType.NVarChar); sqlParams[4].Value = mail.Body; sqlParams[5] = new SqlParameter("@MailFrom", SqlDbType.NVarChar); sqlParams[5].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"]; SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString); SqlHelper.ExecuteNonQuery(myConn, CommandType.Text, sb.ToString(), sqlParams); try { // smtp.Send(mail); } catch (Exception ex) { LogMsg.Log(ex.Message, 5, false); } }
//團隊報名失敗寄信 public static void RegistFail_Team(string activity_id, string emp_id, string regist_by, string webPath) { //andy ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO(); string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(','); Guid id = new Guid(activity_id); vo = bo.SelectActivatyByActivatyID(id); MailMessage mail = new MailMessage(); //收件者 string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower(); if ((string.Compare(mailtype, "online") != 0)) { foreach (string st1 in smtpto) { mail.To.Add(st1); } } else { EmployeeVO empVO = new EmployeeVO(); EMPloyeeDAO empDAO = new EMPloyeeDAO(); if (string.Compare(regist_by, "") != 0) { empVO = empDAO.getEmployee(regist_by); mail.To.Add(empVO.OFFICE_MAIL); } string[] emps = emp_id.Split(','); foreach (string emp in emps) { if (emp != regist_by) { empVO = empDAO.getEmployee(emp); mail.To.Add(empVO.OFFICE_MAIL); } } } mail.Subject = vo.activity_name + ":團隊報名失敗通知"; //寄件者 mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知"); mail.IsBodyHtml = true; mail.Body = "<a href='" + webPath + "?Type=2&ActID=" + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(regist_by) + "'>" + vo.activity_name + ":團隊報名失敗通知</a>"; SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]); try { //smtp.Send(mail); } catch (Exception ex) { LogMsg.Log(ex.Message, 5, false); } }
//個人取消報名寄信 public static void CancelRegist(string activity_id, string emp_id, string cancel_by, string webPath) { //andy ACMS.VO.ActivatyVO vo = new ACMS.VO.ActivatyVO(); ACMS.BO.ActivatyBO bo = new ACMS.BO.ActivatyBO(); string[] smtpto = System.Configuration.ConfigurationManager.AppSettings["SMTPTo"].Split(','); Guid id = new Guid(activity_id); vo = bo.SelectActivatyByActivatyID(id); string[] empids = emp_id.Split(','); foreach (string st in empids) { MailMessage mail = new MailMessage(); //收件者 string mailtype = System.Configuration.ConfigurationManager.AppSettings["MailType"].ToLower(); EmployeeVO empVO = new EmployeeVO(); EmployeeVO empCancelVO = new EmployeeVO(); EMPloyeeDAO empDAO = new EMPloyeeDAO(); empVO = empDAO.getEmployee(emp_id); if ((string.Compare(mailtype, "online") != 0)) { foreach (string st1 in smtpto) { mail.To.Add(st1); } } else { empVO = empDAO.getEmployee(st); mail.To.Add(empVO.OFFICE_MAIL); if (st != cancel_by) { empVO = empDAO.getEmployee(cancel_by); mail.To.Add(empVO.OFFICE_MAIL); } } empVO = empDAO.getEmployee(st); empCancelVO = empDAO.getEmployee(cancel_by); mail.Subject = vo.activity_name + ":取消報名通知"; //寄件者 mail.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"], "報名系統通知"); mail.IsBodyHtml = true; mail.Body = "<table border='1'><tr><td style='background:#548DD4;Color:White' align='center' ><b>取消個人報名通知</b></td> </tr>" + "<tr><td style ='padding-right :50px;padding-left :50px'><br/><br/>" + "" + "<b><font color='Blue'>.姓名:</font></b>" + empVO.NATIVE_NAME + "<br/>" + "" + "<b><font color='Blue'>.工號:</font></b>" + empVO.WORK_ID + "<br/>" + "" + "<b><font color='Blue'>.活動名稱:</font></b>" + vo.activity_name + "<br/>" + "" + "<b><font color='Blue'>.取消日期:</font></b>" + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"); if (cancel_by != emp_id) { mail.Body += "<br/>" + "" + "<b><font color='Blue'>.此活動由</font></b><font color='black'><u>" + empCancelVO.NATIVE_NAME + "</u></font><font color='Blue'><b>代理您完成取消</b></font>"; } mail.Body += "<br/><br/><br/></td></tr><tr><td align='center'><a href='" + webPath + "?Type=1&ActID=" + HttpUtility.UrlEncode(activity_id) + "&RegID=" + HttpUtility.UrlEncode(cancel_by) + "'>" + "報名系統連結</a><br/></td></tr>" + "<tr><td style='background:#548DD4' align='center' > </td> </tr></table>"; SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]); string emailAddr = ""; foreach (MailAddress ma in mail.To) { emailAddr += ma.Address + ","; } string ccAddr = ""; foreach (MailAddress ma1 in mail.CC) { ccAddr += ma1.Address + ","; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Insert into MailItems( MailFrom, MailTo, MailServer, MailCC, MailSubject, MailBody, Status, Description) values( @MailFrom, @MailTo, @MailServer, @MailCC, @MailSubject, @MailBody, 0,'')"); SqlParameter[] sqlParams = new SqlParameter[6]; sqlParams[0] = new SqlParameter("@MailServer", SqlDbType.NVarChar); sqlParams[0].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]; sqlParams[1] = new SqlParameter("@MailTo", SqlDbType.NVarChar); sqlParams[1].Value = emailAddr.TrimEnd(','); sqlParams[2] = new SqlParameter("@MailCC", SqlDbType.NVarChar); sqlParams[2].Value = ccAddr.TrimEnd(','); sqlParams[3] = new SqlParameter("@MailSubject", SqlDbType.NVarChar); sqlParams[3].Value = mail.Subject; sqlParams[4] = new SqlParameter("@MailBody", SqlDbType.NVarChar); sqlParams[4].Value = mail.Body; sqlParams[5] = new SqlParameter("@MailFrom", SqlDbType.NVarChar); sqlParams[5].Value = System.Configuration.ConfigurationManager.AppSettings["SMTPFrom"]; SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString); SqlHelper.ExecuteNonQuery(myConn, CommandType.Text, sb.ToString(), sqlParams); try { // smtp.Send(mail); } catch (Exception ex) { LogMsg.Log(ex.Message, 5, false); } } }