asp.net+sqlite3牙科诊所病历系统

Imports System.Data.SQLite
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub GridView1_PreRender(sender As Object, e As EventArgs) Handles GridView1.PreRender
        Me.GridView1.AllowPaging = True
        Me.GridView1.DataKeyNames = New String() {"rowid"}
        Me.GridView1.DataSource = Me.selectAll()
        Me.GridView1.DataBind()
    End Sub

    Public Function selectAll() As System.Data.DataTable
        Using con As SQLiteConnection = New SQLiteConnection("Data Source=|DataDirectory|mydata.sqlite3")
            Using cmd As SQLiteCommand = New SQLiteCommand("select rowid, * from t_user order by rowid desc", con)
                Using da As SQLiteDataAdapter = New SQLiteDataAdapter(cmd)
                    Using dt As DataTable = New DataTable()
                        da.Fill(dt)
                        Return dt
                    End Using
                End Using
            End Using
        End Using
    End Function

    Protected Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        Me.GridView1.PageIndex = e.NewPageIndex
    End Sub

    Protected Sub GridView1_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GridView1.RowEditing
        Me.GridView1.EditIndex = e.NewEditIndex
    End Sub

    Protected Sub GridView1_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
        Me.GridView1.EditIndex = -1
    End Sub

    Protected Sub GridView1_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim rowid As String = Me.GridView1.Rows(e.RowIndex).Cells(3).Text
        Response.Write(rowid)
        Dim username As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(4).Controls(0), TextBox).Text
        Dim gender As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(5).Controls(0), TextBox).Text
        Dim birthday As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(6).Controls(0), TextBox).Text
        Dim mobile1 As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(7).Controls(0), TextBox).Text
        Dim guomin As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(8).Controls(0), TextBox).Text
        Dim jiwangbingshi As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(9).Controls(0), TextBox).Text
        Dim doctor As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(10).Controls(0), TextBox).Text
        Dim zhusu As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(11).Controls(0), TextBox).Text
        Dim zhiliao As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(12).Controls(0), TextBox).Text
        Dim beizhu As String = CType(Me.GridView1.Rows(e.RowIndex).Cells(13).Controls(0), TextBox).Text

        Using con As SQLiteConnection = New SQLiteConnection("Data Source=|DataDirectory|mydata.sqlite3")
            Using cmd As SQLiteCommand = New SQLiteCommand("update t_user set username = @username, gender = @gender, birthday = @birthday, mobile1 = @mobile1, guomin = @guomin, jiwangbingshi = @jiwangbingshi, doctor = @doctor, zhusu = @zhusu, zhiliao = @zhiliao, beizhu = @beizhu where rowid = @rowid", con)
                cmd.Parameters.AddWithValue("rowid", rowid)
                cmd.Parameters.AddWithValue("username", username)
                cmd.Parameters.AddWithValue("gender", gender)
                cmd.Parameters.AddWithValue("birthday", birthday)
                cmd.Parameters.AddWithValue("mobile1", mobile1)
                cmd.Parameters.AddWithValue("guomin", guomin)
                cmd.Parameters.AddWithValue("jiwangbingshi", jiwangbingshi)
                cmd.Parameters.AddWithValue("doctor", doctor)
                cmd.Parameters.AddWithValue("zhusu", zhusu)
                cmd.Parameters.AddWithValue("zhiliao", zhiliao)
                cmd.Parameters.AddWithValue("beizhu", beizhu)
                con.Open()
                Dim i As Integer = cmd.ExecuteNonQuery()
                Response.Write("更新了" & i & "条")
            End Using
        End Using
        Me.GridView1.EditIndex = -1
    End Sub

    Protected Sub GridView1_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GridView1.RowDeleting
        Dim rowid As String = Me.GridView1.Rows(e.RowIndex).Cells(3).Text
        Response.Write(rowid)
        Using con As SQLiteConnection = New SQLiteConnection("Data Source=|DataDirectory|mydata.sqlite3")
            Using cmd As SQLiteCommand = New SQLiteCommand("delete from t_user where rowid = @rowid", con)
                cmd.Parameters.AddWithValue("rowid", rowid)
                con.Open()
                Dim i As Integer = cmd.ExecuteNonQuery()
                Response.Write("删除了" & i & "条")
            End Using
        End Using
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
        Dim rowid As String = Me.GridView1.SelectedRow.Cells(3).Text
        Response.Write(rowid)
        Response.Redirect("~/HuanZhe.aspx?rowid=" + rowid)
    End Sub

    Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles LinkButton1.Click
        Response.Redirect("~/SouSuo.aspx")
    End Sub
End Class
 

你可能感兴趣的:(java,前端,javascript)