protected void btnAdd_Click(object sender, EventArgs e) { string UserName = tbName.Text.Trim(); if (UserName == "") { Shove._Web.JavaScript.Alert(this.Page, "请输入名人用户名!"); return; } int order = Shove._Convert.StrToInt(tbOrder.Text.Trim(), -1); if (order < 0) { Shove._Web.JavaScript.Alert(this.Page, "顺序输入非法!"); return; } DataTable dt = new DAL.Tables.T_Users().Open("ID", "Name='" + UserName + "'", ""); if (dt == null || dt.Rows.Count == 0) { Shove._Web.JavaScript.Alert(this.Page, "不存在" + UserName + "用户!"); return; } dt = new DAL.Tables.T_Personages().Open("ID", "UserName='******' and LotteryID=" + Shove._Web.Utility.FilteSqlInfusion(ddlLotteries.SelectedValue) + "", ""); if (dt != null && dt.Rows.Count > 0) { Shove._Web.JavaScript.Alert(this.Page, UserName + "已经是" + ddlLotteries.SelectedItem.Text + "的名人了!"); return; } DAL.Tables.T_Personages p = new DAL.Tables.T_Personages(); p.Order.Value = order; p.UserName.Value = UserName; p.LotteryID.Value = ddlLotteries.SelectedValue; p.IsShow.Value = cbisShow.Checked; long l = p.Insert(); if (l > 0) { Shove._Web.Cache.ClearCache("Admin_Personages"); Shove._Web.JavaScript.Alert(this, "添加成功", "Personages.aspx?LotteryID=" + ddlLotteries.SelectedValue); } else { Shove._Web.JavaScript.Alert(this, "添加失败"); } }
protected void btnAdd_Click(object sender, EventArgs e) { string UserName = tbName.Text.Trim(); if (UserName == "") { Shove._Web.JavaScript.Alert(this.Page, "请输入名人用户名!"); return; } int order = Shove._Convert.StrToInt(tbOrder.Text.Trim(), -1); if (order < 0) { Shove._Web.JavaScript.Alert(this.Page, "顺序输入非法!"); return; } DataTable dt = new DAL.Tables.T_Users().Open("ID", "Name='" + UserName + "'", ""); if (dt == null || dt.Rows.Count == 0) { Shove._Web.JavaScript.Alert(this.Page, "不存在" + UserName + "用户!"); return; } int UserID = 0; // 获取用户ID try { UserID = Shove._Convert.StrToInt(dt.Rows[0]["ID"].ToString(), 0); } catch { UserID = 0; } dt = new DAL.Tables.T_Personages().Open("ID", "UserName='******' and LotteryID=" + Shove._Web.Utility.FilteSqlInfusion(ddlLotteries.SelectedValue) + "", ""); if (dt != null && dt.Rows.Count > 0) { Shove._Web.JavaScript.Alert(this.Page, UserName + "已经是" + ddlLotteries.SelectedItem.Text + "的名人了!"); return; } DAL.Tables.T_Personages p = new DAL.Tables.T_Personages(); p.UserID.Value = UserID; p.Order.Value = order; p.UserName.Value = UserName; p.LotteryID.Value = ddlLotteries.SelectedValue; p.IsShow.Value = cbisShow.Checked; p.IsRecommend.Value = cbIsRecommend.Checked; if (cbIsRecommend.Checked) { Shove.Database.MSSQL.ExecuteNonQuery("update T_Personages set IsRecommend = 0"); // 清楚缓存 Shove._Web.Cache.ClearCache("DataCache_CelebrityHall_Recommends"); } long l = p.Insert(); if (l >= 0) { Shove._Web.Cache.ClearCache("Admin_Personages"); Shove._Web.Cache.ClearCache("DataCache_CelebrityHall_Collects"); Shove._Web.Cache.ClearCache("DataCache_CelebrityHall_Star"); Shove._Web.Cache.ClearCache("DataCache_CelebrityHall_Recommends"); Shove._Web.JavaScript.Alert(this, "添加成功", "Personages.aspx?LotteryID=" + ddlLotteries.SelectedValue); } else { Shove._Web.JavaScript.Alert(this, "添加失败"); } }