Current Path : G:/PleskVhosts/mpcdp.in/cmamp.mpcdp.in/cdpp3/ |
Windows NT SG2NWVPWEB022 10.0 build 17763 (Windows Server 2016) i586 |
Current File : G:/PleskVhosts/mpcdp.in/cmamp.mpcdp.in/cdpp3/Advanced_Search.aspx.vb |
Imports System Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports System.Data.SqlClient Imports System.IO Imports System.Drawing Partial Class Advanced_Search Inherits System.Web.UI.Page Dim selectStrCity As String = "" Dim selectStrCompany As String = "" Dim arraylist1 As New ArrayList() Dim arraylist2 As New ArrayList() Dim _finalString = "" Dim company Dim ward Dim sql Dim _splitfield As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then LoadCompany() LoadCitywise() Else Me.BtnSearch_Click(sender, e) If _finalString <> "" Then bindDataSqlAdp(_finalString, company, ward) End If End If sDiv.Focus() 'If Not Context.User.Identity.IsAuthenticated Then 'Else ' If Page.IsPostBack = False Then ' LoadCompany() ' LoadCitywise() ' Else ' Me.BtnSearch_Click(sender, e) ' If _finalString <> "" Then ' bindDataSqlAdp(_finalString, company, ward) ' End If ' End If 'End If 'sDiv.Focus() End Sub Function LoadCitywise() As Integer ' DD_CompanyName.Items.Clear() Dim record As Integer Dim sql = "select distinct ULBNameEnglish,ULBID from CityProfileXLS where ULBNameEnglish!='null' order by ULBNameEnglish " Dim command As New Command(sql, False) 'WHERE Login_ID = " & _loginID & " ", False) Try command.ExecuteReader(True, False) If command.Reader.HasRows Then LBward.Items.Clear() LBward.DataValueField = "ULBID" LBward.DataTextField = "ULBNameEnglish" LBward.DataSource = command.Reader LBward.DataBind() If LBward.Items.Count > 0 Then LBward.Items.Insert(0, New ListItem("Select City", "0")) Return record = 1 End If Return record = 2 Else End If Finally command.Close() End Try End Function Function LoadCityWard() As Integer ' DD_CompanyName.Items.Clear() Dim record As Integer Dim sql = "select distinct WardNumber,CPW_ID from CityProfileWardWise where WardNumber!='null' order by CPW_ID " Dim command As New Command(sql, False) 'WHERE Login_ID = " & _loginID & " ", False) Try command.ExecuteReader(True, False) If command.Reader.HasRows Then LBward.Items.Clear() LBward.DataValueField = "CPW_ID" LBward.DataTextField = "WardNumber" LBward.DataSource = command.Reader LBward.DataBind() If LBward.Items.Count > 0 Then LBward.Items.Insert(0, New ListItem("Select Ward", "0")) Return record = 1 End If Return record = 2 Else End If Finally command.Close() End Try End Function Function LoadCompany() As Integer ' DD_CompanyName.Items.Clear() Dim record As Integer Dim sql = "select distinct Company,companyid from CityProfileWardWise order by Company" Dim command As New Command(sql, False) 'WHERE Login_ID = " & _loginID & " ", False) Try command.ExecuteReader(True, False) If command.Reader.HasRows Then LBCitybox.Items.Clear() LBCitybox.DataValueField = "companyid" LBCitybox.DataTextField = "Company" LBCitybox.DataSource = command.Reader LBCitybox.DataBind() If LBCitybox.Items.Count > 0 Then LBCitybox.Items.Insert(0, New ListItem("Select City", "0")) Return record = 1 End If Return record = 2 Else End If Finally command.Close() End Try End Function Public Function GetListBoxSelStringInComma(ByVal Listbox10 As ListBox, ByVal Listbox11 As ListBox) As String If Listbox10.SelectedIndex >= 0 Then For i As Integer = 0 To Listbox10.Items.Count - 1 If Listbox10.Items(i).Selected Then If Not arraylist1.Contains(Listbox10.Items(i)) Then arraylist1.Add(Listbox10.Items(i)) End If End If Next For i As Integer = 0 To arraylist1.Count - 1 If Not Listbox11.Items.Contains(DirectCast(arraylist1(i), ListItem)) Then Listbox11.Items.Add(DirectCast(arraylist1(i), ListItem)) End If Listbox10.Items.Remove(DirectCast(arraylist1(i), ListItem)) Next Listbox11.SelectedIndex = -1 Else 'lbltxt.Visible = True ' lbltxt.Text = "Please select atleast one in Listbox1 to move" End If End Function Protected Sub BtnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSearch.Click Button1.Visible = True Button1.Focus() Dim _DDString = DD_Drainage.SelectedValue.ToString() + "," + DD_Education.SelectedValue.ToString() company = selectStrCompany ward = selectStrCity Dim _sComp As String = "" Dim _SWord As String = "" Dim _FieldName As New StringBuilder For Each li As ListItem In LBCitybox.Items If li.Selected Then _sComp += "'" + li.Text + "'" + "," End If Next If _sComp.Length > 0 Then company = _sComp.Remove(_sComp.Length - 1, 1) ' company = company.Replace("'", "''").Trim ' _FieldName = "" Else company = "" End If For Each liw As ListItem In LBward.Items If liw.Selected Then _SWord += "'" + liw.Value + "'" + "," End If Next If _SWord.Length > 0 Then ward = _SWord.Remove(_SWord.Length - 1, 1) ' ward = ward.Replace("'", "''").Trim Else ward = "" End If Dim sqlstr1 As New StringBuilder If (DD_Drainage.SelectedIndex = 0) Then ' sqlstr1.Append("" & ",") Else sqlstr1.Append(DD_Drainage.SelectedValue & ",") End If If (DD_Education.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Education.SelectedValue & ",") End If If (DD_Environment.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Environment.SelectedValue & ",") End If If (DD_Health.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Health.SelectedValue & ",") End If If (DD_Heritage.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Heritage.SelectedValue & ",") End If If (DD_LandPercent.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_LandPercent.SelectedValue & ",") End If If (DD_LandUDPFI.SelectedIndex = 0) Then 'sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_LandUDPFI.SelectedValue & ",") End If If (DD_LandUse.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_LandUse.SelectedValue & ",") End If If (DD_MuniipalArea.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_MuniipalArea.SelectedValue & ",") End If If (DD_Population.SelectedIndex = 0) Then 'sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Population.SelectedValue & ",") End If If (DD_Power.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Power.SelectedValue & ",") End If If (DD_ProjectedPopulation.SelectedIndex = 0) Then 'sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_ProjectedPopulation.SelectedValue & ",") End If If (DD_Roads.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Roads.SelectedValue & ",") End If If (DD_Sewerage.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Sewerage.SelectedValue & ",") End If If (DD_Socialsecurity.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Socialsecurity.SelectedValue & ",") End If If (DD_Streetlighting.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Streetlighting.SelectedValue & ",") End If If (DD_SWM.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_SWM.SelectedValue & ",") End If If (DD_Traffic.SelectedIndex = 0) Then ' sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_Traffic.SelectedValue & ",") End If If (DD_WaterSupply.SelectedIndex = 0) Then 'sqlstr1.Append("0" & ",") Else sqlstr1.Append(DD_WaterSupply.SelectedValue & ",") End If _finalString = "" If sqlstr1.ToString.Length > 0 Then _finalString = sqlstr1.ToString.Remove(sqlstr1.ToString.Length - 1, 1) Else End If bindDataSqlAdp(_finalString, company, ward) ' bindData(_finalString, company, ward) 'Dim strS As String = _finalString ' _splitfield = strS End Sub Function bindDataSqlAdp(ByVal viewfield As String, ByVal Coinpar1 As String, ByVal Ctinpar2 As String) As Integer ' DD_CompanyName.Items.Clear() Dim record As Integer 'Dim sql = "select distinct WardNumber,CPW_ID from CityProfileWardWise where WardNumber!='null' order by CPW_ID " If Coinpar1.Length > 0 And Ctinpar2.Length <= 0 Then sql = "select ULBID,CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where companyname in (" + Coinpar1 + ")" End If If Coinpar1.Length <= 0 And Ctinpar2.Length > 0 Then sql = "select ULBID,CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where ULBID in (" + Ctinpar2 + ")" End If If Coinpar1.Length > 0 And Ctinpar2.Length > 0 Then sql = "select ULBID,CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where companyname in (" + Coinpar1 + ")and ULBID in (" + Ctinpar2 + ")" End If If Coinpar1.Length <= 0 And Ctinpar2.Length <= 0 Then sql = "select ULBID,CompanyName,ULBNameEnglish from View_City_Sectoral_IM where companyname in ('0')and ULBID in ('0')" End If Me.SqlDataSource1.SelectCommand = sql ' GridView_advSearh.DataSource = SqlDataSource1 GridView_advSearh.DataBind() End Function Function bindData(ByVal viewfield As String, ByVal Coinpar1 As String, ByVal Ctinpar2 As String) As Integer ' DD_CompanyName.Items.Clear() Dim record As Integer 'Dim sql = "select distinct WardNumber,CPW_ID from CityProfileWardWise where WardNumber!='null' order by CPW_ID " If Coinpar1.Length > 0 And Ctinpar2.Length <= 0 Then sql = "select CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where companyname in (" + Coinpar1 + ")" End If If Coinpar1.Length <= 0 And Ctinpar2.Length > 0 Then sql = "select CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where ULBID in (" + Ctinpar2 + ")" End If If Coinpar1.Length > 0 And Ctinpar2.Length > 0 Then sql = "select CompanyName,ULBNameEnglish, " + viewfield + " from View_City_Sectoral_IM where companyname in (" + Coinpar1 + ")and ULBID in (" + Ctinpar2 + ")" End If If Coinpar1.Length <= 0 And Ctinpar2.Length <= 0 Then sql = "select CompanyName,ULBNameEnglish from View_City_Sectoral_IM where companyname in ('0')and ULBID in ('0')" End If Me.SqlDataSource1.SelectCommand = sql Dim command As New Command(sql, False) 'WHERE Login_ID = " & _loginID & " ", False) Try command.ExecuteReader(True, False) If command.Reader.HasRows Then ' LBward.Items.Clear() ' LBward.DataValueField = "CPW_ID" ' LBward.DataTextField = "WardNumber" GridView_advSearh.DataSource = command.Reader GridView_advSearh.DataBind() GridView_advSearh.SelectedRow.Focus() 'If LBward.Items.Count > 0 Then ' LBward.Items.Insert(0, New ListItem("Select Ward", "0")) ' Return record = 1 'End If 'Return record = 2 Else End If Finally command.Close() End Try End Function Protected Sub BtnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnClear.Click LoadCompany() LoadCitywise() DD_Drainage.SelectedIndex = 0 DD_Education.SelectedIndex = 0 DD_Environment.SelectedIndex = 0 DD_Health.SelectedIndex = 0 DD_Heritage.SelectedIndex = 0 DD_LandPercent.SelectedIndex = 0 DD_LandUDPFI.SelectedIndex = 0 DD_LandUse.SelectedIndex = 0 DD_MuniipalArea.SelectedIndex = 0 DD_Population.SelectedIndex = 0 DD_Power.SelectedIndex = 0 DD_ProjectedPopulation.SelectedIndex = 0 DD_Roads.SelectedIndex = 0 DD_Sewerage.SelectedIndex = 0 DD_Socialsecurity.SelectedIndex = 0 DD_Streetlighting.SelectedIndex = 0 DD_SWM.SelectedIndex = 0 DD_Traffic.SelectedIndex = 0 DD_WaterSupply.SelectedIndex = 0 bindData("", "", "") End Sub 'Protected Sub GridView_advSearh_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView_advSearh.SelectedIndexChanging ' GridView_advSearh.PageIndex = e.NewSelectedIndex ' bindData(_finalString, company, ward) ' 'GridView_advSearh.DataSource = ' 'GridView_advSearh.DataBind() 'End Sub 'Protected Sub GridView_advSearh_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView_advSearh.SelectedIndexChanged 'End Sub Protected Sub GridView_advSearh_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView_advSearh.SelectedIndexChanging GridView_advSearh.PageIndex = e.NewSelectedIndex ' GridView_advSearh.DataSource = SqlDataSource1 GridView_advSearh.ShowHeader = True '.SelectedRow.Focus() ' GridView_advSearh.ClearSelection() Dim nRowIndex As Integer = GridView_advSearh.Rows.Count - 1 GridView_advSearh.SelectedRow.Focus() ' GridView_advSearh.Rows(nRowIndex).Selected = True 'GridView_advSearh.Rows(nRowIndex).Cells(0).Selected = True 'GridView_advSearh.DataBind() End Sub Private Function GetallRecord(ByVal sql1 As String) As DataTable Dim dsAdmin As New Data.DataSet() Dim dt As New Data.DataTable() Global.Command.CreateSqlConnection() Dim da As New Data.SqlClient.SqlDataAdapter(sql1, Global.Command.CreateSqlConnection()) ' DataTable dt = new DataTable(); da.Fill(dsAdmin, "dtData") Dim myDataTable As Data.DataTable = dsAdmin.Tables(0) If myDataTable.Rows.Count > 0 Then 'Session("dt1") = myDataTable 'GVULB.DataSource = myDataTable 'GVULB.DataBind() 'GVULB.EnableViewState = False End If da.Dispose() myDataTable.Dispose() Return myDataTable End Function Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Me.BtnSearch_Click(sender, e) Dim dt1 As DataTable = BuildData() 'Session("dt1") If dt1 Is Nothing Then Throw New Exception("No Records to Export") End If Dim Path As String = "\myexcelfile_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + ".xls" Dim FI As FileInfo = New FileInfo(Path) File.Delete("\" + FI.Name) Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls") Response.Charset = "" Response.ContentType = "application/vnd.xls" Dim stringWrite As New System.IO.StringWriter() Dim htmlWrite1 As New System.Web.UI.HtmlTextWriter(stringWrite) Dim DataGrd1 As DataGrid = New DataGrid() DataGrd1.DataSource = dt1 DataGrd1.DataBind() DataGrd1.RenderControl(htmlWrite1) Response.Write(stringWrite.ToString()) Response.End() Session("dt1") = DBNull.Value End Sub Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender ' Page.ClientScript.RegisterStartupScript(Me.GetType, "OnLoad", "hideDivF();", True) sDiv.Focus() End Sub Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShow.Click ' Me.BtnSearch_Click(sender, e) Dim pieChart As New FusionPieChart() pieChart.showNames = True pieChart.showPercentageInLabel = True pieChart.showPercentageValues = False Dim chartHtml As String = pieChart.CreateSetElement(BuildData(), FusionPieChart.Pie3D, divPieChart.ClientID, "CompanyName", "dbo.CityProfileXLS.MunicipalArea2011", "dbo.CityProfileXLS.Population2011", "ULBID", "test.aspx?id=", True, 600, 400) divPieChart.InnerHtml = chartHtml Dim lineChart As New FusionLineChart() 'chartHtml = lineChart.CreateSetElememtForTrendChart(BuildData(), divLineChart.ClientID, "name", "value", 100, 100); chartHtml = lineChart.CreateSetElement(BuildData(), FusionLineChart.Line2D, divLineChart.ClientID, False, "", "CompanyName", "dbo.CityProfileXLS.MunicipalArea2011", "dbo.CityProfileXLS.Population2011", "ULBID", "", True, 600, 400) divLineChart.InnerHtml = chartHtml ' pieChart.xyaxis() ' lineChart.xAxisName = "companynmae" 'lineChart.yAxisName = "cityName" 'lineChart.xyaxis("Comapany Name", "City Name") End Sub Private Function BuildData() As DataTable Dim dtData As New DataTable() dtData = GetallRecord(sql) Return dtData End Function End Class