forked from hlac/AdvisorBooking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdvisorRegistration.aspx.cs
127 lines (97 loc) · 2.99 KB
/
AdvisorRegistration.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class AdvisorRegistration : System.Web.UI.Page
{
Advisor advisor = new Advisor();
private string s, gender, date;
private int i;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtFName.Focus();
}
}
// for insert values
protected void btnRegister_Click(object sender, EventArgs e)
{
bool correctExtension = false;
advisor.Employee_ID = Convert.ToInt32(txtAdvisorID.Text);
advisor.First_Name = txtFName.Text;
advisor.Last_Name = txtLName.Text;
advisor.Dept_ID = Convert.ToInt32(Dept_DropDownList.SelectedValue);
advisor.EmailId = txtEmailID.Text;
advisor.Password = txtPassword.Text;
string saveFileName = "";
if (FpImg.HasFile)
{
string fileName = FpImg.PostedFile.FileName;
int fileSize = FpImg.PostedFile.ContentLength;
string fileExtension = Path.GetExtension(fileName).ToLower();
string saveFolder = "~/upload"; //Get Folder Path To Save Image
string savePath = saveFolder + fileName + fileExtension;
string[] extensionsAllowed = { ".jpg", ".png" };
if (extensionsAllowed.Contains(fileExtension))
{
correctExtension = true;
}
if (correctExtension)
{
if (fileExtension == ".jpg" || fileExtension == ".png")
{
try
{
string filePath = Server.MapPath("~/Files/Images/" + fileName);
FpImg.PostedFile.SaveAs(filePath);
saveFileName = fileName + fileExtension;
}
catch (Exception ex)
{
}
}
}
}
advisor.Image = saveFileName;
try
{
advisor.SubmitValue();
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"MessageBox",
"alert('Advisor File saved succesffuly');",
true);
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"MessageBox",
"alert('File does not save successfully');",
true);
}
clear();
}
public void clear()
{
txtFName.Text = "";
txtLName.Text = "";
txtAdvisorID.Text = "";
Dept_DropDownList.ClearSelection();
}
protected void txtFName_TextChanged(object sender, EventArgs e)
{
}
protected void txtLName_TextChanged(object sender, EventArgs e)
{
}
protected void txtAdvisorID_TextChanged(object sender, EventArgs e)
{
}
}