Exemple #1
0
        // protected System.Web.UI.HtmlControls.HtmlTable Ttable;
        public void NewsDetial(int i)
        {
            string        picture = "kuaile";
            string        sql     = "select 新闻标题,发布时间,新闻作者,图片描述 from 新闻表 where ID=" + i;
            SqlDataReader dr      = LinkDB.Reader(sql);

            while (dr.Read())
            {
                Ttitle.Text = (string)dr["新闻标题"];
                Ttime.Text  = "    发布单位:地大登山攀岩俱乐部" + "      发布时间:" + ((DateTime)dr["发布时间"]).ToShortDateString() +
                              "        文/" + (string)dr["新闻作者"] + "  浏览次数:20";
                picture = (string)dr["图片描述"];
            }
            dr.Close();
            string  content = "select 新闻内容 from 新闻表 where ID=" + i;
            DataSet newsset = LinkDB.dataSet(content);

            Repeater1.DataSource = newsset.Tables["tables"].DefaultView;
            Repeater1.DataBind();
            newsset.Clear();

            string path = AppDomain.CurrentDomain.BaseDirectory + "Admin\\Images\\upload\\" + picture + ".jpg";

            Image1.ImageUrl = "~/Admin/Images/upload/" + picture + ".jpg";
            Bitmap smallP = new Bitmap(path);

            Image1.Height = 200;
            Image1.Width  = 200 * smallP.Width / smallP.Height;
        }
Exemple #2
0
        public void DataBind(string s)
        {
            string sql = s;

            try
            {
                DataSet ds = LinkDB.dataSet(sql);
                if (sql == sql1)
                {
                    repeater1.DataSource = ds.Tables["tables"].DefaultView;
                    repeater1.DataBind();
                }
                else
                {
                    repeater2.DataSource = ds.Tables["tables"].DefaultView;
                    repeater2.DataBind();
                }
                ds.Clear();
            }
            catch (SqlException ex)
            {
                Response.Write(ex.ToString());
            }
            // finally//可能用不到
        }
Exemple #3
0
        private void RepeaterDataBind(string sql)
        {
            DataSet myds = LinkDB.dataSet(sql);

            RepeaterBind.DataSource = myds;
            RepeaterBind.DataBind();
        }
Exemple #4
0
        public void bindParent()
        {
            string  sqlStr = "select * from 装备表";
            DataSet myds   = LinkDB.dataSet(sqlStr);

            ParentGridView.DataSource   = myds;
            ParentGridView.DataKeyNames = new string[] { "ID", "装备名称" };
            ParentGridView.DataBind();
        }
Exemple #5
0
        public PagedDataSource pds(string i)
        {
            string  sql = "select ID,新闻标题,发布时间 from 新闻表 where 栏目名称= '" + i + "' order by 发布时间 desc";
            DataSet ds  = LinkDB.dataSet(sql);

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource       = ds.Tables["tables"].DefaultView;
            pds.AllowPaging      = true;
            pds.PageSize         = 15;
            pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
            return(pds);
        }
Exemple #6
0
        // 数据绑定
        public void bind()
        {
            DataSet myds = LinkDB.dataSet(sqlStr);

            if (LinkDB.error != "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + LinkDB.error + "');</script>");
                LinkDB.error = "";
                return;
            }
            GridView1.DataSource   = myds;
            GridView1.DataKeyNames = new string[] { "活动名称" };
            GridView1.DataBind();
        }
Exemple #7
0
        protected void ParentGridView_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int parent_index = e.NewEditIndex;

            ParentGridView.EditIndex = parent_index;
            bindParent();
            string tablename = "";

            if (Convert.ToInt32(ParentGridView.DataKeys[parent_index].Values[0]) < 200)
            {
                tablename = ParentGridView.DataKeys[parent_index].Values[1].ToString().Trim() + "1";
            }
            else if (Convert.ToInt32(ParentGridView.DataKeys[parent_index].Values[0]) < 300)
            {
                tablename = ParentGridView.DataKeys[parent_index].Values[1].ToString().Trim() + "2";
            }
            else
            {
                tablename = ParentGridView.DataKeys[parent_index].Values[1].ToString().Trim() + "3";
            }
            string   sql           = "select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tablename + "'";
            GridView childGridView = (GridView)(ParentGridView.Rows[parent_index].FindControl("ChildGridView"));

            childGridView.Columns.Clear();
            SqlDataReader dr = LinkDB.Reader(sql);

            while (dr.Read())
            {
                string     DR = (string)dr["COLUMN_NAME"];
                BoundField bf = new BoundField();
                if (DR != "编号")
                {
                    bf.DataField = DR;
                }
                bf.HeaderText = DR;
                childGridView.Columns.Add(bf);
            }
            dr.Close();
            string  sqlStr = "select * from " + tablename;
            DataSet myds   = LinkDB.dataSet(sqlStr);

            childGridView.DataSource   = myds;
            childGridView.DataKeyNames = new string[] { "编号" };
            childGridView.DataBind();
        }
Exemple #8
0
        public void RepeaterBind(string D)
        {
            Ttitle.Text = D;
            string sql = "select 内容 from 其余项 where ID=";

            if (D == "俱乐部简介")
            {
                sql += 1;
            }
            if (D == "大事记")
            {
                sql += 2;
            }
            else if (D == "联系我们")
            {
                sql += 3;
            }
            DataSet repDS = LinkDB.dataSet(sql);

            Repeater1.DataSource = repDS.Tables["tables"].DefaultView;
            Repeater1.DataBind();
        }
Exemple #9
0
        public void HyperBind(string D)
        {
            string[] b = new string[6];
            string   hyp;

            if (D == "部门介绍")
            {
                hyp = "select 部门名称 from 部门介绍";
            }
            else if (D == "日常活动")
            {
                hyp = "select 活动名称 from 日常活动 ";
            }
            else if (D == "精品活动")
            {
                hyp = "select 活动名称 from 精品活动 ";
            }
            else
            {
                hyp = "select 活动名称 from 户外百科 ";
            }

            DataSet hypDS = LinkDB.dataSet(hyp);

            for (int x = 0; x < hypDS.Tables["tables"].Rows.Count; x++)
            {
                for (int y = 0; y < hypDS.Tables["tables"].Columns.Count; y++)
                {
                    b[x] = hypDS.Tables["tables"].Rows[x][y].ToString();
                }
            }
            HyperLink1.Text = b[0];
            HyperLink2.Text = b[1];
            HyperLink3.Text = b[2];
            HyperLink4.Text = b[3];
            HyperLink5.Text = b[4];
        }
Exemple #10
0
        public void LabBind(string D)
        {
            string[] a = new string[6];
            string   lab;

            if (D == "部门介绍")
            {
                lab = "select 部门简介 from 部门介绍";
            }
            else if (D == "日常活动")
            {
                lab = "select 活动简介 from 日常活动 ";
            }
            else if (D == "精品活动")
            {
                lab = "select 活动简介 from 精品活动 ";
            }
            else
            {
                lab = "select 活动简介 from 户外百科 ";
            }

            DataSet labDS = LinkDB.dataSet(lab);

            for (int x = 0; x < labDS.Tables["tables"].Rows.Count; x++)
            {
                for (int y = 0; y < labDS.Tables["tables"].Columns.Count; y++)
                {
                    a[x] = labDS.Tables["tables"].Rows[x][y].ToString();
                }
            }
            Label1.Text = a[0];
            Label2.Text = a[1];
            Label3.Text = a[2];
            Label4.Text = a[3];
            Label5.Text = a[4];
        }
Exemple #11
0
        public void RepeaterBind(string D)
        {
            string rep;

            if (D == "部门介绍")
            {
                rep = "select 内容 from 部门内容 where 类型ID=";
            }
            else if (D == "日常活动")
            {
                rep = "select 内容 from 日常内容 where 类型ID=";
            }
            else if (D == "精品活动")
            {
                rep = "select 内容 from 精品内容 where 类型ID=";
            }
            else
            {
                rep = "select 内容 from 户外内容 where 类型ID=";
            }
            for (int id = 0; id < 6; id++)
            {
                string  repp  = rep + id;
                DataSet repDS = LinkDB.dataSet(repp);
                switch (id)
                {
                case 0:
                {
                    repeater1.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater1.DataBind();
                    repeater2.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater2.DataBind();
                    break;
                }

                case 1:
                {
                    repeater3.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater3.DataBind();
                    repeater4.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater4.DataBind();
                    break;
                }

                case 2:
                {
                    repeater5.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater5.DataBind();
                    repeater6.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater6.DataBind();
                    break;
                }

                case 3:
                {
                    repeater7.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater7.DataBind();
                    repeater8.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater8.DataBind();
                    break;
                }

                case 4:
                {
                    repeater9.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater9.DataBind();
                    repeater10.DataSource = repDS.Tables["tables"].DefaultView;
                    repeater10.DataBind();
                    break;
                }

                case 5:
                    break;
                }
            }
        }
Exemple #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //上页传参学号
         //string SN = Request.QueryString["id"];
         string SN = "1004105200";
         //个人信息数据绑定
         string  sql1     = "select * from 人员表 where 学号='" + SN + "'";
         DataSet dataset1 = LinkDB.dataSet(sql1);
         Repeater1.DataSource = dataset1.Tables[0].DefaultView;
         Repeater1.DataBind();
         //部门信息数据绑定
         string  sql2     = "select * from 部门表";
         DataSet dataset2 = LinkDB.dataSet(sql2);
         Repeater2_1.DataSource = dataset2.Tables[0].DefaultView;
         Repeater2_1.DataBind();
         Repeater2_2.DataSource = dataset2.Tables[0].DefaultView;
         Repeater2_2.DataBind();
         Repeater2_3.DataSource = dataset2.Tables[0].DefaultView;
         Repeater2_3.DataBind();
         //活动信息数据绑定
         string  sql3     = "select * from 活动表";
         DataSet dataset3 = LinkDB.dataSet(sql3);
         Repeater3.DataSource = dataset3.Tables[0].DefaultView;
         Repeater3.DataBind();
         //欢迎字样数据绑定
         SqlDataReader dr = LinkDB.Reader("select 昵称 from 注册表 where 登录号='" + SN + "'");
         dr.Read();
         string DR = (string)dr["昵称"];
         dr.Close();
         Label1.Text = "您好," + DR + "(" + SN + "),欢迎登录";
     }
     else
     {
         string[] s1 = Label1.Text.Split('(');
         string[] s2 = s1[1].Split(')');
         xuehao = s2[0];
         //表单提交
         string postType = Request.QueryString["s"];
         if (postType != null)
         {
             string old  = Request.Form["old"];
             string new1 = Request.Form["new1"];
             string new2 = Request.Form["new2"];
             if (postType == "withname")
             {
                 string name = Request.Form["name"];
                 LinkDB.ExecuteSql("update 注册表 set 密码='" + new1 + "' , 昵称='" + name + "' where 登录号='" + xuehao + "'");
                 Label1.Text = "您好," + name + "(" + s1[1];
             }
             if (postType == "withoutname")
             {
                 LinkDB.ExecuteSql("update 注册表 set 密码='" + new1 + "'where 登录号='" + xuehao + "'");
             }
             if (LinkDB.error != "")
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('密码更新失败(" + LinkDB.error + ")');</script>");
                 LinkDB.error = "";
             }
             else
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('密码更改成功');</script>");
             }
         }
     }
 }