/** 版本信息模板在安装目录下,可自行修改。 * app_contact_info.cs * * 功 能: N/A * 类 名: app_contact_info * * Ver 变更日期 负责人 变更内容 * ─────────────────────────────────── * V0.01 2024/11/11 15:56:54 N/A 初版 * * Copyright (c) 2012 Maticsoft Corporation. All rights reserved. *┌──────────────────────────────────┐ *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │ *│ 版权所有:动软卓越(北京)科技有限公司              │ *└──────────────────────────────────┘ */ using System; using System.Data; using System.Text; using MySql.Data.MySqlClient; using Maticsoft.DBUtility;//Please add references namespace Competition.Mysql.DAL { /// /// 数据访问类:app_contact_info /// public partial class app_contact_info { public app_contact_info() {} #region BasicMethod /// /// 是否存在该记录 /// public bool Exists(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from app_contact_info"); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar,50) }; parameters[0].Value = id; return DbHelperMySQL.Exists(strSql.ToString(), parameters); } /// /// 增加一条数据 /// public bool Add(Competition.Mysql.Model.app_contact_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into app_contact_info("); strSql.Append("id,client_id,contact_type,contact_man,contact_mobile,create_time,r1,r2,r3)"); strSql.Append(" values ("); strSql.Append("@id,@client_id,@contact_type,@contact_man,@contact_mobile,@create_time,@r1,@r2,@r3)"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar,50), new MySqlParameter("@client_id", MySqlDbType.VarChar,50), new MySqlParameter("@contact_type", MySqlDbType.VarChar,255), new MySqlParameter("@contact_man", MySqlDbType.VarChar,255), new MySqlParameter("@contact_mobile", MySqlDbType.VarChar,255), new MySqlParameter("@create_time", MySqlDbType.DateTime), new MySqlParameter("@r1", MySqlDbType.VarChar,255), new MySqlParameter("@r2", MySqlDbType.VarChar,255), new MySqlParameter("@r3", MySqlDbType.VarChar,255)}; parameters[0].Value = model.id; parameters[1].Value = model.client_id; parameters[2].Value = model.contact_type; parameters[3].Value = model.contact_man; parameters[4].Value = model.contact_mobile; parameters[5].Value = model.create_time; parameters[6].Value = model.r1; parameters[7].Value = model.r2; parameters[8].Value = model.r3; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Update(Competition.Mysql.Model.app_contact_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update app_contact_info set "); strSql.Append("client_id=@client_id,"); strSql.Append("contact_type=@contact_type,"); strSql.Append("contact_man=@contact_man,"); strSql.Append("contact_mobile=@contact_mobile,"); strSql.Append("create_time=@create_time,"); strSql.Append("r1=@r1,"); strSql.Append("r2=@r2,"); strSql.Append("r3=@r3"); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@client_id", MySqlDbType.VarChar,50), new MySqlParameter("@contact_type", MySqlDbType.VarChar,255), new MySqlParameter("@contact_man", MySqlDbType.VarChar,255), new MySqlParameter("@contact_mobile", MySqlDbType.VarChar,255), new MySqlParameter("@create_time", MySqlDbType.DateTime), new MySqlParameter("@r1", MySqlDbType.VarChar,255), new MySqlParameter("@r2", MySqlDbType.VarChar,255), new MySqlParameter("@r3", MySqlDbType.VarChar,255), new MySqlParameter("@id", MySqlDbType.VarChar,50)}; parameters[0].Value = model.client_id; parameters[1].Value = model.contact_type; parameters[2].Value = model.contact_man; parameters[3].Value = model.contact_mobile; parameters[4].Value = model.create_time; parameters[5].Value = model.r1; parameters[6].Value = model.r2; parameters[7].Value = model.r3; parameters[8].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from app_contact_info "); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar,50) }; parameters[0].Value = id; int rows = DbHelperMySQL.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 app_contact_info "); strSql.Append(" where id in (" + idlist + ") "); int rows = DbHelperMySQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public Competition.Mysql.Model.app_contact_info GetModel(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,client_id,contact_type,contact_man,contact_mobile,create_time,r1,r2,r3 from app_contact_info "); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.VarChar,50) }; parameters[0].Value = id; Competition.Mysql.Model.app_contact_info model = new Competition.Mysql.Model.app_contact_info(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } } /// /// 得到一个对象实体 /// public Competition.Mysql.Model.app_contact_info DataRowToModel(DataRow row) { Competition.Mysql.Model.app_contact_info model = new Competition.Mysql.Model.app_contact_info(); if (row != null) { if (row["id"] != null) { model.id = row["id"].ToString(); } if (row["client_id"] != null) { model.client_id = row["client_id"].ToString(); } if (row["contact_type"] != null) { model.contact_type = row["contact_type"].ToString(); } if (row["contact_man"] != null) { model.contact_man = row["contact_man"].ToString(); } if (row["contact_mobile"] != null) { model.contact_mobile = row["contact_mobile"].ToString(); } if (row["create_time"] != null && row["create_time"].ToString() != "") { model.create_time = DateTime.Parse(row["create_time"].ToString()); } if (row["r1"] != null) { model.r1 = row["r1"].ToString(); } if (row["r2"] != null) { model.r2 = row["r2"].ToString(); } if (row["r3"] != null) { model.r3 = row["r3"].ToString(); } } return model; } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,client_id,contact_type,contact_man,contact_mobile,create_time,r1,r2,r3 "); strSql.Append(" FROM app_contact_info "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return DbHelperMySQL.Query(strSql.ToString()); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) FROM app_contact_info "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } object obj = DbHelperMySQL.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 app_contact_info 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 DbHelperMySQL.Query(strSql.ToString()); } /* /// /// 分页获取数据列表 /// public DataSet GetList(int PageSize,int PageIndex,string strWhere) { MySqlParameter[] parameters = { new MySqlParameter("@tblName", MySqlDbType.VarChar, 255), new MySqlParameter("@fldName", MySqlDbType.VarChar, 255), new MySqlParameter("@PageSize", MySqlDbType.Int32), new MySqlParameter("@PageIndex", MySqlDbType.Int32), new MySqlParameter("@IsReCount", MySqlDbType.Bit), new MySqlParameter("@OrderType", MySqlDbType.Bit), new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000), }; parameters[0].Value = "app_contact_info"; 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 DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); }*/ #endregion BasicMethod #region ExtensionMethod #endregion ExtensionMethod } }