| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- using CallCenterApi.DB;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace CallCenterApi.DAL
- {
- public class Rotation
- {
- /// <summary>
- /// 增加一条图片
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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);
- }
- }
- /// <summary>
- /// 查询图片信息
- /// </summary>
- /// <returns></returns>
- public DataSet GetList(string name)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select ");
- strSql.Append(" * ");
- strSql.Append(" FROM Rotation ");
- if (name != "")
- {
- strSql.Append(" where roname like '%" + name + "%' ");
- }
- var ds = DbHelperSQL.Query(strSql.ToString());
- return ds;
- }
- /// <summary>
- /// 禁用图片信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 启用图片信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 删除图片
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public bool SCRotion(string id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from Rotation");
- strSql.Append(" where id in (" + id + ") ");
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.Rotation DataRowToModel(DataRow row)
- {
- #region 之前的
- #endregion
- Model.Rotation model = new Model.Rotation();//主表字段
- if (row != null)
- {
- #region 主表信息======================
- //利用反射获得属性的所有公共属性
- Type modelType = model.GetType();
- for (int i = 0; i < row.Table.Columns.Count; i++)
- {
- PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
- if (proInfo != null && row[i] != DBNull.Value)
- {
- //用索引值设置属性值
- proInfo.SetValue(model, row[i], null);
- }
- }
- #endregion
- }
- return model;
- }
- }
- }
|