chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MessageWriter.ascx.cs"
|
||||
Inherits="forms_訊息發送_MessageWriter" %>
|
||||
<%@ Register Assembly="WNET" Namespace="Wellan.Web.UI" TagPrefix="cc1" %>
|
||||
<cc1:WLabel ID="WLabel1" runat="server" TextMessageId=""
|
||||
CssClass="pageTitle">訊息發送</cc1:WLabel>
|
||||
<asp:CustomValidator ID="cvMessage" runat="server" Display="None"></asp:CustomValidator>
|
||||
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [BDNUM], [BDNAM] FROM [BDPT]">
|
||||
</asp:SqlDataSource>
|
||||
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
|
||||
SelectCommand="SELECT BPNME + ' (' + BPEML + ')' AS BPNME, BPEML
|
||||
FROM BPSNView
|
||||
WHERE BPDPT=@BPDPT
|
||||
AND (BPEML IS NOT NULL AND BPEML <> '')
|
||||
AND BPEDY IS NULL
|
||||
ORDER BY BPENO" >
|
||||
<SelectParameters>
|
||||
<asp:ControlParameter ControlID="DropDownList1" Name="BPDPT"
|
||||
PropertyName="SelectedValue" />
|
||||
</SelectParameters>
|
||||
</asp:SqlDataSource>
|
||||
<table border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table border="0" cellpadding="3" cellspacing="0">
|
||||
<tr>
|
||||
<td align="right">
|
||||
<asp:Label ID="Label1" runat="server" Text="選擇單位:"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
|
||||
DataTextField="BDNAM" DataValueField="BDNUM" AutoPostBack="True"
|
||||
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
|
||||
</asp:DropDownList>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right">
|
||||
<asp:Label ID="Label2" runat="server" Text="選擇人員:"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Button ID="SelectAll" runat="server" Text="全 選"
|
||||
onclick="SelectAll_Click" />
|
||||
<asp:Button ID="SelectNone" runat="server" Text="全不選"
|
||||
onclick="SelectNone_Click" />
|
||||
<asp:Button ID="btnAdd" runat="server" Text="加入收件人"
|
||||
onclick="btnAdd_Click" />
|
||||
<div style="height: 250px; overflow: auto; border: 1 solid black">
|
||||
<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource2"
|
||||
DataTextField="BPNME" DataValueField="BPEML" CellPadding="0"
|
||||
CellSpacing="0" RepeatColumns="1"
|
||||
RepeatDirection="Horizontal">
|
||||
</asp:CheckBoxList>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" colspan="2" align="right">
|
||||
<asp:Label ID="Label7" runat="server"
|
||||
Text="(人員資料有填寫E-Mail且在職者才會出現)"></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="right">
|
||||
<asp:Label ID="Label3" runat="server" Text="收件人:"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Button ID="btnRemove" runat="server" Text="移除勾選"
|
||||
onclick="btnRemove_Click" />
|
||||
<asp:Button ID="btnClear" runat="server" Text="清除收件人"
|
||||
onclick="btnClear_Click" />
|
||||
<div style="height: 250px; overflow: auto; border: 1 solid black">
|
||||
<asp:CheckBoxList ID="CheckBoxList2" runat="server" CellPadding="0"
|
||||
CellSpacing="0" RepeatColumns="1" RepeatDirection="Horizontal">
|
||||
</asp:CheckBoxList>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<table style="width: 100%;" border="0" cellpadding="3"
|
||||
cellspacing="0">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<asp:Button ID="Button4" runat="server" Text="發送"
|
||||
onclick="Button4_Click" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label4" runat="server" Text="主旨:"></asp:Label>
|
||||
</td>
|
||||
<td width="500px">
|
||||
<asp:TextBox ID="txtSubject" runat="server" Columns="10"
|
||||
Width="100%"></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<asp:Label ID="Label5" runat="server" Text="內文:"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtBody" runat="server" Columns="10"
|
||||
Rows="30" TextMode="MultiLine" Width="100%"></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Label ID="Label6" runat="server" Text="(請勿輸入 HTML 內容)"></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
|
||||
public partial class forms_訊息發送_MessageWriter : Wellan.Web.UI.WUserControlBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
DropDownList1.DataBind();
|
||||
CheckBoxList1.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
SqlDataSource1.ConnectionString = ConnectionString;
|
||||
SqlDataSource2.ConnectionString = ConnectionString;
|
||||
}
|
||||
|
||||
protected void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckBoxList1.DataBind();
|
||||
}
|
||||
|
||||
protected void SelectAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ListItem item in CheckBoxList1.Items)
|
||||
item.Selected = true;
|
||||
}
|
||||
|
||||
protected void SelectNone_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ListItem item in CheckBoxList1.Items)
|
||||
item.Selected = false;
|
||||
}
|
||||
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ListItem item in CheckBoxList1.Items)
|
||||
{
|
||||
if (item.Selected)
|
||||
{
|
||||
if (CheckBoxList2.Items.FindByValue(item.Value) == null)
|
||||
CheckBoxList2.Items.Add(new ListItem(item.Text, item.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = CheckBoxList2.Items.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (CheckBoxList2.Items[i].Selected)
|
||||
CheckBoxList2.Items.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
CheckBoxList2.Items.Clear();
|
||||
}
|
||||
|
||||
protected void Button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
MailMessage message = new MailMessage();
|
||||
//SmtpClient sc = new SmtpClient();
|
||||
message.Subject = txtSubject.Text;
|
||||
|
||||
foreach (ListItem item in CheckBoxList2.Items)
|
||||
message.To.Add(new MailAddress(item.Value, item.Text));
|
||||
|
||||
message.BodyEncoding = Encoding.UTF8;
|
||||
message.IsBodyHtml = false;
|
||||
message.Body = txtBody.Text;
|
||||
|
||||
Wellan.Service.WMailSender.GetInstance().Send(message, String.Format("訊息發送 主旨:{0}", txtSubject.Text));
|
||||
//sc.Send(message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user