357 lines
15 KiB
C#
357 lines
15 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Wuqi.Webdiyer;
|
|
using System.Data;
|
|
|
|
namespace Mtxfw.Utility
|
|
{
|
|
/// <summary>
|
|
/// 宇宙达人ASP.NET 数据层抽象类
|
|
/// </summary>
|
|
public abstract class Myabstract
|
|
{
|
|
protected String TABLE_NAME = String.Empty;
|
|
|
|
protected Myabstract(String table_name)
|
|
{
|
|
TABLE_NAME = table_name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取数据总数
|
|
/// </summary>
|
|
public int GetCount(string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select count(id) from " + TABLE_NAME + " a");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.ExecuteScalar(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取数据总数
|
|
/// </summary>
|
|
public int GetCount1(string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select count(id) from " + TABLE_NAME + " a WITH(READPAST)");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.ExecuteScalar(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取数据总数
|
|
/// </summary>
|
|
public DataSet GetCount0(string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select count(id) from " + TABLE_NAME + " a");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取每个字段总数
|
|
/// </summary>
|
|
public object GetCount(string zd, string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select Sum(" + zd + ") from " + TABLE_NAME + " a");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.GetObject(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取每个最大字段
|
|
/// </summary>
|
|
public object GetMax(string zd, string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select Max(" + zd + ") from " + TABLE_NAME);
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.GetObject(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取每个最小字段
|
|
/// </summary>
|
|
public object GetMin(string zd, string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select Min(" + zd + ") from " + TABLE_NAME);
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.GetObject(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取某个字段值
|
|
/// </summary>
|
|
public object Getzd(string zd, string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select top 1 " + zd + " from " + TABLE_NAME + " a");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.GetObject(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取某个字段值
|
|
/// </summary>
|
|
public object Getzd2(string zd, string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("select " + zd + " from " + TABLE_NAME + " a");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
return SqlDbHelper_U.GetObject(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
public DataSet GetPager(AspNetPager pager, string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.Pager(pager, strSql.ToString(), TABLE_NAME);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
public DataSet GetPager2(AspNetPager pager, string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.Pager(pager, strSql.ToString(), TABLE_NAME);
|
|
}
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
public DataSet GetDataSet(string groupby, string orderBy, string fieldlist, string fieldlist2, string filter, int Start, int Limit, out Int32 Recount)
|
|
{
|
|
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(TABLE_NAME, groupby, orderBy, fieldlist, fieldlist2, filter, Start, Limit, out Recount);
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetList(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetAList(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetADataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetCList(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetCDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetZHList(string top, string table, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select " + top + " FROM " + TABLE_NAME + " a," + table + " b");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetList1(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select " + top + " FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetViewList(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select " + top + " FROM " + TABLE_NAME + "_View a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
public DataSet GetList2(string top, string where)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 从缓存中获取数据列表
|
|
/// </summary>
|
|
public DataSet GetCacheList(string top, string where, string cacheName)
|
|
{
|
|
if (System.Web.HttpContext.Current.Cache[cacheName] == null)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select ");
|
|
if (top.Trim() != "")
|
|
{
|
|
strSql.Append(top);
|
|
}
|
|
strSql.Append(" * ");
|
|
strSql.Append(" FROM " + TABLE_NAME + " a");
|
|
if (where.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + where);
|
|
}
|
|
DataSet Ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
System.Web.HttpContext.Current.Cache[cacheName] = Ds;
|
|
return Ds;
|
|
}
|
|
else
|
|
return System.Web.HttpContext.Current.Cache[cacheName] as DataSet;
|
|
}
|
|
/// <summary>
|
|
/// 获取某个字段值
|
|
/// </summary>
|
|
public void Delete(string where)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("Delete from " + TABLE_NAME + "");
|
|
if (!String.IsNullOrEmpty(where))
|
|
sb.Append(" where " + where);
|
|
Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sb.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 清空数据
|
|
/// </summary>
|
|
public void DeleteData(int gtype)
|
|
{
|
|
List<string> list = new List<string>();
|
|
list.Add("Delete from user_info Where gtype=" + gtype + " And Id<>68 And Id<>69 And Id<>70 And Id<>71 And Id<>72 And Id<>73 And Id<>74 And Id<>75 And (IFStores=0 or IFStores=2)");
|
|
list.Add("Delete from user_proxy where gtype=" + gtype);
|
|
list.Add("Delete from user_Results Where gtype=" + gtype + " and utype<>'15'");
|
|
list.Add("Delete from user_Results_jl where gtype=" + gtype);
|
|
list.Add("Delete from user_Results_jl2 where gtype=" + gtype);
|
|
list.Add("Delete from user_Results_jl3 Where gtype=" + gtype + " and utype<>'0'");
|
|
list.Add("Delete from user_Results_jl4 where gtype=" + gtype);
|
|
list.Add("Delete from User_CZ_log where gtype=" + gtype);
|
|
list.Add("Delete from qiandao where gtype=" + gtype);
|
|
list.Add("Delete from User_tuiguang where gtype=" + gtype);
|
|
list.Add("Delete from User_OnLine where gtype=" + gtype);
|
|
list.Add("Delete from User_Errlog where gtype=" + gtype);
|
|
list.Add("Delete from user_address where gtype=" + gtype + " and UserID<>68");
|
|
list.Add("Delete from order_info where gtype=" + gtype);
|
|
list.Add("Delete from order_product_info where gtype=" + gtype);
|
|
list.Add("Delete from Article where gtype=" + gtype + " and (ParentID=15 or ParentID=20 or ParentID=21 or ParentID=22 or ParentID=23)");
|
|
list.Add("update user_info set umoney=0, umoney0=0, umoney1=0, umoney2=0, umoney3=0, umoney4=0, umoney5=0, umoney6=0, umoney7=0, umoney8=0, umoney9=0, umoney10=0, umoney11=0,umoney12=0,umoney13=0,umoney14=0,umoney15=0,umoney16=0,umoney17=0,umoney18=0,umoney19=0,umoney20=0,umoney21=0,umoney22=0,umoney23=0,umoney24=0,umoney25=0,umoney26=0,umoney27=0,umoney28=0,umoney29=0,umoney30=0,umoney31=0,umoney32=0,umoney33=0,umoney34=0,umoney35=0,umoney36=0,umoney37=0,umoney38=0,umoney39=0,umoney40=0,umoney41=0, uLevel=0, uLevel2=0, uLevel3=0, uLevel4=0, uLevel5=0,uLevel6=0,uLevel7=0,uLevel8=0,uLevel9=0,uLevel10=0,uLevel11=0,uLevel12=0,uLevel13=0,uLevel14=0,uLevel15=0,uLevel16=0,uLevel19=0,uLevel20=0,uLevel21=0,uLevel22=0,gmcount=0,tjcount=0,temcount=0,RememberIDS='',SJRememberIDS='',IFBecomeBusiness=0,IFBecomeAgents=0 Where gtype=" + gtype + " and uutype='0' And IFStores<>1");//,regtime=getdate()
|
|
list.Add("update user_jjfp set count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0 where gtype=" + gtype + " and TType=0 Or TType=1");
|
|
list.Add("Delete from user_jjfp where gtype=" + gtype + " and TType>1 and TType<>5");
|
|
Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(list);
|
|
}
|
|
/// <summary>
|
|
/// 清空数据
|
|
/// </summary>
|
|
public void DeleteData2()
|
|
{
|
|
List<string> list = new List<string>();
|
|
list.Add("Delete from user_Results Where utype<>'15'");
|
|
list.Add("Delete from user_Results_jl2");
|
|
list.Add("Delete from user_Results_jl3 Where utype<>'5'");
|
|
list.Add("update user_info set umoney=0,umoney15=0,umoney16=0,umoney17=0,umoney23=0,umoney24=0,umoney30=0,umoney31=0,umoney32=0,umoney33=0,umoney34=0,umoney35=0,umoney36=0,RememberIDS='',SJRememberIDS='' Where uutype='0' And IFStores=0");
|
|
Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(list);
|
|
}
|
|
/// <summary>
|
|
/// 清空数据
|
|
/// </summary>
|
|
public void DeleteData3(int MemberId)
|
|
{
|
|
List<string> list = new List<string>();
|
|
list.Add("Delete from user_Results Where utype<>'15' And MemberId in(select id from user_info b where b.uutype='0' And b.UserState='正常' And b.IFStores=0 and (b.id=" + MemberId + " Or b.SuperiorsIDS like '%," + MemberId + ",%' Or b.ContactIDS like '%," + MemberId + ",%'))");
|
|
list.Add("update user_info set umoney=0,umoney15=0,umoney16=0,umoney17=0,umoney22=0,umoney30=0,umoney31=0,umoney32=0,umoney33=0,umoney34=0,umoney35=0 Where uutype='0' And IFStores=0 and (id=" + MemberId + " Or SuperiorsIDS like '%," + MemberId + ",%' Or ContactIDS like '%," + MemberId + ",%')");
|
|
Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(list);
|
|
}
|
|
}
|
|
}
|