调查管理

最近在做调查管理的,写的不好,还需努力!

前台

None.gif Imports  System.Data
None.gif
Imports  System.Data.SqlClient
ExpandedBlockStart.gifContractedBlock.gifPartial 
Class index Class index
InBlock.gif    
Inherits System.Web.UI.Page
InBlock.gif
InBlock.gif    
Dim myid As Integer
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Protected Sub Page_Load()Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load
InBlock.gif       
InBlock.gif        
If Not Page.IsPostBack Then Dim myQuestion As New quest
InBlock.gif            
Dim myreader As SqlDataReader
InBlock.gif            myreader 
= myQuestion.RetriveReader
InBlock.gif            
If myreader.Read Then
InBlock.gif                lbshow.Text 
= myreader("QuestionContent")
InBlock.gif                myid 
= myreader("QuestionId")
InBlock.gif                llId.Text 
= myid.ToString
InBlock.gif            
End If
InBlock.gif            
Dim myanswer As New answer
InBlock.gif            myanswer.QuestionId 
= myid
InBlock.gif            RadioButtonList1.DataSource 
= myanswer.RetriveDs
InBlock.gif            RadioButtonList1.DataTextField 
= "AnswerContent"
InBlock.gif            RadioButtonList1.DataValueField 
= "AnswerId"
InBlock.gif            RadioButtonList1.DataBind()
InBlock.gif            
'RadioButtonList1.SelectedIndex = 0
InBlock.gif

InBlock.gif        
End If
ExpandedSubBlockEnd.gif    
End Sub

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Protected Sub Button1_Click()Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click
InBlock.gif        
Dim myanswer As New answer(CInt(RadioButtonList1.SelectedValue))
InBlock.gif        
With myanswer
InBlock.gif
InBlock.gif            .DianJi 
= .DianJi + 1
InBlock.gif            .update()
InBlock.gif        
End With
InBlock.gif 
ExpandedSubBlockEnd.gif    
End Sub

ExpandedBlockEnd.gif
End Class
quest.vb
None.gif Imports  System.Web
None.gif
Imports  System.Web.Services
None.gif
Imports  System.Web.Services.Protocols
None.gif
Imports  System.Data
None.gif
Imports  System.Data.SqlClient
ExpandedBlockStart.gifContractedBlock.gif
Public   Class quest Class quest
InBlock.gif    
Private _QuestionId As Integer
InBlock.gif    
Private _QuestionContent As String
InBlock.gif    
Private _CheckIf As Boolean
InBlock.gif    
Private _connstr As String
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Sub New()Sub New()
InBlock.gif        getconnstr()
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property QuestionId()Property QuestionId() As Integer
InBlock.gif        
Get
InBlock.gif            
Return _QuestionId
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Integer)
InBlock.gif            _QuestionId 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property QuestionContent()Property QuestionContent() As String
InBlock.gif        
Get
InBlock.gif            
Return _QuestionContent
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As String)
InBlock.gif            _QuestionContent 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property connstr()Property connstr() As String
InBlock.gif        
Get
InBlock.gif            
Return _connstr
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As String)
InBlock.gif            _connstr 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property CheckIf()Property CheckIf() As Boolean
InBlock.gif        
Get
InBlock.gif            
Return _CheckIf
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Boolean)
InBlock.gif            _CheckIf 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif   
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Sub New()Sub New(ByVal QuestionId As Integer)
InBlock.gif        getconnstr() 
'得到数据库的连接串
InBlock.gif
        Dim sqlstr As String = "select * from my_question where QuestionId=" + QuestionId.ToString
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(sqlstr, Conn)
InBlock.gif        
Dim myreader As SqlDataReader
InBlock.gif        myreader 
= Com.ExecuteReader
InBlock.gif        
If myreader.Read Then
InBlock.gif            _QuestionId 
= QuestionId
InBlock.gif            _QuestionContent 
= myreader("QuestionContent")
InBlock.gif        
End If
InBlock.gif        myreader.Close()
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif   
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function RetriveReader()Function RetriveReader() As SqlDataReader
InBlock.gif        
Dim strSqlstr As String = "select * from my_question where CheckIf=1"
InBlock.gif        
'连接数据库
InBlock.gif
        Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(strSqlstr, Conn)
InBlock.gif        
'验证
InBlock.gif
        Return Com.ExecuteReader(CommandBehavior.CloseConnection)
ExpandedSubBlockEnd.gif    
End Function

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function retrive()Function retrive() As DataSet
InBlock.gif        getconnstr() 
'得到数据库的连接串
InBlock.gif
        Dim sqlstr As String
InBlock.gif        sqlstr 
= "select * from my_question "
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif
InBlock.gif        Conn.Open()
InBlock.gif        
Dim da As New SqlDataAdapter(sqlstr, Conn)
InBlock.gif        
Dim ds As New DataSet
InBlock.gif        da.Fill(ds)
InBlock.gif        da.Dispose()
InBlock.gif        Conn.Close()
InBlock.gif        
Return ds
ExpandedSubBlockEnd.gif    
End Function

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Sub getconnstr()Sub getconnstr()
InBlock.gif        _connstr 
= ConfigurationManager.AppSettings("connStr")
ExpandedSubBlockEnd.gif    
End Sub

ExpandedBlockEnd.gif
End Class

answer.vb
None.gif Imports  System.Web
None.gif
Imports  System.Web.Services
None.gif
Imports  System.Web.Services.Protocols
None.gif
Imports  System.Data
None.gif
Imports  System.Data.SqlClient
None.gif
ExpandedBlockStart.gifContractedBlock.gif
Public   Class answer Class answer
InBlock.gif    
Private _AnswerId As Integer
InBlock.gif    
Private _AnswerContent As String
InBlock.gif    
Private _QuestionId As Integer
InBlock.gif    
Private _connstr As String
InBlock.gif    
Private _DianJi As Integer
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Sub New()Sub New()
InBlock.gif        getconnstr()
ExpandedSubBlockEnd.gif    
End Sub

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Sub New()Sub New(ByVal AnswerId As Integer)
InBlock.gif        getconnstr() 
'得到数据库的连接串
InBlock.gif
        Dim sqlstr As String = "select * from my_answer where AnswerId=" + AnswerId.ToString
InBlock.gif        
Dim conn As New SqlConnection(_connstr)
InBlock.gif        conn.Open()
InBlock.gif        
Dim com As New SqlCommand(sqlstr, conn)
InBlock.gif        
Dim myreader As SqlDataReader
InBlock.gif        myreader 
= com.ExecuteReader
InBlock.gif        
If myreader.Read Then
InBlock.gif            _AnswerId 
= AnswerId
InBlock.gif            _AnswerContent 
= myreader("AnswerContent")
InBlock.gif            _DianJi 
= myreader("DianJi")
InBlock.gif            _QuestionId 
= myreader("QuestionId")
InBlock.gif
InBlock.gif        
End If
InBlock.gif        myreader.Close()
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property AnswerId()Property AnswerId() As Integer
InBlock.gif        
Get
InBlock.gif            
Return _AnswerId
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Integer)
InBlock.gif            _AnswerId 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property AnswerContent()Property AnswerContent() As String
InBlock.gif        
Get
InBlock.gif            
Return _AnswerContent
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As String)
InBlock.gif            _AnswerContent 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property QuestionId()Property QuestionId() As Integer
InBlock.gif        
Get
InBlock.gif            
Return _QuestionId
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Integer)
InBlock.gif            _QuestionId 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Property DianJi()Property DianJi() As Integer
InBlock.gif        
Get
InBlock.gif            
Return _DianJi
InBlock.gif        
End Get
InBlock.gif        
Set(ByVal value As Integer)
InBlock.gif            _DianJi 
= value
InBlock.gif        
End Set
ExpandedSubBlockEnd.gif    
End Property

InBlock.gif  
InBlock.gif   
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Sub update()Sub update()
InBlock.gif        
Dim sqlstr As String = "Update my_answer set AnswerContent='" + _AnswerContent + "',DianJi=" + _DianJi.ToString + ",QuestionId=" + _QuestionId.ToString + "where AnswerId=" + _AnswerId.ToString
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(sqlstr, Conn)
InBlock.gif        Com.ExecuteNonQuery()
InBlock.gif        Conn.Close()
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Sub getconnstr()Sub getconnstr()
InBlock.gif        _connstr 
= ConfigurationManager.AppSettings("connStr")
ExpandedSubBlockEnd.gif    
End Sub

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function checklogin()Function checklogin() As Integer
InBlock.gif        
'对密码加密
InBlock.gif
        '到数据库验证
InBlock.gif
        'dim strSqlstr as String="select * from Portal_User where UserName='' and userPassword=''"
InBlock.gif
        '' Dim strJiaMi As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(myuserpassword, "sha1")
InBlock.gif
        Dim strsqlstr As String = "select * from my_answer where AnswerContent='" + _AnswerContent + "'"
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(strsqlstr, Conn)
InBlock.gif        
'验证
InBlock.gif
        Dim myreader As SqlDataReader = Com.ExecuteReader()
InBlock.gif        
If myreader.Read Then
InBlock.gif            myreader.Close()
InBlock.gif            Conn.Close()
InBlock.gif            
Return 1
InBlock.gif        
Else
InBlock.gif            myreader.Close()
InBlock.gif            Conn.Close()
InBlock.gif            
Return 0
InBlock.gif        
End If
InBlock.gif        
' myreader.Close()
ExpandedSubBlockEnd.gif
    End Function

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function RetriveReader()Function RetriveReader() As SqlDataReader
InBlock.gif        
Dim strSqlstr As String = "select * from my_answer where QuestionId=" + _QuestionId.ToString
InBlock.gif        
'连接数据库
InBlock.gif
        Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(strSqlstr, Conn)
InBlock.gif        
'验证
InBlock.gif
        Return Com.ExecuteReader(CommandBehavior.CloseConnection)
ExpandedSubBlockEnd.gif    
End Function

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function RetriveDs()Function RetriveDs() As DataSet
InBlock.gif        
Dim strSqlstr As String = "select * from my_answer where QuestionId=" + _QuestionId.ToString
InBlock.gif        
'连接数据库
InBlock.gif
        Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim da As New SqlDataAdapter(strSqlstr, Conn)
InBlock.gif        
Dim ds As New DataSet
InBlock.gif        da.Fill(ds)
InBlock.gif        da.Dispose()
InBlock.gif        Conn.Close()
InBlock.gif        
Return ds
ExpandedSubBlockEnd.gif    
End Function

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Sub Create()Sub Create()
InBlock.gif        
Dim sqlstr As String
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        sqlstr 
= "insert into my_answer(AnswerContent,QuestionId) values('" + _AnswerContent + "'," + _QuestionId.ToString + ")"
InBlock.gif        
'需要增加
InBlock.gif
        Dim Com As New SqlCommand(sqlstr, Conn)
InBlock.gif        Com.CommandText 
= sqlstr
InBlock.gif        Com.Connection 
= Conn
InBlock.gif        Com.ExecuteNonQuery()
InBlock.gif        Conn.Close()
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Sub delete()Sub delete()
InBlock.gif        
Dim sqlstr As String = "delete from my_answer where AnswerId=" & _AnswerId.ToString
InBlock.gif        
Dim Conn As New SqlConnection(_connstr)
InBlock.gif        Conn.Open()
InBlock.gif        
Dim Com As New SqlCommand(sqlstr, Conn)
InBlock.gif        Com.ExecuteNonQuery()
InBlock.gif        Conn.Close()
ExpandedSubBlockEnd.gif    
End Sub

ExpandedBlockEnd.gif
End Class

None.gif

转载于:https://www.cnblogs.com/liaolei/archive/2006/12/27/604804.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值