70 lines
4.4 KiB
C#
70 lines
4.4 KiB
C#
using HelperDB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DrawGraph
|
|
{
|
|
public static partial class PhysioDataService
|
|
{
|
|
//Add Mothed Start
|
|
public static readonly string InsertSql = "INSERT PhysioData (PatientId, PhysioDataConfigId, RecordTime, Value )VALUES (@PatientId, @PhysioDataConfigId, @RecordTime, @Value )";
|
|
public static int AddPhysioData(PhysioData physioData)
|
|
{
|
|
string sql = InsertSql;
|
|
SqlParameter[] para = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@PatientId",physioData.PatientId), new SqlParameter("@PhysioDataConfigId",physioData.PhysioDataConfigId), new SqlParameter("@RecordTime",physioData.RecordTime), new SqlParameter("@Value",physioData.Value)
|
|
};
|
|
return DBHelper.ExecNonQuery(sql, para);
|
|
}
|
|
|
|
public static void UpdatePhysioData(PhysioData oldphysioData, PhysioData newphysioData, string OperatorName)
|
|
{
|
|
string sql = "update PhysioData set Value= '" + newphysioData.Value + "' where convert(varchar,RecordTime,120) >='" + oldphysioData.RecordTime.AddSeconds(-120).ToString("yyyy-MM-dd HH:mm:ss") + "' and convert(varchar,RecordTime,120) <='" + oldphysioData.RecordTime.AddSeconds(120).ToString("yyyy-MM-dd HH:mm:ss") + "' and PhysioDataConfigId=" + oldphysioData.PhysioDataConfigId + " and PatientId=" + oldphysioData.PatientId;
|
|
DBHelper.ExecNonQuery(sql);
|
|
|
|
InsertPhysioDataUpdate(oldphysioData, newphysioData, OperatorName);
|
|
}
|
|
|
|
public static void InsertPhysioDataUpdate(PhysioData oldphysioData, PhysioData newphysioData, string OperatorName)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(string.Format(@" INSERT PhysioDataUpdate (PatientId, PhysioDataConfigId, RecordTime, OldParamValue,ParamValue, OperatorName,OperatorTime)VALUES ({0},{1},'{2}',{3},{4},'{5}','{6}') ", newphysioData.PatientId, newphysioData.PhysioDataConfigId, newphysioData.RecordTime, oldphysioData.Value, newphysioData.Value, OperatorName, DateTime.Now));
|
|
DBHelper.ExecNonQuery(sb.ToString());
|
|
}
|
|
|
|
public static void DelPhysioByValueData(PhysioData physioData)
|
|
{
|
|
string sql = "Delete FROM PhysioData where RecordTime between DATEADD( minute,-2,@RecordTime) and DATEADD( minute,2,@RecordTime) and PatientId=@PatientId and PhysioDataConfigId=@PhysioDataConfigId ";
|
|
SqlParameter[] para = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@RecordTime",physioData.RecordTime),
|
|
new SqlParameter("@PatientId",physioData.PatientId),
|
|
new SqlParameter("@PhysioDataConfigId",physioData.PhysioDataConfigId)
|
|
};
|
|
DBHelper.ExecNonQuery(sql, para);
|
|
}
|
|
|
|
public static void DelPhysioasDataParameterID(DateTime RecordTime, DateTime EndTime, int PhysioParamID, int PatientId)
|
|
{
|
|
string sql = "Delete FROM PhysioData where RecordTime between DATEADD( ss,-59,@RecordTime) and DATEADD( ss,59,@EndTime) and PatientId=@PatientId and PhysioDataConfigId=@PhysioDataConfigId ";
|
|
SqlParameter[] para = new SqlParameter[]
|
|
{
|
|
new SqlParameter("@RecordTime",RecordTime),
|
|
new SqlParameter("@EndTime",EndTime),
|
|
new SqlParameter("@PatientId",PatientId),
|
|
new SqlParameter("@PhysioDataConfigId",PhysioParamID)
|
|
};
|
|
DBHelper.ExecNonQuery(sql, para);
|
|
}
|
|
|
|
public static void DelectPhysioDataByID(int operationId, DateTime startTime, DateTime endTime, double startValue, double endValue, int PhysioDataConfigId)
|
|
{
|
|
string sqlStr = "delete FROM PhysioData where PhysioDataConfigId = " + PhysioDataConfigId + " and PatientId = " + operationId + " and [RecordTime] >='" + startTime + "' and [RecordTime] <='" + endTime + "' and [Value] >='" + startValue + "' and [Value] <='" + endValue + "' ";
|
|
DBHelper.ExecNonQuery(sqlStr);
|
|
}
|
|
}
|
|
} |