When we think about a new project which is going to start, we first try to know which architecture will be useful and how to implement it with this project. So, architecture is the main concern before starting to develop new application. We divide our application into different tiers architecture or layers architecture, which helps developers to work easily with different components on the same time.
What we will learn with this article
- Three Tiers vs. Three Layers
- Details about Three Layers Architecture
- How to implement the Three Layers Architecture with ASP.NET
There are lots of misconception between developers that both 3 Tier Architecture and 3 Layers Architecture, are same. But this is not true and both are totally different to each other. So, first we need to know the difference between both and after that we will proceed with how to implement 3 Layers Architecture.
Three Tiers vs. Three Layers Architecture
Tier
Tier is basically a physical separation of the project components. It can be on different system or machine. Each tier has their own responsibility to perform their own task. For example, there is one tier which can get the data from database, so it can be some service or some APIs and it can also be on different machines or systems.
Other tier gets the data from first tier [services or APIs or some data access logic] and performs some business login on this and modifies the data before presenting to users.
And the other one or last tier can be used to show the data to user on UI.
So, this is not necessary that tier architecture must be 3 Tiers Architecture. It can be n-tiers architecture. Tiers Architecture is used when we are creating a broad range or enterprise application which has multiple module and using some third party service or APIs.
Layer
Layer is actually a logical separation of the component of the project. It has different layers like Data Access Layer, Business Access Layer and User Interface. You can also create some other layers as per your project requirement.
Details about Three Layers Architecture
As we have learned that layer architecture is basically a logical separation of the component on the same machine, so Three Layers Architecture has mainly 3 layers and these are Data Access Layer, Business Access Layer and Presentation Layer or User Interface.
Data Access Layer
It is the component of the architecture which has responsibility to handle data access logic. It stores the logic to access data from database or to add the data into the database. It contains all the logic to perform CRUD operation with database, xml or any other data source.
Business Access Layer
It is the component of the architecture where we define the business logic of the application. It is basically a bridge between Data Access Layer and Presentation Layer. So, responsibility of business access layer is that it performs some logic on the data which is coming from Data Access Layer and pass it to Presentation Layer.
Presentation Layer
It is nothing but only a user interface, which is used to show the data coming from business access layer. It is graphical user interface of the application which is used for interaction to users.
See the following image which will help you to understand the three layers architecture.
How to Implement the Three Layers Architecture with ASP.NET So, the time is to implement the actual code with ASP.NET application. We will go through one by one every layer and understand the code implementation.
Data Access Layer
Here we can add database connection logic, database CRUD operation activity like Insert, Update, Delete and Select with database. In this layer, we check the connection is open or not, how to manage database connection, how to get data from database and add data into database. We can also handle exception if any error occurred on the time of database activities performed.
In the above code, we can see that data access logic has defined in that way, we don’t need to write any other code to perform database access logic [you can also write code for update and delete].
Business Access Layer
This layer performs all the business logic before passing the data to Presentation Layer. The data which is coming from Data Access Layer, might not be valid or user friendly, we need to modify the data before representing to user. So, the complete business logic performed inside the Business Access Layer.
- using System;
- using System.Data;
- using System.Data.Odbc;
-
-
-
-
- public class career
- {
- DBAccess db;
- OdbcDataReader _objDtReader = null;
- public career()
- {
-
-
-
- }
- public long _careerID;
- private string _name;
- private string _firstName;
- private string _lastName;
- private string _emailID;
- private string _mobileNo;
- private string _dateOfBirth;
- private string _gender;
- private string _funcationalArea;
- private string _skills;
- private string _experience;
- private string _location;
- private string _resume;
- private int _jobID;
- private string _createdDate;
-
- public long CareerID
- {
- get { return _careerID; }
- set { _careerID = value; }
- }
-
- public string Name
- {
- get { return _name; }
- set { _name = value; }
- }
- public string FirstName
- {
- get { return _firstName; }
- set { _firstName = value; }
- }
- public string LastName
- {
- get { return _lastName; }
- set { _lastName = value; }
- }
- public string EmailID
- {
- get { return _emailID; }
- set { _emailID = value; }
- }
- public string MobileNo
- {
- get { return _mobileNo; }
- set { _mobileNo = value; }
-
- }
- public string DateOfBirth
- {
- get { return _dateOfBirth; }
- set { _dateOfBirth = value; }
- }
- public string Gender
- {
- get { return _gender; }
- set { _gender = value; }
-
- }
- public string FunctionalArea
- {
- get { return _funcationalArea; }
- set { _funcationalArea = value; }
- }
- public string Skills
- {
- get { return _skills; }
- set { _skills = value; }
- }
- public string Experience
- {
- get { return _experience; }
- set { _experience = value; }
- }
- public string Locatin
- {
- get { return _location; }
- set { _location = value; }
- }
- public string Resume
- {
- get { return _resume; }
- set{_resume=value;}
- }
- public int JobID
- {
- get { return _jobID; }
- set { _jobID = value; }
- }
- public string CreatedDate
- {
- get { return _createdDate; }
- set { _createdDate = value; }
- }
-
- public int addCareerDetailsByVisiter(career objClsCareer)
- {
- db = new DBAccess();
- int result = db.Insert("Call Insert_Career_Details('"+FirstName+"','"+LastName+"','"+EmailID+"','"+MobileNo+"','"+DateOfBirth+"','"+Gender+"','"+FunctionalArea+"','"+Skills+"','"+Experience+"','"+Locatin+"','"+Resume+"','"+JobID+"')");
- return result;
- }
- public DataTable viewAppliedJob(career objClsCareer)
- {
-
- db = new DBAccess();
- DataTable _dt = new DataTable();
- _dt.Columns.Add("Career_ID");
- _dt.Columns.Add("Created_Date");
- _dt.Columns.Add("Name");
- _dt.Columns.Add("City");
- _dt.Columns.Add("Experience");
- _dt.Columns.Add("Functional_Area");
- _dt.Columns.Add("Mobile_No");
- _dt.Columns.Add("Resume");
-
- _objDtReader = db.ExecuterReader("Call select_applied_job()");
- DataRow _dr = null;
- while (_objDtReader.Read())
- {
- _dr = _dt.NewRow();
- _dr["Career_ID"] = Convert.ToInt32(_objDtReader["career_id"]);
- _dr["Created_Date"] =Convert.ToDateTime(_objDtReader["created_date"]).ToString("dd/MMM/yy");
- _dr["Name"]=string.Concat(Convert.ToString(_objDtReader["first_name"])," ",Convert.ToString(_objDtReader["last_name"]));
- _dr["City"] = _objDtReader["city"];
- _dr["Experience"] = Convert.ToString(_objDtReader["Experience"]);
- _dr["Functional_Area"] = Convert.ToString(_objDtReader["functional_Area"]);
- _dr["mobile_no"] = _objDtReader["mobile_no"];
- _dr["resume"] ="../Resume/"+ Convert.ToString(_objDtReader["resume"]);
- _dt.Rows.Add(_dr);
-
- } _objDtReader.Close();
- return _dt;
- }
-
- public DataTable viewParticularAppliedJob(career objClsCareer)
- {
-
- db = new DBAccess();
- DataTable _dt = new DataTable();
- _dt.Columns.Add("Career_ID");
- _dt.Columns.Add("Created_Date");
- _dt.Columns.Add("Job_Title");
- _dt.Columns.Add("Name");
- _dt.Columns.Add("City");
- _dt.Columns.Add("Experience");
- _dt.Columns.Add("Functional_Area");
- _dt.Columns.Add("Mobile_No");
- _dt.Columns.Add("Resume");
-
- _objDtReader = db.ExecuterReader("Call select_applied_for_particular_job()");
- DataRow _dr = null;
- while (_objDtReader.Read())
- {
- _dr = _dt.NewRow();
- _dr["Career_ID"] = Convert.ToInt32(_objDtReader["career_id"]);
- _dr["Created_Date"] = Convert.ToDateTime(_objDtReader["created_date"]).ToString("dd/MMM/yy");
- _dr["Job_Title"] = Convert.ToString(_objDtReader["job_title"]);
- _dr["Name"] = string.Concat(Convert.ToString(_objDtReader["first_name"]), " ", Convert.ToString(_objDtReader["last_name"]));
- _dr["City"] = _objDtReader["city"];
- _dr["Experience"] = Convert.ToString(_objDtReader["Experience"]);
- _dr["Functional_Area"] = Convert.ToString(_objDtReader["functional_Area"]);
- _dr["mobile_no"] = _objDtReader["mobile_no"];
- _dr["resume"] = "../Resume/" + Convert.ToString(_objDtReader["resume"]);
- _dt.Rows.Add(_dr);
-
- } _objDtReader.Close();
- return _dt;
- }
- public static career getJobAppliedCareerProfile(long careerID)
- {
- DBAccess db = new DBAccess();
- OdbcDataReader _objDtReader = null;
- _objDtReader = db.ExecuterReader("Call select_applied_job_career_profile('"+careerID+"')");
- if (_objDtReader.HasRows)
- {
- career objClsCareer = new career();
- while (_objDtReader.Read())
- {
- objClsCareer.Name = string.Concat(Convert.ToString(_objDtReader["first_name"]), " ", Convert.ToString(_objDtReader["last_name"]));
- objClsCareer.EmailID = Convert.ToString(_objDtReader["email_id"]);
- objClsCareer.MobileNo = Convert.ToString(_objDtReader["mobile_no"]);
- objClsCareer.DateOfBirth = Convert.ToDateTime(_objDtReader["date_of_birth"]).ToString("dd-MMM-yyyy");
- objClsCareer.Gender = Convert.ToString(_objDtReader["gender"]);
- objClsCareer.FunctionalArea = Convert.ToString(_objDtReader["functional_area"]);
- objClsCareer.Skills = Convert.ToString(_objDtReader["skills"]);
- objClsCareer.Experience = Convert.ToString(_objDtReader["experience"]);
- objClsCareer.Locatin = Convert.ToString(_objDtReader["city"]);
- objClsCareer.Resume =Convert.ToString(_objDtReader["resume"]);
- objClsCareer.CreatedDate = Convert.ToDateTime(_objDtReader["created_date"]).ToString("dd-MMM-yyyy");
- } _objDtReader.Close();
- return objClsCareer;
- }
- else
- {
- _objDtReader.Close();
- return new career();
- }
- }
- public DataTable getCurrentOpening()
- {
- db = new DBAccess();
- DataTable _dt = new DataTable();
- _dt.Columns.Add("job_id");
- _dt.Columns.Add("job_title");
- _dt.Columns.Add("experience");
- _dt.Columns.Add("location");
- _dt.Columns.Add("created_date");
- string varStatus="active";
- _objDtReader = db.ExecuterReader("Call select_current_opening('" + varStatus + "')");
- if (_objDtReader.HasRows)
- {
- DataRow _dr = null;
- while (_objDtReader.Read())
- {
- _dr = _dt.NewRow();
- _dr["job_id"] = Convert.ToInt32(_objDtReader["job_id"]);
- _dr["job_title"] = Convert.ToString(_objDtReader["job_title"]);
- _dr["experience"] = Convert.ToString(_objDtReader["experience"]);
- _dr["location"] = Convert.ToString(_objDtReader["location"]);
- _dr["created_date"] = Convert.ToDateTime(_objDtReader["created_date"]).ToString("dd-MMM-yyyy");
- _dt.Rows.Add(_dr);
- } _objDtReader.Close();
-
- }
- return _dt;
-
-
- }
-
- }
Presentation Layer
It is only a user interface which represents the data to user. This layer is always visible to user. So, users can see the data and perform some access from here to pass the input logic. In ASP.NET, there are two files which participate in Presentation Layer, one is your design file[.aspx page] and second one is your code behind file [.aspx.cs page]
CareerApply.aspx - <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CareerApply.aspx.cs" Inherits="View_CareerApply" %>
- <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
- <!DOCTYPE html>
- <html lang="en">
- <link rel="shortcut icon" href="../images/favicon.ico" />
-
- <head runat="server">
- <title></title>
- <meta charset="utf-8">
- <link href="../css/reset.css" rel="stylesheet" />
- <link href="../css/style.css" rel="stylesheet" />
- <link href="../css/layout.css" rel="stylesheet" />
- <script src="../js/jquery-1.6.min.js"></script>
- <script src="../js/cufon-yui.js"></script>
- <script src="../js/cufon-replace.js"></script>
- <script src="../js/Open_Sans_400.font.js"></script>
- <script src="../js/Open_Sans_Light_300.font.js"></script>
- <script src="../js/Open_Sans_Semibold_600.font.js"></script>
- <script src="../js/tms-0.3.js"></script>
- <script src="../js/tms_presets.js"></script>
- <script src="../js/jquery.easing.1.3.js"></script>
- <script src="../js/FF-cash.js"></script>
- <script src="../js/validation.js"></script>
- </head>
-
- <body id="page1">
- <!-- header -->
- <form id="form1" runat="server">
- <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
- <div class="bg">
- <div class="main">
- <header>
- <div class="row-1">
- <h1>
-
- <a class="logo"></a>
- </h1> </div>
- <div class="row-2">
- <nav>
- <ul class="menu">
- <li><a href="../home.aspx">Home</a></li>
- <li><a href="aboutus.aspx">About Us</a></li>
- <li><a href="Product.aspx">Products</a></li>
- <li><a href="Value.aspx">Our Value</a></li>
- <li><a href="brand.aspx">Our Brand</a></li>
- <li><a class="active" href="CareerApply.aspx">Careers</a></li>
- <li class="last-item"><a href="contact.aspx">Contact Us</a></li>
- </ul>
- </nav>
- </div>
- </header>
- <section id="content">
- <div class="padding">
- <div class="wrapper">
- <div class="col-3">
- <div class="indent">
- <p class="color-4 p1"> </p>
- <div> <img src="../images/career.jpg" alt="Career with us" /> </div>
- <table style="width: 100%;">
- <tr>
- <td style="width: 120px; text-align: left;">First Name <span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtFirstName" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" onkeypress="return isCharacterKey(this,event);"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;"></td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="reqName" ControlToValidate="txtFirstName" ErrorMessage="First Name Required" Font-Names="Sans-Sarif" ForeColor="#BF19D5" EnableClientScript="true"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Last Name
- <br />
- <br /> </td>
- <td>
- <asp:TextBox runat="server" ID="txtLastName" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" onkeypress="return isCharacterKey(this,event);"></asp:TextBox>
- <br />
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Email ID<span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtEmailID" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;"></td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" Display="Dynamic" ControlToValidate="txtEmailID" ErrorMessage="Email ID Required" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br />
- <asp:RegularExpressionValidator ID="regE_1" Display="Dynamic" runat="server" ErrorMessage="You must enter valid email address" ControlToValidate="txtEmailID" ForeColor="#BF19D5" ValidationExpression="^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$"> </asp:RegularExpressionValidator>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Mobile No<span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtMobileNo" Width="20%" MaxLength="10" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" onkeypress="return isNum_Hyph(this,event);"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br /> </td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" Display="Dynamic" ControlToValidate="txtMobileNo" ErrorMessage="Mobile No Required" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Date of Birth<span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtDateOfBirth" Width="25%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" ValidationGroup="cal_1"></asp:TextBox>
- <asp:ImageButton runat="server" ID="ibtnDOB" ImageUrl="~/images/calendar_icon.png" Width="30px" Height="25px" ImageAlign="AbsBottom" ValidationGroup="cal_2" />
- <cc1:CalendarExtender runat="server" ID="Calendar1" TargetControlID="txtDateOfBirth" PopupButtonID="ibtnDOB" Animated="true" EnabledOnClient="true" EnableViewState="false" Format="dd/MMM/yyyy"> </cc1:CalendarExtender>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br /> </td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" Display="Dynamic" ControlToValidate="txtDateOfBirth" ErrorMessage="Date of Birth Required" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Gender
- <br />
- <br /> </td>
- <td>
- <asp:RadioButton runat="server" ID="rdbMale" GroupName="gender" Text="Male" />
- <asp:RadioButton runat="server" ID="rdbFemale" GroupName="gender" Text="FeMale" />
- <br />
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Functional Area<span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtFunctionalArea" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" MaxLength="255"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br /> </td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator6" Display="Dynamic" ControlToValidate="txtFunctionalArea" ErrorMessage="Functional Area Required!" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Skill Details
- <br />
- <br /> </td>
- <td>
- <asp:TextBox runat="server" ID="txtSkillDetail" TextMode="MultiLine" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" ValidationGroup="cal_1"></asp:TextBox>
- <br />
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Experience<span style="color: red;">*</span> </td>
- <td>
- <asp:DropDownList runat="server" ID="ddlExperience" onselectedindexchanged="ddlExperience_SelectedIndexChanged" AutoPostBack="True">
- <asp:ListItem Enabled="true" Selected="True" Text="select" Value="0"></asp:ListItem>
- <asp:ListItem Text="Fresher" Value="1"></asp:ListItem>
- <asp:ListItem Text="Experienced" Value="2"></asp:ListItem>
- </asp:DropDownList>
- <asp:UpdatePanel runat="server" ID="upnlExperiece">
- <ContentTemplate>
- <asp:Label runat="server" ID="lblExperience" Visible="false"></asp:Label>
- <asp:TextBox runat="server" ID="txtExperience" Width="50%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" Visible="false"></asp:TextBox>
- <br />
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" Display="Dynamic" ControlToValidate="txtExperience" ErrorMessage="Fill Experience Value!" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- </ContentTemplate>
- <Triggers>
- <asp:AsyncPostBackTrigger ControlID="ddlExperience" EventName="SelectedIndexChanged" /> </Triggers>
- </asp:UpdatePanel>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br /> </td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator7" Display="Dynamic" ControlToValidate="ddlExperience" ErrorMessage="Experience Required!" InitialValue="0" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Current Location<span style="color: red;">*</span> </td>
- <td>
- <asp:TextBox runat="server" ID="txtCity" Width="100%" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid" MaxLength="255"></asp:TextBox>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br /> </td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" Display="Dynamic" ControlToValidate="txtCity" ErrorMessage="Current Location Required!" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Upload Resume<span style="color: red;">*</span>
- <br />
- <br /> </td>
- <td>
- <asp:FileUpload runat="server" ID="fupResume" />
- <br />
- <asp:RegularExpressionValidator runat="server" ID="rex1" ControlToValidate="fupResume" Display="Dynamic" EnableClientScript="true" EnableViewState="false" ErrorMessage="Only doc file allowed" SetFocusOnError="true" ToolTip="Only doc file allowed " TabIndex="1" ValidationExpression="^.*?\.(doc|docx)$"></asp:RegularExpressionValidator>
- <br />
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="fupResume" ErrorMessage="Upload Your Updated Resume" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">
- <br />
- <br /> </td>
- <td>
- <asp:Image ID="Image1" runat="server" ImageUrl="~/View/CImage.aspx" />
- <br />
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;">Security Text<span style="color: red;">*</span> </td>
- <td>
- <div> </div>
- <asp:TextBox ID="txtimgcode" runat="server" BorderColor="#ACC3DB" BorderWidth="1px" BorderStyle="Solid"></asp:TextBox>
- <br /> <span style="font-family:sans-serif; font-size:x-small;">Enter the characters shown in the image.</span>
- <asp:Label ID="lblmsg" runat="server" Font-Bold="false" ForeColor="Red" Text=""></asp:Label>
- </td>
- </tr>
- <tr>
- <td style="width: 30px; text-align: left;"></td>
- <td>
- <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="txtimgcode" ErrorMessage="Fill Image Code" Font-Names="Sans-Sarif" ForeColor="#BF19D5"></asp:RequiredFieldValidator>
- <br /> </td>
- </tr>
- <tr>
- <td style="width: 30px;">
- <br />
- <br /> </td>
- <td style="text-align: center;">
- <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" />
- <br />
- <br /> </td>
- </tr>
- </table>
- </div>
- </div>
- <div class="col-2">
- <div class="block-news">
- <h4 class="color-4 p2">Current Opening</h4>
- <asp:Repeater runat="server" ID="repCurrentOpening">
- <ItemTemplate>
- <table style="width:100%;" border="1">
- <tr>
- <td colspan="3">
- <hr style="border: 1px dashed #CACACA;" /> </td>
- </tr>
- <tr>
- <td colspan="3"> <a href="ViewCurrentOpeningJob.aspx?job=<%# Eval(" job_id ") %>" style="text-decoration:none;"><span style="color:#E931C1; font-size:medium; "><%# Eval("job_title") %></span></a>
- <br />
- <br /> </td>
- </tr>
- <tr>
- <td style="color:#1491C6; font-size:small; font-weight:bold; width:80px;"> Location </td>
- <td style="width:2px;"> : </td>
- <td style="color:#1491C6; font-size:smaller; padding-left:5px; ">
- <%# Eval("location") %>
- </td>
- </tr>
- <tr>
- <td style="color:#1491C6; font-size:small; font-weight:bold; width:80px;"> Experience </td>
- <td style="width:2px;"> : </td>
- <td style="color:#1491C6; font-size:smaller; padding-left:5px; ">
- <%# Eval("experience") %>
- </td>
- </tr>
- <tr>
- <td style="color:#1491C6; font-size:small; font-weight:bold; width:80px;"> Posted Date </td>
- <td style="width:2px;"> : </td>
- <td style="color:#1491C6; font-size:smaller; padding-left:5px; ">
- <%# Eval("created_date") %>
- </td>
- </tr>
- </table>
- </ItemTemplate>
- </asp:Repeater>
- </div>
- </div>
- </div>
- </div>
- </section>
- </div>
- </div>
- <script type="text/javascript">
- Cufon.now();
- </script>
- <script type="text/javascript">
- $(function ()
- {
- $('.slider')
- ._TMS(
- {
- prevBu: '.prev',
- nextBu: '.next',
- playBu: '.play',
- duration: 800,
- easing: 'easeOutQuad',
- preset: 'simpleFade',
- pagination: false,
- slideshow: 3000,
- numStatus: false,
- pauseOnHover: true,
- banners: true,
- waitBannerAnimation: false,
- bannerShow: function (banner)
- {
- banner.hide()
- .fadeIn(500)
- },
- bannerHide: function (banner)
- {
- banner.show()
- .fadeOut(500)
- }
- });
- })
- </script>
- </form>
- </body>
-
- </html>
CareerApply.aspx.cs - using System;
- using System.IO;
- using System.Data;
- public partial class View_CareerApply: System.Web.UI.Page
- {
- string varResumeName, varExperiece;
- protected void Page_Load(object sender, EventArgs e)
- {
- if(!IsPostBack)
- {
- this.txtFirstName.Focus();
- getCurrentOpening();
- }
- }
- protected void btnSubmit_Click(object sender, EventArgs e)
- {
- if(this.txtimgcode.Text == this.Session["CaptchaImageText"].ToString())
- {
- career objClsCareer = new career();
- objClsCareer.FirstName = txtFirstName.Text;
- objClsCareer.LastName = txtLastName.Text;
- objClsCareer.EmailID = txtEmailID.Text;
- objClsCareer.MobileNo = txtMobileNo.Text;
- objClsCareer.DateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text)
- .ToString("yyyy-MM-dd");
- if(rdbMale.Checked == true)
- {
- objClsCareer.Gender = "Male";
- }
- else if(rdbFemale.Checked == true)
- {
- objClsCareer.Gender = "Female";
- }
- else
- {
- objClsCareer.Gender = "";
- }
- objClsCareer.FunctionalArea = txtFunctionalArea.Text;
- objClsCareer.Skills = txtSkillDetail.Text;
- if(Convert.ToString(txtExperience.Text)
- .Equals(""))
- {
- varExperiece = "fresher";
- }
- else
- {
- varExperiece = txtExperience.Text;
- }
- objClsCareer.Experience = varExperiece;
- objClsCareer.Locatin = txtCity.Text;
- if(fupResume.HasFile)
- {
- varResumeName = "Resume_" + DateTime.Now.ToString("ddMMMyyyy") + DateTime.Now.Hour + DateTime.Now.Minute + Path.GetFileName(fupResume.PostedFile.FileName);
- fupResume.SaveAs(Server.MapPath("~/Resume/" + varResumeName));
- objClsCareer.Resume = varResumeName;
- }
- objClsCareer.JobID = 0;
- int result = objClsCareer.addCareerDetailsByVisiter(objClsCareer);
- if(result > 0)
- {
- Response.Write("<script language='javascript'>alert('Thank you! We will contact with you very soon'); window.location.href='../home.aspx'</script>");
- }
- }
- else
- {
- lblmsg.Text = "image code is not valid.";
- }
- this.txtimgcode.Text = "";
- }
- public void getCurrentOpening()
- {
- career objClsCareer = new career();
- DataTable dt = new DataTable();
- dt = objClsCareer.getCurrentOpening();
- if(dt.Rows.Count > 0)
- {
- repCurrentOpening.DataSource = dt;
- repCurrentOpening.DataBind();
- }
- else
- {}
- }
- protected void ddlExperience_SelectedIndexChanged(object sender, EventArgs e)
- {
- if(Convert.ToInt32(ddlExperience.SelectedValue) == 2)
- {
-
- lblExperience.Visible = true;
- lblExperience.Text = "Enter Experience Here";
- txtExperience.Visible = true;
- }
- else
- {
- lblExperience.Visible = false;
- txtExperience.Visible = false;
-
- }
- }
- }
I hope this article will help beginners as well as experience developers to understand the three layers architecture who has not worked on this.