Current Path : G:/PleskVhosts/mpcdp.in/cmamp.mpcdp.in/cdpp3/App_Code/ |
Windows NT SG2NWVPWEB022 10.0 build 17763 (Windows Server 2016) i586 |
Current File : G:/PleskVhosts/mpcdp.in/cmamp.mpcdp.in/cdpp3/App_Code/FileUtilities.vb |
Imports System.Configuration Imports System.Data.SqlClient Imports System.Data Imports Microsoft.VisualBasic 'Imports System.Configuration 'Imports System.Data.SqlClient 'Imports System.Data Public Class FileUtilities 'Namespace ASPNetFileUpDownLoad.Utilities 'Public Class FileUtilities Public Shared Function GetConnectionString() As String ' Private Shared ConnectionString As [String] Return General.GetAppSetting("ConnectionString") ' Return ConfigurationManager.AppSettings("ApplicationServices") End Function Private Shared Sub OpenConnection(ByVal connection As SqlConnection) connection.ConnectionString = GetConnectionString() connection.Open() End Sub Public Shared Function GetAdminFileList() As DataTable Dim fileList As New DataTable() Using connection As New SqlConnection() OpenConnection(connection) Dim cmd As New SqlCommand() cmd.Connection = connection cmd.CommandTimeout = 0 cmd.CommandText = "SELECT ID,City_ULB_Name FROM Files order by City_ULB_Name " cmd.CommandType = CommandType.Text Dim adapter As New SqlDataAdapter() adapter.SelectCommand = cmd adapter.Fill(fileList) connection.Close() End Using Return fileList End Function ' Get the list of the files in the database Public Shared Function GetFileList(ByVal loginid As Integer) As DataTable Dim fileList As New DataTable() Using connection As New SqlConnection() OpenConnection(connection) Dim cmd As New SqlCommand() cmd.Connection = connection cmd.CommandTimeout = 0 cmd.CommandText = "SELECT ID,City_ULB_Name FROM Files where AdminID =" & loginid & "" cmd.CommandType = CommandType.Text Dim adapter As New SqlDataAdapter() adapter.SelectCommand = cmd adapter.Fill(fileList) connection.Close() End Using Return fileList End Function ' Save a file into the database'ByVal P_T1 As String,ByVal P_T1 As String, Public Shared Sub Savecmpanywardwise(ByVal P_CompanyID As String, ByVal P_ulbid As String, ByVal P_uldname As String, ByVal P_coname As String, ByVal P_wardname As String, ByVal P_T1 As String, ByVal P_T2 As String, ByVal P_T3 As String, ByVal P_T4 As String, ByVal P_T5 As String, ByVal P_T6 As String, ByVal P_T7 As String, ByVal P_T8 As String, ByVal P_T9 As String, ByVal P_T10 As String, ByVal P_T11 As String, ByVal P_T12 As String, ByVal P_T13 As String, ByVal P_T14 As String, ByVal P_T15 As String, ByVal P_T16 As String, ByVal P_T17 As String, ByVal P_T18 As String, ByVal P_T19 As String, ByVal P_T20 As String, ByVal P_T21 As String, ByVal P_T22 As String, ByVal P_T23 As String, ByVal P_T24 As String, ByVal P_T25 As String, ByVal P_T26 As String, ByVal P_T27 As String, ByVal P_T28 As String, ByVal P_T29 As String, ByVal P_T30 As String, ByVal P_T31 As String, ByVal P_T32 As String, ByVal P_T33 As String, ByVal P_T34 As String, ByVal P_T35 As String, ByVal P_T36 As String, ByVal P_T37 As String, ByVal P_T38 As String, ByVal P_T39 As String, ByVal P_T40 As String, ByVal P_T41 As String, ByVal P_T42 As String, ByVal P_T43 As String, ByVal P_T44 As String, ByVal P_T45 As String, ByVal P_T46 As String, ByVal P_T47 As String, ByVal P_T48 As String, ByVal P_T49 As String, ByVal P_T50 As String, ByVal P_T51 As String, ByVal P_T52 As String, ByVal P_T53 As String, ByVal P_T54 As String, ByVal P_T55 As String, ByVal P_T56 As String, ByVal P_T57 As String, ByVal P_T58 As String) ', ByVal contentType As String, ByVal size As Integer, ByVal data As Byte()) Using connection As New SqlConnection() OpenConnection(connection) Dim cmd As New SqlCommand() Dim Mid As Double = GetMaxSno_comanywardwise() cmd.Connection = connection cmd.CommandTimeout = 0 ' ' WardPopulation2011, WardArea, PopulationDensity, PopulationMale, PopulationFemale, PopulationSC, PopulationST, PopulationBPL, SexRatio, LiteracyRate, NoOfSchool, NoOfHealthCentre, NoOfHouseHold, PrimaryOccupation, SecondayOccupation, TertiaryOccupation, NoOfIndustrialUnit, NoOfCommercialEstablishments, NoOfSlumPockets, SlumPopulation, NoOfSlumHousehold, NoOfIndividualWaterConnection, NoOfCommunityWaterConnections, NoOfCommercialWaterConnection, NoOfTubewell, NoOfHandpump, NoOfOHT, CoverageOfPipedWaterSupply, NoOfIndividualToilet, NoOfIndividualSepticTanks, NoOfCommunitySepticTank, NoOfCommunityToilet, PopulationOpenDefecation, NoOfDustBin, WardwiseWasteGenerated, RoadSweeping, NoOfSanitaryWorker, LengthOfPuccaRoad, LengthOfKucchaRoad, LengthOfStateHighway, LengthOfNationalHighway, LengthOfRoadSideDrainsPucca, LengthOfNaturalDrainPucca, LengthOfNaturalDrainKuttcha, NoOfStreetlight, NoOfElectricityConnection, NameOfTouristSite, NameOfHeritageSite, NoOfBusStop, NoOfBusStand, NoOfPark, NoOfPlayground, NoOfResidentialProperty, NoOfCommercialProperty, TotalPropertyTaxCollection, PropertyTaxCoverag, AvailableGovernmentLand, Remarks ''INSERT INTO CityProfileWardWise VALUES CompanyID,ULBID,Company,City,WardNumber Dim commandText As String = "INSERT INTO CityProfileWardWise (CompanyID,ULBID,sno,Company,City,WardNumber,WardPopulation2011, WardArea, PopulationDensity, PopulationMale, PopulationFemale, PopulationSC, PopulationST, PopulationBPL, SexRatio, LiteracyRate, NoOfSchool, NoOfHealthCentre, NoOfHouseHold, PrimaryOccupation, SecondayOccupation, TertiaryOccupation, NoOfIndustrialUnit, NoOfCommercialEstablishments, NoOfSlumPockets, SlumPopulation, NoOfSlumHousehold, NoOfIndividualWaterConnection, NoOfCommunityWaterConnections, NoOfCommercialWaterConnection, NoOfTubewell, NoOfHandpump, NoOfOHT, CoverageOfPipedWaterSupply, NoOfIndividualToilet, NoOfIndividualSepticTanks, NoOfCommunitySepticTank, NoOfCommunityToilet, PopulationOpenDefecation, NoOfDustBin, WardwiseWasteGenerated, RoadSweeping, NoOfSanitaryWorker, LengthOfPuccaRoad, LengthOfKucchaRoad, LengthOfStateHighway, LengthOfNationalHighway, LengthOfRoadSideDrainsPucca, LengthOfNaturalDrainPucca, LengthOfNaturalDrainKuttcha, NoOfStreetlight, NoOfElectricityConnection, NameOfTouristSite, NameOfHeritageSite, NoOfBusStop, NoOfBusStand, NoOfPark, NoOfPlayground, NoOfResidentialProperty, NoOfCommercialProperty, TotalPropertyTaxCollection, PropertyTaxCoverage, AvailableGovernmentLand, Remarks) VALUES (@CompanyID,@ULBID,@sno,@Company,@City,@WardNumber, @WardPopulation2011,@WardArea ,@PopulationDensity ,@PopulationMale ,@PopulationFemale,@PopulationSC,@PopulationST,@PopulationBPL,@SexRatio ,@LiteracyRate ,@NoOfSchool ,@NoOfHealthCentre ,@NoOfHouseHold ,@PrimaryOccupation ,@SecondayOccupation ,@TertiaryOccupation ,@NoOfIndustrialUnit ,@NoOfCommercialEstablishments,@NoOfSlumPockets ,@SlumPopulation ,@NoOfSlumHousehold ,@NoOfIndividualWaterConnection ,@NoOfCommunityWaterConnections ,@NoOfCommercialWaterConnection ,@NoOfTubewell ,@NoOfHandpump ,@NoOfOHT ,@CoverageOfPipedWaterSupply ,@NoOfIndividualToilet , @NoOfIndividualSepticTanks ,@NoOfCommunitySepticTank ,@NoOfCommunityToilet ,@PopulationOpenDefecation ,@NoOfDustBin ,@WardwiseWasteGenerated ,@RoadSweeping ,@NoOfSanitaryWorker ,@LengthOfPuccaRoad ,@LengthOfKucchaRoad ,@LengthOfStateHighway ,@LengthOfNationalHighway ,@LengthOfRoadSideDrainsPucca ,@LengthOfNaturalDrainPucca,@LengthOfNaturalDrainKuttcha ,@NoOfStreetlight ,@NoOfElectricityConnection ,@NameOfTouristSite,@NameOfHeritageSite,@NoOfBusStop,@NoOfBusStand ,@NoOfPark ,@NoOfPlayground ,@NoOfResidentialProperty ,@NoOfCommercialProperty ,@TotalPropertyTaxCollection ,@PropertyTaxCoverage," commandText = commandText & "@AvailableGovernmentLand ,@Remarks)" cmd.CommandText = commandText cmd.CommandType = CommandType.Text cmd.Parameters.Add("@CompanyID", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@ULBID", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@sno", SqlDbType.Float) cmd.Parameters.Add("@Company", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@city", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@WardNumber", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@WardPopulation2011", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@WardArea", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationDensity", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationMale", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationFemale", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationSC", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationST", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationBPL", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@SexRatio", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LiteracyRate", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfSchool", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfHealthCentre", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfHouseHold", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PrimaryOccupation", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@SecondayOccupation", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@TertiaryOccupation", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfIndustrialUnit", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommercialEstablishments", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfSlumPockets", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@SlumPopulation", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfSlumHousehold", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfIndividualWaterConnection", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommunityWaterConnections", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommercialWaterConnection", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfTubewell", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfHandpump", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfOHT", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@CoverageOfPipedWaterSupply", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfIndividualToilet", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfIndividualSepticTanks", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommunitySepticTank", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommunityToilet", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PopulationOpenDefecation", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfDustBin", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@WardwiseWasteGenerated", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@RoadSweeping", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfSanitaryWorker", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfPuccaRoad", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfKucchaRoad", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfStateHighway", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfNationalHighway", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfRoadSideDrainsPucca", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfNaturalDrainPucca", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@LengthOfNaturalDrainKuttcha", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfStreetlight", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfElectricityConnection", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NameOfTouristSite", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NameOfHeritageSite", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfBusStop", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfBusStand", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfPark", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfPlayground", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfResidentialProperty", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@NoOfCommercialProperty", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@TotalPropertyTaxCollection", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@PropertyTaxCoverage", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@AvailableGovernmentLand", SqlDbType.NVarChar, 255) cmd.Parameters.Add("@Remarks", SqlDbType.NVarChar, 255) '---------------------------- cmd.Parameters("@CompanyID").Value = P_CompanyID cmd.Parameters("@ULBID").Value = P_ulbid cmd.Parameters("@sno").Value = Mid cmd.Parameters("@Company").Value = P_coname cmd.Parameters("@city").Value = P_uldname cmd.Parameters("@WardNumber").Value = P_wardname cmd.Parameters("@WardPopulation2011").Value = P_T3 cmd.Parameters("@WardArea").Value = P_T2 cmd.Parameters("@PopulationDensity").Value = P_T1 cmd.Parameters("@PopulationMale").Value = P_T4 cmd.Parameters("@PopulationFemale").Value = P_T5 cmd.Parameters("@PopulationSC").Value = P_T6 cmd.Parameters("@PopulationST").Value = P_T7 cmd.Parameters("@PopulationBPL").Value = P_T8 cmd.Parameters("@SexRatio").Value = P_T9 cmd.Parameters("@LiteracyRate").Value = P_T10 cmd.Parameters("@NoOfSchool").Value = P_T11 cmd.Parameters("@NoOfHealthCentre").Value = P_T12 cmd.Parameters("@NoOfHouseHold").Value = P_T13 cmd.Parameters("@PrimaryOccupation").Value = P_T14 cmd.Parameters("@SecondayOccupation").Value = P_T15 cmd.Parameters("@TertiaryOccupation").Value = P_T16 cmd.Parameters("@NoOfIndustrialUnit").Value = P_T17 cmd.Parameters("@NoOfCommercialEstablishments").Value = P_T18 cmd.Parameters("@NoOfSlumPockets").Value = P_T19 cmd.Parameters("@SlumPopulation").Value = P_T20 cmd.Parameters("@NoOfSlumHousehold").Value = P_T21 cmd.Parameters("@NoOfIndividualWaterConnection").Value = P_T22 cmd.Parameters("@NoOfCommunityWaterConnections").Value = P_T23 cmd.Parameters("@NoOfCommercialWaterConnection").Value = P_T24 cmd.Parameters("@NoOfTubewell").Value = P_T25 cmd.Parameters("@NoOfHandpump").Value = P_T26 cmd.Parameters("@NoOfOHT").Value = P_T27 cmd.Parameters("@CoverageOfPipedWaterSupply").Value = P_T28 cmd.Parameters("@NoOfIndividualToilet").Value = P_T29 cmd.Parameters("@NoOfIndividualSepticTanks").Value = P_T30 cmd.Parameters("@NoOfCommunitySepticTank").Value = P_T31 cmd.Parameters("@NoOfCommunityToilet").Value = P_T32 cmd.Parameters("@PopulationOpenDefecation").Value = P_T33 cmd.Parameters("@NoOfDustBin").Value = P_T34 cmd.Parameters("@WardwiseWasteGenerated").Value = P_T35 cmd.Parameters("@RoadSweeping").Value = P_T36 cmd.Parameters("@NoOfSanitaryWorker").Value = P_T37 cmd.Parameters("@LengthOfPuccaRoad").Value = P_T38 cmd.Parameters("@LengthOfKucchaRoad").Value = P_T39 cmd.Parameters("@LengthOfStateHighway").Value = P_T40 cmd.Parameters("@LengthOfNationalHighway").Value = P_T41 cmd.Parameters("@LengthOfRoadSideDrainsPucca").Value = P_T42 cmd.Parameters("@LengthOfNaturalDrainPucca").Value = P_T43 cmd.Parameters("@LengthOfNaturalDrainKuttcha").Value = P_T44 cmd.Parameters("@NoOfStreetlight").Value = P_T45 cmd.Parameters("@NoOfElectricityConnection").Value = P_T46 cmd.Parameters("@NameOfTouristSite").Value = P_T47 cmd.Parameters("@NameOfHeritageSite").Value = P_T48 cmd.Parameters("@NoOfBusStop").Value = P_T49 cmd.Parameters("@NoOfBusStand").Value = P_T50 cmd.Parameters("@NoOfPark").Value = P_T51 cmd.Parameters("@NoOfPlayground").Value = P_T52 cmd.Parameters("@NoOfResidentialProperty").Value = P_T53 cmd.Parameters("@NoOfCommercialProperty").Value = P_T54 cmd.Parameters("@TotalPropertyTaxCollection").Value = P_T55 cmd.Parameters("@PropertyTaxCoverage").Value = P_T56 cmd.Parameters("@AvailableGovernmentLand").Value = P_T57 cmd.Parameters("@Remarks").Value = P_T58 ' cmd.Parameters("@Data").Value = Data cmd.ExecuteNonQuery() connection.Close() End Using End Sub ' Get a file from the database by ID Public Shared Function GetAFile(ByVal id As Integer) As DataTable Dim file As New DataTable() Using connection As New SqlConnection() OpenConnection(connection) Dim cmd As New SqlCommand() cmd.Connection = connection cmd.CommandTimeout = 0 cmd.CommandText = "SELECT ID,City_ULB_Name, Name, ContentType, Size, Data FROM Files " & "WHERE ID=@ID" cmd.CommandType = CommandType.Text Dim adapter As New SqlDataAdapter() cmd.Parameters.Add("@ID", SqlDbType.Int) cmd.Parameters("@ID").Value = id adapter.SelectCommand = cmd adapter.Fill(file) connection.Close() End Using Return file End Function Public Shared Function GetMaxSno_comanywardwise() As Double Dim maxid As Double Dim dsList As New DataSet() Command.CreateSqlConnection() Dim da As New SqlDataAdapter("select max(sno)+1 from CityProfileWardWise", Command.CreateSqlConnection()) da.Fill(dsList, "List") Dim myDataTable As DataTable = dsList.Tables(0) For Each dRow As DataRow In myDataTable.Rows maxid = dRow.ItemArray(0) Next da.Dispose() myDataTable.Dispose() Return maxid End Function 'End Class 'End Namespace End Class