-
Notifications
You must be signed in to change notification settings - Fork 0
/
applyjob.aspx.cs
154 lines (112 loc) · 4.59 KB
/
applyjob.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace JobHunt
{
public partial class applyjob : System.Web.UI.Page
{
SqlConnection con = null;
SqlCommand cmd = null;
SqlDataReader dr = null;
SqlDataAdapter adp = null;
static String CVLink;
private String jobId = "";
int jobapplyid = 0;
int cid = 0;
int CId = 0;
int jobseekerid = 0;
int zero = 0;
protected void Page_Load(object sender, EventArgs e)
{
//System.Diagnostics.Debug.WriteLine(Request.QueryString["ApplyId"]);
//job id
this.jobId = Request.QueryString["ApplyId"];
jobapplyid = Convert.ToInt32(this.jobId);
//if not logged in
if (Session["JName"] == null)
{
Response.Redirect("~/Jobseeker_login.aspx");
}
//getting company id from this.jobapplyid or this.jobid
cid = getCid(jobapplyid);
Session.Add("Cid", cid);
CId = Convert.ToInt32(Session["Cid"].ToString());
//getting jobseeker/applicants id
jobseekerid = Convert.ToInt32(Session["jid"].ToString());
//status
}
protected void want_a_job_Click(object sender, EventArgs e)
{
Response.Redirect("~/wantjob.aspx");
}
public int getCid(int JOBID)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString());
con.Open();
int js;
string query = "select company_id from PostAJob where job_id='" + JOBID+ "' ";
adp = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
adp.Fill(ds);
js = Convert.ToInt32(ds.Tables[0].Rows[0]["company_id"].ToString());
return (js);
}
protected void postjob(object sender, EventArgs e)
{
if (UploadCV() == true)
{
// if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox5.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "")
// {
// MessageBox.Show("Please fill up all the fields");
// Response.Write("<script>alert('Please fill up all the fields');</script>");
// }
// else
// {
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString());
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into ApplyforJob(comapany_id,job_id,jobseeker_id,applystatus,applicant_firstname,applicant_lastname,email,phoneno,city,addres,qualification,experience,CV) values('" + CId + "','" + jobapplyid + "','" + jobseekerid + "','" + zero + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "' ,'" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + CVLink + "' )", con);
cmd1.ExecuteNonQuery();
con.Close();
Response.Redirect("~/wantjob.aspx");
// }
}
}
protected void back(object sender, EventArgs e)
{
Response.Redirect("~/wantjob.aspx");
}
private Boolean UploadCV()
{
Boolean CVsaved = false;
if (FileUpload1.HasFile == true)
{
String contenttype = FileUpload1.PostedFile.ContentType;
if (contenttype == "application/pdf")
{
int filesize;
filesize = FileUpload1.PostedFile.ContentLength;
//postjob();
FileUpload1.SaveAs(Server.MapPath("~/UploadedCV/") + jobapplyid + ".pdf");
CVLink = "UploadedCV/" + jobapplyid + ".pdf";
CVsaved = true;
Label1.Text = "";
}
else
{
Label1.Text = "Upload CV in PDF Format Only";
}
}
else
{
Label1.Text = "Kindly Upload your CV in PDF Format before Applying";
}
return CVsaved;
}
}
}