digg_manage.aspx.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using iNethinkCMS.BLL;
  2. using iNethinkCMS.Command;
  3. using iNethinkCMS.Helper;
  4. using iNethinkCMS.Model;
  5. using iNethinkCMS.Web.UI;
  6. using System;
  7. using System.Data;
  8. using System.Web.UI.HtmlControls;
  9. using System.Web.UI.WebControls;
  10. namespace iNethinkCMS.Web.plugs.digg
  11. {
  12. public class digg_manage : Admin_BasePage
  13. {
  14. private BLL_iNethinkCMS_Plugs_Digg bll = new BLL_iNethinkCMS_Plugs_Digg();
  15. private Model_iNethinkCMS_Plugs_Digg model = new Model_iNethinkCMS_Plugs_Digg();
  16. private BLL_iNethinkCMS_Special bll_special = new BLL_iNethinkCMS_Special();
  17. private string vNavInfo = "当前位置:";
  18. private string vAct = "";
  19. private int vPage = 1;
  20. private int vID;
  21. private string vSQL = "";
  22. private string vKeyType = "";
  23. private string vKey = "";
  24. protected HtmlForm form_digg_manage;
  25. protected HtmlGenericControl navInfoID;
  26. protected DropDownList sKeyType;
  27. protected TextBox sKey;
  28. protected Button Button_Search;
  29. protected HtmlGenericControl mainID;
  30. protected HtmlTableRow iNoInfo;
  31. protected Repeater Repeater;
  32. protected DropDownList exportSID;
  33. protected Button Button_Export;
  34. protected HtmlGenericControl pagelist;
  35. protected void Page_Load(object sender, EventArgs e)
  36. {
  37. base.CheckUserPower("a");
  38. this.vAct = ((base.Request.QueryString["Act"] != null) ? base.Request.QueryString["Act"] : "");
  39. if (base.Request.QueryString["Page"] != null && base.Request.QueryString["Page"].Trim() != "" && !int.TryParse(base.Request.QueryString["Page"], out this.vPage))
  40. {
  41. this.vPage = 1;
  42. }
  43. this.vKeyType = ((base.Request.QueryString["sKeyType"] != null) ? base.Request.QueryString["sKeyType"] : "");
  44. this.vKey = ((base.Request.QueryString["sKey"] != null) ? base.Request.QueryString["sKey"] : "");
  45. this.vKey = this.vKey.Replace("'", "");
  46. if (base.Request.QueryString["ID"] != null && base.Request.QueryString["ID"].Trim() != "" && !int.TryParse(base.Request.QueryString["ID"], out this.vID))
  47. {
  48. base.Response.Write("ID Error");
  49. base.Response.End();
  50. }
  51. if (this.vKey.Length > 0)
  52. {
  53. if (this.vKeyType == "ID")
  54. {
  55. if (Command_Validate.IsNumber(this.vKey))
  56. {
  57. this.vSQL += this.vKeyType + " = " + this.vKey;
  58. }
  59. else
  60. {
  61. this.vKey = "";
  62. }
  63. }
  64. else
  65. {
  66. this.vSQL = string.Concat(new string[]
  67. {
  68. this.vSQL,
  69. this.vKeyType,
  70. " Like '%",
  71. this.vKey,
  72. "%'"
  73. });
  74. }
  75. }
  76. this.mainID.Visible = false;
  77. string a = this.vAct;
  78. if (a == "delete")
  79. {
  80. this.Fun_Delete(this.vID);
  81. return;
  82. }
  83. this.navInfoID.InnerText = this.vNavInfo + "投票管理";
  84. this.mainID.Visible = true;
  85. if (!base.IsPostBack)
  86. {
  87. this.BindDropdownList_Special(this.exportSID);
  88. this.sKeyType.SelectedValue = this.vKeyType;
  89. this.sKey.Text = this.vKey;
  90. }
  91. this.PageListInfo();
  92. }
  93. protected void PageListInfo()
  94. {
  95. int num = int.Parse(this.siteConfig.PageListNum);
  96. int recordCount = this.bll.GetRecordCount(this.vSQL);
  97. this.Repeater.DataSource = this.bll.GetListByPage(this.vSQL, "ID Desc", (this.vPage - 1) * num, this.vPage * num);
  98. this.Repeater.DataBind();
  99. string innerHtml = "";
  100. if (recordCount > 0)
  101. {
  102. innerHtml = WebUI_PageList.GetPagingInfo_Manage((int)Math.Ceiling((double)recordCount / (double)num), recordCount, this.vPage, num);
  103. }
  104. this.pagelist.InnerHtml = innerHtml;
  105. this.iNoInfo.Visible = (recordCount == 0);
  106. }
  107. protected void Button_Search_Click(object sender, EventArgs e)
  108. {
  109. base.Response.Redirect(string.Concat(new string[]
  110. {
  111. base.Request.Path,
  112. "?skeytype=",
  113. this.sKeyType.SelectedValue,
  114. "&skey=",
  115. this.sKey.Text
  116. }));
  117. }
  118. protected void Button_Export_Click(object sender, EventArgs e)
  119. {
  120. string selectedValue = this.exportSID.SelectedValue;
  121. if (selectedValue == "0")
  122. {
  123. MessageBox.Show(this, "请选择相应的专题!");
  124. return;
  125. }
  126. string text = "Select [ID] AS 编号,[Title] AS 标题,[DiggNumber] AS 投票分值 From [iNethinkCMS_Content] A Where [Display] = 1";
  127. if (selectedValue != "0")
  128. {
  129. text += " And SID = " + selectedValue;
  130. }
  131. text += " Order by [DiggNumber] Desc";
  132. XLSHelper.DataTableExportExcel(SQLHelper.Query(text).Tables[0], "[" + this.exportSID.SelectedItem + "]投票排名信息");
  133. }
  134. protected void Fun_Delete(int byID)
  135. {
  136. this.model = this.bll.GetModel(byID);
  137. SQLHelper.ExecuteSql(string.Concat(new object[]
  138. {
  139. "Update [iNethinkCMS_Content] Set [DiggNumber] = [DiggNumber] - ",
  140. this.model.DiggPoint,
  141. " Where [ID] = ",
  142. this.vID
  143. }));
  144. if (this.bll.Delete(byID))
  145. {
  146. base.Response.Redirect(base.Request.UrlReferrer.AbsoluteUri);
  147. }
  148. }
  149. protected void BindDropdownList_Special(DropDownList byDropDownList)
  150. {
  151. DataTable dataTable = this.bll_special.GetList(0, "[Display] = 1", "OrderNum Desc").Tables[0];
  152. for (int i = 0; i < dataTable.Rows.Count; i++)
  153. {
  154. byDropDownList.Items.Add(new ListItem(dataTable.Rows[i]["SpecialName"].ToString(), dataTable.Rows[i]["ID"].ToString()));
  155. }
  156. }
  157. }
  158. }