Uploadresume.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Uploadresume.aspx.cs" Inherits="Uploadresume" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
Subj<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Upload<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
</form>
</body>
</html>
Uploadresume.aspx.cs
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;
public partial class Uploadresume : System.Web.UI.Page
{
static String resumelink;
static Int32 Id;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (uploadresume() == true)
{
String query = "insert into tbl_resume(Id,sub,resumefile) values(" + Id + ",'" + TextBox1.Text + "','" + resumelink + "')";
String mycon = (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\forsir\App_Data\Database.mdf;Integrated Security=True");
SqlConnection con = new SqlConnection(mycon);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = query;
cmd.Connection = con;
cmd.ExecuteNonQuery();
Label1.Text = "Your ID is " + Id.ToString() + " for Further Reference .Thanks For sumit Form: Developer. We will Reach at You Soon.";
TextBox1.Text = "";
TextBox1.Text = "";
}
}
private Boolean uploadresume()
{
Boolean resumesaved = false;
if (FileUpload1.HasFile == true)
{
String contenttype = FileUpload1.PostedFile.ContentType;
if (contenttype == "application/pdf")
{
int filesize;
filesize = FileUpload1.PostedFile.ContentLength;
getapplicationid();
FileUpload1.SaveAs(Server.MapPath("~/UploadedResume/") + Id + ".pdf");
resumelink = "UploadedResume/" + Id + ".pdf";
resumesaved = true;
Label1.Text = "";
}
else
{
Label1.Text = "Upload Resume in PDF Format Only";
}
}
else
{
Label1.Text = "Kindly Upload Resume Before Apply in PDF Format";
}
return resumesaved;
}
public void getapplicationid()
{
String mycon = (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\forsir\App_Data\Database.mdf;Integrated Security=True");
SqlConnection scon = new SqlConnection(mycon);
String myquery = "select Id from tbl_resume";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = myquery;
cmd.Connection = scon;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
scon.Close();
if (ds.Tables[0].Rows.Count < 1)
{
Id = 10001;
}
else
{
String mycon1 = (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\forsir\App_Data\Database.mdf;Integrated Security=True");
SqlConnection scon1 = new SqlConnection(mycon1);
String myquery1 = "select max(Id) from tbl_resume";
SqlCommand cmd1 = new SqlCommand();
cmd1.CommandText = myquery1;
cmd1.Connection = scon1;
SqlDataAdapter da1 = new SqlDataAdapter();
da1.SelectCommand = cmd1;
DataSet ds1 = new DataSet();
da1.Fill(ds1);
Id = Convert.ToInt32(ds1.Tables[0].Rows[0][0].ToString());
Id = Id + 1;
scon1.Close();
}
}
}
0 Comments