C#计算机实验课在线答疑系统设计
显示疑问详细内容的方法为AddThread(),代码为
public void AddThread(System.Int32 threadID,System.String author,System.String subject,System.String content,System.Int32 reply,System.Int32 totalView)
{ //创建数据库实例和命令对象
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand myCommand = new SqlCommand("AddThread", myConnection);
//下面为把命令对象类型设置为数据库已经创建好的存储过程,能把一大段sql语句存储为一个过程,便于调用
myCommand.CommandType = CommandType.StoredProcedure;
//向存储过程中传递参数
SqlParameter parameterAuthor = new SqlParameter("@author", SqlDbType.NVarChar,50);
parameterAuthor.Value = author;
myCommand.Parameters.Add(parameterAuthor);
SqlParameter parameterSubject = new SqlParameter("@subject", SqlDbType.NVarChar,50);
parameterSubject.Value = subject;
myCommand.Parameters.Add(parameterSubject);
SqlParameter parameterContent = new SqlParameter("@content", SqlDbType.NText,16);
parameterContent.Value = content;
myCommand.Parameters.Add(parameterContent);
SqlParameter parameterTotalView = new SqlParameter("@totalView", SqlDbType.Int,4);
parameterTotalView.Value = totalView;
myCommand.Parameters.Add(parameterTotalView);
SqlParameter parameterReply = new SqlParameter("@reply", SqlDbType.Int,4);
parameterReply.Value = reply;
myCommand.Parameters.Add(parameterReply);
//打开数据库并执行
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close(); }
知识扩展模块
班级公告模块
4.2.2 后台主要功能模块介绍
在后台管理页面中,包含了母版页adminMasterPage.master,主要是各子功能模块管理的链接按钮,集中管理了后台的显示。
用户管理模块:
该模块的页面为admin.aspx,主要是使用SqlDataSource控件实现应用程序与数据库的链接,gridview数据控件显示、编辑、删除学生数据信息,FormView控件实现数据插入功能。
SqlDataSource控件的代码为:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [UserInfo] WHERE [id] = @id" InsertCommand="INSERT INTO [UserInfo] ([username], [password], [isadmin], [isonline], [lastchatinfo]) VALUES (@username, @password, @isadmin, @isonline, @lastchatinfo)" SelectCommand="SELECT * FROM [UserInfo]" UpdateCommand="UPDATE [UserInfo] SET [username] = @username, [password] = @password, [isadmin] = @isadmin, [isonline] = @isonline, [lastchatinfo] = @lastchatinfo WHERE [id] = @id">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="username" Type="String" />
<asp:Parameter Name="password" Type="String" />
<asp:Parameter Name="isadmin" Type="Boolean" />
<asp:Parameter Name="isonline" Type="Boolean" />
<asp:Parameter Name="lastchatinfo" Type="Int32" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="username" Type="String" />
<asp:Parameter Name="password" Type="String" />
<asp:Parameter Name="isadmin" Type="Boolean" />
<asp:Parameter Name="isonline" Type="Boolean" />
<asp:Parameter Name="lastchatinfo" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
gridview数据控件的设计代码为:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
SortExpression="id" />
<asp:BoundField DataField="username" HeaderText="姓名" SortExpression="username" />
<asp:BoundField DataField="password" HeaderText="密码" SortExpression="password" />
<asp:CheckBoxField DataField="isadmin" HeaderText="isadmin" SortExpression="isadmin" />
<asp:CheckBoxField DataField="isonline" HeaderText="isonline" SortExpression="isonline" />
<asp:BoundField DataField="lastchatinfo" HeaderText="lastchatinfo" SortExpression="lastchatinfo" />
<asp:CommandField ButtonType="Button" HeaderText="操作" ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
FormView控件的插入功能代码为:
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="id"
DataSourceID="SqlDataSource1" DefaultMode="Insert" Width="377px" Height="57px" CellPadding="4" ForeColor="#333333">
<InsertItemTemplate>
<table style="width: 550px; height: 12px">
<tr>
<td style="width: 141px; height: 27px">
姓名:<asp:TextBox ID="usernameTextBox" runat="server" Text='<%# Bind("username") %>' Width="82px"></asp:TextBox></td>
<td style="width: 145px; height: 27px">
密码:<asp:TextBox ID="passwordTextBox" runat="server" Text='<%# Bind("password") %>' Width="88px"></asp:TextBox></td>
<td style="width: 87px; height: 27px">
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
C#计算机实验课在线答疑系统设计(答辩PPT) 第6页下载如图片无法显示或论文不完整,请联系qq752018766