-
Notifications
You must be signed in to change notification settings - Fork 0
/
Advertising.aspx.cs
executable file
·266 lines (200 loc) · 9.03 KB
/
Advertising.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
public partial class Master_Advertising : System.Web.UI.Page
{
SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["terrible1ConnectionString"].ToString());
int PresentationID = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetDefaultView();
PresentationID = Convert.ToInt32(Request.QueryString.Get("PresentationID"));
}
//for Attendee
DataView dvSql = (DataView)dsAdvertisingObjectives.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView drvSql in dvSql)
{
int aID = Convert.ToInt32(drvSql["AdvertisingObjectivesID"].ToString());
if ((aID == 0))
{
MultiView1.ActiveViewIndex = 0;
}
else
{
MultiView1.ActiveViewIndex = 1;
HiddenFieldAdvertisingObjectivesID.Value = Convert.ToInt32(aID).ToString();
loadAttendee(Convert.ToInt32(HiddenFieldAdvertisingObjectivesID.Value));
}
}
}
protected void BtnCancel_Click(object sender, System.EventArgs e)
{
// Response.Redirect("PresentationMaster.aspx", false);
}
protected void BtnSave_Click(object sender, System.EventArgs e)
{
//save Attendee
PresentationID = Convert.ToInt32(Request.QueryString.Get("PresentationID"));
PreviewButton_Click(null, EventArgs.Empty);
string UserSignature = TextPreview.InnerHtml;
c.Open();
using (SqlCommand cmd = c.CreateCommand())
{
cmd.Parameters.Clear();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_InsertAdvertisingObjectives";
cmd.Parameters.Add("@AdvertisingObjectivesPage", SqlDbType.NVarChar).Value = System.Convert.ToString(UserSignature);
cmd.Parameters.Add("@PresentationID", SqlDbType.Int).Value = PresentationID;
cmd.ExecuteNonQuery();
}
c.Close();
//FileInfo f = new FileInfo(MapPath("~/") + "2.html");
//TextWriter tw = f.CreateText();
//tw.Write(string.Format("<head><title></title></head><body >{0}</body></html>", TextPreview.InnerHtml));
//tw.Close();
PresentationID = Convert.ToInt32(Request.QueryString.Get("PresentationID"));
string pathToCreate = "~/" + Session["CompanyID"] + "/" + PresentationID;
Directory.CreateDirectory(Server.MapPath(pathToCreate));
string fileLoc = Server.MapPath(pathToCreate) + "/" + "ao01.html";
FileStream fs = null;
if (!File.Exists(fileLoc))
{
using (fs = File.Create(fileLoc))
{
}
}
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.Write(string.Format("<!DOCTYPE HTML><html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta name='viewport' content='width=device-width' /><title>Director's Treatment Summary</title><link href='style.css' rel='stylesheet' type='text/css' media='screen'><script src='js/jquery-latest.min.js'></script><link rel='stylesheet' href='css/orangebox.css' type='text/css' /></head><body><div id='wrapper'><div id='dt_summ'>{0}</div></div></body></html>", TextPreview.InnerText));
}
}
// Response.Redirect("PresentationMaster.aspx", false);
}
protected void PreviewButton_Click(object sender, EventArgs e)
{
switch (Selections.SelectedValue)
{
case "Formatted":
TextPreview.InnerHtml = Editor.Text;
break;
case "Html":
TextPreview.InnerText = Editor.Text;
break;
default:
break;
}
}
protected void ClearButton_Click(object sender, EventArgs e)
{
Editor.Text = String.Empty;
}
private void SetDefaultView()
{
MultiView1.ActiveViewIndex = 0;
}
private void loadAttendee(int AdvertisingObjectivesID)
{
AdvertisingObjectives myAdvertisingObjectives;
myAdvertisingObjectives = clsadvertisingObjectives.getAdvertisingObjectives(AdvertisingObjectivesID);
DivContent.InnerHtml = HttpUtility.HtmlDecode(myAdvertisingObjectives.AdvertisingObjectivesPage.ToString());
}
protected void btnEditAttendee_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
EditAttendee(Convert.ToInt32(HiddenFieldAdvertisingObjectivesID.Value));
}
private void EditAttendee(int AdvertisingObjectivesID)
{
AdvertisingObjectives myAdvertisingObjectives;
myAdvertisingObjectives = clsadvertisingObjectives.getAdvertisingObjectives(AdvertisingObjectivesID);
EditorEdit.Text = HttpUtility.HtmlDecode(myAdvertisingObjectives.AdvertisingObjectivesPage.ToString());
}
//for edit
protected void ClearButtonEdit_Click(object sender, EventArgs e)
{
EditorEdit.Text = String.Empty;
MultiView1.ActiveViewIndex = 2;
}
protected void PreviewButtonEdit_Click(object sender, EventArgs e)
{
switch (SelectionsEdit.SelectedValue)
{
case "Formatted":
TextPreviewEdit.InnerHtml = EditorEdit.Text;
break;
case "Html":
TextPreviewEdit.InnerText = EditorEdit.Text;
break;
default:
break;
}
}
protected void BtnUpdateEdit_Click(object sender, System.EventArgs e)
{
//Cover myCover;
//myCover = new Cover();
//myCover.CoverID = System.Convert.ToInt32(txtCoverID.Text);
//myCover.CoverTitle = System.Convert.ToString(txtCoverTitle.Text);
//myCover.CoverPage = System.Convert.ToString(txtCoverPage.Text);
//myCover.CoverFileName = System.Convert.ToString(txtCoverFileName.Text);
//myCover.CreatedBy = System.Convert.ToString(txtCreatedBy.Text);
//myCover.CreatedDate = System.Convert.ToDateTime(calCreatedDate.SelectedDate);
//myCover.ModifiedBy = System.Convert.ToString(txtModifiedBy.Text);
//myCover.ModifiedDate = System.Convert.ToDateTime(calModifiedDate.SelectedDate);
//clscover.Update(myCover);
//Response.Redirect("CoverGrid.aspx", false);
PreviewButtonEdit_Click(null, EventArgs.Empty);
string UserSignature = TextPreviewEdit.InnerHtml;
c.Open();
using (SqlCommand cmd = c.CreateCommand())
{
cmd.Parameters.Clear();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_UpdateAdvertisingObjectives";
cmd.Parameters.Add("@AdvertisingObjectivesPage", SqlDbType.NVarChar).Value = System.Convert.ToString(UserSignature);
cmd.Parameters.Add("@AdvertisingObjectivesID", SqlDbType.Int).Value = HiddenFieldAdvertisingObjectivesID.Value;
cmd.ExecuteNonQuery();
}
c.Close();
PresentationID = Convert.ToInt32(Request.QueryString.Get("PresentationID"));
string pathToCreate = "~/" + Session["CompanyID"] + "/" + PresentationID;
Directory.CreateDirectory(Server.MapPath(pathToCreate));
string fileLoc = Server.MapPath(pathToCreate) + "/" + "ao01.html";
System.IO.File.Delete(fileLoc);
FileStream fs = null;
if (!File.Exists(fileLoc))
{
using (fs = File.Create(fileLoc))
{
}
}
if (File.Exists(fileLoc))
{
using (StreamWriter sw = new StreamWriter(fileLoc))
{
sw.Flush();
sw.Write(string.Format("<!DOCTYPE HTML><html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta name='viewport' content='width=device-width' /><title>Director's Treatment Summary</title><link href='style.css' rel='stylesheet' type='text/css' media='screen'><script src='js/jquery-latest.min.js'></script><link rel='stylesheet' href='css/orangebox.css' type='text/css' /></head><body><div id='wrapper'><div id='dt_summ'>{0}</div></div></body></html>", TextPreviewEdit.InnerText));
}
}
}
protected void BtnCancelEdit_Click(object sender, System.EventArgs e)
{
// Response.Redirect("PresentationMaster.aspx", false);
}
protected void btnCancelEditAttendee_Click(object sender, EventArgs e)
{
// Response.Redirect("PresentationMaster.aspx", false);
}
}