using System; using Dapper; using HNWD.Pregrant.Model; using System.Collections.Generic; using System.Text; namespace HNWD.Pregrant.DataAccess { public class WD_UrgeInfoDataAccess : GenericDataAccess { private WD_UrgeInfo wd_UrgeInfo = null; public WD_UrgeInfoExt ext = new WD_UrgeInfoExt(); private readonly static WD_UrgeInfoDataAccess wd_UrgeInfoDataAccess = new WD_UrgeInfoDataAccess(null); private readonly static object lockobj = new object(); public static WD_UrgeInfoDataAccess GetInstance() { lock (lockobj) { return wd_UrgeInfoDataAccess; } } private WD_UrgeInfoDataAccess(WD_UrgeInfo wd_UrgeInfo) { this.wd_UrgeInfo = wd_UrgeInfo; } public List QueryAll() { string strSql = " select {0} from [WD_UrgeInfo] "; ext.messageDataList = this.Query(strSql, new WD_UrgeInfo()); ext.messageDataList.ForEach(f => f.bSuccess = this.bSuccess); ext.messageDataList.ForEach(f => f.Code = this.Code); ext.messageDataList.ForEach(f => f.Message = this.Message); ext.messageDataList.ForEach(f => f.Rows = this.Rows); ext.bSuccess = this.bSuccess; ext.Code = this.Code; ext.Message = this.Message; ext.Rows = this.Rows; return ext.messageDataList; } public void Business(List il,List ul,List dl) { string strSql_i = " Insert into WD_UrgeInfo(URGE_PATIENT_ID , URGE_VALUE ,URGE_DATETIME) values('{0}' , '{1}', '{2}') "; string strSql_u = " Update WD_UrgeInfo set URGE_VALUE = '{0}' where ID = '{1}'"; string strSql_d = " delete WD_UrgeInfo where ID = '{0}'"; StringBuilder sb_i = new StringBuilder(); foreach(WD_UrgeInfo wd in il) { sb_i.AppendFormat(strSql_i, wd.URGE_PATIENT_ID, wd.URGE_VALUE, wd.URGE_DATETIME); } StringBuilder sb_u = new StringBuilder(); foreach (WD_UrgeInfo wd in ul) { sb_u.AppendFormat(strSql_u, wd.URGE_VALUE, wd.ID); } StringBuilder sb_d = new StringBuilder(); foreach (WD_UrgeInfo wd in dl) { sb_d.AppendFormat(strSql_d, wd.ID); } this.Execute(sb_i.ToString(), sb_u.ToString(), sb_d.ToString()); } } }