123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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 NBDevManufacturerService
- {
- SqlHelper sqlHelper = new SqlHelper("NBDB");
- /// <summary>
- /// 保存NBDevManufacturer 设备厂商
- /// </summary>
- /// <param name="entity"></param>
- /// <returns> </returns>
- public bool SaveNBDevManufacturer(NBDevManufacturerEntity entity)
- {
- try
- {
- string insertSql = DataHelper.ModelToInsertSql<NBDevManufacturerEntity>(entity, "RMRS_NBDevManufacturer");
- return sqlHelper.ExecuteNoParams(insertSql, CommandType.Text) > 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 更新NBDevManufacturer
- /// </summary>
- /// <param name="entity"></param>
- /// <returns></returns>
- public bool UpdateNBDevManufacturer(NBDevManufacturerEntity entity)
- {
- try
- {
- string updateSql = DataHelper.ModelToUpdateSql<NBDevManufacturerEntity>(entity, "RMRS_NBDevManufacturer");
- return sqlHelper.ExecuteNoParams(updateSql, CommandType.Text) > 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除NBDevManufacturer
- /// </summary>
- /// <param name="NBDevManufacturerID"></param>
- /// <returns>3 不可删除 1 删除成功 0删除失败</returns>
- public int DeleteNBDevManufacturer(string NBDevManufacturerID)
- {
- try
- {
- //判断次类型下有无表
- string sqlMeter = "SELECT * FROM RMRS_MeterInfo WHERE NBDevManufacturer = " + NBDevManufacturerID;
- DataTable dtMeter = sqlHelper.ExecuteDataTable(sqlMeter, CommandType.Text, null);
- if (dtMeter.Rows.Count > 0)
- {
- return 3;
- }
- string delSql = "DELETE FROM RMRS_NBDevManufacturer WHERE NBDevManufacturerID = " + NBDevManufacturerID;
- return sqlHelper.ExecuteNoParams(delSql, CommandType.Text) > 0 ? 1 : 0;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取NBDevManufacturer
- /// </summary>
- /// <param name="NBDevManufacturerID"></param>
- /// <returns></returns>
- public NBDevManufacturerEntity GetEntityById(string NBDevManufacturerID)
- {
- try
- {
- string sqlNBDevManufacturer = "SELECT * FROM RMRS_NBDevManufacturer WHERE NBDevManufacturerID = " + NBDevManufacturerID;
- DataTable dtResult = sqlHelper.ExecuteDataTable(sqlNBDevManufacturer, CommandType.Text, null);
- List<NBDevManufacturerEntity> lists = DataHelper.DataTableToT<NBDevManufacturerEntity>(dtResult);
- if (lists != null)
- {
- return lists[0];
- }
- return new NBDevManufacturerEntity();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|