123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using LeaRun.Application.Entity.NBManage;
- using LeaRun.Data;
- using LeaRun.Util;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LeaRun.Application.Service.NBManage
- {
- public class NBTypeCodeService
- {
- SqlHelper sqlHelper = new SqlHelper("NBDB");
- /// <summary>
- /// 保存NBTypeCode
- /// </summary>
- /// <param name="entity"></param>
- /// <returns> </returns>
- public bool SaveNBTypeCode(NBTypeCodeEntity entity)
- {
- try
- {
- string insertSql = DataHelper.ModelToInsertSql<NBTypeCodeEntity>(entity, "RMRS_NBTypeCode");
- return sqlHelper.ExecuteNoParams(insertSql, CommandType.Text) > 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 更新设备类型
- /// </summary>
- /// <param name="entity"></param>
- /// <returns></returns>
- public bool UpdateNBTypeCode(NBTypeCodeEntity entity)
- {
- try
- {
- string updateSql = DataHelper.ModelToUpdateSql<NBTypeCodeEntity>(entity, "RMRS_NBTypeCode");
- return sqlHelper.ExecuteNoParams(updateSql, CommandType.Text) > 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除设备类型
- /// </summary>
- /// <param name="NBTypeCodeID"></param>
- /// <returns>3 不可删除 1 删除成功 0删除失败</returns>
- public int DeleteNBTypeCode(string NBTypeCodeID)
- {
- try
- {
- //判断次类型下有无表
- string sqlMeter = "SELECT * FROM RMRS_MeterInfo WHERE NBTypeCode = " + NBTypeCodeID;
- DataTable dtMeter = sqlHelper.ExecuteDataTable(sqlMeter, CommandType.Text, null);
- if (dtMeter.Rows.Count > 0)
- {
- return 3;
- }
- string delSql = "DELETE FROM RMRS_NBTypeCode WHERE NBTypeCodeID = " + NBTypeCodeID;
- return sqlHelper.ExecuteNoParams(delSql, CommandType.Text) > 0 ? 1 : 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取类型
- /// </summary>
- /// <param name="NBTypeCodeID"></param>
- /// <returns></returns>
- public NBTypeCodeEntity GetEntityById(string NBTypeCodeID)
- {
- try
- {
- string sqlNBTypeCode = "SELECT * FROM RMRS_NBTypeCode WHERE NBTypeCodeID = " + NBTypeCodeID;
- DataTable dtResult = sqlHelper.ExecuteDataTable(sqlNBTypeCode, CommandType.Text, null);
- List<NBTypeCodeEntity> lists = DataHelper.DataTableToT<NBTypeCodeEntity>(dtResult);
- if (lists != null)
- {
- return lists[0];
- }
- return new NBTypeCodeEntity();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|