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

相关推荐
腾讯TNTWeb前端团队7 小时前
helux v5 发布了,像pinia一样优雅地管理你的react状态吧
前端·javascript·react.js
mghio8 小时前
Dubbo 中的集群容错
java·微服务·dubbo
范文杰10 小时前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪10 小时前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪10 小时前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy11 小时前
macOS 命令行 原生挂载 webdav 方法
前端
uhakadotcom12 小时前
Astro 框架:快速构建内容驱动型网站的利器
前端·javascript·面试
uhakadotcom12 小时前
了解Nest.js和Next.js:如何选择合适的框架
前端·javascript·面试
uhakadotcom12 小时前
React与Next.js:基础知识及应用场景
前端·面试·github