-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.aspx.cs
133 lines (94 loc) · 3.42 KB
/
message.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class message : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int runNum = 0;
try
{
DropDownList DDL = sender as DropDownList;
DBservices dbs = new DBservices();
List<Message> ListMessage = new List<Message>();
Table MessageTbl = new Table();
ListMessage = dbs.ReadMessage();
MessageTbl.Attributes.Add("class", "CSSTableGenerator");
TableRow CRow = new TableRow();
TableCell CHEAKCell = new TableCell();
CHEAKCell.Text = "סימון למחיקה";
CRow.Cells.Add(CHEAKCell);
TableCell MessageCell = new TableCell();
MessageCell.Text = "הודעות";
CRow.Cells.Add(MessageCell);
MessageTbl.Rows.Add(CRow);
foreach (Message x in ListMessage)
{
TableRow tRow = new TableRow();
TableCell ChekCell = new TableCell();
CheckBox ChekItem = new CheckBox();
ChekItem.ID = "ChekBox" + (runNum++).ToString();
ChekCell.Controls.Add(ChekItem);
tRow.Cells.Add(ChekCell);
TableCell textCell = new TableCell();
textCell.Text = x.Text_message;
tRow.Cells.Add(textCell);
MessageTbl.Rows.Add(tRow);
}
divmessage.Controls.Add(MessageTbl);
Session["MessageTbl"] = MessageTbl;
}
catch (Exception ex)
{
ErrHandler.WriteError(ex.Message);
Response.Write("ארעה שגיאה");
}
}
protected void Delete_Click(object sender, EventArgs e)
{
try
{
int i = 0;
Table TBL = new Table();
TBL = (Table)(Session["MessageTbl"]);
int num = TBL.Rows.Count;
foreach (TableRow x in TBL.Rows)
{
if (((x.Cells[1].Text) != "הודעות") && (i < num - 1))
{
CheckBox itemBox = divmessage.FindControl("ChekBox" + i.ToString()) as CheckBox;
i++;
if (itemBox.Checked == true)
{
DBservices.DeleteMessage(x.Cells[1].Text);
}
}
}
Response.Redirect("message.aspx");
}
catch (Exception ex)
{
ErrHandler.WriteError(ex.Message);
Response.Write("ארעה שגיאה");
}
}
protected void AddMessage_Click(object sender, EventArgs e)
{
DBservices dbs = new DBservices();
try
{
string text_message =TBnewMessage.Text;
dbs.insertNewMessage(text_message);
Response.Write("<script>alert('נוספה הודעה חדשה במערכת');</script>");
Response.Redirect("message.aspx");
}
catch (Exception ex)
{
ErrHandler.WriteError(ex.Message);
Response.Write("קיימת בעיה אנא נסה שנית מאוחר יותר");
}
}
}