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

相关推荐
半开半落几秒前
nuxt3安装pinia报错500[vite-node] [ERR_LOAD_URL]问题解决
前端·javascript·vue.js·nuxt
百事老饼干8 分钟前
Java[面试题]-真实面试
java·开发语言·面试
customer0816 分钟前
【开源免费】基于SpringBoot+Vue.JS医院管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·spring cloud·开源·intellij-idea
2402_8575893626 分钟前
SpringBoot框架:作业管理技术新解
java·spring boot·后端
理想不理想v28 分钟前
vue经典前端面试题
前端·javascript·vue.js
不收藏找不到我29 分钟前
浏览器交互事件汇总
前端·交互
HBryce2430 分钟前
缓存-基础概念
java·缓存
小阮的学习笔记42 分钟前
Vue3中使用LogicFlow实现简单流程图
javascript·vue.js·流程图
YBN娜43 分钟前
Vue实现登录功能
前端·javascript·vue.js