| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- using System;
- using System.Data;
- using System.Text;
- using System.Data.SqlClient;
- using CallCenterApi.DB;
- namespace CallCenterApi.DAL
- {
- /// <summary>
- /// 数据访问类:T_Chat_IPList
- /// </summary>
- public partial class T_Chat_IPList
- {
- public T_Chat_IPList()
- { }
- #region BasicMethod
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- public bool Exists(int F_Id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) from T_Chat_IPList");
- strSql.Append(" where F_Id=@F_Id");
- SqlParameter[] parameters = {
- new SqlParameter("@F_Id", SqlDbType.Int,4)
- };
- parameters[0].Value = F_Id;
- return DbHelperSQL.Exists(strSql.ToString(), parameters);
- }
- /// <summary>
- /// 增加一条数据
- /// </summary>
- public int Add(CallCenterApi.Model.T_Chat_IPList model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("insert into T_Chat_IPList(");
- strSql.Append("F_OpenId,F_IP,F_Country,F_CountryCode,F_Area,F_AreaCode,F_Region,F_RegionCode,F_City,F_CityCode,F_County,F_CountyCode,F_ISP,F_ISPCode,F_CreateTime,F_Type)");
- strSql.Append(" values (");
- strSql.Append("@F_OpenId,@F_IP,@F_Country,@F_CountryCode,@F_Area,@F_AreaCode,@F_Region,@F_RegionCode,@F_City,@F_CityCode,@F_County,@F_CountyCode,@F_ISP,@F_ISPCode,@F_CreateTime,@F_Type)");
- strSql.Append(";select @@IDENTITY");
- SqlParameter[] parameters = {
- new SqlParameter("@F_OpenId", SqlDbType.VarChar,500),
- new SqlParameter("@F_IP", SqlDbType.VarChar,50),
- new SqlParameter("@F_Country", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CountryCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_Area", SqlDbType.NVarChar,50),
- new SqlParameter("@F_AreaCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_Region", SqlDbType.NVarChar,50),
- new SqlParameter("@F_RegionCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_City", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CityCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_County", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CountyCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_ISP", SqlDbType.NVarChar,50),
- new SqlParameter("@F_ISPCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
- new SqlParameter("@F_Type", SqlDbType.Int,4)};
- parameters[0].Value = model.F_OpenId;
- parameters[1].Value = model.F_IP;
- parameters[2].Value = model.F_Country;
- parameters[3].Value = model.F_CountryCode;
- parameters[4].Value = model.F_Area;
- parameters[5].Value = model.F_AreaCode;
- parameters[6].Value = model.F_Region;
- parameters[7].Value = model.F_RegionCode;
- parameters[8].Value = model.F_City;
- parameters[9].Value = model.F_CityCode;
- parameters[10].Value = model.F_County;
- parameters[11].Value = model.F_CountyCode;
- parameters[12].Value = model.F_ISP;
- parameters[13].Value = model.F_ISPCode;
- parameters[14].Value = model.F_CreateTime;
- parameters[15].Value = model.F_Type;
- object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <summary>
- /// 更新一条数据
- /// </summary>
- public bool Update(CallCenterApi.Model.T_Chat_IPList model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update T_Chat_IPList set ");
- strSql.Append("F_OpenId=@F_OpenId,");
- strSql.Append("F_IP=@F_IP,");
- strSql.Append("F_Country=@F_Country,");
- strSql.Append("F_CountryCode=@F_CountryCode,");
- strSql.Append("F_Area=@F_Area,");
- strSql.Append("F_AreaCode=@F_AreaCode,");
- strSql.Append("F_Region=@F_Region,");
- strSql.Append("F_RegionCode=@F_RegionCode,");
- strSql.Append("F_City=@F_City,");
- strSql.Append("F_CityCode=@F_CityCode,");
- strSql.Append("F_County=@F_County,");
- strSql.Append("F_CountyCode=@F_CountyCode,");
- strSql.Append("F_ISP=@F_ISP,");
- strSql.Append("F_ISPCode=@F_ISPCode,");
- strSql.Append("F_CreateTime=@F_CreateTime,");
- strSql.Append("F_Type=@F_Type");
- strSql.Append(" where F_Id=@F_Id");
- SqlParameter[] parameters = {
- new SqlParameter("@F_OpenId", SqlDbType.VarChar,500),
- new SqlParameter("@F_IP", SqlDbType.VarChar,50),
- new SqlParameter("@F_Country", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CountryCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_Area", SqlDbType.NVarChar,50),
- new SqlParameter("@F_AreaCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_Region", SqlDbType.NVarChar,50),
- new SqlParameter("@F_RegionCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_City", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CityCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_County", SqlDbType.NVarChar,50),
- new SqlParameter("@F_CountyCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_ISP", SqlDbType.NVarChar,50),
- new SqlParameter("@F_ISPCode", SqlDbType.VarChar,50),
- new SqlParameter("@F_CreateTime", SqlDbType.DateTime),
- new SqlParameter("@F_Type", SqlDbType.Int,4),
- new SqlParameter("@F_Id", SqlDbType.Int,4)};
- parameters[0].Value = model.F_OpenId;
- parameters[1].Value = model.F_IP;
- parameters[2].Value = model.F_Country;
- parameters[3].Value = model.F_CountryCode;
- parameters[4].Value = model.F_Area;
- parameters[5].Value = model.F_AreaCode;
- parameters[6].Value = model.F_Region;
- parameters[7].Value = model.F_RegionCode;
- parameters[8].Value = model.F_City;
- parameters[9].Value = model.F_CityCode;
- parameters[10].Value = model.F_County;
- parameters[11].Value = model.F_CountyCode;
- parameters[12].Value = model.F_ISP;
- parameters[13].Value = model.F_ISPCode;
- parameters[14].Value = model.F_CreateTime;
- parameters[15].Value = model.F_Type;
- parameters[16].Value = model.F_Id;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 删除一条数据
- /// </summary>
- public bool Delete(int F_Id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_Chat_IPList ");
- strSql.Append(" where F_Id=@F_Id");
- SqlParameter[] parameters = {
- new SqlParameter("@F_Id", SqlDbType.Int,4)
- };
- parameters[0].Value = F_Id;
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 批量删除数据
- /// </summary>
- public bool DeleteList(string F_Idlist)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from T_Chat_IPList ");
- strSql.Append(" where F_Id in (" + F_Idlist + ") ");
- int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_Chat_IPList GetModel(int F_Id)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 F_Id,F_OpenId,F_IP,F_Country,F_CountryCode,F_Area,F_AreaCode,F_Region,F_RegionCode,F_City,F_CityCode,F_County,F_CountyCode,F_ISP,F_ISPCode,F_CreateTime,F_Type from T_Chat_IPList ");
- strSql.Append(" where F_Id=@F_Id");
- SqlParameter[] parameters = {
- new SqlParameter("@F_Id", SqlDbType.Int,4)
- };
- parameters[0].Value = F_Id;
- CallCenterApi.Model.T_Chat_IPList model = new CallCenterApi.Model.T_Chat_IPList();
- DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- return DataRowToModel(ds.Tables[0].Rows[0]);
- }
- else
- {
- return null;
- }
- }
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public CallCenterApi.Model.T_Chat_IPList DataRowToModel(DataRow row)
- {
- CallCenterApi.Model.T_Chat_IPList model = new CallCenterApi.Model.T_Chat_IPList();
- if (row != null)
- {
- if (row["F_Id"] != null && row["F_Id"].ToString() != "")
- {
- model.F_Id = int.Parse(row["F_Id"].ToString());
- }
- if (row["F_OpenId"] != null)
- {
- model.F_OpenId = row["F_OpenId"].ToString();
- }
- if (row["F_IP"] != null)
- {
- model.F_IP = row["F_IP"].ToString();
- }
- if (row["F_Country"] != null)
- {
- model.F_Country = row["F_Country"].ToString();
- }
- if (row["F_CountryCode"] != null)
- {
- model.F_CountryCode = row["F_CountryCode"].ToString();
- }
- if (row["F_Area"] != null)
- {
- model.F_Area = row["F_Area"].ToString();
- }
- if (row["F_AreaCode"] != null)
- {
- model.F_AreaCode = row["F_AreaCode"].ToString();
- }
- if (row["F_Region"] != null)
- {
- model.F_Region = row["F_Region"].ToString();
- }
- if (row["F_RegionCode"] != null)
- {
- model.F_RegionCode = row["F_RegionCode"].ToString();
- }
- if (row["F_City"] != null)
- {
- model.F_City = row["F_City"].ToString();
- }
- if (row["F_CityCode"] != null)
- {
- model.F_CityCode = row["F_CityCode"].ToString();
- }
- if (row["F_County"] != null)
- {
- model.F_County = row["F_County"].ToString();
- }
- if (row["F_CountyCode"] != null)
- {
- model.F_CountyCode = row["F_CountyCode"].ToString();
- }
- if (row["F_ISP"] != null)
- {
- model.F_ISP = row["F_ISP"].ToString();
- }
- if (row["F_ISPCode"] != null)
- {
- model.F_ISPCode = row["F_ISPCode"].ToString();
- }
- if (row["F_CreateTime"] != null && row["F_CreateTime"].ToString() != "")
- {
- model.F_CreateTime = DateTime.Parse(row["F_CreateTime"].ToString());
- }
- if (row["F_Type"] != null && row["F_Type"].ToString() != "")
- {
- model.F_Type = int.Parse(row["F_Type"].ToString());
- }
- }
- return model;
- }
- /// <summary>
- /// 获得数据列表
- /// </summary>
- public DataSet GetList(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select F_Id,F_OpenId,F_IP,F_Country,F_CountryCode,F_Area,F_AreaCode,F_Region,F_RegionCode,F_City,F_CityCode,F_County,F_CountyCode,F_ISP,F_ISPCode,F_CreateTime,F_Type ");
- strSql.Append(" FROM T_Chat_IPList ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- return DbHelperSQL.Query(strSql.ToString());
- }
- /// <summary>
- /// 获得前几行数据
- /// </summary>
- 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(" F_Id,F_OpenId,F_IP,F_Country,F_CountryCode,F_Area,F_AreaCode,F_Region,F_RegionCode,F_City,F_CityCode,F_County,F_CountyCode,F_ISP,F_ISPCode,F_CreateTime,F_Type ");
- strSql.Append(" FROM T_Chat_IPList ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- strSql.Append(" order by " + filedOrder);
- return DbHelperSQL.Query(strSql.ToString());
- }
- /// <summary>
- /// 获取记录总数
- /// </summary>
- public int GetRecordCount(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) FROM T_Chat_IPList ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- object obj = DbHelperSQL.GetSingle(strSql.ToString());
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- 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.F_Id desc");
- }
- strSql.Append(")AS Row, T.* from T_Chat_IPList 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());
- }
- /*
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- 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 = "T_Chat_IPList";
- parameters[1].Value = "F_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
- }
- }
|