diff --git a/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj b/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj
index 89d6643..2736737 100644
--- a/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj
+++ b/WebSiteCode/Cmdjy/Cmdjy/Cmdjy.csproj
@@ -153,6 +153,8 @@
+
+
@@ -211,6 +213,7 @@
+
diff --git a/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs b/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs
index 7bec3ac..4f01cbb 100644
--- a/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs
+++ b/WebSiteCode/Cmdjy/Cmdjy/Dal/DjyDbContext.cs
@@ -13,7 +13,7 @@ namespace Cmdjy.Dal
public partial class DjyDbContext:DbContext
{
public DjyDbContext() : base("DjyDbContext") {
- Database.SetInitializer(null);
+ //Database.SetInitializer(null);
}
}
///
diff --git a/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisDrugInfoWapper.cs b/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisDrugInfoWapper.cs
new file mode 100644
index 0000000..b312a8b
--- /dev/null
+++ b/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisDrugInfoWapper.cs
@@ -0,0 +1,18 @@
+namespace Cmdjy.Dal.Wappers
+{
+ ///
+ /// 药品信息墙纸
+ ///
+ public class HisDrugInfoWapper:Dal.Tables.HisDrugInfo
+ {
+ public HisDrugInfoWapper(ws.HisDrugInfo s) {
+ if(s == null) return;
+ foreach(var p in s.GetType().GetProperties()) {
+ var tp = this.GetType().GetProperty(p.Name);
+ if(tp != null && tp.CanWrite && p.CanRead) {
+ tp.SetValue(this,p.GetValue(s));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisPrescriptyInfoWapper.cs b/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisPrescriptyInfoWapper.cs
new file mode 100644
index 0000000..96ea15d
--- /dev/null
+++ b/WebSiteCode/Cmdjy/Cmdjy/Dal/Wappers/HisPrescriptyInfoWapper.cs
@@ -0,0 +1,15 @@
+namespace Cmdjy.Dal.Wappers
+{
+ public class HisPrescriptyInfoWapper:Dal.Tables.HisPrescriptionInfo
+ {
+ public HisPrescriptyInfoWapper(ws.HisPrescriptionInfo s) {
+ if(s == null) return;
+ foreach(var p in s.GetType().GetProperties()) {
+ var tp = this.GetType().GetProperty(p.Name);
+ if(tp != null && tp.CanWrite && p.CanRead) {
+ tp.SetValue(this,p.GetValue(s));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/WebSiteCode/Cmdjy/Cmdjy/ws/HisInterface.asmx.cs b/WebSiteCode/Cmdjy/Cmdjy/ws/HisInterface.asmx.cs
index 90d230a..aba98f2 100644
--- a/WebSiteCode/Cmdjy/Cmdjy/ws/HisInterface.asmx.cs
+++ b/WebSiteCode/Cmdjy/Cmdjy/ws/HisInterface.asmx.cs
@@ -4,6 +4,9 @@ using System.Linq;
using System.Web;
using System.Web.Services;
using Newtonsoft.Json;
+using Cmdjy.Dal;
+using Cmdjy.Dal.Wappers;
+using System.Data.Entity;
namespace Cmdjy.ws
{
@@ -20,21 +23,51 @@ namespace Cmdjy.ws
[WebMethod(Description = "医疗机构上传处方信息")]
public string PostPrescriptionInfo(HisPrescriptionInfo info) {
- var json = JsonConvert.SerializeObject(info);
- var result = new HisPrescriptionResult {
- Code = ResultCode.Success,PrescriptionId = "1",
- Msg = json,
- };
+ HisPrescriptionResult result = null;
+ using(var db = new DjyDbContext()) {
+ var en = new HisPrescriptyInfoWapper(info) as Dal.Tables.HisPrescriptionInfo;
+ en.RawAddress = this.Context.Request.UserHostAddress;
+ en.CreateDatetime = DateTime.Now;
+ db.Entry(en).State = EntityState.Added;
+ try {
+ db.SaveChanges();
+ result = new HisPrescriptionResult {
+ Code = ResultCode.Success,PrescriptionId = en.Id.ToString(),
+ Msg = "保存成功",
+ };
+ }
+ catch(Exception ex) {
+ result = new HisPrescriptionResult {
+ Code = ResultCode.Exception,PrescriptionId = "0",
+ Msg = ex.ToString(),
+ };
+ }
+ }
return JsonConvert.SerializeObject(result);
}
[WebMethod(Description = "医疗机构上传药品信息")]
public string PostDrugInfo(HisDrugInfo info) {
- var json = JsonConvert.SerializeObject(info);
- var result = new HisDrugResult {
- Code = ResultCode.Success,DrugId = "1",
- Msg = json,
- };
+ HisDrugResult result = null;
+ using(var db = new DjyDbContext()) {
+ var en = new HisDrugInfoWapper(info) as Dal.Tables.HisDrugInfo;
+ en.RawAddress = this.Context.Request.UserHostAddress;
+ en.CreateDatetime = DateTime.Now;
+ db.Entry(en).State = EntityState.Added;
+ try {
+ db.SaveChanges();
+ result = new HisDrugResult {
+ Code = ResultCode.Success,DrugId = en.Id.ToString(),
+ Msg = "保存成功",
+ };
+ }
+ catch(Exception ex) {
+ result = new HisDrugResult {
+ Code = ResultCode.Exception,DrugId = "0",
+ Msg = ex.ToString(),
+ };
+ }
+ }
return JsonConvert.SerializeObject(result);
}
}