public AdInfo ReadAd(int id) { SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.NVarChar) }; pt[0].Value = id; AdInfo info = new AdInfo(); using (SqlDataReader reader = ShopMssqlHelper.ExecuteReader(ShopMssqlHelper.TablePrefix + "ReadAd", pt)) { if (reader.Read()) { info.ID = reader.GetInt32(0); info.Title = reader[1].ToString(); info.Introduction = reader[2].ToString(); info.AdClass = reader.GetInt32(3); info.Display = reader[4].ToString(); info.Width = reader.GetInt32(5); info.Height = reader.GetInt32(6); info.Url = reader[7].ToString(); info.StartDate = reader.GetDateTime(8); info.EndDate = reader.GetDateTime(9); info.Remark = reader[10].ToString(); info.ClickCount = reader.GetInt32(11); info.IsEnabled = reader.GetInt32(12); } } return info; }
public async Task <IHttpActionResult> PutAdInfo(int id, AdInfo adInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != adInfo.Id) { return(BadRequest()); } db.Entry(adInfo).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void bind() { if (adid > 0) { hfadid.Value = adid.ToString(); AdInfo info = BLL.AdBLL.GetModel(adid); txbadname.Text = info.adname; adpositionid = info.adpositionid; if (info.adimg != null && info.adimg.Trim().Length > 0) { img = BLL.AdBLL.showad(info.adimg, info.suffix, info.adblank, info.adlink, -1, 50); } if (img.Trim().Length > 0) { img = img + "<br/>"; } //img = "<img src=\"" + Common.Constant.URL_ad + info.adimg + "\" height=\"50\"/><br/>"; txbadlink.Text = info.adlink; if (info.adblank == 0) { rbtnadblank0.Checked = true; } else if (info.adblank == 1) { rbtnadblank1.Checked = true; } try { ddlstatus.SelectedValue = info.status.ToString(); } catch { } txbclick.Text = info.click.ToString(); } ddlAdPositionbind(); }
public string DeleteAdinfo(AdInfo AdInfo) { if (this.BasicAgent.Tier != 1) { return("0"); } if (this.BasicAgent.IsTeiPai == 0) { return("0"); } if (AdInfo.Id.IsNullOrEmpty()) { return("0"); } var baseAdInfo = this.Entity.AdInfo.FirstOrDefault(o => o.Id == AdInfo.Id && o.AgentId == BasicAgent.Id); if (baseAdInfo == null) { return("0"); } this.Entity.AdInfo.DeleteObject(baseAdInfo); this.Entity.SaveChanges(); System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(() => { ClearCacheAdInfo(); }); return("1"); }
/// <summary> /// 更新物料 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int Update(AdInfo model) { string strSQL = "UPDATE Ads SET Name = @Name,ClickUrl = @ClickUrl,TargetWindow = @TargetWindow,Type = @Type,Width= @Width,height = @Height,Words = @Words WHERE Id = @Id"; SqlParameter[] parms = { new SqlParameter("Name", SqlDbType.NVarChar), new SqlParameter("ClickUrl", SqlDbType.NVarChar), new SqlParameter("Id", SqlDbType.Int), new SqlParameter("TargetWindow", SqlDbType.Int), new SqlParameter("Type", SqlDbType.Int), new SqlParameter("Width", SqlDbType.Int), new SqlParameter("Height", SqlDbType.Int), new SqlParameter("Words", SqlDbType.NVarChar) }; parms[0].Value = model.Name; parms[1].Value = model.ClickUrl; parms[2].Value = model.Id; parms[3].Value = model.TargetWindow; parms[4].Value = model.Type; parms[5].Value = model.Width; parms[6].Value = model.Height; parms[7].Value = model.Words; return(Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms)); }
/// <summary> /// 物料列表 /// </summary> /// <param name="setting"></param> /// <returns></returns> public static IPageOfList <AdInfo> List(AdSearchSetting setting) { FastPaging fp = new FastPaging(); fp.OverOrderBy = " CreateDateTime DESC"; fp.PageIndex = setting.PageIndex; fp.PageSize = setting.PageSize; fp.QueryFields = "*"; fp.TableName = "Ads"; fp.PrimaryKey = "Id"; fp.WithOptions = " WITH(NOLOCK)"; IList <AdInfo> list = new List <AdInfo>(); AdInfo model = null; DataTable dt = SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005()); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { model = GetByRow(dr); if (model != null) { list.Add(model); } } } int count = Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, fp.BuildCountSQL())); return(new PageOfList <AdInfo>(list, setting.PageIndex, setting.PageSize, count)); }
public ActionResult SaveAdinfo(AdInfo AdInfo) { if (AdInfo.Id.IsNullOrEmpty()) { AdInfo.StartTime = DateTime.Now; AdInfo.EndTime = new DateTime(5000, 1, 1); AdInfo.State = 1; this.Entity.AdInfo.AddObject(AdInfo); } else { var baseAdInfo = this.Entity.AdInfo.FirstOrDefault(o => o.Id == AdInfo.Id); if (baseAdInfo == null) { ViewBag.ErrorMsg = "数据不存在"; return(View("Error")); } baseAdInfo = Request.ConvertRequestToModel <AdInfo>(baseAdInfo, AdInfo); } this.Entity.SaveChanges(); System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(() => { ClearCacheAdInfo(); }); return(this.RedirectToRoute("ManageAction", new { action = "Index", Controller = "APPModule", Id = AdInfo.AgentId })); //BaseRedirect(); }
public void CanMap_AdInfo_to_EditAdModel() { var mapper = GetMapper(); var src = new AdInfo(); var dst = mapper.Map <EditAdModel>(src); }
void Start() { adInfo = manager.SPAds.Find(ad => ad.SceneName == "IconScene"); // 初回のみResister(),Start(),Show()を呼び、 // 2度目以降は、SetVisibility()を使用してください if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerInline(adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start(adInfo.TestSID); var iconParam = new IMobileIconParams(); iconParam.iconNumber = 5; iconParam.iconSize = 52; iconParam.iconTitleEnable = false; adInfo.AdViewId = IMobileSdkAdsUnityPlugin.show(adInfo.TestSID, IMobileSdkAdsUnityPlugin.AdType.ICON, IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER, IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE, iconParam); } else { IMobileSdkAdsUnityPlugin.setVisibility(adInfo.AdViewId.Value, true); } }
public void Add(AdInfo AdInfo) { AdInfo = Request.ConvertRequestToModel <AdInfo>(AdInfo, AdInfo); Entity.AdInfo.AddObject(AdInfo); Entity.SaveChanges(); BaseRedirect(); }
public static int AddAd(AdInfo ad) { ad.ID = dal.AddAd(ad); UploadBLL.UpdateUpload(TableID, 0, ad.ID, Cookies.Admin.GetRandomNumber(false)); CreateAdFile(ad); return(ad.ID); }
public async Task <ActionResult> About() { var apiBaseUrl = Environment.GetEnvironmentVariable("API_URL") ?? "http://localhost:60201/"; var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true }); client.BaseAddress = new Uri(apiBaseUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); string json = await Task.Run(() => JsonConvert.SerializeObject(new UPNInfo() { UPN = LDAPHelper.GetUPN(User.Identity.Name) })); var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync("api/values", content); AdInfo adinfo = new AdInfo(); if (response.IsSuccessStatusCode) { string data = await response.Content.ReadAsStringAsync(); JavaScriptSerializer JSserializer = new JavaScriptSerializer(); adinfo = JSserializer.Deserialize <AdInfo>(data); } return(View(adinfo)); }
public async Task <IHttpActionResult> PostAdInfo(AdInfo adInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AdInfos.Add(adInfo); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (AdInfoExists(adInfo.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = adInfo.Id }, adInfo)); }
/// <summary> /// GameObj에 있는 물체를 Unity 공간에서 파괴한다. /// </summary> public override void Destroy() { MonoBehaviour.Destroy(GameObj); DestroyCommentCanvas(); GameObj = null; Info = null; }
void ParsePlatformData(JsonData rootData) { string key = "platform"; if (!Common.JsonDataContainsKey(rootData, key)) { return; } JsonData jsonItems = rootData[key]; for (int i = 0; i < jsonItems.Count; i++) { AdInfo info = new AdInfo(); JsonData current = jsonItems[i]; info.source = (string)current["source"]; if (IsInPlatformList(info.source)) { continue; } info.appid = (string)current["appid"]; info.appkey = GetJsonKey(current, "appkey"); info.key_splash = GetJsonKey(current, "key_splash"); info.key_splash_insert = GetJsonKey(current, "key_splash_insert"); info.key_banner = (string)current["key_banner"]; info.key_insert = (string)current["key_insert"]; info.key_native = GetJsonKey(current, "key_native"); info.key_video = GetJsonKey(current, "key_video"); info.key_insert_video = GetJsonKey(current, "key_insert_video"); listPlatform.Add(info); } }
/// <summary> /// 根据分页获得数据列表 /// </summary> /// <param name="TbFields">返回字段</param> /// <param name="strWhere">查询条件</param> /// <param name="OrderField">排序字段</param> /// <param name="PageIndex">页码</param> /// <param name="PageSize">页尺寸</param> /// <param name="TotalCount">返回总记录数</param> /// <returns>IList<AdInfo></returns> public IList <AdInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount) { IList <AdInfo> list = new List <AdInfo>(); using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation")) { db.AddInParameter(cmd, "@TbName", DbType.String, "Ad"); db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields); db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere); db.AddInParameter(cmd, "@OrderField", DbType.String, orderField); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize); db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue); using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0]) { if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { AdInfo model = new AdInfo(); model.LoadFromDataRow(dr); list.Add(model); } } } totalCount = (int)db.GetParameterValue(cmd, "@Total"); return(list); } }
public void Save(AdInfo AdInfo) { AdInfo baseAdInfo = Entity.AdInfo.FirstOrDefault(n => n.Id == AdInfo.Id); baseAdInfo = Request.ConvertRequestToModel <AdInfo>(baseAdInfo, AdInfo); Entity.SaveChanges(); BaseRedirect(); }
public InterstitialAd(AdInfo adInfo) { this.adInfo = adInfo; Context = new MSAd.InterstitialAd(); Context.AdReady += InterstitialAd_AdReady; Context.ErrorOccurred += InterstitialAd_ErrorOccurred; Context.Completed += InterstitialAd_Completed; Context.Cancelled += InterstitialAd_Cancelled; }
public void ChangeStatus(AdInfo AdInfo, string InfoList, string Clomn, string Value) { if (string.IsNullOrEmpty(InfoList)) { InfoList = AdInfo.Id.ToString(); } int Ret = Entity.ChangeEntity <AdInfo>(InfoList, Clomn, Value); Entity.SaveChanges(); Response.Write(Ret); }
public string GetAppId(string source) { string ret = ""; AdInfo info = GetAdInfo(source); if (info != null) { ret = info.appid; } return(ret); }
public void Delete(AdInfo AdInfo, string InfoList, int?IsDel) { if (string.IsNullOrEmpty(InfoList)) { InfoList = AdInfo.Id.ToString(); } int Ret = Entity.MoveToDeleteEntity <AdInfo>(InfoList, IsDel, AdminUser.UserName); Entity.SaveChanges(); Response.Write(Ret); }
public async Task <IHttpActionResult> GetAdInfo(int id) { AdInfo adInfo = await db.AdInfos.FindAsync(id); if (adInfo == null) { return(NotFound()); } return(Ok(adInfo)); }
/// <summary> /// 提交标签修改 /// </summary> /// <param name="ad"></param> /// <returns></returns> public bool PutAdInfo(AdInfo ad) { if (ad.AutoId == 0) { return(Add(ad)); } else { return(Update(ad)); } }
/// <summary> /// 添加或编辑物料信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static AdInfo Create(AdInfo model) { if (model.Id == 0) { int id = AdManage.Insert(model); } else { AdManage.Update(model); } return(model); }
void Start () { adInfo = manager.SPAds.Find (ad => ad.SceneName == "WallScene"); // 初回のみResister(),Start()を呼びます。 // 2度目以降と区別するため、AdViewIdに0を設定します if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerFullScreen (adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start (adInfo.TestSID); adInfo.AdViewId = 0; } }
void ParsePriorityItem(List <AdInfo> ls, string key, JsonData json) { JsonData jsonItems = json[key]; for (int i = 0; i < jsonItems.Count; i++) { AdInfo info = new AdInfo(); JsonData current = jsonItems[i]; info.source = (string)current["source"]; ls.Add(info); } }
void Start() { adInfo = manager.SPAds.Find(ad => ad.SceneName == "TextPopupScene"); // 初回のみResister(),Start()を呼びます。 // 2度目以降と区別するため、AdViewIdに0を設定します if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerFullScreen(adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start(adInfo.TestSID); adInfo.AdViewId = 0; } }
protected void SubmitButton_Click(object sender, EventArgs e) { AdInfo ad = new AdInfo(); ad.ID = RequestHelper.GetQueryString <int>("ID"); ad.Title = this.Title.Text; ad.Introduction = this.Introduction.Text; ad.AdClass = Convert.ToInt32(this.AdClass.Text); if (ad.AdClass == 1) { ad.Display = this.TextDisplay.Text; ad.Url = this.TextURL.Text; } else if (ad.AdClass == 2) { ad.Display = this.PictureDisplay.Text; ad.Url = this.PictureURL.Text; } else if (ad.AdClass == 3) { ad.Display = this.FlashDisplay.Text; ad.Url = string.Empty; } else { ad.Display = this.CodeDisplay.Text; ad.Url = string.Empty; } ad.Width = Convert.ToInt32(this.Width.Text); ad.Height = Convert.ToInt32(this.Height.Text); ad.StartDate = Convert.ToDateTime(this.StartDate.Text); ad.EndDate = Convert.ToDateTime(this.EndDate.Text).AddDays(1.0).AddSeconds(-1.0); ad.Remark = this.Remark.Text; ad.IsEnabled = Convert.ToInt32(this.IsEnabled.Text); string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (ad.ID == -2147483648) { base.CheckAdminPower("AddAd", PowerCheckType.Single); int id = AdBLL.AddAd(ad); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Ad"), id); } else { base.CheckAdminPower("UpdateAd", PowerCheckType.Single); AdBLL.UpdateAd(ad); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Ad"), ad.ID); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl); }
public async Task <IHttpActionResult> DeleteAdInfo(int id) { AdInfo adInfo = await db.AdInfos.FindAsync(id); if (adInfo == null) { return(NotFound()); } db.AdInfos.Remove(adInfo); await db.SaveChangesAsync(); return(Ok(adInfo)); }
private void SerializeInternal(AdInfo model, IDictionary<string, object> result) { result.Add("adid", model.AdID); result.Add("apid", model.ApID); result.Add("title", model.Title); result.Add("hits", model.Hits); result.Add("offtime", model.OffTime); result.Add("imgurl", model.ImgUrl); result.Add("link", model.Link); result.Add("width", model.Width); result.Add("height", model.Height); result.Add("state", model.State); result.Add("isdeleted", model.IsDeleted); result.Add("sort", model.Sort); }
public static void CreateAdFile(AdInfo ad) { AdClass class2 = new AdClass(); class2.AdType = (AdType)ad.AdClass; class2.Display = ad.Display; class2.EndDate = ad.EndDate; class2.FileName = ServerHelper.MapPath(ShopCommon.GetAdFile(ad.ID.ToString())); class2.Height = ad.Height; class2.IsEnabled = ad.IsEnabled; class2.StartDate = ad.StartDate; class2.Title = ad.Title; class2.Url = "/Ad.aspx?AdID=" + ad.ID.ToString() + "&URL=" + HttpContext.Current.Server.UrlEncode(ad.Url); class2.Width = ad.Width; class2.MakeAdFile(); }
void Start () { adInfo = manager.SelectedAdInfo; // 初回のみResister(),Start(),Show()を呼び、 // 2度目以降は、SetVisibility()を使用してください if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerInline (adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start (adInfo.TestSID); adInfo.AdViewId = IMobileSdkAdsUnityPlugin.show (adInfo.TestSID, adInfo.AdType.Value, IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER, IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE); } else { IMobileSdkAdsUnityPlugin.setVisibility(adInfo.AdViewId.Value, true); } }
public void UpdateAd(AdInfo ad) { SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@title", SqlDbType.NVarChar), new SqlParameter("@introduction", SqlDbType.NText), new SqlParameter("@adClass", SqlDbType.Int), new SqlParameter("@display", SqlDbType.NText), new SqlParameter("@width", SqlDbType.Int), new SqlParameter("@height", SqlDbType.Int), new SqlParameter("@url", SqlDbType.NVarChar), new SqlParameter("@startDate", SqlDbType.DateTime), new SqlParameter("@endDate", SqlDbType.DateTime), new SqlParameter("@remark", SqlDbType.NVarChar), new SqlParameter("@isEnabled", SqlDbType.Int) }; pt[0].Value = ad.ID; pt[1].Value = ad.Title; pt[2].Value = ad.Introduction; pt[3].Value = ad.AdClass; pt[4].Value = ad.Display; pt[5].Value = ad.Width; pt[6].Value = ad.Height; pt[7].Value = ad.Url; pt[8].Value = ad.StartDate; pt[9].Value = ad.EndDate; pt[10].Value = ad.Remark; pt[11].Value = ad.IsEnabled; ShopMssqlHelper.ExecuteNonQuery(ShopMssqlHelper.TablePrefix + "UpdateAd", pt); }
void Start () { adInfo = manager.SPAds.Find (ad => ad.SceneName == "BannerScene"); // 初回のみResister(),Start(),Show()を呼び、 // 2度目以降は、SetVisibility()を使用してください if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerInline (adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start (adInfo.TestSID); adInfo.AdViewId = IMobileSdkAdsUnityPlugin.show (adInfo.TestSID, IMobileSdkAdsUnityPlugin.AdType.BANNER, IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER, IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE, true); } else { IMobileSdkAdsUnityPlugin.setVisibility(adInfo.AdViewId.Value, true); } }
/// <summary> /// 更新数据 /// </summary> /// <param name="mod">AdInfo</param> /// <returns>受影响行数</returns> public int Update(AdInfo mod) { using (DbConnection conn = db.CreateConnection()) { conn.Open(); using (DbTransaction tran = conn.BeginTransaction()) { try { using (DbCommand cmd = db.GetStoredProcCommand("SP_Ad_Update")) { db.AddInParameter(cmd, "@AdID", DbType.Int32, mod.AdID); db.AddInParameter(cmd, "@ApID", DbType.Int32, mod.ApID); db.AddInParameter(cmd, "@Title", DbType.String, mod.Title); db.AddInParameter(cmd, "@Hits", DbType.Int32, mod.Hits); db.AddInParameter(cmd, "@OffTime", DbType.DateTime, mod.OffTime); db.AddInParameter(cmd, "@ImgUrl", DbType.String, mod.ImgUrl); db.AddInParameter(cmd, "@Link", DbType.String, mod.Link); db.AddInParameter(cmd, "@Width", DbType.Int32, mod.Width); db.AddInParameter(cmd, "@Height", DbType.Int32, mod.Height); db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); tran.Commit(); return db.ExecuteNonQuery(cmd); } } catch (Exception e) { tran.Rollback(); throw e; } finally { conn.Close(); } } } }
void Start () { adInfo = manager.SPAds.Find (ad => ad.SceneName == "IconScene"); // 初回のみResister(),Start(),Show()を呼び、 // 2度目以降は、SetVisibility()を使用してください if (adInfo.AdViewId == null) { IMobileSdkAdsUnityPlugin.registerInline (adInfo.TestPID, adInfo.TestMID, adInfo.TestSID); IMobileSdkAdsUnityPlugin.start (adInfo.TestSID); var iconParam = new IMobileIconParams(); iconParam.iconNumber = 5; iconParam.iconSize = 52; iconParam.iconTitleEnable = false; adInfo.AdViewId = IMobileSdkAdsUnityPlugin.show (adInfo.TestSID, IMobileSdkAdsUnityPlugin.AdType.ICON, IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER, IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE, iconParam); } else { IMobileSdkAdsUnityPlugin.setVisibility(adInfo.AdViewId.Value, true); } }
/// <summary> /// 根据分页获得数据列表 /// </summary> /// <param name="TbFields">返回字段</param> /// <param name="strWhere">查询条件</param> /// <param name="OrderField">排序字段</param> /// <param name="PageIndex">页码</param> /// <param name="PageSize">页尺寸</param> /// <param name="TotalCount">返回总记录数</param> /// <returns>IList<AdInfo></returns> public IList<AdInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount) { IList<AdInfo> list = new List<AdInfo>(); using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation")) { db.AddInParameter(cmd, "@TbName", DbType.String, "Ad"); db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields); db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere); db.AddInParameter(cmd, "@OrderField", DbType.String, orderField); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize); db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue); using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0]) { if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { AdInfo model = new AdInfo(); model.LoadFromDataRow(dr); list.Add(model); } } } totalCount = (int)db.GetParameterValue(cmd, "@Total"); return list; } }
/// <summary> /// 获得实体 /// </summary> /// <param name="keyValue">编号</param> /// <returns>AdInfo</returns> public AdInfo Get(int keyValue) { AdInfo model = null; using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord")) { db.AddInParameter(cmd, "@TableName", DbType.String, "Ad"); db.AddInParameter(cmd, "@KeyName", DbType.String, "AdID"); db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue); using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0]) { if (dt.Rows.Count > 0) { model = new AdInfo(); model.LoadFromDataRow(dt.Rows[0]); } } return model; } }