医院管理系统课程设计(2)
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字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [外语考试]管理学 第13章 沟通
- [外语考试]07、中高端客户销售流程--分类、筛选讲
- [外语考试]2015-2020年中国高筋饺子粉市场发展现
- [外语考试]“十三五”重点项目-汽车燃油表生产建
- [外语考试]雅培奶粉培乐系列适用年龄及特点
- [外语考试]九三学社入社申请人调查问卷
- [外语考试]等级薪酬体系职等职级表
- [外语考试]货物买卖合同纠纷起诉状(范本一)
- [外语考试]青海省实施消防法办法
- [外语考试]公交车语音自动报站系统的设计第3稿11
- [外语考试]logistic回归模型在ROC分析中的应用
- [外语考试]2017-2021年中国隔膜泵行业发展研究与
- [外语考试]神经内科下半年专科考试及答案
- [外语考试]园林景观设计规范标准
- [外语考试]2018八年级语文下册第一单元4合欢树习
- [外语考试]分布式发电及微网运行控制技术应用
- [外语考试]三人行历史学笔记:中世纪人文主义思想
- [外语考试]2010届高考复习5年高考3年联考精品历史
- [外语考试]挖掘机驾驶员安全生产责任书
- [外语考试]某211高校MBA硕士毕业论文开题报告(范
- 用三层交换机实现大中型企业VLAN方案
- 斯格配套系种猪饲养管理
- 涂层测厚仪厂家直销
- 研究生学校排行榜
- 鄱阳湖湿地景观格局变化及其驱动力分析
- 医学基础知识试题库
- 2010山西省高考历年语文试卷精选考试技
- 脉冲宽度法测量电容
- 谈高职院校ESP教师的角色调整问题
- 低压配电网电力线载波通信相关技术研究
- 余额宝和城市商业银行的转型研究
- 篮球行进间运球教案
- 气候突变的定义和检测方法
- 财经大学基坑开挖应急预案
- 高大支模架培训演示
- 一种改进的稳健自适应波束形成算法
- 2-3-鼎视通核心人员薪酬股权激励管理手
- 我国电阻焊设备和工艺的应用现状与发展
- MTK手机基本功能覆盖测试案例
- 七年级地理教学课件上册第四章第一节




