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

相关推荐
生椰拿铁You3 分钟前
09 —— Webpack搭建开发环境
前端·webpack·node.js
喵叔哟11 分钟前
重构代码中引入外部方法和引入本地扩展的区别
java·开发语言·重构
狸克先生15 分钟前
如何用AI写小说(二):Gradio 超简单的网页前端交互
前端·人工智能·chatgpt·交互
尘浮生17 分钟前
Java项目实战II基于微信小程序的电影院买票选座系统(开发文档+数据库+源码)
java·开发语言·数据库·微信小程序·小程序·maven·intellij-idea
sinat_3842410917 分钟前
在有网络连接的机器上打包 electron 及其依赖项,在没有网络连接的机器上安装这些离线包
javascript·arcgis·electron
baiduopenmap29 分钟前
百度世界2024精选公开课:基于地图智能体的导航出行AI应用创新实践
前端·人工智能·百度地图
loooseFish37 分钟前
小程序webview我爱死你了 小程序webview和H5通讯
前端
不是二师兄的八戒40 分钟前
本地 PHP 和 Java 开发环境 Docker 化与配置开机自启
java·docker·php
小牛itbull41 分钟前
ReactPress vs VuePress vs WordPress
开发语言·javascript·reactpress
请叫我欧皇i1 小时前
html本地离线引入vant和vue2(详细步骤)
开发语言·前端·javascript