Esempio n. 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;
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        public void NewsDataBind(int i)
        {
            string        sql1   = "select 新闻标题,栏目名称,新闻内容,图片描述,新闻作者 from 新闻表 where ID=" + i;
            SqlDataReader reader = LinkDB.Reader(sql1);

            while (reader.Read())
            {
                Ttitle.Text = (string)reader["新闻标题"];
                RadioButtonList1.ClearSelection();
                //RadioButtonList1.SelectedValue=dr["栏目名称"].ToString();//两者都可以实现Radiobuttonlist的数据库显示
                RadioButtonList1.Text = reader["栏目名称"].ToString();
                FreeTextBox1.Text    += reader["新闻内容"].ToString();
                TPath.Text            = (string)reader["图片描述"];
                Tauthor.Text          = (string)reader["新闻作者"];
            }
            reader.Close();
            LinkDB.closeConnection();
        }
Esempio n. 4
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>");
             }
         }
     }
 }