<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="add_property.aspx.vb" Inherits="add_property" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<section class="subHeader page">
<div class="container">
<h1>Submit Properties</h1>
</div><!-- end subheader container -->
</section><!-- end subheader section -->
<!-- start my properties list -->
<section class="properties">
<div class="container">
<div class="row">
<!-- start property info -->
<div class="col-lg-4 col-md-4">
<h3>PROPERTY INFO</h3>
<div class="divider"></div>
<div class="sidebarWidget submission">
<form method="post" action="#">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock select">
<label for="city">City</label><br/>
<asp:DropDownList ID="DDLCITY" runat="server" AutoPostBack="true" CssClass="formDropdown">
</asp:DropDownList>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock select">
<label for="state">Location</label><br/>
<asp:DropDownList ID="DDLLocation" runat="server" CssClass="formDropdown">
</asp:DropDownList>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock select">
<label for="propertyType">Property Type</label><br/>
<asp:DropDownList ID="DDLPType" runat="server" CssClass="formDropdown">
<asp:ListItem>Select Property Type</asp:ListItem>
<asp:ListItem>Residential Plot</asp:ListItem>
<asp:ListItem>Bungalow</asp:ListItem>
<asp:ListItem>Studio Apartment</asp:ListItem>
<asp:ListItem>Penthouse</asp:ListItem>
<asp:ListItem>Kothi</asp:ListItem>
<asp:ListItem>Villa</asp:ListItem>
<asp:ListItem>Shop</asp:ListItem>
<asp:ListItem>Showroom</asp:ListItem>
<asp:ListItem>Office Space</asp:ListItem>
<asp:ListItem>Factory</asp:ListItem>
<asp:ListItem>Shed</asp:ListItem>
<asp:ListItem>Industrial Plots</asp:ListItem>
<asp:ListItem>IT Plots</asp:ListItem>
<asp:ListItem>IT Building</asp:ListItem>
<asp:ListItem>Corporate Building</asp:ListItem>
<asp:ListItem>Corporate Plot</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock select">
<label for="contractType">Available For</label><br/>
<asp:DropDownList ID="DDLPFor" runat="server" CssClass="formDropdown">
<asp:ListItem>Sale</asp:ListItem>
<asp:ListItem>Rent</asp:ListItem>
</asp:DropDownList>
</select>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock">
<label for="address">Title</label><br/>
<asp:TextBox ID="txttitle" runat="server"></asp:TextBox>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock">
<label for="description">Description</label><br/>
<asp:TextBox ID="txtdes" runat="server" TextMode="MultiLine"></asp:TextBox>
<br/><br/>
</div>
</div>
<div style="clear:both;"></div>
</div><!-- end row -->
</form><!-- end form -->
</div>
</div>
<!-- end property info -->
<!-- start amenities -->
<div class="col-lg-4 col-md-4">
<h3>AMENITIES</h3>
<div class="divider"></div>
<div class="sidebarWidget submission">
<form method="post" action="#">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="amenityCheckList formBlock">
<label>Amenities</label><br/><br/>
<div class="row">
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbac" runat="server" Text="Air Conditioning"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbsec" runat="server" Text="Security Personals"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbpow" runat="server" Text="Power Backup"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbinte" runat="server" Text="Intercom Facility"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cblift" runat="server" Text="Lift"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbhis" runat="server" Text="Hi Speed Internet"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbcaf" runat="server" Text="Cafeteria"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbpar" runat="server" Text="Reserved Parking"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbmain" runat="server" Text="Maintenance Staff"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbcon" runat="server" Text="Conference Room"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbwat" runat="server" Text="Water Storage"></asp:CheckBox>
</div>
<div style="clear:both;"></div>
<div class="amenityCheck col-lg-6 col-md-12">
<asp:CheckBox ID="cbcctv" runat="server" Text="CCTV Camera"></asp:CheckBox>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>
<div style="clear:both;"></div>
</div><!-- end row -->
</form><!-- end form -->
</div>
</div>
<!-- end amenities -->
<!-- start additional info -->
<div class="col-lg-4 col-md-4">
<h3>ADDITIONAL INFO</h3>
<div class="divider"></div>
<div class="sidebarWidget submission">
<form method="post" action="#">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock">
<label for="price">Price (<img src="images/rupee-Small.png" alt="" style="margin-right:2px;" width="20" height="20" />)</label><br/>
<asp:TextBox ID="txtprice" runat="server"></asp:TextBox>
</div>
</div>
<div class="col-lg-12 col-md-5 col-sm-2">
<div class="formBlock">
<label for="address">Size</label><br/>
<asp:TextBox ID="txtsize" runat="server"></asp:TextBox>
</div>
</div>
<div class="col-lg-12 col-md-7 col-sm-4">
<div class="formBlock select">
<label for="state">Unit</label><br/>
<asp:DropDownList ID="DDLUnit" runat="server" CssClass="formDropdown">
<asp:ListItem>Select Unit</asp:ListItem>
<asp:ListItem>Sq.Ft.</asp:ListItem>
<asp:ListItem>Sq.Mtr.</asp:ListItem>
<asp:ListItem>Sq.yrd.</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="formBlock">
<label for="image">Image</label><br/>
<asp:FileUpload ID="FileUpload1" runat="server"></asp:FileUpload>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-6">
<div class="formBlock">
<label>Photos</label><br/>
<asp:FileUpload ID="FileUpload2" runat="server"></asp:FileUpload>
<asp:FileUpload ID="FileUpload3" runat="server"></asp:FileUpload>
<asp:FileUpload ID="FileUpload4" runat="server"></asp:FileUpload>
<asp:FileUpload ID="FileUpload5" runat="server"></asp:FileUpload>
<asp:FileUpload ID="FileUpload6" runat="server"></asp:FileUpload>
</div>
</div>
<div style="clear:both;"></div>
</div><!-- end row -->
</form><!-- end form -->
</div>
</div>
<!-- end additional info -->
<div class="col-lg-4 col-lg-offset-4 col-md-4">
<div class="formBlock">
<asp:Button ID="btnsubmit" runat="server" Text="SUBMIT PROPERTY" CssClass="buttonColor"></asp:Button>
</div>
</div>
<div class="col-lg-4 col-lg-offset-4 col-md-4">
<div class="formBlock">
<asp:Label ID="lblmsg" runat="server" Text=""></asp:Label>
</div>
</div>
</div><!-- end row -->
</div><!-- end container -->
</section>
<!-- end my properties list -->
</asp:Content>
and here is code behind
Imports System
Imports System.Data
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Control
Imports System.Data.SqlClient
Partial Class add_property
Inherits System.Web.UI.Page
Public usernm As String
Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim pdate As Date = Date.Parse(DateString)
Dim mdate As Date = Date.Parse(DateString)
Dim propid As Integer = GeneratePropertID()
Dim userid As String = Session.Item("user").ToString
Dim p_type As String = DDLPType.SelectedItem.Text.ToString
Dim pfor As String = DDLPFor.SelectedItem.Text.ToString
Dim psize As String = txtsize.Text.ToString
Dim p_unit As String = DDLUnit.SelectedItem.Text.ToString
Dim city As String = DDLCITY.SelectedItem.Text.ToString
Dim location As String = DDLLocation.SelectedItem.Text.ToString
Dim pprice As String = txtprice.Text.ToString
Dim subje As String = txttitle.Text.ToString
Dim description As String = txtdes.Text.ToString
Dim st As String = "active"
Dim pst As String = "Cold"
Dim ac As String = ""
If (cbac.Checked = True) Then
ac = "True"
Else
ac = "False"
End If
Dim sec As String = ""
If (cbsec.Checked = True) Then
sec = "True"
Else
sec = "False"
End If
Dim pow As String = "'"
If (cbpow.Checked = True) Then
pow = "Ture"
Else
pow = "False"
End If
Dim inter As String = ""
If (cbinte.Checked = True) Then
inter = "True"
Else
inter = "False"
End If
Dim lift As String = ""
If (cblift.Checked = True) Then
lift = "True"
Else
lift = "False"
End If
Dim his As String = ""
If (cbhis.Checked = True) Then
his = "True"
Else
his = "False"
End If
Dim cafe As String = ""
If (cbcaf.Checked = True) Then
cafe = "True"
Else
cafe = "False"
End If
Dim parking As String = ""
If (cbpar.Checked = True) Then
parking = "True"
Else
parking = "False"
End If
Dim maint As String = ""
If (cbmain.Checked = True) Then
maint = "True"
Else
maint = "False"
End If
Dim conf As String = ""
If (cbcon.Checked = True) Then
conf = "True"
Else
conf = "False"
End If
Dim wat As String = ""
If (cbwat.Checked = True) Then
wat = "True"
Else
wat = "False"
End If
Dim cctv As String = ""
If (cbcctv.Checked = True) Then
cctv = "True"
Else
cctv = "False"
End If
Dim imgp As String = ""
If FileUpload1.HasFile Then
Dim asa() As String = FileUpload1.FileName.ToString().Split(".")
Dim imgname As String = propid & "." & asa(asa.Length - 1)
' Dim imgext As String = Path.GetExtension(FileUpload1.PostedFile.FileName)
'Dim imgname As String = propid & "." & imgext
imgp = "Prop_Images/" + imgname
Dim imgsize As Integer = FileUpload1.PostedFile.ContentLength
If imgsize >= 2097152 Then
lblmsg.Text = "Please Upload only Less Than 1 MB File "
End If
FileUpload1.SaveAs(Server.MapPath(imgp))
Else : imgp = "Prop_Images/notAvail.jpg"
End If
Dim constring As String = ConfigurationManager.ConnectionStrings("RealEstatePortalConnectionString").ConnectionString
Using con As New SqlConnection(constring)
Try
con.Open()
Dim cmd As New SqlCommand() '(ss, con)
cmd.Connection = con
cmd.CommandText = "sp_AddProperty"
cmd.CommandType = CommandType.StoredProcedure
'@dt ,@T_id ,@u_id ,@Ptype ,@P_for ,@bed_R ,@bath_R ,@size ,@unit ,@city ,@loc ,@price ,@title ,@st,
'@des ,@img_path,@P_St ,@park
Dim p As New SqlParameter("@dt", pdate)
Dim p1 As New SqlParameter("@T_id", propid)
Dim p2 As New SqlParameter("@u_id", userid)
Dim p3 As New SqlParameter("@ptype", p_type)
Dim p4 As New SqlParameter("@P_for", pfor)
' Dim p5 As New SqlParameter("@bed_R", bed)
' Dim p6 As New SqlParameter("@bath_R", bath)
Dim p7 As New SqlParameter("@size", psize)
Dim p8 As New SqlParameter("@unit", p_unit)
Dim p9 As New SqlParameter("@city", city)
Dim p10 As New SqlParameter("@loc", location)
Dim p11 As New SqlParameter("@price", pprice)
Dim p12 As New SqlParameter("@title", subje)
Dim p13 As New SqlParameter("@st", st)
Dim p14 As New SqlParameter("@des", description)
Dim p15 As New SqlParameter("@img_path", imgp)
Dim p16 As New SqlParameter("@p_st", pst)
'Dim p17 As New SqlParameter("@park", garage)
Dim p18 As New SqlParameter("result", SqlDbType.Int)
p18.Direction = ParameterDirection.Output
cmd.Parameters.Add(p)
cmd.Parameters.Add(p1)
cmd.Parameters.Add(p2)
cmd.Parameters.Add(p3)
cmd.Parameters.Add(p4)
'cmd.Parameters.Add(p5)
'cmd.Parameters.Add(p6)
cmd.Parameters.Add(p7)
cmd.Parameters.Add(p8)
cmd.Parameters.Add(p9)
cmd.Parameters.Add(p10)
cmd.Parameters.Add(p11)
cmd.Parameters.Add(p12)
cmd.Parameters.Add(p13)
cmd.Parameters.Add(p14)
cmd.Parameters.Add(p15)
cmd.Parameters.Add(p16)
'cmd.Parameters.Add(p17)
cmd.Parameters.Add(p18)
cmd.ExecuteNonQuery()
Dim res As Integer
Try
res = Integer.Parse(p18.Value.ToString)
Catch ex As Exception
res = -1
End Try
If res = 1 Then
'vb Code ConstructType for successful save
'Session("user") = txtemail.Text
txtclear()
lblmsg.ForeColor = Drawing.Color.Red
lblmsg.Text = " Your Account in De-Activated Please contact us!"
' Response.Redirect("UserHome.aspx")
ElseIf res = -1 Then
'code for error
lblmsg.ForeColor = Drawing.Color.Red
lblmsg.Text = "Some error occured try again Latar"
ElseIf res = 0 Then
txtclear()
Response.Redirect("Success.aspx?Ticket_Id=" & propid & "")
End If
Catch ex As Exception
lblmsg.ForeColor = Drawing.Color.Red
lblmsg.Text = (ex.Message.ToString)
Finally
con.Close()
End Try
End Using
End Sub
Private Function GeneratePropertID() As Integer
'Dim id As Integer
Dim n As Integer
Dim constring As String = ConfigurationManager.ConnectionStrings("RealEstatePortalConnectionString").ConnectionString
Using con As New SqlConnection(constring)
Try
Dim cc As String = "select count(*) from Properties"
con.Open()
Dim cmm As New SqlCommand(cc, con)
Dim dr As SqlDataReader
dr = cmm.ExecuteReader
If dr.Read Then
n = CInt(dr.Item(0))
End If
n = n + 1
' id = n.ToString.Length
Catch ex As Exception
lblmsg.Text = ex.Message.ToString
Finally
con.Close()
End Try
Return (n)
End Using
End Function
End Class