引入EF管理数据库。定义数据库模型

This commit is contained in:
falcon 2019-03-01 14:52:25 +08:00
parent 60fc4392f3
commit 7c5e81c1af
7 changed files with 323 additions and 2 deletions

View File

@ -45,6 +45,12 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -148,6 +154,10 @@
<Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" /> <Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\TestController.cs" />
<Compile Include="Dal\DjyDbContext.cs" />
<Compile Include="Dal\Tables\HisDrugInfo.cs" />
<Compile Include="Dal\Tables\HisPrescriptionInfo.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>
@ -202,6 +212,7 @@
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
<Folder Include="Models\" /> <Folder Include="Models\" />
<Folder Include="Views\Test\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff2" /> <Content Include="fonts\glyphicons-halflings-regular.woff2" />

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Cmdjy.Controllers
{
public class TestController:Controller
{
// GET: Test
public ActionResult Index(string msg) {
return Json(new { msg },JsonRequestBehavior.AllowGet);
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using Cmdjy.Dal.Tables;
namespace Cmdjy.Dal
{
/// <summary>
/// 崇明代煎药数据库
/// </summary>
public partial class DjyDbContext:DbContext
{
public DjyDbContext() : base("DjyDbContext") {
Database.SetInitializer<DjyDbContext>(null);
}
}
/// <summary>
/// 数据表定义
/// </summary>
public partial class DjyDbContext
{
/// <summary>
/// 处方信息
/// </summary>
public DbSet<HisPrescriptionInfo> PrescriptionInfos { get; set; }
/// <summary>
/// 药品信息
/// </summary>
public DbSet<HisDrugInfo> DrugInfos { get; set; }
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace Cmdjy.Dal.Tables
{
/// <summary>
/// HIS发送的药品信息
/// </summary>
[Table("HisPrescriptionInfo")]
public class HisDrugInfo
{
/// <summary>
/// 主键,药品流水号
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
/// 记录创建时间
/// </summary>
public DateTime CreateDatetime { get; set; }
/// <summary>
/// 处方流水号
/// </summary>
public int PrescriptionId { get; set; }
/// <summary>
/// 发送请求的原始IP地址
/// </summary>
public string RawAddress { get; set; }
/// <summary>
/// "药品医保代码":"YP0306401000650",
/// </summary>
public string DrugNo { get; set; }
/// <summary>
/// 药品单价 0.085
/// </summary>
public string Price { get; set; }
/// <summary>
/// 单贴数量
/// </summary>
public string Count { get; set; }
/// <summary>
/// 单位 克
/// </summary>
public string Unit { get; set; }
/// <summary>
/// 单项总价
/// </summary>
public string Sum { get; set; }
/// <summary>
/// 规格 15.00000000
/// </summary>
public string DrugType { get; set; }
/// <summary>
/// 药品编码
/// </summary>
public string DrugLocalNo { get; set; }
/// <summary>
/// 药品名称
/// </summary>
public string DrugName { get; set; }
/// <summary>
/// 特殊要求
/// </summary>
public string Remark { get; set; }
}
}

View File

@ -0,0 +1,171 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Cmdjy.Dal.Tables
{
/// <summary>
/// HIS发送的处方信息
/// </summary>
[Table("HisPrescriptionInfo")]
public class HisPrescriptionInfo
{
/// <summary>
/// 主键,处方流水号
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
/// 记录创建时间
/// </summary>
public DateTime CreateDatetime { get; set; }
/// <summary>
/// 发送请求的原始IP地址
/// </summary>
public string RawAddress { get; set; }
/// <summary>
/// 处方类型
/// </summary>
public PrescriptionType Type { get; set; }
/// <summary>
/// 如果为退方,这里传要退的处方流水号。此编号在下单应答消息中提供
/// </summary>
public string RawRecordId { get; set; }
/// <summary>
/// 药品明细数量
/// </summary>
public string DrugCount { get; set; }
/// <summary>
/// 处方备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 带回病房 否
/// </summary>
public string TakeBack { get; set; }
/// <summary>
/// "操作类型": "煎药自取", or "操作类型": "煎药快递", or "操作类型": "配药快递"
/// </summary>
public string OpType { get; set; }
/// <summary>
/// 操作员
/// </summary>
public string OpUser { get; set; }
/// <summary>
/// 病区
/// </summary>
public string Area { get; set; }
/// <summary>
/// 病床号
/// </summary>
public string Bed { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public string OpDatatime { get; set; }
/// <summary>
/// 处方号
/// </summary>
public string PrescriptionNo { get; set; }
/// <summary>
/// 处方日期
/// </summary>
public string PrescriptionDatatime { get; set; }
/// <summary>
/// 单位编号 医疗机构编号
/// </summary>
public string HosNo { get; set; }
/// <summary>
/// 医疗机构名称
/// </summary>
public string HosName { get; set; }
/// <summary>
/// 发票号
/// </summary>
public string InvoiceNo { get; set; }
/// <summary>
/// 病人编号
/// </summary>
public string PatientNo { get; set; }
/// <summary>
/// 病人卡号
/// </summary>
public string CardNo { get; set; }
/// <summary>
/// 科室名称
/// </summary>
public string DepName { get; set; }
/// <summary>
/// 病人年龄
/// </summary>
public string PatientAge { get; set; }
/// <summary>
/// 病人生日
/// </summary>
public string PatientBrithday { get; set; }
/// <summary>
/// 病人手机号码
/// </summary>
public string PatientMobile { get; set; }
/// <summary>
/// 病人电话
/// </summary>
public string PatientPhone { get; set; }
/// <summary>
/// 所在区县街道
/// </summary>
public string District { get; set; }
/// <summary>
/// 送货地址
/// </summary>
public string PostAddress { get; set; }
/// <summary>
/// 送货时间
/// </summary>
public string PostDatatime { get; set; }
/// <summary>
/// 贴数
/// </summary>
public string UseCount { get; set; }
/// <summary>
/// 病人性别
/// </summary>
public string PatientSex { get; set; }
/// <summary>
/// 病人姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 医生姓名
/// </summary>
public string DoctorName { get; set; }
/// <summary>
/// 诊断
/// </summary>
public string Diagnosis { get; set; }
/// <summary>
/// 用法
/// </summary>
public string Usage { get; set; }
}
/// <summary>
/// 处方类型
/// </summary>
[Flags]
public enum PrescriptionType
{
/// <summary>
/// 订单
/// </summary>
Order = 1,
/// <summary>
/// 撤销订单,退单
/// </summary>
CancelOrder = 2,
/// <summary>
/// 测试方。测试处方不会发送给第三方
/// </summary>
TestOrder = 4,
}
}

View File

@ -4,12 +4,21 @@
https://go.microsoft.com/fwlink/?LinkId=301880 https://go.microsoft.com/fwlink/?LinkId=301880
--> -->
<configuration> <configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings> <appSettings>
<add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" /> <add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" /> <add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings> </appSettings>
<connectionStrings>
<add name="DjyDbContext"
connectionString="Data Source=FALCON-PC\SQLSERVER2008R2;Persist Security info=True;Initial Catalog=cmdjy;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web> <system.web>
<compilation debug="true" targetFramework="4.6.1" /> <compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" /> <httpRuntime targetFramework="4.6.1" />
@ -26,7 +35,7 @@
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" /> <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.1" newVersion="4.0.2.1" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.1" newVersion="4.0.2.1" />
</dependentAssembly> </dependentAssembly>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" /> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" /> <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
@ -68,4 +77,14 @@
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers> </compilers>
</system.codedom> </system.codedom>
</configuration> <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

View File

@ -2,6 +2,7 @@
<packages> <packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net461" /> <package id="Antlr" version="3.5.0.2" targetFramework="net461" />
<package id="bootstrap" version="3.3.7" targetFramework="net461" /> <package id="bootstrap" version="3.3.7" targetFramework="net461" />
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="jQuery" version="3.3.1" targetFramework="net461" /> <package id="jQuery" version="3.3.1" targetFramework="net461" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net461" /> <package id="jQuery.Validation" version="1.17.0" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net461" />