public int Insert(P_Admin p_Admin) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform)) { return(conn.Execute(DapperExtentions.MakeInsertSql(p_Admin), p_Admin)); } }
public MessageEntity AddPointArea(PointAreaInfo pointTable) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide)) { var rows = 0; string sql = $@"select count(0) as count from PointAreaInfo p where p.PlanAreaId = {pointTable.PlanAreaId} and p.PointName='{ pointTable.PointName}'"; List <dynamic> pointcc = conn.Query <dynamic>(sql).ToList(); if (pointcc[0].count > 0) { return(MessageEntityTool.GetMessage(ErrorType.NotUnique, "同一区域内不能添加相同关键点")); } var updateSql = DapperExtentions.MakeInsertSql(pointTable); if (string.IsNullOrEmpty(updateSql)) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类")); } try { rows = conn.Execute(updateSql, pointTable); return(MessageEntityTool.GetMessage(rows)); } catch (Exception e) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message)); } } }
public MessageEntity AddEventType(M_EventType eventType) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide)) { var rows = 0; var insertSql = DapperExtentions.MakeInsertSql(eventType); if (string.IsNullOrEmpty(insertSql)) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类")); } try { rows = conn.Execute(insertSql, eventType); return(MessageEntityTool.GetMessage(rows)); } catch (Exception e) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message)); } } }
public MessageEntity PostTaskEqument(L_Task_CompleteDetail task_CompleteDetail) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide)) { var rows = 0; int recordNum = 0; var insertSql = DapperExtentions.MakeInsertSql(task_CompleteDetail); if (string.IsNullOrEmpty(insertSql)) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类")); } if (task_CompleteDetail.EquType != null) { recordNum = conn.ExecuteScalar <int>("select count(0) from L_Task_CompleteDetail where TaskId=@TaskId and Devicesmid=@Devicesmid and EquType=@EquType", task_CompleteDetail); } else { recordNum = conn.ExecuteScalar <int>("select count(0) from L_Task_CompleteDetail where TaskId=@TaskId and Devicesmid=@Devicesmid", task_CompleteDetail); } if (recordNum > 0) { return(MessageEntityTool.GetMessage(ErrorType.NotUnique, null, "同一任务不能重复巡检设备")); } try { rows = conn.Execute(insertSql, task_CompleteDetail); return(MessageEntityTool.GetMessage(rows)); } catch (Exception e) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message)); } } }
public int InsertEntity(object entity, ConnectionFactory.DBConnNames dBConnName, out MessageEntity messageEntity) { using (var conn = ConnectionFactory.GetDBConn(dBConnName)) { var rows = 0; var result = DapperExtentions.MakeInsertSql(entity); if (string.IsNullOrEmpty(result)) { messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类"); return(0); } try { rows = conn.Execute(result, entity); messageEntity = MessageEntityTool.GetMessage(rows); } catch (Exception e) { messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message); } return(rows); } }