-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeadPage.aspx.cs
124 lines (108 loc) · 3.4 KB
/
LeadPage.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Drawing;
using System.Reflection;
public partial class LeadPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Session["tab"] = "cLead";
}
protected void sendLead_Click(object sender, EventArgs e)
{
if (!this.CheckLead())
{
return;
}
this.SendLead();
}
private void SendLead()
{
UTF8Encoding leadConvertor = new UTF8Encoding();
byte[] le1 = leadConvertor.GetBytes(this.getLeadName.Text);
string name = leadConvertor.GetString(le1);
byte[] le2 = leadConvertor.GetBytes(this.getLeadTitle.Text);
string title = leadConvertor.GetString(le1);
byte[] le3 = leadConvertor.GetBytes(this.getLeadBody.Text);
string body = leadConvertor.GetString(le1);
try
{
Lead l = new Lead()
{
LeadBody = body,
LeadDate = TimeNow.TheTimeNow,
LeadID = this.Master._CoachingDal.GetNextAvailableID("lead"),
LeadMail = this.getLeadMail.Text,
LeadName = name,
LeadTitle = title,
spLeadDate = TimeNow.TheTimeNow.ToShortDateString()
};
this.Master._CoachingDal.Add("lead", l, TimeNow.TheTimeNow);
this.Master._Logger.Log(new AdminException(". Lead " + title +
"Was Successfully Received"), MethodBase.GetCurrentMethod().Name);
this.leadLabel.ForeColor = Color.Blue;
this.leadLabel.Text = "ההודעה נשלחה בהצלחה";
}
catch (Exception e)
{
this.Master._Logger.Error(e, MethodBase.GetCurrentMethod().Name);
this.leadLabel.ForeColor = Color.Red;
this.leadLabel.Text = "אנא נס/י לשלוח שוב";
}
finally
{
this.ClearFields(1);
}
}
protected void cancelLead_Click(object sender, EventArgs e)
{
this.ClearFields(2);
Response.Redirect("Default.aspx");
}
private void ClearFields(int action)
{
if (action <= 0)
{
this.Master._Logger.Error(new AdminException
(". action <= 0"), MethodBase.GetCurrentMethod().Name);
Response.Redirect("Default.aspx?error=true");
}
this.getLeadName.Text = "";
this.getLeadMail.Text = "";
this.getLeadTitle.Text = "";
this.getLeadBody.Text = "";
if (action == 2)
{
this.leadLabel.Text = "";
}
}
private bool CheckLead()
{
if (this.getLeadName.Text == "")
{
this.leadLabel.Text = "אנא הכנס/י את שמך";
return false;
}
if (this.getLeadMail.Text == "")
{
this.leadLabel.Text = "אנא הכנס/י דואר אלקטרוני";
return false;
}
if (this.getLeadTitle.Text == "")
{
this.leadLabel.Text = "אנא הכנס/י נושא";
return false;
}
if (this.getLeadBody.Text == "")
{
this.leadLabel.Text = "אנא הכנס/י הודעה";
return false;
}
return true;
}
}