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 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 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); } } }
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("取消報名失敗!。"); } }