//------------------------------Tools public static string GetTbName(SType type) { string tbname = ""; switch (type)//ExpHisID { case SType.Purse: tbname = "ZL_UserExpDomP"; break; case SType.SIcon: tbname = "ZL_UserCoinHis"; break; case SType.UserPoint: case SType.DummyPoint: tbname = "ZL_User_DummyPoint"; break; case SType.Point: case SType.Credit: tbname = "ZL_UserExpHis"; break; } return(tbname); }
public M_UserExpHis SelReturnModel(SType type, int id) { M_UserExpHis model = new M_UserExpHis(); using (SqlDataReader reader = Sql.SelReturnReader(GetTbName(type), PK, id)) { if (reader.Read()) { return(new M_UserExpHis().GetModelFromReader(reader)); } else { return(null); } } }
/// <summary> /// 用于财务流水 /// </summary> /// <param name="stype"></param> /// <param name="searchtype">搜索类型 1:按userid检索,2:按UserName检索</param> /// <param name="search"></param> /// <returns></returns> public DataTable SelByType(SType stype, int searchtype = 1, string search = "") { string sql = ""; string strwhere = ""; string joinstr = "LEFT JOIN ZL_User B ON A.UserID=B.UserID"; if (!string.IsNullOrEmpty(search)) { if (searchtype == 1) { strwhere = " AND A.UserID=@search"; search = DataConverter.CLng(search).ToString(); } else { strwhere = " AND UserName LIKE @search"; search = "%" + search + "%"; } } SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@search", search) }; switch (stype) { case M_UserExpHis.SType.Purse: sql = "SELECT A.*,B.UserName FROM ZL_UserExpDomP A " + joinstr + " WHERE 1=1 " + strwhere; //ZL_UserExpDomP break; case M_UserExpHis.SType.SIcon: sql = "SELECT A.*,B.UserName FROM ZL_UserCoinHis A " + joinstr + " WHERE 1=1 " + strwhere; //ZL_UserCoinHis break; case M_UserExpHis.SType.Point: case M_UserExpHis.SType.Credit: sql = "SELECT A.*,B.UserName FROM ZL_UserExpHis A " + joinstr + " Where ScoreType=" + (int)stype + strwhere; break; case M_UserExpHis.SType.UserPoint: //点券 case M_UserExpHis.SType.DummyPoint: //虚拟币 sql = "SELECT A.*,B.UserName FROM ZL_User_DummyPoint A " + joinstr + " Where ScoreType=" + (int)stype + strwhere; break; default: break; } sql += " ORDER BY HisTime DESC"; return(SqlHelper.ExecuteTable(CommandType.Text, sql, sp)); }
/// <summary> /// 用于财务流水 /// </summary> /// <param name="searchtype">搜索类型 1:按userid检索,2:按UserName检索</param> /// <returns></returns> public DataTable SelByType(SType stype, int searchtype = 1, string search = "") { string strwhere = "1=1 "; if (!string.IsNullOrEmpty(search)) { if (searchtype == 1 && DataConvert.CLng(search) > 0) { strwhere += " AND A.UserID=" + Convert.ToInt32(search); search = DataConverter.CLng(search).ToString(); } else { strwhere += " AND UserName LIKE @search"; search = "%" + search + "%"; } } SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@search", "%" + search + "%") }; string tbname = GetTbName(stype); return(DBCenter.JoinQuery("A.*,B.UserName", tbname, "ZL_User", "A.UserID=B.UserID", strwhere, "A.HisTime DESC", sp)); }
public bool DelByIDS(SType stype, string ids) { SafeSC.CheckIDSEx(ids); return(DBCenter.DelByIDS(GetTbName(stype), PK, ids)); }