互动媒体学习社区

发布视频或语音教程

 

系统介绍

根据需求分析的描述以及实际考察,现制定网站实现功能如下:

l         操作简单方便、界面简洁美观。

l         注册功能,用户通过注册成为网站会员。

l         发布下载教程,对会员提供发布教程和下载教程的功能。

l         密码找回功能,当会员忘记密码时可以通过此功能找回。

l         留言功能,通过留言功能进行互动交流。

l         查询功能,使用户通过查询快速找到需要的教程。

l         后台管理功能,管理员通过后台进行网站的维护和管理。

l         系统运行稳定、安全可靠。

操作注意事项

1)本系统管理员用户名为:tsoft,密码为:111

2)实例执行文件位置:TM\06\index.aspx

3)用户注册登后进可进行发布教程及下载操作。

4)在后台进行添加语音和视频信息默认发布人为校长。

5)单击首页底部的“进入后台”按钮,输入用户名、密码进入后台管理界面。

操作流程

1.后台

1)用户注册登录后可进行发布教程、下载等操作,如图1.5所示。

1.5  用户登录

2)单击“发布教程”导航按钮,可对教程信息进行添加、查询操作。

3)单击“视频课堂”导航按钮,对视频课堂信息进行查看操作。

4)单击“语音课堂”导航按钮,对语音课堂信息进行查看操作。

2.后台

1)输入用户名及密码登录后台管理界面,如图1.6所示。

1.6后台管理

2)在“公告管理”下拉菜单中,主要对公告信息的发布、查看及删除操作。

3)在“教程管理”下拉菜单中,主要对教程信息发布和视频信息、音频信息查看、删除及留言管理操作。

4)在“用户管理”下拉菜单中,对用户信息进行查看、锁定及删除操作,如图1.7所示。

 

数据操练类   对access数据库,可以用撒

 

/// <summary>
/// dataOperate 的摘要说明
/// </summary>
public class dataOperate
{
 
 public dataOperate()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }
    //添加数据或删除数据 
     public  bool adlData(string sql)
    {
        OleDbConnection Odbc = createCon();
        Odbc.Open();
        OleDbCommand com = new OleDbCommand(sql, Odbc);
        int i = Convert.ToInt32(com.ExecuteNonQuery());
        Odbc.Close();
        if (i > 0)
        {
           return true;
        }
        else
        {
           return false;
        }     
    }

    //查找数据 
    public  int isData(string sql)
    {
        OleDbConnection Odbc =createCon();                 
        Odbc.Open();
        OleDbCommand com = new OleDbCommand(sql, Odbc);
        int i = Convert.ToInt32(com.ExecuteScalar());
        Odbc.Close();
        return i;      
    }

    //更新数据 
    public  void updateData(string sql)
    {
        OleDbConnection Odbc =createCon();               
        Odbc.Open();
        OleDbCommand com = new OleDbCommand(sql,Odbc);      
        com.ExecuteScalar();
        Odbc.Close();
    }

    //查找并返回一条数据
    public  OleDbDataReader row(string sql)
    {
        OleDbConnection Odbc =createCon();
        Odbc.Open();
        OleDbCommand com = new OleDbCommand(sql, Odbc);
        return com.ExecuteReader();      
    }


    //查找并返回多条数据
    public  DataTable rows(string sql, string table)
    {
        DataSet ds;
        OleDbConnection Odbc =createCon();
        Odbc.Open();
        OleDbDataAdapter oda = new OleDbDataAdapter(sql,Odbc);
        ds = new DataSet();
        oda.Fill(ds,table);
        Odbc.Close();
        return ds.Tables[table];
    }

    //创建数据库连接
    public  OleDbConnection createCon()
    {
        OleDbConnection odbc = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=|DataDirectory|db_study.mdb;");
        return odbc;
    }
}

 

 业务功能类 加密解密方法撒,可以直接用啊

 

 

//using System.Security.Cryptography;
//using System.IO;
//using System.Text;

/// <summary>
/// Operate 的摘要说明
/// </summary>
public class Operate
{
    public static DataSet ds;
 public Operate()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }
    //加密:
    public static string Encrypting(string strSource)
    {
        //把字符串放到byte数组中
        byte[] bytIn = System.Text.Encoding.Default.GetBytes(strSource);
        //建立加密对象的密钥和偏移量       
        byte[] iv = { 102, 16, 93, 156, 78, 4, 218, 32 };//定义偏移量
        byte[] key = { 55, 103, 246, 79, 36, 99, 167, 3 };//定义密钥
        //实例DES加密类
        DESCryptoServiceProvider mobjCryptoService = new DESCryptoServiceProvider();
        mobjCryptoService.Key = iv;
        mobjCryptoService.IV = key;
        ICryptoTransform encrypto = mobjCryptoService.CreateEncryptor();
        //实例MemoryStream流加密密文件
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);
        cs.Write(bytIn, 0, bytIn.Length);
        cs.FlushFinalBlock();
        return System.Convert.ToBase64String(ms.ToArray());
    }


    //解密:
    public static string Decrypting(string Source)
    {
        try
        {
            //将解密字符串转换成字节数组
            byte[] bytIn = System.Convert.FromBase64String(Source);
            //给出解密的密钥和偏移量,密钥和偏移量必须与加密时的密钥和偏移量相同
            byte[] iv = { 102, 16, 93, 156, 78, 4, 218, 32 };//定义偏移量
            byte[] key = { 55, 103, 246, 79, 36, 99, 167, 3 };//定义密钥
            DESCryptoServiceProvider mobjCryptoService = new DESCryptoServiceProvider();
            mobjCryptoService.Key = iv;
            mobjCryptoService.IV = key;
            //实例流进行解密
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytIn, 0, bytIn.Length);
            ICryptoTransform encrypto = mobjCryptoService.CreateDecryptor();
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Read);
            StreamReader strd = new StreamReader(cs, Encoding.Default);
            return strd.ReadToEnd();
        }
        catch (Exception ex)
        {
            throw new Exception("在文件解密的时候出现错误!错误提示: \n" + ex.Message);
        }
    }

 
}

 

首页实现小技术

公告是用网页对话框来做的。

采用大量自定义控件,两个gridview用于分别呈现视频和音频,用panel来装登录或欢迎,从而实现显示和隐藏


<%@ Register Src="userBulletinInfo.ascx" TagName="userBulletinInfo" TagPrefix="uc5" %>
<%@ Register Src="userSound.ascx" TagName="userSound" TagPrefix="uc6" %>
<%@ Register Src="userVideo.ascx" TagName="userVideo" TagPrefix="uc7" %>
<%@ Register Src="bottomT.ascx" TagName="bottomT" TagPrefix="uc4" %>
<%@ Register Src="search.ascx" TagName="search" TagPrefix="uc3" %>
<%@ Register Src="dh.ascx" TagName="dh" TagPrefix="uc2" %>
<%@ Register Src="entry.ascx" TagName="entry" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>

    <script>
     function openPWD(i)
   {
      window.showModalDialog("bulletinInfo.aspx?ID="+i,"","dialogHeight: 300px; dialogWidth: 480px;dialogTop:px; dialogLeft:px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No");
   }
    
    </script>

    <style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
    <link href="css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
    <form id="form1" runat="server">
        <div>
            &nbsp;</div>
        <table id="__01" width="1002" height="83" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="814" height="83">
                    <uc2:dh ID="Dh1" runat="server" />
                </td>
            </tr>
        </table>
        <table width="802" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td height="33" valign="top" background="images/index_03.jpg" style="width: 746px">
                    <asp:Panel align="center" ID="PanelEntry" runat="server">
                        &nbsp;<uc1:entry ID="Entry1" runat="server" />
                    </asp:Panel>
                    <asp:Panel ID="PanelHello" runat="server">
                        欢迎<asp:Label ID="Label1" runat="server" Text="Label" Width="11px"></asp:Label>登录!<asp:Button
                            ID="Button1" runat="server" OnClick="Button1_Click" Text="退出登录" />&nbsp;<br />
                        &nbsp;
                    </asp:Panel>
                </td>
                <td height="33" valign="top" background="images/index_03.jpg" style="width: 5px">
                    &nbsp;</td>
            </tr>
        </table>
        <br />
        <table width="190" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/index_05.jpg" width="802" height="126"></td>
            </tr>
        </table>
        <table width="190" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <img src="images/index_06.jpg" width="802" height="3"></td>
            </tr>
        </table>
        <table width="802" height="600" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="240" valign="top">
                    <table width="239" cellpadding="0" cellspacing="0" style="height: 5px">
                        <tr>
                            <td>
                                </td>
                        </tr>
                        <tr>
                            <td>
                                <uc5:userBulletinInfo id="UserBulletinInfo1" runat="server">
                                </uc5:userBulletinInfo></td>
                        </tr>
                    </table>
                    <table width="100%" height="4" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                            </td>
                        </tr>
                    </table>
                    <uc6:userSound id="UserSound1" runat="server">
                    </uc6:userSound>
                    <uc7:userVideo id="UserVideo1" runat="server">
                    </uc7:userVideo></td>
                <td valign="top" style="width: 560px">
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td align="right">
                                <table width="239" height="29" align="right" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td style="width: 559px">
                                            <img src="images/sousuolangif.gif" width="557" height="29"></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 559px; height: 77px; text-align: left">
                                            <uc3:search ID="Search1" runat="server" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%" height="4" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                            </td>
                        </tr>
                    </table>
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td align="right">
                                <table width="239" height="29" align="right" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <img src="images/shipin.gif" width="557" height="29"></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <table width="100%" cellpadding="1" cellspacing="1" bgcolor="D4D4D4">
                                                <tr>
                                                    <td bgcolor="#FFFFFF" style="height: 41px; text-align: left;">
                                                        <asp:GridView ID="gvNewVideo" runat="server" AutoGenerateColumns="False" ShowHeader="False"
                                                            Width="549px" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                                                            CellPadding="3" CellSpacing="1" GridLines="None" CssClass="chengse" Height="185px">
                                                            <Columns>
                                                                <asp:TemplateField HeaderText="最新视频">
                                                                    <ItemTemplate>
                                                                        <a target="_blank" href='seeVideo.aspx?VideoID=<%#Eval("VideoID") %>' class="heihei">
                                                                            <%#Eval("VideoName") %>
                                                                        </a>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:BoundField DataField="TypeName" HeaderText="语言类型" />
                                                                <asp:BoundField HeaderText="发布时间" DataField="FBDate" DataFormatString="{0:yy-MM-dd}"
                                                                    HtmlEncode="False" />
                                                            </Columns>
                                                            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                                            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                                            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                                            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                                            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                                        </asp:GridView>
                                                    </td>
                                                </tr>
                                            </table>
                                            <table width="100%" height="5" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td align="right">
                                <table width="239" height="29" align="right" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td style="height: 22px">
                                            <img src="images/yinpin.gif" width="557" height="29"></td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: left">
                                            <asp:GridView ID="gvNewSound" runat="server" AutoGenerateColumns="False" BackColor="White"
                                                BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
                                                GridLines="None" ShowHeader="False" Width="550px" CssClass="chengse">
                                                <Columns>
                                                    <asp:TemplateField>
                                                        <ItemTemplate>
                                                            <a target="_blank" href='playSound.aspx?SoundID=<%#Eval("SoundID") %>' class="heihei">
                                                                <%#Eval("SoundName") %>
                                                            </a>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="TypeName" HeaderText="语言类型" />
                                                    <asp:BoundField DataField="FBDate" HeaderText="发布日期" DataFormatString="{0:yy-MM-dd}"
                                                        HtmlEncode="False" />
                                                </Columns>
                                                <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                                <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                                <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                                <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2" valign="top">
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="height: 84px; text-align: center">
                                <uc4:bottomT ID="BottomT1" runat="server" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <!-- End ImageReady Slices -->
        <map name="Map">
            <area shape="rect" coords="408,39,467,57" href="issuance.aspx">
            <area shape="rect" coords="509,38,571,56" href="typeInfo.aspx">
      用图来做链接,外观上比较漂亮

      <area shape="rect" coords="614,38,674,57" href="typeInfo.aspx">
            <area shape="rect" coords="703,38,766,56" href="login.aspx">
            <area shape="rect" coords="794,38,853,57" href="mailto:tmoonbook@sina.com">
        </map>
    </form>
</body>
</html>

后台代码

 

public partial class _Default : System.Web.UI.Page
{
    dataOperate mydo = new dataOperate();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["UserName"] != null)
        {
            PanelEntry.Visible = false;
            PanelHello.Visible = true;
            this.Label1.Text = Session["UserName"].ToString();
        }
        else
        {
            PanelHello.Visible = false;
            PanelEntry.Visible = true;
        }    
        cretVideo();
        creatSound();
    }

   

    //最新视频
    protected void cretVideo()
    {
        try
        {
            string sql = "SELECT top 10 * from tb_Video as a inner join tb_Type as b on a.VideoType=b.TypeID  ORDER BY VideoID DESC";
            gvNewVideo.DataSource = mydo.rows(sql, "tb_Video").DefaultView;
            gvNewVideo.DataBind();
        }
        catch (Exception error)
        {
            Response.Redirect(error.Message.ToString());

        }
    }
    //最新语音
    protected void creatSound()
    {
        try
        {
            string sql = "select top 10 * from tb_sound as a inner join tb_Type as b on a.SoundType=b.TypeID order by SoundID DESC";
            gvNewSound.DataSource = mydo.rows(sql, "tb_sound").DefaultView;
            gvNewSound.DataBind();

        }
        catch (Exception error)
        {
            Response.Write(error.ToString());
            Response.Write("<script language=javascript>alert('数据库失败!')</script>");
        }
    }
 
  

    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["UserName"] = null;

        PanelHello.Visible = false;
        PanelEntry.Visible = true;
    }
}

代码少因为用户控件解决了好多工作哇,多清晰的流程。

 

注册页面

这里使用了密码加密算法md5
 

   string sql = "select count(*) from tb_login where Name='" + this.txtName.Text.Trim() + "'";

string sql = "insert into tb_login(Name,Pass,ZName,Sex,Email,IDCard,PassQuestion,PassSolution) values('" + name + "','" + pass + "','" + trueName + "','" + sex + "','" + email + "','" + idCard + "','" + passQuestion + "','" + passSolution + "')";

string passSolution = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassSolution.Text, "MD5");

 

 用户登录设计

用户登录后才可以上传下载课件

session是个好东西

 

用户控件实现

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="entry.ascx.cs" Inherits="entry" %>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
<table align="center" cellpadding="0" cellspacing="0" style="height: 3px" width="802">
    <tr>
        <td background="images/index_03.jpg" style="height: 32px" valign="top">
              用户名:<asp:TextBox ID="txtName" runat="server" Width="67px">
            </asp:TextBox>密码:<asp:TextBox ID="txtPass" runat="server" TextMode="Password" Width="66px">
            </asp:TextBox>验证码:<asp:TextBox ID="txtYzm" runat="server" Width="64px"></asp:TextBox>
            <asp:Image ID="Image1" runat="server" Height="19px" Width="51px" />
            <asp:LinkButton ID="lnkbtnRe" runat="server" Font-Size="9pt"
                OnClick="LinkButton2_Click">看不清</asp:LinkButton>
            <asp:ImageButton ID="imgbtnLanding" runat="server" ImageUrl="~/images/denglu.gif"
                OnClick="imgbtnLanding_Click" />
            <asp:LinkButton ID="lnkbtnNew" runat="server" Font-Bold="True"
                Font-Size="10pt" Font-Underline="false" PostBackUrl="~/login.aspx"
                CssClass="baibai" Width="100px">[新用户注册]</asp:LinkButton>
            <asp:LinkButton ID="lnkbtnPass" runat="server" PostBackUrl="~/seekPass.aspx" CssClass="baibai"
                Width="86px">忘记密码</asp:LinkButton></td>
    </tr>
</table>

 

 .baibai:link {
 font-size:12px;
 color:#FFFFCC;
 text-decoration:none;
 line-height: 18px;
}
.baibai:visited {
 font-size:12px;
 color:#FFFFCC;
 text-decoration:none;
 line-height: 18px;
}
.baibai:hover {
 font-size:12px;
 color:#FFFFFF;
 text-decoration:none;
 font-family: "宋体";
 line-height: 18px;
}
.baibai:active {
 font-size:12px;
 color:#FFFFFF;
 text-decoration:none;
 font-family: "宋体";
 line-height: 18px;
}

 

 

public partial class entry : System.Web.UI.UserControl
{
    dataOperate mydo = new dataOperate();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.Image1.ImageUrl = "ValidateCode.aspx";
        }
    }
    //单击登陆先判断验证码正确后判断用户名和密码;


    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        this.Image1.ImageUrl = "ValidateCode.aspx";
    }
  
    protected void imgbtnLanding_Click(object sender, ImageClickEventArgs e)
    {
        string name = txtName.Text;
        string pass = Operate.Encrypting(txtPass.Text);
        string yzm = txtYzm.Text;
        if (Session["CheckCode"].ToString().Equals(yzm))
        {
            try
            {
                string sql = "select count(*) from tb_login where Name='" + name + "' and Pass ='" + pass + "'";
                int i = mydo.isData(sql);
                if (i > 0)
                {
                    sql = "select * from tb_login where Name='" + name + "'";
                    OleDbDataReader odr = mydo.row(sql);
                    odr.Read();

             可以锁用户哇       if (odr["lock"].ToString() == "0")
                    {
                        Session["UserName"] = name;
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        Page.RegisterStartupScript("false", "<script>alert('此用户已被锁定!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('密码或用户名错误!')</script>");
                }

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
            }

        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('验证码错误!')</script>");
        }
    }
}

 

发布并管理教程
重点

dropdownlist绑定数据源,类别,娃娃

 protected void bindLanguage()
    {
        string sql = "select * from tb_Type  ";
        this.ddlLanguage.DataSource = mydo.rows(sql, "tb_Type").DefaultView;
        this.ddlLanguage.DataBind();
    }

 <asp:DropDownList ID="ddlLanguage" runat="server" DataTextField="TypeName" 显示文本DataValueField="TypeID">本身的值 </asp:DropDownList>前台要干的就是这个

用户可以删除gridview自己发布的不好的课程

//删除已发布的视频教程
    protected void gvFBVideo_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = gvFBVideo.DataKeys[e.RowIndex].Value.ToString();从参数中找到索引然后再找关键key的值
        string vsql = "delete from tb_Video where VideoID= " + id;
        bool delVideo = mydo.adlData(vsql);
        if (delVideo)如果成功删除该课程,就把它的留言也删除掉,娃娃
        {
            string ssql = "delete from tb_Speak where TutorialType='Video' and TutorialID=" + id;
            mydo.adlData(ssql);
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('删除失败!')</script>");
        }
        Yvidoe();重新绑定
       
    }

 

页面技术

用三个pannel实现发布教程、已发布的视频、已发布的音频的容器,可以显示和隐藏

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="issuance.aspx.cs" Inherits="issuance" %>

<%@ Register Src="userBulletinInfo.ascx" TagName="userBulletinInfo" TagPrefix="uc3" %>
<%@ Register Src="userSound.ascx" TagName="userSound" TagPrefix="uc4" %>
<%@ Register Src="userVideo.ascx" TagName="userVideo" TagPrefix="uc5" %>
<%@ Register Src="bottomT.ascx" TagName="bottomT" TagPrefix="uc6" %>
<%@ Register Src="entry.ascx" TagName="entry" TagPrefix="uc2" %>
<%@ Register Src="dh.ascx" TagName="dh" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style>
    <link href="css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
    <form id="form1" runat="server">
        <div style="text-align: center">
            <uc1:dh ID="Dh1" runat="server" />
            <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 711px;
                height: 499px">
                <tr>
                    <td rowspan="1" valign="top" style="text-align: left">
                        <uc3:userBulletinInfo ID="UserBulletinInfo1" runat="server" />
                        <uc5:userVideo ID="UserVideo1" runat="server" />
                        <uc4:userSound ID="UserSound1" runat="server" />
                    </td>
                    <td colspan="3" rowspan="3" valign="top" align="center" style="text-align: left">
                        <table cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td style="height: 27px; text-align: center" valign="top">
                                    <img src="images/pangbian.gif" width="558" height="29">
                                </td>
                            </tr>
                            <tr>
                                <td style="text-align: center; height: 27px;" valign="top">
                                    <table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" height="22"
                                        width="428">
                                        <tr>
                                            <td style="height: 22px">
       三个按钮控制展示哪个面板                                         <asp:ImageButton ID="imgbtnIssuance" runat="server" ImageUrl="images/fabuanniu_01.jpg"
                                                    OnClick="imgbtnIssuance_Click" CausesValidation="False" />
                                                <td style="height: 22px">
                                                    <asp:ImageButton ID="imgbtnYFVideo" runat="server" ImageUrl="images/fabuanniu_02.jpg"
                                                        OnClick="imgbtnYFVideo_Click" CausesValidation="False" />
                                                </td>
                                                <td style="height: 22px">
                                                    <asp:ImageButton ID="imgbtnYFSound" runat="server" ImageUrl="images/fabuanniu_03.jpg"
                                                        OnClick="imgbtnYFSound_Click" CausesValidation="False" />
                                                </td>
                                                <td style="height: 22px">
                                                    <asp:ImageButton ID="imgbtnExit" runat="server" ImageUrl="images/fabuanniu_04.gif"
                                                        OnClick="imgbtnExit_Click" CausesValidation="False" />
                                                </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td bgcolor="#FFFFFF" style="height: 27px; text-align: center" valign="top">
                                    <table width="516" align="center" cellpadding="0" cellspacing="0" background="images/dline.gif">
                                        <tr>
                                            <td height="1" class="shenlancu" style="text-align: center">
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <span style="font-size: 16pt; color: #ff00ff"><strong><span style="color: #6633cc"></span>
                        </strong></span>
                        <asp:Panel ID="PanelFB" runat="server" Height="50px" Width="500px">
                            <img height="29" src="images/fbjc.gif" style="width: 417px" />
                            <table id="TABLE1" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td align="right" style="width: 86px; height: 24px;">
                                        教程名称:</td>
                                    <td style="width: 155px; height: 24px;">
                                        <asp:TextBox ID="txtName" runat="server"></asp:TextBox></td>
                                    <td style="width: 100px; height: 24px;">
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写"
                                            ControlToValidate="txtName"></asp:RequiredFieldValidator></td>
                                </tr>
                                <tr style="color: #000000">
                                    <td align="right" style="width: 86px; height: 1px;" valign="top">
                                        教程类型:</td>
                                    <td style="width: 155px; height: 1px; text-align: left;" valign="top">
                                        <table border="0" cellpadding="0" cellspacing="0" style="width: 179px">
                                            <tr>
                                                <td style="width: 63px; height: 20px;">
                                                    <asp:RadioButton ID="rdibtnVideo" runat="server" GroupName="Type" Text="视频" Checked="True" /></td>
                                                <td style="width: 100px; height: 20px;">
                                                    <asp:RadioButton ID="rdibtnSound" runat="server" GroupName="Type" Text="语音" /></td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 100px; height: 1px;">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="width: 86px; height: 22px">
                                        课程类型:</td>
                                    <td style="width: 155px; height: 22px">
                                        <asp:DropDownList ID="ddlLanguage" runat="server" DataTextField="TypeName" DataValueField="TypeID">
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 100px; height: 22px">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="width: 86px" valign="top">
                                        内容简介:</td>
                                    <td style="width: 155px">
                                        <asp:TextBox ID="txtContent" runat="server" Height="140px" Width="142px" TextMode="MultiLine"></asp:TextBox></td>
                                    <td style="width: 100px">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right" style="width: 86px; height: 20px;">
                                        上传教程:</td>
                                    <td style="width: 155px; height: 20px;">
                                        <asp:FileUpload ID="FileUpload1" runat="server" /></td>
                                    <td style="width: 100px; height: 20px;">
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3" rowspan="3" style="text-align: center; height: 24px;">
                                        <asp:Button ID="btnFB" runat="server" Text="发布" Width="65px" OnClick="btnFB_Click" />
                                    </td>
                                </tr>
                                <tr>
                                </tr>
                                <tr>
                                </tr>
                            </table>
                            <strong></strong>
                        </asp:Panel>
                        <asp:Panel CssClass="chengse" ID="PanelYvideo" runat="server" >
                            <span>
                                <br />
                                <asp:GridView ID="gvFBVideo" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvFBVideo_RowDataBound"
                                    OnRowDeleting="gvFBVideo_RowDeleting" Width="409px">
                                    <Columns>
                                        <asp:BoundField HeaderText="编号" />
                                        <asp:BoundField DataField="VideoName" HeaderText="视频名称" />
                                        <asp:BoundField DataField="TypeName" HeaderText="语言类型" />
                                        <asp:BoundField HeaderText="发布日期" DataField="FBDate" DataFormatString="{0:yy-MM-dd}"
                                            HtmlEncode="False" />
                                        <asp:HyperLinkField DataNavigateUrlFields="VideoID" DataNavigateUrlFormatString="seeVideo.aspx?VideoID={0}"
                                            HeaderText="查看留言" NavigateUrl="~/seeVideo.aspx" Target="_blank" Text="查看" />
                                        <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
                                    </Columns>
                                    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                    <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                    <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                </asp:GridView>
                                &nbsp;&nbsp; </span>
                        </asp:Panel>
                        <asp:Panel CssClass="chengse" ID="PanelYsound" runat="server" >
                            <strong>
                                <br />
                                <asp:GridView ID="gvFBSound" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvFBSound_RowDataBound"
                                    OnRowDeleting="gvFBSound_RowDeleting" Width="495px">
                                    <Columns>
                                        <asp:BoundField HeaderText="编号" />
                                        <asp:BoundField DataField="SoundName" HeaderText="语音名称" />
                                        <asp:BoundField DataField="TypeName" HeaderText="语言类型" />
                                        <asp:BoundField DataField="FBDate" DataFormatString="{0:yy-MM-dd}" HeaderText="发布日期"
                                            HtmlEncode="False" />
                                        <asp:HyperLinkField DataNavigateUrlFields="SoundID" DataNavigateUrlFormatString="playSound.aspx?SoundID={0}"
                                            HeaderText="查看留言" Target="_blank" Text="查看">
                                            <ControlStyle Font-Underline="False" />
                                        </asp:HyperLinkField>
                                        <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
                                    </Columns>
                                    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                                    <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                                    <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                                </asp:GridView>
                            </strong>
                        </asp:Panel>
                    </td>
                </tr>
                <tr>
                    <td style="width: 76px;" valign="top" rowspan="2">
                    </td>
                </tr>
                <tr>
                </tr>
                <tr>
                    <td style="height: 31px; text-align: center;" colspan="4">
                        <uc6:bottomT ID="BottomT1" runat="server" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

 

public partial class issuance : System.Web.UI.Page
{
    dataOperate mydo = new dataOperate();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PanelFB.Visible = false;
            PanelYvideo.Visible = false;
            if (Session["UserName"] == null)
            {
                RegisterStartupScript("null", "<script>alert('请先登录!');location='index.aspx'</script>");
            }
            else
            {                             
                PanelFB.Visible = true;
                Ysound();           //通过自定义方法绑定已发布的语音
        Yvidoe();           //通过自定义方法绑定已发布的视频
            }
            PanelYsound.Visible = false;
        }
       
        bindLanguage();     //通过自定义方法绑定语言类型
    }


   
 
 

 

    //已发布视频
    protected void Yvidoe()
    {
        string sql = "select * from tb_Video as a inner join tb_Type as b on a.VideoType=b.TypeID where a.Name='" + Session["UserName"].ToString() + "' order by VideoID desc";
        this.gvFBVideo.DataSource = mydo.rows(sql, "tb_Video");
        this.gvFBVideo.DataKeyNames = new string[] { "VideoID" };
        this.gvFBVideo.DataBind();

    }
    //已发布语音
    protected void Ysound()
    {
        string sql = "select * from tb_Sound as a inner join tb_Type as b on a.SoundType=b.TypeID where a.Name='" + Session["UserName"].ToString() + "'";
        this.gvFBSound.DataSource = mydo.rows(sql, "tb_Sound");
        this.gvFBSound.DataKeyNames = new string[] { "SoundID" };
        this.gvFBSound.DataBind();
    }

  
 

 
 
    //给已发布的视频添加自动编号
    protected void gvFBVideo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = id.ToString();
        }
    }
    //给已发布的语音 添加自动编号

    protected void gvFBSound_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = id.ToString();
        }
    }
    //删除已发布的视频教程

    protected void gvFBVideo_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = gvFBVideo.DataKeys[e.RowIndex].Value.ToString();
        string vsql = "delete from tb_Video where VideoID= " + id;
        bool delVideo = mydo.adlData(vsql);
        if (delVideo)
        {
            string ssql = "delete from tb_Speak where TutorialType='Video' and TutorialID=" + id;
            mydo.adlData(ssql);
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('删除失败!')</script>");
        }
        Yvidoe();
       
    }
    //删除已发布语音教程
    protected void gvFBSound_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = gvFBSound.DataKeys[e.RowIndex].Value.ToString();
        string vsql = "delete from tb_Sound where SoundID= " + id;
        bool delSound = mydo.adlData(vsql);
        if (delSound)
        {
            string ssql = "delete from tb_Speak where TutorialType='Sound' and TutorialID=" + id;
            mydo.adlData(ssql);
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('删除失败!')</script>");
        }
        Ysound();
    }

    //绑定语言类型
    protected void bindLanguage()
    {
        string sql = "select * from tb_Type  ";
        this.ddlLanguage.DataSource = mydo.rows(sql, "tb_Type").DefaultView;
        this.ddlLanguage.DataBind();
    }
        
   
       
  
       
   
       
  
    //发布教程!!
    protected void btnFB_Click(object sender, EventArgs e)
    {
        string vsname = txtName.Text;                       //获取教程名称
        string isVS;
        if (rdibtnSound.Checked)                           //获取教程类型
        {
            isVS = "tb_Sound";
        }
        else
        {
            isVS = "tb_Video";
        }
        string typ = this.ddlLanguage.SelectedValue;        //获取语言类型
        string content = txtContent.Text;                   //获取内容简介
        string name = Session["UserName"].ToString();       //获取用户登录名
        int clicksum = 0;                                   //初始化点击率  
        string Path = "";
        try
        {
            string sql = "";
            if (isVS == "tb_Sound")                        //判断教程是否是语音类型
            {
                //判断用户上传的文件类型
                if (FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1) == "mp3")
                {
                    //判断用户上传的语音教程是否存在
                    if (!File.Exists(Server.MapPath(".") + "\\Sound\\" + this.FileUpload1.FileName))
                    {
                        sql = "insert into tb_Sound(SoundType,SoundName,SoundUrl,ClickSum,SoundContent,Name) values('" + typ + "','" + vsname + "','" + this.FileUpload1.FileName + "','" + clicksum + "','" + content + "','" + name + "')";
                        //设置路径用于保存上传的语音
                        Path = Server.MapPath("./") + "Sound" + "\\" + this.FileUpload1.FileName;
                        if (mydo.adlData(sql))
                        {
                            //将文件保存到指定位置
                            FileUpload1.PostedFile.SaveAs(Path);
                            Page.RegisterStartupScript("true", "<script>alert('上传成功!')</script>");
    txtName.Text="";
    txtContent.Text="";
                        }
                        else
                        {
                            Page.RegisterStartupScript("true", "<script>alert('上传失败!')</script>");
                        }
                    }
                    else
                        Page.RegisterStartupScript("false", "<script>alert('教程名称已经存在!')</script>");
                }
                else
                    RegisterStartupScript("false", "<script>alert('只能上传mp3类型!')</script>");
            }
            else
            {
                //判断用户上传的文件类型
                if (FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1) == "wmv")
                {
                    //判断用户上传的视频教程是否存在
                    if (!File.Exists(Server.MapPath(".") + "\\Video\\" + this.FileUpload1.FileName))
                    {
                        sql = "insert into tb_Video(VideoType,VideoName,VideoUrl,ClickSum,VideoContent,Name) values(" + typ + ",'" + vsname + "','" + this.FileUpload1.FileName + "'," + clicksum + ",'" + content + "','" + name + "')";
                        //设置路径用于保存上传的视频
                        Path = Server.MapPath("./") + "Video" + "\\" + this.FileUpload1.FileName;
                        if (mydo.adlData(sql))
                        {
                            FileUpload1.PostedFile.SaveAs(Path);
                            Page.RegisterStartupScript("true", "<script>alert('上传成功!')</script>");
    txtName.Text="";
    txtContent.Text="";
                        }
                        else
                        {
                            Page.RegisterStartupScript("true", "<script>alert('上传失败!')</script>");
                        }
                    }
                    else
                    {
                        Page.RegisterStartupScript("false", "<script>alert('教程名称已经存在!')</script>");
                    }
                }
                else
                    RegisterStartupScript("false", "<script>alert('只能上传wmv类型!')</script>");
            }
        }
        catch (Exception ex)
        {
            Page.RegisterStartupScript("false", "<script>alert('上传教程不能为空!')</script>");
   开始隐藏些东西了,娃娃     }
    }
    //发布教程按钮
    protected void imgbtnIssuance_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["UserName"] != null)
        {
            PanelFB.Visible = true;
            PanelYvideo.Visible = false;
            PanelYsound.Visible = false;
        }
    }
    //已发布视频按钮
    protected void imgbtnYFVideo_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["UserName"] != null)
        {
            Yvidoe();
            PanelFB.Visible = false;
            PanelYvideo.Visible = true;

            PanelYsound.Visible = false;
        }
    }
    //  已发布语音按钮
    protected void imgbtnYFSound_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["UserName"] != null)
        {
            Ysound();
            PanelFB.Visible = false;
            PanelYvideo.Visible = false;

            PanelYsound.Visible = true;
        }
    }
    //  退出按钮
    protected void imgbtnExit_Click(object sender, ImageClickEventArgs e)
    {
        Session["UserName"] = null;
        Response.Redirect("index.aspx");
    }
}

 

web.config设置文件大小 

<httpRuntime maxRequestLength="40960" executionTimeout="6000"/>

n查看视频教程页,可查看视频教程的发布日期,发布人,点击率,内容简介,下方有可留言

播放技术html<embed>

<asp:DataList ID="dlSpeak" runat="server" >
                                    <ItemTemplate>
                                        <table border="1" cellpadding="0" cellspacing="0" backcolor="Brown">
                                            <tr bgcolor="#B0A299" class="hongcu">
                                                <td >
                                                    <span style="font-size: 12pt">发言人:</span></td>
                                                <td >
                                                    <asp:Label ID="Label3" runat="server" Text='<%#Eval("Spokesman") %>'></asp:Label></td>
                                            </tr>
                                            <tr bgcolor="#FBF5EC" class="chengse">
                                                <td valign="top" >
                                                    <span style="font-size: 12pt">发言内容:</span></td>
                                                <td >
                                                    <asp:TextBox ID="TextBox3" runat="server" Font-Size="12pt" Height="95px" ReadOnly="True"
                                                        TextMode="MultiLine" Width="351px" Text='<%#Eval("SpeakContent") %>'></asp:TextBox></td>
                                            </tr>
                                            <tr bgcolor="#FBF5EC" class="chengse">
                                                <td >
                                                </td>
                                                <td  >
                                                   
                                                    <table border="0" cellpadding="0" cellspacing="0" >
                                                        <tr>
                                                            <td >
                                                                <span style="font-size: 12pt">
                                                                发言时间:</span></td>
                                                            <td >
                                                          
                                                               <asp:Label ID="Label2" runat="server" Text='<%#Eval("SpeakDate") %>' Width="258px"></asp:Label></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </ItemTemplate>
                                </asp:DataList>


 网页里的全局变量哇塞<embed src="<%=VUrl%>" noerror="true" style="width: 579px; height: 321px"></embed>

 

 

public partial class seeVideo : System.Web.UI.Page
{
    public string VUrl;                     //存储视频路径   
    public string VideoTitle;               //存储视频名称  
    public string Content;                 //存储视频内容简介
    public string Name;                    //存储发布人
    public string FBDate;                  //存储发布时间
    public string ClickSum;                //存储点击率
    dataOperate mydo = new dataOperate();  //创建数据库操作类对象
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.Image1.ImageUrl = "ValidateCode.aspx";
            addClickSum();
            seekSpeak();
        }
        seeVi();
    }
    //添加点击率
    public void addClickSum()
    {
        try
        {
            string sql = "update tb_Video set [ClickSum]=[ClickSum]+1 where [VideoID]=" + Request.QueryString["VideoID"].ToString();
            mydo.updateData(sql);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }
    //观看视频
    protected void seeVi()
    {
        try
        {
            string sql = "select * from tb_Video where VideoID=" + Convert.ToInt32(Request.QueryString["VideoID"]);
            OleDbDataReader odr = mydo.row(sql);//调用数据库操作类中的row方法         
            odr.Read();          //前进一条记录
            VUrl = "Video" + "\\" + odr["VideoUrl"].ToString();   //存储视频教程的路径
            if (!File.Exists(Server.MapPath(".") + "\\" + VUrl))//判断此教程是否存在
            {
                string dlsql = "delete from tb_Video where VideoID=" + Convert.ToInt32(Request.QueryString["VideoID"]);
                mydo.adlData(dlsql);
                Page.RegisterStartupScript("true", "<script>alert('文件不存在!请返回!');location='index.aspx'</script>");
            }
            VideoTitle = odr["VideoName"].ToString();
            Content = odr["VideoContent"].ToString();
            Name = odr["Name"].ToString();
            FBDate = odr["FBDate"].ToString();
            ClickSum = odr["ClickSum"].ToString();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }
    //查看留言
    protected void seekSpeak()
    {
        int noncePage = Convert.ToInt32(this.labPage.Text);                      //存储当前页
        PagedDataSource ps = new PagedDataSource();                              //生成PagedDataSource的实例        string selectSql = "select * from tb_Speak  where [TutorialID]=" + Request.QueryString["VideoID"] + " and [TutorialType]='Video' ORDER BY SpeakID DESC ";
        ps.DataSource = mydo.rows(selectSql, "tb_Speak").DefaultView;           //获取数据源
        ps.AllowPaging = true;                                                  //启用分页
        ps.PageSize = 15;                                                       //当前页显示15条记录                                   
        ps.CurrentPageIndex = noncePage - 1;                                    //设置当前页的索引
        this.lnkbtnFront.Enabled = true;      
        this.lnkbtnNext.Enabled = true;
        this.lnkbtnLast.Enabled = true;
        this.lnkbtnFirst.Enabled = true;

        if (noncePage == 1) //等于第一页
        {
            this.lnkbtnFirst.Enabled = false;//不显示第一页按钮
            this.lnkbtnFront.Enabled = false;//不显示上一页按钮
        }
        if (noncePage == ps.PageCount) //等于最后一页
        {
            this.lnkbtnNext.Enabled = false;//不显示下一页
            this.lnkbtnLast.Enabled = false;//不显示最后一页
        }
        this.labBackPage.Text = Convert.ToString(ps.PageCount);                 //显示总页数
        this.dlSpeak.DataSource = ps;
        dlSpeak.DataKeyField = "SpeakID";                                       //设置数据源的关键字段
        dlSpeak.DataBind();
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {

        this.Image1.ImageUrl = "ValidateCode.aspx";

    }

 
    protected void lnkbtnFirst_Click(object sender, EventArgs e)//首页
    {
        this.labPage.Text = "1";        //设置当前页为1
        this.seekSpeak();
    }
    protected void lnkbtnFront_Click(object sender, EventArgs e)//上一页
    {
        this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) - 1); //设置当前页减1
        this.seekSpeak();
    }
    protected void lnkbtnNext_Click(object sender, EventArgs e) //下一页
    {
        this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) + 1);  //设置当前页加1
        this.seekSpeak();
    }
    protected void lnkbtnLast_Click(object sender, EventArgs e) //尾页
    {
        this.labPage.Text = this.labBackPage.Text;          //设置当前页为最后一页
        this.seekSpeak();
    }

    protected void btnDown_Click(object sender, EventArgs e)
    {
        if (Session["UserName"] != null)
        {
            string path = Server.MapPath(".\\") + VUrl;
            //初始化 FileInfo 类的实例,它作为文件路径的包装
            FileInfo fi = new FileInfo(path);
            Response.Write(path);
            //   判断文件是否存在
            if (fi.Exists)
            {
                // 将文件保存到本机上
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
                Response.AddHeader("Content-Length", fi.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.Filter.Close();
                Response.WriteFile(fi.FullName);
                Response.End();
            }
 }
            else
            {
                RegisterStartupScript("null", "<script>alert('您还未登录不能下载')</script>");
            }
       
    }
    protected void btnSpeak_Click(object sender, EventArgs e)
    {
        string spokesman;
        if (Session["UserName"] != null)                                              //判断用户是否登录如登录发言人存储登录名为登录存储为游客
        {
            spokesman = Session["UserName"].ToString();
        }
        else
        {
            spokesman = "游客";
        }
        string speakContent = this.txtContent.Text;                                   //存储用户发言内容          
        string tutorialType = "Video";                                                //教程类型
        string tutorialID = Request.QueryString["VideoID"];                           //视频编号
        string insertSql = "insert into tb_Speak([Spokesman],[TutorialType],[TutorialID],[SpeakContent]) values('" + spokesman + "','" + tutorialType + "'," + tutorialID + ",'" + speakContent + "')";
        if (Session["CheckCode"].ToString().Equals(this.txtYzm.Text.ToString()))     //判断验证码是否正确
        {
            bool bo = mydo.adlData(insertSql);
            if (bo)
            {
                seekSpeak();                                                        //从新绑定留言信息
                Page.RegisterStartupScript("true", "<script>alert('发言成功!');</script>");
            }
            else
            {
                Page.RegisterStartupScript("false", "<script>alert('发言失败!')</script>");
            }
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('验证码错误')</script>");
        }
    }
 
}

 

用户管理页面

注册用户的锁定和删除

图片替换

 

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None" OnRowDeleting="GridView1_RowDeleting" CssClass="chengse">
            <Columns>
                <asp:BoundField DataField="Name" HeaderText="用户名" />
                <asp:TemplateField HeaderText="状态">
                    <ItemTemplate>
                        <asp:Image ID="Image1" ImageUrl='<%#ImgUrl(Convert.ToString(Eval("ID")))%>' runat="server" />不仅绑定还调用函数哇

                    </ItemTemplate>
                </asp:TemplateField>             
                <asp:BoundField DataField="LoginDate" HeaderText="注册时间" />
                <asp:TemplateField HeaderText="操作">
                    <ItemTemplate>
                    <a href="change.aspx?id=<%# Convert.ToString(Eval("ID"))%>"><%#BtnText(Convert.ToString(Eval("ID")))%></a>文本
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField HeaderText="删除" ShowDeleteButton="True">
                    <ControlStyle Font-Underline="False" />
                </asp:CommandField>
            </Columns>
            <EmptyDataTemplate>
              
            </EmptyDataTemplate>
            <PagerTemplate>
               
            </PagerTemplate>
            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />           
        </asp:GridView>

后台

 

public partial class Manage_manage_user : System.Web.UI.Page
{
    dataOperate mydo = new dataOperate();
    protected void Page_Load(object sender, EventArgs e)
    {
        createUser();
    }

    protected void createUser()
    {
        string sql = "select * from tb_login";
        this.GridView1.DataSource = mydo.rows(sql, "tb_login").DefaultView;
        this.GridView1.DataKeyNames = new string[] { "ID" };       
        this.GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string sql = "delete from tb_login where ID=" + GridView1.DataKeys[e.RowIndex].Value.ToString();
        if (mydo.adlData(sql))
        {
            Page.RegisterStartupScript("true", "<script>alert('删除成功!')</script>");
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('删除失败!')</script>");
        }
        createUser();
    } 
   //绑定图标
    public string ImgUrl(string id)
    {
        string sql = "select Lock from tb_login where ID=" +id;
        OleDbDataReader odr = mydo.row(sql);        //调用数据库操作类的Row方法查找用户的详细信息
        odr.Read();

        int i =Convert.ToInt32(odr["Lock"]);        //判断用户是否被锁定
        if (i == 0)
        {
            return "../images/kaisuo.gif";                //返回未锁定的图标
        }
        else
        {
            return "../images/suo.gif";            //返回锁定的图标
        }
       
    }
    //绑定操作
    public string BtnText(string id)
    {
        string sql = "select Lock from tb_login where ID=" +id;
        OleDbDataReader odr = mydo.row(sql);         //调用数据库操作类的Row方法查找用户的详细信息
        odr.Read();
        int i = Convert.ToInt32(odr["Lock"]);       //判断用户是否被锁定
        if (i == 0)
        {
            return "锁定";                          //返回锁定
        }
        else
        {
            return "解锁";                          //返回解锁
        }
      
    }


   
}

视频管理页面


  <table border="0" cellpadding="0" cellspacing="0" style="width: 444px; height: 372px">
            <tr>
                <td style="width: 100px; text-align: center">
                    <span style="font-size: 16pt; color: #006633"></span></td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: left" valign="top">


                    <asp:GridView ID="grvVideo" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        Height="305px" OnPageIndexChanging="grvVideo_PageIndexChanging" OnRowDeleting="grvVideo_RowDeleting"
                        PageSize="5" Width="419px" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None" CssClass="chengse">
                        <Columns>
                            <asp:HyperLinkField DataNavigateUrlFields="VideoID" DataNavigateUrlFormatString="manage_seeVideo.aspx?VideoID={0}"
                                DataTextField="VideoName" HeaderText="视频名称" Target="rightFrame">
                                <ControlStyle Font-Underline="False" />
                            </asp:HyperLinkField>
                            <asp:BoundField DataField="FBDate" HeaderText="发布日期" />
                            <asp:HyperLinkField Target="rightFrame" HeaderText="管理留言" Text="管理" DataNavigateUrlFields="VideoID" DataNavigateUrlFormatString="manage_videoSpeak.aspx?VideoID={0}" >
                                <ControlStyle Font-Underline="False" />
                            </asp:HyperLinkField>
                            <asp:CommandField HeaderText="删除" ShowDeleteButton="True">
                                <ControlStyle Font-Underline="False" />
                            </asp:CommandField>
                        </Columns>
                        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                    </asp:GridView>
                </td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                </td>
            </tr>
        </table>

 

public partial class Manage_manage_video : System.Web.UI.Page
{
    dataOperate mydo = new dataOperate();
    protected void Page_Load(object sender, EventArgs e)
    {
        createVideo();
    }

    protected void createVideo()
    {
       
        string sql = "select * from tb_Video order by VideoID DESC";
        grvVideo.DataSource = mydo.rows(sql, "tb_Video");
        grvVideo.DataKeyNames = new string[] { "VideoID" };
        grvVideo.DataBind();

    }

    protected void grvVideo_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvVideo.PageIndex = e.NewPageIndex;
        grvVideo.DataBind();
    }
   

protected void grvVideo_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string vsql = "delete from tb_Video where VideoID=" + grvVideo.DataKeys[e.RowIndex].Value.ToString();
        bool delVideo=mydo.adlData(vsql);  下面还要删相关留言
        
        if (delVideo)
        { 
     string ssql = "delete from tb_Speak where TutorialType='Video' and TutorialID=" + grvVideo.DataKeys[e.RowIndex].Value.ToString();
            mydo.adlData(ssql);
            Page.RegisterStartupScript("true", "<script>alert('删除成功!')</script>");
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('删除失败!')</script>");
        }
        createVideo();
    }
}


 

 

 

posted @ 2009-04-15 22:13  minmin8110  阅读(819)  评论(0)    收藏  举报