using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using SqlSugar; using System.Collections.Generic; namespace HL_FristAidPlatform_DataBase { /// /// 急救信息 V2.1版 /// public class T_Service_ChestPain_FirstAIDInfoDB : BaseDB, IT_Service_ChestPain_FirstAIDInfo { public SqlSugarClient db = GetClient(); #region 增 /// /// 新增 /// /// 实体 /// public bool Add(T_Service_ChestPain_FirstAIDInfo model) { return db.Insertable(model).ExecuteCommand() == 0 ? false : true; } /// /// 新增 仅更新赋值的字段 /// /// 实体类 /// public int AddNotNullColumns(T_Service_ChestPain_FirstAIDInfo model) { //Where(true/* Is no insert null */, true/*off identity*/) return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand(); } /// /// 新增 仅更新赋值的字段 /// 用于移动端 /// /// 实体类 /// public int AddForApp(T_Service_ChestPain_FirstAIDInfo model) { return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand(); } #endregion #region 删 /// /// 删除一条数据 /// public bool Delete(long ID) { return db.Deleteable(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; } #endregion #region 改 /// /// 更新一条数据 /// public bool Update(T_Service_ChestPain_FirstAIDInfo model) { return db.Updateable(model).ExecuteCommand() == 0 ? false : true; } /// /// 仅更新赋值的字段 /// /// 实体类 /// public int UpdateNotNullColumns(T_Service_ChestPain_FirstAIDInfo model) { return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); } public int UpdateTime(T_Service_ChestPain_FirstAIDInfo model) { return db.Updateable(model).UpdateColumns(i => new { i.Attack_Time, i.CW_120_Arrived_Hospital_Time, i.CW_120_First_Doctor_Time, i.CW_120_First_MC_Time, i.CW_120_Help_Time, i.CW_YNFB_Consultation_Time, i.Start_Agree_time, i.CW_ZY_First_MC_Time, i.CW_ZY_Outhospital_Visit_Time, i.CW_ZY_Transfer_Time, i.CW_ZY_Leave_Outhospital_Time, i.CW_ZY_Arrived_Hospital_Time, i.CW_ZY_Admission_Time, i.CW_ZXLY_Arrived_Hospital_Time, i.CW_ZXLY_First_MC_Time, i.CW_ZXLY_First_Doctor_Time, i.CW_YNFB_First_MC_Time, i.CW_YNFB_Leave_Department_Time, i.Throm_Start_Time, i.Sign_Agree_Time, i.Throm_End_Time, i.Start_Radiography_Time, i.Operation_Time }).ExecuteCommand(); } /// /// 修改--仅更新赋值的字段 /// 用于移动端 /// /// 实体类 /// public int UpdateForApp(T_Service_ChestPain_FirstAIDInfo model) { if (!string.IsNullOrEmpty(model.PatientGuid)) { var patient = db.Queryable().Where(i => i.GUID == model.PatientGuid).First(); if (patient != null && model.CW_120_Is_Trans_Hospital == "1") { patient.Province = model.Province; patient.City = model.City; patient.Area = model.Area; patient.Area = model.Area; patient.IsGreenChannel = 3; db.Updateable(patient).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); } } T_Service_ChestPain_FirstAIDInfo info = db.Queryable().Where(i => i.PatientGuid == model.PatientGuid).First(); return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); } #endregion #region 查 /// /// 得到一个对象实体 /// public T_Service_ChestPain_FirstAIDInfo GetModel(long ID) { return db.Queryable().First(it => it.ID == ID); } public T_Service_ChestPain_FirstAIDInfo GetModelOfPatient(string guid) { return db.Queryable().First(it => it.PatientGuid == guid); } /// /// 获得前几行数据 /// /// 起始页 /// 每页条数 /// public TableModel GetPageList(int pageIndex, int pageSize) { int total = 0; List data = db.Queryable().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total); TableModel t = new TableModel(); t.Code = 0; t.PageCount = data.Count; t.TotalNumber = total; t.Data = data; t.Msg = "成功"; return t; } /// /// 根据患者编号(GUID) 获取数据信息 /// /// 病人编号(GUID) /// public TableModel GetByPatientGuid(string patientGuid) { TableModel t = new TableModel(); List listMode = db.Queryable().Where(it => it.PatientGuid == patientGuid && it.DeleteFlag == 0).ToList(); t.Code = 0; t.TotalNumber = listMode.Count; t.Data = listMode; t.Msg = "成功"; return t; } /// /// 查--根据患者编号(GUID) 获取数据信息 /// 用于移动端 /// /// 病人编号(GUID) /// public TableModel GetByPatientGuidForApp(string patientGuid) { TableModel t = new TableModel(); List listMode = db.Queryable().Where(it => it.PatientGuid == patientGuid && it.DeleteFlag == 0).ToList(); t.Code = 0; t.TotalNumber = listMode.Count; t.Data = listMode; t.Msg = "成功"; return t; } #endregion } }