教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 外语考试 >

医院管理系统课程设计(2)

来源:网络收集 时间:2026-05-30
导读: private System.Windows.Forms.StatusStrip statusStrip2; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5

private System.Windows.Forms.StatusStrip statusStrip2;

private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5; private System.Windows.Forms.GroupBox groupBox9; private System.Windows.Forms.TextBox price; private System.Windows.Forms.Button button3; private System.Windows.Forms.TextBox CarInfo; private System.Windows.Forms.Button button8;

private System.Windows.Forms.Button butClean;

医院药品管理系统

4.2 数据库设计核心代码 4.2.1用户管理插入存储过程: create proc proc_userinsert @usernum varchar(15), @username varchar(20), @userid varchar(18), @company varchar(50), @usertelep varchar(11), @userEmail varchar(50), @password varchar(35), @usertype int , @address varchar(100), @message varchar(100)output as

declare @num int declare @error int begin

select @num = count(*) from tb_users where usernum = @usernum and username = @username if(@num > 0)

set @message = '对不起,此用户已存在!' else begin

insert into tb_users values

(@usernum,@username,@userid,@company,@usertelep,@userEmail, @password,@usertype,@address) set @error = @@error if (@error <> 0)

set @message = '添加用户失败,添加异常' else

set @message = '0' end end GO

SET QUOTED_IDENTIFIER ON GO

SET ANSI_NULLS ON

医院药品管理系统

GO

4.2.2用户管理删除存储过程:

create proc [dbo].[proc_userdelete] --@usernum varchar(15), @username varchar(20), @message varchar(100)output as

declare @number int declare @error int begin

select @number =count(*)from tb_users where username = @username if (@number<1)

set @message ='对不起,该用户不存在!' else begin

delete from tb_users where username= @username set @error = @@error if (@error <> 0 )

set @message = '对不起,删除失败!' else

set @message = '0' end end GO

SET QUOTED_IDENTIFIER OFF GO

SET ANSI_NULLS ON GO

4.2.3 药品信息更新存储过程:

ALTER proc proc_medicineupdate @medicineId varchar(15), @medicineBrand varchar(50), @medicinename varchar(50), @price money,

@medicineinfo varchar(128),

医院药品管理系统

@username varchar (15), @spacenum varchar(15), @message varchar(100) output as

declare @usernum varchar(50) declare @error int declare @number int begin

BEGIN TRANSACTION set @error = 0

select @number = count(*) from tb_medicinemobile where medicineId = @medicineID if(@number<1)

set @message = '对不起,此药品信息不存在' else begin

select @usernum = usernum from tb_users where username= @username print @username

update tb_new set 药品编号=@medicineId ,药品品牌=@medicineBrand,用户= where 药品编号=@medicineId

SET @ERROR = @@error

update tb_transactionManger set startTime = getdate() where usernum=@usernum

SET @ERROR = @ERROR + @@error

update tb_showspace set isoccupy=1 where spacenum=@spacenum SET @ERROR = @ERROR + @@error

--select @aotoId= medicineId from medicinemobile where aotoId= @medicineId Update

@price,medicineInfo=@medicineinfo

where medicineId=@medicineId SET @ERROR = @ERROR + @@error if(@error = 0) begin

commit transaction set @message = '0' end else

@username,药品名=@medicinename,价位=@price,车位=@spacenum,药品信息=@medicineinfo

tb_medicinemobile set

medicineId=@medicineId ,medicineBrand=@medicineBrand,medicinename=@medicinename,price=

医院药品管理系统

begin

ROLLBACK TRANSACTION

set @message = '用户更新药品信息异常!!' end end end GO

SET QUOTED_IDENTIFIER OFF GO

SET ANSI_NULLS ON GO

4.3 连接数据库核心代码 4.3.1连接数据库核心代码:

namespace medicinemobileshow.ShareClass {

public class DBConnection {

private String URL = null; //用于存放连接数据库的字符串 private SqlConnection con = null; //数据连接对象 public DBConnection() { this.link(); }

/// 连接数据库 private void link() { try {

URL = "Data Source = .;Initial Catalog = db_medicinemobile;User ID =sa ;Password =123456 "; con = new SqlConnection(URL); }catch(Exception e){

MessageBox.Show(e.ToString(),"数据库连接异",MessageBoxButtons.OK,MessageBoxIcon.Error); } }

/// 获得数据库连接

/// <returns>返回数据连接</returns> public SqlConnection getConnection() { return con; }

/// 打开数据库连接

/// <param name="conn">要打开的数据库连接对象</param> /// <returns>返回数据库连接对象</returns>

public SqlConnection openConnection(SqlConnection conn) { conn.Open(); return conn; }

/// 关闭数据库连接

/// <param name="conn">要关闭的数据库连接对象</param> public void closeConnection(SqlConnection conn) { try {

conn.Close(); }catch(Exception e){

MessageBox.Show(e.ToString(), "数据库连接异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } }

医院药品管理系统

} }

4.3.2将查询结果显示到DataGridView中的核心代码:

private void butAdd_Click(object sender, EventArgs e) {

try {

con = new SqlConnection(); con = conn.getConnection();

com = new SqlCommand("proc_medicineinsert", con); mandType = CommandType.StoredProcedure;

com.Parameters.Add(new SqlParameter("@usernum", erN …… 此处隐藏:4204字,全部文档内容请下载后查看。喜欢就下载吧 ……

医院管理系统课程设计(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/117564.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)