using HelperDB; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Text; namespace AIMSExtension { public class ProgramLog { public ProgramLog() { } public int ID { get; set; } public string Content { get; set; } //[DBField("PatientID")] public string PatientID { get; set; } //[DBField("IsUpData")] public int IsUpData { get; set; } //[DBField("OperatorId")] public int OperatorId { get; set; } //[DBField("OperatorName")] public string OperatorName { get; set; } //[DBField("OperatorIP")] public string OperatorIP { get; set; } //[DBField("OperatorTime")] public DateTime OperatorTime { get; set; } //[DBField("Remark")] public string Remark { get; set; } } public static partial class ProgramLogService { public static readonly string InsertSql = "INSERT ProgramLog (Content, PatientID, IsUpData, OperatorId, OperatorName, OperatorIP, OperatorTime, Remark)VALUES (@Content, @PatientID, @IsUpData, @OperatorId, @OperatorName, @OperatorIP, @OperatorTime, @Remark)"; public static readonly string UpdateSql = "Update ProgramLog set Content=@Content, PatientID=@PatientID, IsUpData=@IsUpData, OperatorId=@OperatorId, OperatorName=@OperatorName, OperatorIP=@OperatorIP, OperatorTime=@OperatorTime, Remark=@Remark where ID=@ID"; public static readonly string DeleteSql = "Delete FROM ProgramLog where ID=@ID"; public static readonly string SelectSql = "Select * FROM ProgramLog"; public static readonly string SelectSqlById = "Select * FROM ProgramLog where ID =@ID"; public static int AddProgramLog(ProgramLog programLog) { string sql = InsertSql; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Content",programLog.Content), new SqlParameter("@PatientID",programLog.PatientID), new SqlParameter("@IsUpData",programLog.IsUpData), new SqlParameter("@OperatorId",programLog.OperatorId), new SqlParameter("@OperatorName",programLog.OperatorName), new SqlParameter("@OperatorIP",programLog.OperatorIP), new SqlParameter("@OperatorTime",programLog.OperatorTime), new SqlParameter("@Remark",programLog.Remark) }; return DBHelper.ExecNonQuery(sql, para); } public static int UpdateProgramLog(ProgramLog programLog) { string sql = UpdateSql; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ID",programLog.ID), new SqlParameter("@Content",programLog.Content), new SqlParameter("@PatientID",programLog.PatientID), new SqlParameter("@IsUpData",programLog.IsUpData), new SqlParameter("@OperatorId",programLog.OperatorId), new SqlParameter("@OperatorName",programLog.OperatorName), new SqlParameter("@OperatorIP",programLog.OperatorIP), new SqlParameter("@OperatorTime",programLog.OperatorTime), new SqlParameter("@Remark",programLog.Remark) }; return DBHelper.ExecNonQuery(sql, para); } public static int DelProgramLog(ProgramLog programLog) { string sql = DeleteSql; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ID",programLog.ID) }; return DBHelper.ExecNonQuery(sql, para); } public static IList GetAllList() { string sql = SelectSql; return GetListBySql(sql); } public static ProgramLog GetProgramLogByID(int ID) { string sql = SelectSqlById; SqlParameter para = new SqlParameter("@ID", ID); IList list = GetListBySql(sql, para); if (list.Count > 0) return list[0]; else return null; } private static IList GetListBySql(string sql, params SqlParameter[] para) { IList list = new List(); using (SqlDataReader reader = DBHelper.GetReader(sql, para)) { while (reader.Read()) { ProgramLog temp = new ProgramLog(); temp.ID = DBHelper.GetInt(reader["ID"]); temp.Content = DBHelper.GetString(reader["Content"]); temp.PatientID = DBHelper.GetString(reader["PatientID"]); temp.IsUpData = DBHelper.GetInt(reader["IsUpData"]); temp.OperatorId = DBHelper.GetInt(reader["OperatorId"]); temp.OperatorName = DBHelper.GetString(reader["OperatorName"]); temp.OperatorIP = DBHelper.GetString(reader["OperatorIP"]); temp.OperatorTime = DBHelper.GetDateTime(reader["OperatorTime"]); temp.Remark = DBHelper.GetString(reader["Remark"]); list.Add(temp); } reader.Close(); return list; } } } }