62,244
社区成员




private void Getuserinfo(int userid)
{
//获取该用户的信息
BLL.Admin_userBLL bll = new Admin_userBLL();
Model.admin_user admintemp = (Model.admin_user)(bll.GetModel(userid));
this.txtusername.Text = admintemp.UserName.ToString(); //获取账号
this.txtpwd.Text = admintemp.UserPassWord.ToString();//获取密码
string flag = admintemp.Flag.ToString();
string[] ycs = flag.Split('/');
string[] allflag = { "001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011", "012" }; //所有权限
for (int i = 0; i < ycs.Length; i++)
{
for (int j = 0; j <allflag.Length; j++)
{
if (ycs[i] == allflag[j])
{
this.CheckBoxList1.Items[j].Selected = true; //如果存在权限选项 则checkbox选中该项
}
continue;
}
}
}
foreach(string s in ycs)
{
foreach(ListItem li in this.CheckBoxList1.Items)
{
li.Text.Contains(s))
{
li.Selected=true;
}
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class findbook : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["pagenow"] = "findbook";
}
protected void btnsearch_Click(object sender, EventArgs e)
{
//控件数组
bool[] ckb = new bool[] {
this.ckb1.Checked,this.ckb2.Checked,this.ckb3.Checked,this.ckb4.Checked,this.ckb5.Checked,
this.ckb6.Checked,this.ckb7.Checked,this.ckb8.Checked,this.ckb9.Checked,this.ckb10.Checked,this.ckb11.Checked,
this.ckb12.Checked,this.ckb13.Checked,this.ckb14.Checked,this.ckb15.Checked,this.ckb16.Checked,this.ckb17.Checked,
this.ckb18.Checked,this.ckb19.Checked,this.ckb20.Checked,this.ckb21.Checked,this.ckb22.Checked,this.ckb23.Checked,
this.ckb24.Checked,this.ckb25.Checked,this.ckb26.Checked,this.ckb27.Checked,this.ckb28.Checked,this.ckb29.Checked,
this.ckb30.Checked,this.ckb31.Checked,this.ckb32.Checked,this.ckb33.Checked,this.ckb34.Checked,this.ckb35.Checked,
this.ckb36.Checked,this.ckb37.Checked,this.ckb38.Checked,this.ckb39.Checked,this.ckb40.Checked,this.ckb41.Checked,
this.ckb42.Checked,this.ckb43.Checked,this.ckb44.Checked,this.ckb45.Checked,this.ckb46.Checked,this.ckb47.Checked,
this.ckb48.Checked,this.ckb49.Checked,this.ckb50.Checked,this.ckb51.Checked,this.ckb52.Checked,this.ckb53.Checked,
this.ckb54.Checked,this.ckb55.Checked,this.ckb56.Checked,this.ckb57.Checked,this.ckb58.Checked,this.ckb59.Checked,
this.ckb60.Checked,this.ckb61.Checked,this.ckb62.Checked,this.ckb63.Checked,this.ckb64.Checked,this.ckb65.Checked,
this.ckb66.Checked,this.ckb67.Checked,this.ckb68.Checked,this.ckb69.Checked,this.ckb70.Checked,this.ckb71.Checked,
this.ckb72.Checked,this.ckb73.Checked,this.ckb74.Checked,this.ckb75.Checked,this.ckb76.Checked,this.ckb77.Checked,
this.ckb78.Checked,this.ckb79.Checked,this.ckb80.Checked,this.ckb81.Checked,this.ckb82.Checked,this.ckb83.Checked,
this.ckb84.Checked,this.ckb85.Checked,this.ckb86.Checked};
//检查是否输入至少一个类别
int x=0;
for (int n = 0; n < 86; n++)
{
if (ckb[n])
{
x += 1;
}
}
if (x == 0)
{
Page.RegisterStartupScript("ServiceManHistoryButtonClick", "<script>alert('难道您想找所有的书吗?',null);</script>");
return;
}
//以下数行用来组合查询字符串
string []strsearch=new string[]{"booklxA","booklxB","booklxC","booklxD","booklxE",
"zhujuesexA","zhujuesexB","ifchuanyueA","ifchuanyueB","azhiyeA","azhiyeB",
"azhiyeC","azhiyeD","azhiyeE","azhiyeF","azhiyeG","azhiyeH","azhiyeI","azhiyeJ",
"azhiyeK","azhiyeL","zhiyeA","zhiyeB","zhiyeC","zhiyeD","zhiyeE","zhiyeF",
"zhiyeG","zhiyeH","zhiyeI","zhiyeJ","zhiyeK","zhiyeL","zhiyeM","zhiyeN","zhiyeO",
"chuanyuelxA","chuanyuelxB","chuanyuelxC","chuanyuelxD","chuanyuelxE",
"chuanyuelxF","chuanyuelxG","chuanyuelxH","chuanyuelxI","chuanyuelxJ",
"chuanyuelxK","chuanyuelxL","chuanyuelxM","bookjdA","bookjdB","bookjdC","bookjdD",
"bookjdE","jjl","mwl","sxl","zsl","srl","kxl","qtl","ifone","ifmany","ifonezhujue",
"ifmanyzhujue","bzclh","yzqdd","ageA","ageB","ageC","ageD","ageE","ptchuanyue",
"cschuanyue","yxchuanyue","wzchuanyue","ifwanbenA","ifwanbenB","zhuangbeiA",
"zhuangbeiB","zhuangbeiC","zhuangbeiD","zhuangbeiE","zhuangbeiF","zhuangbeiG",
"zhuangbeiH"};
string strselect;
string strtemp="";
string strtemp2="";
string strtemp3;
for(int i=0;i<86;i++)
{
strtemp+=(strsearch[i]+",");
}
for (int i = 0; i < 86; i++)
{
if (ckb[i])
{
strtemp2+=(" and "+strsearch[i]+">0");
}
}
strtemp3=strtemp2.Substring(4);
string strconn = ConfigurationManager.AppSettings["ConnectionString"];
strselect = "select id,bookname,bookzz," + strtemp + "outputusers,booklink from books where " + strtemp3;
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(strselect, conn);
DataSet ds = new DataSet();
da.Fill(ds,"books");
DataTable tablebook;
tablebook=ds.Tables[0];
DataRow dr = tablebook.NewRow();
int rowcount=tablebook.Rows.Count;
if (rowcount> 0)
{
//此处用来更新查询人数统计
for (int i = 0; i < rowcount; i++)
{
dr = ds.Tables[0].Rows[i];
dr[89] = Convert.ToInt32(dr[89]) + 1;
}
SqlCommandBuilder objCommandBuilder = new SqlCommandBuilder(da);
da.Update(ds, "books");
//构建一个小说匹配概率列,输出列表以此来排序
DataColumn newcolumn = new DataColumn();
newcolumn.ColumnName = "justpercent";
newcolumn.DataType=typeof(float);
string strtemp4="";
string strtemp5="";
string strtemp6="";
for (int k=0; k < 86; k++)
{
if (ckb[k])
{
strtemp4 +=("+" + tablebook.Columns[k + 3].ColumnName);
}
else
{
strtemp5+=("+"+tablebook.Columns[k + 3].ColumnName);
}
}
//计算小说匹配概率公式
strtemp6 = "(" + strtemp4.Substring(1) + ")*1.00/(" + strtemp4.Substring(1) + "+" + strtemp5.Substring(1) + ")";
newcolumn.Expression = strtemp6;
tablebook.Columns.Add(newcolumn);
//排序规则为小说匹配列
tablebook.DefaultView.Sort = "justpercent desc";
Session["tblsearch"] = tablebook;
conn.Close();
Response.Redirect("booklist.aspx");
}
else
{
Page.RegisterStartupScript("ServiceManHistoryButtonClick1", "<script>alert('没有查到所要的结果',null);</script>");
}
conn.Close();
}
}