/** 版本信息模板在安装目录下,可自行修改。
* AutoCallOut.cs
*
* 功 能: N/A
* 类 名: AutoCallOut
*
* Ver 变更日期 负责人 变更内容
* ───────────────────────────────────
* V0.01 2021/11/16 15:58:24 N/A 初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
*│ 版权所有:动软卓越(北京)科技有限公司 │
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using CallCenterApi.DB;
namespace CallCenterApi.DAL
{
///
/// 数据访问类:AutoCallOut
///
public partial class AutoCallOut
{
public AutoCallOut()
{}
#region BasicMethod
///
/// 得到最大ID
///
public int GetMaxId()
{
return DbHelperSQL.GetMaxID("ID", "AutoCallOut");
}
///
/// 是否存在该记录
///
public bool Exists(int ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from AutoCallOut");
strSql.Append(" where ID=@ID");
SqlParameter[] parameters = {
new SqlParameter("@ID", SqlDbType.Int,4)
};
parameters[0].Value = ID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
///
/// 增加一条数据
///
public int Add(CallCenterApi.Model.AutoCallOut model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into AutoCallOut(");
strSql.Append("usercode,tel,createtime,isphoned,identification,callid)");
strSql.Append(" values (");
strSql.Append("@usercode,@tel,@createtime,@isphoned,@identification,@callid)");
strSql.Append(";select @@IDENTITY");
SqlParameter[] parameters = {
new SqlParameter("@usercode", SqlDbType.VarChar,20),
new SqlParameter("@tel", SqlDbType.VarChar,50),
new SqlParameter("@createtime", SqlDbType.DateTime),
new SqlParameter("@isphoned", SqlDbType.Int,4),
new SqlParameter("@identification", SqlDbType.VarChar,100),
new SqlParameter("@callid", SqlDbType.VarChar,200)};
parameters[0].Value = model.usercode;
parameters[1].Value = model.tel;
parameters[2].Value = model.createtime;
parameters[3].Value = model.isphoned;
parameters[4].Value = model.identification;
parameters[5].Value = model.callid;
object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
///
/// 更新一条数据
///
public bool Update(CallCenterApi.Model.AutoCallOut model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update AutoCallOut set ");
strSql.Append("usercode=@usercode,");
strSql.Append("tel=@tel,");
strSql.Append("createtime=@createtime,");
strSql.Append("isphoned=@isphoned,");
strSql.Append("identification=@identification,");
strSql.Append("callid=@callid");
strSql.Append(" where ID=@ID");
SqlParameter[] parameters = {
new SqlParameter("@usercode", SqlDbType.VarChar,20),
new SqlParameter("@tel", SqlDbType.VarChar,50),
new SqlParameter("@createtime", SqlDbType.DateTime),
new SqlParameter("@isphoned", SqlDbType.Int,4),
new SqlParameter("@identification", SqlDbType.VarChar,100),
new SqlParameter("@callid", SqlDbType.VarChar,200),
new SqlParameter("@ID", SqlDbType.Int,4)};
parameters[0].Value = model.usercode;
parameters[1].Value = model.tel;
parameters[2].Value = model.createtime;
parameters[3].Value = model.isphoned;
parameters[4].Value = model.identification;
parameters[5].Value = model.callid;
parameters[6].Value = model.ID;
int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 删除一条数据
///
public bool Delete(int ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from AutoCallOut ");
strSql.Append(" where ID=@ID");
SqlParameter[] parameters = {
new SqlParameter("@ID", SqlDbType.Int,4)
};
parameters[0].Value = ID;
int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 批量删除数据
///
public bool DeleteList(string IDlist )
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from AutoCallOut ");
strSql.Append(" where ID in ("+IDlist + ") ");
int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
///
/// 得到一个对象实体
///
public CallCenterApi.Model.AutoCallOut GetModel(int ID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select top 1 ID,usercode,tel,createtime,isphoned,identification,callid from AutoCallOut ");
strSql.Append(" where ID=@ID");
SqlParameter[] parameters = {
new SqlParameter("@ID", SqlDbType.Int,4)
};
parameters[0].Value = ID;
CallCenterApi.Model.AutoCallOut model=new CallCenterApi.Model.AutoCallOut();
DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
if(ds.Tables[0].Rows.Count>0)
{
return DataRowToModel(ds.Tables[0].Rows[0]);
}
else
{
return null;
}
}
///
/// 得到一个对象实体
///
public CallCenterApi.Model.AutoCallOut DataRowToModel(DataRow row)
{
CallCenterApi.Model.AutoCallOut model=new CallCenterApi.Model.AutoCallOut();
if (row != null)
{
if(row["ID"]!=null && row["ID"].ToString()!="")
{
model.ID=int.Parse(row["ID"].ToString());
}
if(row["usercode"]!=null)
{
model.usercode=row["usercode"].ToString();
}
if(row["tel"]!=null)
{
model.tel=row["tel"].ToString();
}
if(row["createtime"]!=null && row["createtime"].ToString()!="")
{
model.createtime=DateTime.Parse(row["createtime"].ToString());
}
if(row["isphoned"]!=null && row["isphoned"].ToString()!="")
{
model.isphoned=int.Parse(row["isphoned"].ToString());
}
if(row["identification"]!=null)
{
model.identification=row["identification"].ToString();
}
if(row["callid"]!=null)
{
model.callid=row["callid"].ToString();
}
}
return model;
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select ID,usercode,tel,createtime,isphoned,identification,callid ");
strSql.Append(" FROM AutoCallOut ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获得前几行数据
///
public DataSet GetList(int Top,string strWhere,string filedOrder)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select ");
if(Top>0)
{
strSql.Append(" top "+Top.ToString());
}
strSql.Append(" ID,usercode,tel,createtime,isphoned,identification,callid ");
strSql.Append(" FROM AutoCallOut ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获取记录总数
///
public int GetRecordCount(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) FROM AutoCallOut ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
object obj = DbHelperSQL.GetSingle(strSql.ToString());
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
///
/// 分页获取数据列表
///
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("SELECT * FROM ( ");
strSql.Append(" SELECT ROW_NUMBER() OVER (");
if (!string.IsNullOrEmpty(orderby.Trim()))
{
strSql.Append("order by T." + orderby );
}
else
{
strSql.Append("order by T.ID desc");
}
strSql.Append(")AS Row, T.* from AutoCallOut T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
return DbHelperSQL.Query(strSql.ToString());
}
/*
///
/// 分页获取数据列表
///
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
{
SqlParameter[] parameters = {
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
new SqlParameter("@PageSize", SqlDbType.Int),
new SqlParameter("@PageIndex", SqlDbType.Int),
new SqlParameter("@IsReCount", SqlDbType.Bit),
new SqlParameter("@OrderType", SqlDbType.Bit),
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
};
parameters[0].Value = "AutoCallOut";
parameters[1].Value = "ID";
parameters[2].Value = PageSize;
parameters[3].Value = PageIndex;
parameters[4].Value = 0;
parameters[5].Value = 0;
parameters[6].Value = strWhere;
return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
}*/
#endregion BasicMethod
#region ExtensionMethod
#endregion ExtensionMethod
}
}