基于C#与SQLsever医院信息系统开发

目录

 一.功能:

二.初级数据流图:

三.数据字典:

四.概念结构设计:

五.逻辑结构设计:

六.数据库创建:

七.界面设计:

八.代码实现:


 一.功能:

用户1:患者,可登录账号,查看自己电子病历,以及自己的相关信息

用户2:医生,可登录账号,查询自己所治疗病人的他们的病历,并能添加和更新病历信息

用户3:数据库管理人员,可登陆账号,对医生,病人等用户做数据的更新

二.初级数据流图:

三.数据字典:

①病人数据结构的数据项

序号数据项名称数据项含义说明
1病人编号含义:唯一标识每一个患者;类型:字符;
2姓名含义:病人的姓名;类型:字符;
3性别类型:字符;
4年龄含义:病人的年玲;类型:字符
5联系电话类型:字符;
6密码类型:字符

②医生数据结构的数据项

序号数据项名称数据项含义说明
1医生编号含义:唯一标识每一个医生;类型:字符;
2姓名含义:医生的姓名;类型:字符;
3性别类型:字符;
4年龄含义:医生的年玲;类型:char
5联系电话类型:字符;
6密码类型:字符

③病历数据结构的数据项

序号数据项名称数据项含义说明
1病人编号含义:唯一标识每一个患者;类型:字符;
2过往病史含义:展示病人的过往病史;类型:字符;
3诊断结果类型:字符;
4治疗方案类型:字符;
5是否缴费类型:字符;

④管理员数据结构的数据项

序号数据项名称数据项含义说明
1管理员Id类型:字符;
2密码类型:字符;

四.概念结构设计:

局部E-R图

全局E-R图

五.逻辑结构设计:

doctor(DNO,DN,SEX,DB,DTN,D.Password)//医生
patient(PNO,PN,SEX,PB,PTN,P.Password)//病人
MH(PNO,history,result,plans,pay)//病历
admin(adminId,adminpassword)//管理员

六.数据库创建:

CREATE TABLE [dbo].[admin] (
    [adminId]       NVARCHAR (10) NOT NULL,
    [adminpassword] NVARCHAR (10) NULL,
    PRIMARY KEY CLUSTERED ([adminId] ASC)
);
​
CREATE TABLE [dbo].[doctor] (
    [DNO]        NVARCHAR (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [DN]         NVARCHAR (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [SEX]        NVARCHAR (2)  NULL,
    [DB]         DATE          NULL,
    [DTN]        NVARCHAR (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [D.Password] NVARCHAR (8)  NULL,
    PRIMARY KEY CLUSTERED ([DNO] ASC)
);
​
CREATE TABLE [dbo].[MH] (
    [PNO]     NVARCHAR (10)  COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [history] NVARCHAR (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [result]  NVARCHAR (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [plans]   NVARCHAR (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [pay]     NVARCHAR (2)   NULL,
    PRIMARY KEY CLUSTERED ([PNO] ASC),
    FOREIGN KEY ([PNO]) REFERENCES [dbo].[patient] ([PNO])
);
​
CREATE TABLE [dbo].[patient] (
    [PNO]        NVARCHAR (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [PN]         NVARCHAR (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [SEX]        NVARCHAR (2)  NULL,
    [PB]         DATE          NULL,
    [PTN]        NVARCHAR (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [P.Password] NVARCHAR (8)  NULL,
    PRIMARY KEY CLUSTERED ([PNO] ASC)
);
​

七.界面设计:

笔者在此共制作14个窗体,数量多,不一一展示,部分窗体效果如下,窗口设计因人而异,本文章将不介绍窗口的制作,请读者依靠自己的喜好进行设计

窗体列表:

八.代码实现:

在此提供大部分窗体的功能代码,其他窗体代码的功能实现与这些窗体代码的功能大同小异。

1.Splash(加载)页面功能代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
​
namespace Hospital
{
    public partial class Splash : Form
    {
        public Splash()
        {
            InitializeComponent();//初始化页面
        }
​
        private void splash_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }
​
        private void label1_Click(object sender, EventArgs e)
        {
​
        }
​
        private void label2_Click(object sender, EventArgs e)
        {
​
        }
        int startpos = 0;
        private void timer1_Tick(object sender, EventArgs e) //进度条函数。
        {
            startpos += 4;
            Myprogress.Value = startpos;
            PercentageLbl.Text = startpos.ToString() + "%";
            if (Myprogress.Value == 100) //加载到100%,跳转到login界面
            {
                Myprogress.Value = 0;
                timer1.Stop();
                Login log = new Login();
                log.Show();
                this.Hide();
            }
        }
    }
}
​

2.login界面功能代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient; //导入库
​
namespace Hospital
{
    public partial class Login : Form
    {
        SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\解决SQL一点问题的文件夹\Hospital.mdf;Integrated Security=True;Connect Timeout=30");//连接到数据库
        public Login()
        {
            InitializeComponent();
        }
​
        private void label1_Click(object sender, EventArgs e)
        {
​
        }
​
        private void label2_Click(object sender, EventArgs e)
        {
​
        }
​
        public static string UPNO = "";        //设置全局变量,用于其他页面数据的传接
        public static string UPName = "";
        public static string UPsex = "";
        public static string UPB = "";
        public static string UPTN = "";
        private void button1_Click(object sender, EventArgs e)
        {
            Con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from patient where PNO = '"+PatPNO.Text+"'and [P.Password] = '"+PatPassword.Text+"'",Con);//检查账号密码是否正确
            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1") 
            {
                UPNO = PatPNO.Text;
                SqlCommand myCommand = Con.CreateCommand();
                myCommand.CommandText = "select PN,SEX,PB,PTN from patient where PNO = '" + PatPNO.Text + "'";//查询病人相对应信息,并赋值给当前窗格的全局变量,为下个页面做准备
                SqlDataReader myReader = myCommand.ExecuteReader();
                myReader.Read();
                UPName = myReader["PN"].ToString();
                UPsex = myReader["SEX"].ToString();
                UPB = myReader["PB"].ToString();
                UPTN = myReader["PTN"].ToString();
                patient_information obj = new patient_information();
                obj.Show();
                this.Hide();
                Con.Close();
            }
            else 
            {
                MessageBox.Show("账号或密码错误!");
            }
            Con.Close();
        }
​
        private void label4_Click(object sender, EventArgs e)//登录界面的切换
        {
            doctorlogin obj = new doctorlogin();
            obj.Show();
            this.Hide();
        }
​
        private void Login_Load(object sender, EventArgs e)
        {
            
        }
​
        private void label5_Click(object sender, EventArgs e)
        {
            adminlogin obj = new adminlogin();
            obj.Show();
            this.Hide();
        }
    }
}

3.adminlogin界面功能实现

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Xml.Linq;
​
namespace Hospital
{
    public partial class adminlogin : Form
    {
        SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\解决SQL一点问题的文件夹\Hospital.mdf;Integrated Security=True;Connect Timeout=30");
        public adminlogin()
        {
            InitializeComponent();
        }
​
        private void label4_Click(object sender, EventArgs e)
        {
            doctorlogin obj = new doctorlogin();
            obj.Show();
            this.Hide();
        }
​
        private void adminlogin_Load(object sender, EventArgs e)
        {
            
        }
​
        private void label5_Click(object sender, EventArgs e)
        {
            Login obj = new Login();
            obj.Show();
            this.Hide();
        }
​
        private void button1_Click(object sender, EventArgs e)
        {
            Con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from admin where adminId = '" + adnum.Text + "'and [adminpassword] = '" + adpassword.Text + "'", Con);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                User_root_1 obj = new User_root_1();
                obj.Show();
                this.Hide();
                Con.Close();
            }
            else
            {
                MessageBox.Show("账号或密码错误!");
            }
            Con.Close();
        }
    }
}

4.doctorlogin界面功能实现

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing.Printing;
using System.Xml.Linq;
​
namespace Hospital
{
    public partial class doctorlogin : Form
    {
        SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\解决SQL一点问题的文件夹\Hospital.mdf;Integrated Security=True;Connect Timeout=30");
        public doctorlogin()
        {
            InitializeComponent();
        }
​
        private void label5_Click(object sender, EventArgs e)
        {
            adminlogin obj = new adminlogin();
            obj.Show();
            this.Hide();
        }
​
        private void label4_Click(object sender, EventArgs e)
        {
            Login obj = new Login();
            obj.Show();
            this.Hide();
        }
​
        public static string UDNO = "";
        public static string UDName = "";
        public static string UDsex = "";
        public static string UDB = "";
        public static string UDTN = "";
        private void button1_Click(object sender, EventArgs e)
        {
            Con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("select count(*) from doctor where DNO = '" + DocDNO.Text + "'and [D.Password] = '" + DocPassword.Text + "'", Con);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                UDNO = DocDNO.Text;
                SqlCommand myCommand = Con.CreateCommand();
                myCommand.CommandText = "select DN,SEX,DB,DTN from doctor where DNO = '" + DocDNO.Text + "'";
                SqlDataReader myReader = myCommand.ExecuteReader();
                myReader.Read();
                UDName = myReader["DN"].ToString();
                UDsex = myReader["SEX"].ToString();
                UDB = myReader["DB"].ToString();
                UDTN = myReader["DTN"].ToString();
                Doctor_information obj = new Doctor_information();
                obj.Show();
                this.Hide();
                Con.Close();
            }
            else
            {
                MessageBox.Show("账号或密码错误!");
            }
            Con.Close();
        }
​
        private void doctorlogin_Load(object sender, EventArgs e)
        {
​
        }
    }
}
​

5.patient_information页面功能实现

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing.Printing;
using System.Xml.Linq;
​
namespace Hospital
{
    public partial class patient_information : Form
    {
        SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\解决SQL一点问题的文件夹\Hospital.mdf;Integrated Security=True;Connect Timeout=30");
        
        public static string Phistory="";
        public static string Presult = "";
        public static string Pplans = "";
        public static string Ppay = "";
        public patient_information()
        {
            InitializeComponent();
            PNOLB.Text = Login.UPNO;
            PNLB.Text = Login.UPName;
            PSEXLB.Text = Login.UPsex;
            PPBLB.Text = Login.UPB;
            PPTNLB.Text= Login.UPTN;
​
            Con.Open();
            SqlCommand myCommand = Con.CreateCommand();
            myCommand.CommandText = "select history,result,plans,pay from MH where PNO = '" + PNOLB.Text + "'";
            SqlDataReader myReader = myCommand.ExecuteReader();
            myReader.Read();
            Phistory = myReader["history"].ToString();
            Presult = myReader["result"].ToString();
            Pplans = myReader["plans"].ToString();
            Ppay = myReader["pay"].ToString();
            Con.Close();
        }
​
        private void label7_Click(object sender, EventArgs e)
        {
​
        }
​
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
​
        }
​
        private void PNOLB_Click(object sender, EventArgs e)
        {
            
        }
​
        private void PPBLB_Click(object sender, EventArgs e)
        {
​
        }
​
        private void PNLB_Click(object sender, EventArgs e)
        {
​
        }
​
        private void label3_Click(object sender, EventArgs e)
        {
            Login obj = new Login();
            obj.Show();
            this.Hide();
        }
​
        private void label2_Click(object sender, EventArgs e)
        {
            Patient obj = new Patient();
            obj.Show();
            this.Hide();
        }
​
        private void patient_information_Load(object sender, EventArgs e)
        {
​
        }
    }
}

6.User_root_1代码实现

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
​
​
namespace Hospital
{
    public partial class User_root_1 : Form
    {
        SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\解决SQL一点问题的文件夹\Hospital.mdf;Integrated Security=True;Connect Timeout=30");
        public User_root_1()
        {
            InitializeComponent();
            populate();
        }
        private void populate() 
        {
            Con.Open();
            string query = "select *from patient";
            SqlDataAdapter sda = new SqlDataAdapter(query,Con);
            SqlCommandBuilder builder = new SqlCommandBuilder(sda);
            var ds = new DataSet();
            sda.Fill(ds);
            patient_data.DataSource = ds.Tables[0];
            Con.Close();
        }
​
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
​
        }
​
        private void panel7_Paint(object sender, PaintEventArgs e)
        {
​
        }
​
        private void patient_data_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
​
        }
​
        private void label1_Click(object sender, EventArgs e)
        {
​
        }
​
        private void label6_Click(object sender, EventArgs e)
        {
            Login obj = new Login();
            obj.Show();
            this.Hide();
        }
​
        private void label4_Click(object sender, EventArgs e)
        {
            User_root_2 obj = new  User_root_2();
            obj.Show();
            this.Hide();
        }
​
        private void label5_Click(object sender, EventArgs e)
        {
            User_root_3 obj = new User_root_3();
            obj.Show();
            this.Hide();
        }
​
        private void label3_Click(object sender, EventArgs e)
        {
            User_root_4 obj = new User_root_4();
            obj.Show();
            this.Hide();
        }
​
        private void User_root_1_Load(object sender, EventArgs e)
        {
​
        }
    }
}

  • 28
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值