-
Notifications
You must be signed in to change notification settings - Fork 0
/
MsgAnnocement.aspx.cs
executable file
·148 lines (126 loc) · 6.24 KB
/
MsgAnnocement.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MsgAnnocement : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session.Count == 0 || Session["UserName"].ToString() == "" || Session["UserID"].ToString() == "" || Session["ClassCode"].ToString() == "")
Response.Redirect("../SessionOut.aspx");
TbExpirationDate.Attributes.Add("readonly", "true");
}
private bool CheckData()
{
if (string.IsNullOrEmpty(TbMsg.Text.Trim()))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + Resources.Resource.TipMsgError + "')", true);
return false;
}
if (string.IsNullOrEmpty(TbSubject.Text.Trim()))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + Resources.Resource.TipSubjectError + "')", true);
return false;
}
if (string.IsNullOrEmpty(TbExpirationDate.Text.Trim()))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + Resources.Resource.TipExpirationDate + "')", true);
return false;
}
return true;
}
private void getUserID(ArrayList data)
{
ManageSQL ms = new ManageSQL();
string query = string.Empty;
}
protected void BtnSend_Click(object sender, EventArgs e)
{
if (CheckData())
{
ManageSQL ms = new ManageSQL();
StringBuilder sb = new StringBuilder();
string userid = string.Empty;
IndexFactory receiverCollection = new ConcreateFactory(Session["UserID"].ToString(), Session["Province"].ToString());
if (Session["ClassCode"].ToString().Equals("2"))
{
receiverCollection.prepareReceiver(IndexFactory.DATA_TYPE.FromExpertToMingde);
receiverCollection = new AddMultiReceiver(receiverCollection).CopySet();
receiverCollection.prepareReceiver(IndexFactory.DATA_TYPE.MingdeExpert);
receiverCollection = new AddMultiReceiver(receiverCollection).CopySet();
receiverCollection.prepareReceiver(IndexFactory.DATA_TYPE.SchoolMaster);
receiverCollection = new AddMultiReceiver(receiverCollection).CopySet();
receiverCollection.prepareReceiver(IndexFactory.DATA_TYPE.SystemManager);
receiverCollection = new AddMultiReceiver(receiverCollection).CopySet();
receiverCollection.completeMultiCal();
}
else if (Session["ClassCode"].ToString().Equals("1"))
{
receiverCollection.prepareReceiver(IndexFactory.DATA_TYPE.FromExpertToSchoolMaster);
}
foreach (string[] data in receiverCollection.receiverSet)
{
userid = data[0];
string Query = "insert into MsgSubject (Subjects, Msg, SendTime, NotifyDeadLine) VALUES (N'" +
TbSubject.Text.Trim() + "',N'" +
TbMsg.Text.Trim() + "','" +
DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "','" +
TbExpirationDate.Text + "')";
if (!ms.WriteData(Query, sb))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
if (string.IsNullOrEmpty(sb.ToString()))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
if (Convert.ToInt32(sb.ToString()) == 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
Query = "select top 1 EmailID from MsgSubject order by EmailID desc";
if (!ms.GetOneData(Query, sb))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
Query = "insert into MsgUserData (ReceiverID, ReceiverIsReadMsg, EmailID, SenderID, Annocement) VALUES ('" +
userid + "','" +
"False" + "','" +
sb.ToString() + "','" +
Session["UserID"].ToString() + "','" +
"true" + "')";
if (!ms.WriteData(Query, sb))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
if (string.IsNullOrEmpty(sb.ToString()))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
if (Convert.ToInt32(sb.ToString()) == 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('oops, we have an error.');window.opener=null;window.close();", true);
return;
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + Resources.Resource.TipLetterFinish + "');window.opener=null;window.close();", true);
}
}
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
if(Session["NotifyAll"] != null)
Session.Remove("NotifyAll");
ScriptManager.RegisterStartupScript(this, this.GetType(), "Close", "window.close();", true);
}
}