C#计算机实验课在线答疑系统设计
SortExpression="id" />
<asp:HyperLinkField DataNavigateUrlFields="Send_File" DataTextField="Send_FileName" HeaderText="文件名" SortExpression="Send_FileName" >
<ItemStyle HorizontalAlign="Left" />
</asp:HyperLinkField>
<asp:BoundField DataField="Send_UserName" HeaderText="上传者" SortExpression="Send_UserName" />
<asp:BoundField DataField="Send_Time" HeaderText="上传时间" SortExpression="Send_Time" >
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
</asp:GridView>
处理上传文件的函数为SaveBtn_Click(),主要代码为:
protected void SaveBtn_Click(object sender, EventArgs e)
{
String Send_user1 = Send_User.Text;
String TimeNow = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()+"-"+DateTime.Now.Hour.ToString()+":"+DateTime.Now.Minute.ToString()+":"+DateTime.Now.Second.ToString(); //获得时间
MyUpload MyUpload = new MyUpload();
string Pic1 = "File/"; //保存路径
MyUpload.Path = "File";
MyUpload.Sizes = 2048; //文件大小
MyUpload.FileType = "jpg|gif|bmp|JPG|GIF|BMP|doc|DOC|txt|TXT|xls|XLS|FLV|flv|SWF|swf"; //文件类型
string[] a = MyUpload.PostedFile.FileName.Split('\\'); //分离出文件名
string b = a[a.Length - 1];
FileTitle1 = b;
MyUpload.PostedFile = FileUpload1.PostedFile;
String Pic2 = MyUpload.Upload();
if (Pic2 == null)
{ Page.RegisterStartupScript("", "<script>alert('上传失败!')</script>");
Response.AddHeader("Refresh", "0.0001");
}
else
{ Pic2 = Pic1 + Pic2;
String Sql = "insert into SendFile(Accept_UserName,Send_UserName,Send_File,Send_Time,Send_FileName) values('" + username + "','" + Send_user1 + "','" + Pic2 + "','" + TimeNow + "','" + FileTitle1 + "')";
if (db.insert(Sql)) //插入数据
Page.RegisterStartupScript("", "<script>alert('上传成功!')</script>");
Accept_User.Text = "";
Send_User.Text = "";
发表疑问模块:
该模块主要页面包括显示疑问列表页面showthread.aspx,某疑问及相应回复列表页面showmessages.aspx,发表新疑问页面editthread.aspx。该模块主要实现疑问的发表和回复。删除功能包含在后台管理页面中。
发表疑问利用一个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();
显示疑问列表采用GetThreads()方法,代码为
private DataSet GetThreads()
{
//创建数据库实例和命令对象
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlDataAdapter myCommand = new SqlDataAdapter("GetThreads", myConnection);
//下面为把命令对象类型设置为数据库已经创建好的存储过程,能把一大段sql语句存储为一个过程,便于调用
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
// 建立并且填充一个dataset数据集
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
// 返回一个dataset数据集
return myDataSet;
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
C#计算机实验课在线答疑系统设计(答辩PPT) 第5页下载如图片无法显示或论文不完整,请联系qq752018766