using System; using Dapper; using HNWD.Pregrant.Model; using System.Collections.Generic; using System.Text; namespace HNWD.Pregrant.DataAccess { public class WD_NoticeInfoDataAccess : GenericDataAccess { private WD_NoticeInfo wd_NoticeInfo= null; public WD_NoticeInfoExt ext = new WD_NoticeInfoExt(); private readonly static WD_NoticeInfoDataAccess wd_NoticeInfoDataAccess = new WD_NoticeInfoDataAccess(null); private readonly static object lockobj = new object(); public static WD_NoticeInfoDataAccess GetInstance() { lock (lockobj) { return wd_NoticeInfoDataAccess; } } private WD_NoticeInfoDataAccess(WD_NoticeInfo wd_NoticeInfo) { this.wd_NoticeInfo = wd_NoticeInfo; } //public List QueryAll() //{ // string strSql = " select {0} from [WD_NoticeInfo] " ; // ext.NoticeArray = this.Query(strSql, new WD_NoticeInfo()); // ext.messageDataList = ext.NoticeArray; // ext.NoticeArray.ForEach(f => f.bSuccess = this.bSuccess); // ext.NoticeArray.ForEach(f => f.Code = this.Code); // ext.NoticeArray.ForEach(f => f.Message = this.Message); // ext.NoticeArray.ForEach(f => f.Rows = this.Rows); // 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.NoticeArray; //} public List QueryAll() { //string strSql = " select {0} from [WD_NoticeInfo] where abs(DATEDIFF(n,getdate(),[NOTICE_STARTTIME])) <4 and DATEDIFF(n,getdate(),[NOTICE_ENDTIME] )>0 and [NOTICE_PATIENT_ID] =" + this.wd_NoticeInfo.NOTICE_PATIENT_ID.Trim(); string strSql = " select {0} from [WD_NoticeInfo] where abs(DATEDIFF(n,getdate(),[NOTICE_STARTTIME])) <4 and DATEDIFF(n,getdate(),[NOTICE_ENDTIME] )>0 "; ext.NoticeArray = this.Query(strSql, new WD_NoticeInfo()); ext.messageDataList = ext.NoticeArray; ext.NoticeArray.ForEach(f => f.bSuccess = this.bSuccess); ext.NoticeArray.ForEach(f => f.Code = this.Code); ext.NoticeArray.ForEach(f => f.Message = this.Message); ext.NoticeArray.ForEach(f => f.Rows = this.Rows); 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.NoticeArray; } public void Business(List il, List ul, List dl) { string strSql_i = " Insert into WD_NoticeInfo([NOTICE_PATIENT_ID],[NOTICE_TEXT],[NOTICE_STARTTIME],[NOTICE_ENDTIME],[NOTICE_DATETIME]) VALUES ('{0}' , '{1}', '{2}', '{3}', '{4}') "; string strSql_u = " Update WD_NoticeInfo set NOTICE_PATIENT_ID = '{0}' , NOTICE_TEXT = '{1}' , NOTICE_STARTTIME = '{2}' , NOTICE_ENDTIME = '{3}' , NOTICE_DATETIME = '{4}' where ID = '{5}' "; string strSql_d = " delete WD_NoticeInfo where ID = '{0}' "; StringBuilder sb_i = new StringBuilder(); foreach (WD_NoticeInfo wd in il) { sb_i.AppendFormat(strSql_i, wd.NOTICE_PATIENT_ID, wd.NOTICE_TEXT, wd.NOTICE_STARTTIME, wd.NOTICE_ENDTIME, wd.NOTICE_DATETIME); } StringBuilder sb_u = new StringBuilder(); foreach (WD_NoticeInfo wd in ul) { sb_u.AppendFormat(strSql_u, wd.NOTICE_PATIENT_ID, wd.NOTICE_TEXT, wd.NOTICE_STARTTIME, wd.NOTICE_ENDTIME, wd.NOTICE_DATETIME ,wd.ID); } StringBuilder sb_d = new StringBuilder(); foreach (WD_NoticeInfo wd in dl) { sb_d.AppendFormat(strSql_d, wd.ID); } this.Execute(sb_i.ToString(), sb_u.ToString(), sb_d.ToString()); } } }