using CallCenterApi.DB; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CallCenterApi.DAL { public class Rotation { /// /// 增加一条图片 /// /// /// public int Add(Model.Rotation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Rotation("); strSql.Append("roname,romath,uploadpeo,uploaddate,isEnable)"); strSql.Append(" values ("); strSql.Append("@roname,@romath,@uploadpeo,@uploaddate,@isEnable)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@roname", SqlDbType.NVarChar,100), new SqlParameter("@romath", SqlDbType.NVarChar,300), new SqlParameter("@uploadpeo", SqlDbType.NVarChar,100), new SqlParameter("@uploaddate", SqlDbType.DateTime), new SqlParameter ("@isEnable",SqlDbType.Int,4)}; parameters[0].Value = model.roname; parameters[1].Value = model.romath; parameters[2].Value = model.uploadpeo; parameters[3].Value = model.uploaddate; parameters[4].Value = model.isEnable; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 查询图片信息 /// /// public DataSet GetList() { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" * "); strSql.Append(" FROM Rotation "); var ds = DbHelperSQL.Query(strSql.ToString()); return ds; } /// /// 禁用图片信息 /// /// /// public bool delrotation(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Rotation set isEnable=1 "); strSql.Append(" where id in (" + id + ") "); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 启用图片信息 /// /// /// public bool poenRotion(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Rotation set isEnable=0 "); strSql.Append(" where id in (" + id + ") "); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } } }