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 { /// /// 数据访问类:T_Repository_List_Audit /// public partial class T_Repository_List_Audit { public T_Repository_List_Audit() { } #region Method /// /// 是否存在该记录 /// public bool Exists(int F_AuditId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from T_Repository_List_Audit"); strSql.Append(" where F_AuditId=@F_AuditId"); SqlParameter[] parameters = { new SqlParameter("@F_AuditId", SqlDbType.Int,4) }; parameters[0].Value = F_AuditId; return DbHelperSQL.Exists(strSql.ToString(), parameters); } /// /// 增加一条数据 /// public int Add(CallCenterApi.Model.T_Repository_List_Audit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Repository_List_Audit("); strSql.Append("F_RepositoryId,F_Action,F_CreateOn,F_CreateBy,F_PreLogID,F_AfterLogID,F_AuditOn,F_AuditBy,F_ISPass,F_AuditRemark,F_Expand1,F_Expand2,F_IntExpand1)"); strSql.Append(" values ("); strSql.Append("@F_RepositoryId,@F_Action,@F_CreateOn,@F_CreateBy,@F_PreLogID,@F_AfterLogID,@F_AuditOn,@F_AuditBy,@F_ISPass,@F_AuditRemark,@F_Expand1,@F_Expand2,@F_IntExpand1)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@F_RepositoryId", SqlDbType.Int,4), new SqlParameter("@F_Action", SqlDbType.Int,4), new SqlParameter("@F_CreateOn", SqlDbType.DateTime), new SqlParameter("@F_CreateBy", SqlDbType.Int,4), new SqlParameter("@F_PreLogID", SqlDbType.Int,4), new SqlParameter("@F_AfterLogID", SqlDbType.Int,4), new SqlParameter("@F_AuditOn", SqlDbType.DateTime), new SqlParameter("@F_AuditBy", SqlDbType.Int,4), new SqlParameter("@F_ISPass", SqlDbType.Int,4), new SqlParameter("@F_AuditRemark", SqlDbType.NText), new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100), new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200), new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2)}; parameters[0].Value = model.F_RepositoryId; parameters[1].Value = model.F_Action; parameters[2].Value = model.F_CreateOn; parameters[3].Value = model.F_CreateBy; parameters[4].Value = model.F_PreLogID; parameters[5].Value = model.F_AfterLogID; parameters[6].Value = model.F_AuditOn; parameters[7].Value = model.F_AuditBy; parameters[8].Value = model.F_ISPass; parameters[9].Value = model.F_AuditRemark; parameters[10].Value = model.F_Expand1; parameters[11].Value = model.F_Expand2; parameters[12].Value = model.F_IntExpand1; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public bool Update(CallCenterApi.Model.T_Repository_List_Audit model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Repository_List_Audit set "); strSql.Append("F_RepositoryId=@F_RepositoryId,"); strSql.Append("F_Action=@F_Action,"); strSql.Append("F_CreateOn=@F_CreateOn,"); strSql.Append("F_CreateBy=@F_CreateBy,"); strSql.Append("F_PreLogID=@F_PreLogID,"); strSql.Append("F_AfterLogID=@F_AfterLogID,"); strSql.Append("F_AuditOn=@F_AuditOn,"); strSql.Append("F_AuditBy=@F_AuditBy,"); strSql.Append("F_ISPass=@F_ISPass,"); strSql.Append("F_AuditRemark=@F_AuditRemark,"); strSql.Append("F_Expand1=@F_Expand1,"); strSql.Append("F_Expand2=@F_Expand2,"); strSql.Append("F_IntExpand1=@F_IntExpand1"); strSql.Append(" where F_AuditId=@F_AuditId"); SqlParameter[] parameters = { new SqlParameter("@F_RepositoryId", SqlDbType.Int,4), new SqlParameter("@F_Action", SqlDbType.Int,4), new SqlParameter("@F_CreateOn", SqlDbType.DateTime), new SqlParameter("@F_CreateBy", SqlDbType.Int,4), new SqlParameter("@F_PreLogID", SqlDbType.Int,4), new SqlParameter("@F_AfterLogID", SqlDbType.Int,4), new SqlParameter("@F_AuditOn", SqlDbType.DateTime), new SqlParameter("@F_AuditBy", SqlDbType.Int,4), new SqlParameter("@F_ISPass", SqlDbType.Int,4), new SqlParameter("@F_AuditRemark", SqlDbType.NText), new SqlParameter("@F_Expand1", SqlDbType.NVarChar,100), new SqlParameter("@F_Expand2", SqlDbType.NVarChar,200), new SqlParameter("@F_IntExpand1", SqlDbType.SmallInt,2), new SqlParameter("@F_AuditId", SqlDbType.Int,4)}; parameters[0].Value = model.F_RepositoryId; parameters[1].Value = model.F_Action; parameters[2].Value = model.F_CreateOn; parameters[3].Value = model.F_CreateBy; parameters[4].Value = model.F_PreLogID; parameters[5].Value = model.F_AfterLogID; parameters[6].Value = model.F_AuditOn; parameters[7].Value = model.F_AuditBy; parameters[8].Value = model.F_ISPass; parameters[9].Value = model.F_AuditRemark; parameters[10].Value = model.F_Expand1; parameters[11].Value = model.F_Expand2; parameters[12].Value = model.F_IntExpand1; parameters[13].Value = model.F_AuditId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(int F_AuditId) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_Repository_List_Audit "); strSql.Append(" where F_AuditId=@F_AuditId"); SqlParameter[] parameters = { new SqlParameter("@F_AuditId", SqlDbType.Int,4) }; parameters[0].Value = F_AuditId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 批量删除数据 /// public bool DeleteList(string F_AuditIdlist) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from T_Repository_List_Audit "); strSql.Append(" where F_AuditId in (" + F_AuditIdlist + ") "); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return true; } else { return false; } } /// /// 得到一个对象实体 /// public CallCenterApi.Model.T_Repository_List_Audit GetModel(int F_AuditId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_AuditId,F_RepositoryId,F_Action,F_CreateOn,F_CreateBy,F_PreLogID,F_AfterLogID,F_AuditOn,F_AuditBy,F_ISPass,F_AuditRemark,F_Expand1,F_Expand2,F_IntExpand1 from T_Repository_List_Audit "); strSql.Append(" where F_AuditId=@F_AuditId"); SqlParameter[] parameters = { new SqlParameter("@F_AuditId", SqlDbType.Int,4) }; parameters[0].Value = F_AuditId; CallCenterApi.Model.T_Repository_List_Audit model = new CallCenterApi.Model.T_Repository_List_Audit(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["F_AuditId"] != null && ds.Tables[0].Rows[0]["F_AuditId"].ToString() != "") { model.F_AuditId = int.Parse(ds.Tables[0].Rows[0]["F_AuditId"].ToString()); } if (ds.Tables[0].Rows[0]["F_RepositoryId"] != null && ds.Tables[0].Rows[0]["F_RepositoryId"].ToString() != "") { model.F_RepositoryId = int.Parse(ds.Tables[0].Rows[0]["F_RepositoryId"].ToString()); } if (ds.Tables[0].Rows[0]["F_Action"] != null && ds.Tables[0].Rows[0]["F_Action"].ToString() != "") { model.F_Action = int.Parse(ds.Tables[0].Rows[0]["F_Action"].ToString()); } if (ds.Tables[0].Rows[0]["F_CreateOn"] != null && ds.Tables[0].Rows[0]["F_CreateOn"].ToString() != "") { model.F_CreateOn = DateTime.Parse(ds.Tables[0].Rows[0]["F_CreateOn"].ToString()); } if (ds.Tables[0].Rows[0]["F_CreateBy"] != null) { model.F_CreateBy = ds.Tables[0].Rows[0]["F_CreateBy"].ToString(); } if (ds.Tables[0].Rows[0]["F_PreLogID"] != null && ds.Tables[0].Rows[0]["F_PreLogID"].ToString() != "") { model.F_PreLogID = int.Parse(ds.Tables[0].Rows[0]["F_PreLogID"].ToString()); } if (ds.Tables[0].Rows[0]["F_AfterLogID"] != null && ds.Tables[0].Rows[0]["F_AfterLogID"].ToString() != "") { model.F_AfterLogID = int.Parse(ds.Tables[0].Rows[0]["F_AfterLogID"].ToString()); } if (ds.Tables[0].Rows[0]["F_AuditOn"] != null && ds.Tables[0].Rows[0]["F_AuditOn"].ToString() != "") { model.F_AuditOn = DateTime.Parse(ds.Tables[0].Rows[0]["F_AuditOn"].ToString()); } if (ds.Tables[0].Rows[0]["F_AuditBy"] != null) { model.F_AuditBy = ds.Tables[0].Rows[0]["F_AuditBy"].ToString(); } if (ds.Tables[0].Rows[0]["F_ISPass"] != null && ds.Tables[0].Rows[0]["F_ISPass"].ToString() != "") { model.F_ISPass = int.Parse(ds.Tables[0].Rows[0]["F_ISPass"].ToString()); } if (ds.Tables[0].Rows[0]["F_AuditRemark"] != null && ds.Tables[0].Rows[0]["F_AuditRemark"].ToString() != "") { model.F_AuditRemark = ds.Tables[0].Rows[0]["F_AuditRemark"].ToString(); } if (ds.Tables[0].Rows[0]["F_Expand1"] != null && ds.Tables[0].Rows[0]["F_Expand1"].ToString() != "") { model.F_Expand1 = ds.Tables[0].Rows[0]["F_Expand1"].ToString(); } if (ds.Tables[0].Rows[0]["F_Expand2"] != null && ds.Tables[0].Rows[0]["F_Expand2"].ToString() != "") { model.F_Expand2 = ds.Tables[0].Rows[0]["F_Expand2"].ToString(); } if (ds.Tables[0].Rows[0]["F_IntExpand1"] != null && ds.Tables[0].Rows[0]["F_IntExpand1"].ToString() != "") { model.F_IntExpand1 = int.Parse(ds.Tables[0].Rows[0]["F_IntExpand1"].ToString()); } return model; } else { return null; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM T_Repository_List_Audit "); 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(" * "); strSql.Append(" FROM T_Repository_List_Audit "); 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 T_Repository_List_Audit "); 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.F_AuditId desc"); } strSql.Append(")AS Row, T.* from T_Repository_List_Audit 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()); } #endregion Method } }