public override List <AdSiteInfoVO> GetModels(ref AdSiteInfoPara mp) { string where = GetConditionByPara(mp); int pStart = mp.PageIndex.Value * mp.PageSize.Value; int pEnd = mp.PageSize.Value; string cmd = QUERYPAGE .Replace("@PAGESIZE", pEnd.ToString()) .Replace("@PTOP", pStart.ToString()) .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); CodeCommand command = new CodeCommand(); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <AdSiteInfoVO> list = new List <AdSiteInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new AdSiteInfoVO(table.Rows[i])); } if (!mp.Recount.HasValue) { mp.Recount = GetRecords(mp); } return(list); }
public override string GetOrderByPara(AdSiteInfoPara mp) { if (!string.IsNullOrEmpty(mp.OrderBy)) { return(string.Format(" order by {0}", mp.OrderBy)); } return(""); }
public override AdSiteInfoVO GetSingle(AdSiteInfoPara mp) { var list = GetModels(mp); if (list.Count == 1) { return(list[0]); } return(null); }
public override int GetRecords(AdSiteInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = QUERYCOUNT + where; var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command); return(int.Parse(result.ToString())); }
private void Bind(int pageIndex = 1) { AdSiteInfoPara cip = new AdSiteInfoPara(); cip.PageIndex = pageIndex - 1; cip.PageSize = 10; cip.UserId = Account.UserId; cip.OrderBy = " id desc "; var list = AdSiteInfoBLL.Instance.GetModels(ref cip); rptTable.DataSource = list; rptTable.DataBind(); apPager.RecordCount = cip.Recount.Value; }
public override bool Delete(AdSiteInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = DELETE + where; int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command); if (result >= 1) { return(true); } return(false); }
public override string GetConditionByPara(AdSiteInfoPara mp) { StringBuilder sb = new StringBuilder(); if (mp.Id.HasValue) { sb.AppendFormat(" AND [Id]='{0}' ", mp.Id); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Name))) { sb.AppendFormat(" AND [Name]='{0}' ", mp.Name); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Desc))) { sb.AppendFormat(" AND [Desc]='{0}' ", mp.Desc); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.WebSite))) { sb.AppendFormat(" AND [WebSite]='{0}' ", mp.WebSite); } if (mp.UserId.HasValue) { sb.AppendFormat(" AND [UserId]='{0}' ", mp.UserId); } if (mp.CreateDate.HasValue) { sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate); } if (mp.LastDate.HasValue) { sb.AppendFormat(" AND [LastDate]='{0}' ", mp.LastDate); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.PlatformType))) { sb.AppendFormat(" AND [PlatformType]='{0}' ", mp.PlatformType); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Contact))) { sb.AppendFormat(" AND [Contact]='{0}' ", mp.Contact); } sb.Insert(0, " WHERE 1=1 "); return(sb.ToString()); }
public override List <AdSiteInfoVO> GetModels(AdSiteInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); string cmd = LOAD .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <AdSiteInfoVO> list = new List <AdSiteInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new AdSiteInfoVO(table.Rows[i])); } return(list); }
public override string GetOtherConditionByPara(AdSiteInfoPara mp) { return(""); }