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

相关推荐
V+zmm101348 分钟前
基于微信小程序的乡村政务服务系统springboot+论文源码调试讲解
java·微信小程序·小程序·毕业设计·ssm
wakangda21 分钟前
React Native 集成原生Android功能
javascript·react native·react.js
吃杠碰小鸡24 分钟前
lodash常用函数
前端·javascript
Oneforlove_twoforjob33 分钟前
【Java基础面试题025】什么是Java的Integer缓存池?
java·开发语言·缓存
emoji11111134 分钟前
前端对页面数据进行缓存
开发语言·前端·javascript
xmh-sxh-131435 分钟前
常用的缓存技术都有哪些
java
泰伦闲鱼36 分钟前
nestjs:GET REQUEST 缓存问题
服务器·前端·缓存·node.js·nestjs
m0_7482500341 分钟前
Web 第一次作业 初探html 使用VSCode工具开发
前端·html
一个处女座的程序猿O(∩_∩)O1 小时前
vue3 如何使用 mounted
前端·javascript·vue.js
m0_748235951 小时前
web复习(三)
前端