好友
阅读权限30
听众
最后登录1970-1-1
|
夏沫梦影
发表于 2019-12-31 22:06
本帖最后由 夏沫梦影 于 2019-12-31 22:07 编辑
项目要求:
使用开发工具Microsoft Visual Studio 2012以上,数据库Microsoft SQL Server 2012以上,服务器IIS,在Windows 平台上开发基于B/S模式的高校教育实习管理系统。
1、 系统的用户角色分为:学生用户、指导老师、实习企业、管理员
2、 学生用户:
(1) 实习信息录入:
(2) 学生个人基本信息 (姓名、班级、学号、联系电话、实习单位、实习地址)
(3) 实习单位基本信息 (公司名称、地点、简介、公司联络人、联系电话)
(4) 实习信息变更
(5) 学生实习成果资料上传区 (实习周记、实习总结报告)
(6) 实习相关文档资料下载区(实习周记、实习鉴定表、实习总结、满意度调查表等)
3、 实习企业:
(1)学生信息查看
(2)实习信息交流
(3)实习成绩评定
4、 指导教师:
(1)学生信息查看
(2)企业信息查看
(3)实习信息交流
(4)学生实习周记查看与评分
(5)实习成绩评定
5、 管理员:
(1)基本信息管理(学生信息、实习企业信息、指导教师信息)
(2)公告管理
(3)实习相关文档资料上传
(4)实习周记、总结报告管理
(5)评价管理
(6)数据管理
(7)系统组件更新 |
原型设计:
原型设计文件因为硬盘损坏已丢失,只剩图片了,凑合看吧...
使用Balsamiq_Mockups_3绘画
logo
主页
管理员
企业
学生
数据库设计:
管理员
企业
学生
指导老师
成果
文件
公告
企业信息
关系模型
成品:
演示效果
|
公共类:
Alert.cs
[Visual Basic .NET] 纯文本查看 复制代码 using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// Alert 的摘要说明
/// </summary>
public class Alert
{
public Alert()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void Alertjs(string AlertStr)
{
string Alert = "";
Alert = "<script language='javascript'>alert('" + AlertStr + "')</script>";
HttpContext.Current.Response.Write(Alert);
}
/// <summary>
/// 弹出提示并跳转
/// </summary>
/// <param name="Message">提示信息</param>
/// <param name="RedirectUrl">跳转Url</param>
public static void AlertAndRedirect(string Message, string RedirectUrl)
{
string js = "";
js = "<script language='javascript'>alert('{0}');window.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, Message, RedirectUrl));
} /// <summary>
/// 弹出新页面
/// </summary>
/// <param name="url">页面地址</param>
/// <param name="width">宽度</param>
/// <param name="heigth">高度</param>
/// <param name="top">上边位置</param>
/// <param name="left">左边位置</param>
public static void AlertNewWebForm(string url, int width, int heigth, int top, int left)
{
string js = @"<Script language='JavaScript'>window.open('" + url + @"','','height=" + heigth + ",width=" + width + ",top=" + top + ",left=" + left + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');</Script>";
HttpContext.Current.Response.Write(js);
}
}
stUpLoad.cs
[Visual Basic .NET] 纯文本查看 复制代码 using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// stUpLoad 的摘要说明
/// </summary>
public class stUpLoad
{
public stUpLoad()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string[] Resup ={ "上传失败或指定的文件不存在", "图片大于1000K,重新传图片!", "格式不对,限制上传(只允许gif/jpg格式文件)!", "上传成功!" };
public string s = string.Empty;
public string Up(FileUpload File2, string Pa, string fileName)
{
//
// TODO: 在此处添加构造函数逻辑
//
if (File2.PostedFile.ContentLength.ToString() == "0")
{
return "0";
}
else
{
//获取文件名称
string ss;
ss = fileName;
if (File2.PostedFile.ContentLength / 1024 > 1000)
{ return "1"; }
else
{
File2.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath(Pa) + ss);
s = ss;
return "3";
//Up= ss;
}
}
}
}
upload.cs
[Visual Basic .NET] 纯文本查看 复制代码 using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// upload 的摘要说明
/// </summary>
public class upload
{
public upload()
{
//
// TODO: 在此处添加构造函数逻辑
//
} public string[] Resup ={ "上传失败或指定的文件不存在", "图片大于1000K,重新传图片!", "格式不对,限制上传(只允许gif/jpg格式文件)!", "上传成功!" };
public string s = string.Empty;
public string Up(System.Web.UI.HtmlControls.HtmlInputFile File2, string Pa)
{
//
// TODO: 在此处添加构造函数逻辑
//
if (File2.PostedFile.ContentLength.ToString() == "0")
{
return "0";
}
else
{
//获取文件名称
string ss;
ss = System.DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "").Replace("/","") + Path.GetExtension(File2.PostedFile.FileName);
if (File2.PostedFile.ContentLength / 1024 > 1000)
{ return "1"; }
else
{
File2.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath(Pa) + ss);
s = ss;
return "3";
//Up= ss;
}
}
}
}
SqlHelper.cs
[Visual Basic .NET] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// SqlHelper 的摘要说明
/// </summary>
public class SqlHelper
{
public static readonly string connstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());
private SqlConnection con;
private SqlCommand cmd;
private SqlDataAdapter sda;
private SqlDataReader sdr;
private DataSet ds;
private DataView dv;
public static SqlConnection getConnection()//定义成静态的,很重要!
{
return new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
}
/// <summary>
/// 打开数据库连接
/// </summary>
public void OpenDataBase()
{
con = new SqlConnection(connstring);
con.Open();
}
/// <summary>
/// 关闭数据库连接
/// </summary>
public void CloseDataBase()
{
con.Close();
con.Dispose();
}
/// <summary>
/// 返回DataSet数据集
/// </summary>
/// <param name="SqlStr">数据库查询字符串</param>
/// <returns>dataset</returns>
public DataSet GetDs(string SqlStr, string TableName)
{
OpenDataBase();
sda = new SqlDataAdapter(SqlStr, con);
ds = new DataSet();
sda.Fill(ds, TableName);
CloseDataBase();
return ds;
}
public DataView GetDv(string SqlStr)
{
OpenDataBase();
sda = new SqlDataAdapter(SqlStr, con);
ds = new DataSet();
sda.Fill(ds);
dv = ds.Tables[0].DefaultView;
CloseDataBase();
return dv;
}
/// <summary>
/// 返回Datareader对象
/// </summary>
/// <param name="Sqlstr">查询字符串</param>
/// <returns>返回值</returns>
public SqlDataReader GetDataReader(string Sqlstr)
{
OpenDataBase();
cmd = new SqlCommand(Sqlstr, con);
sdr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
return sdr;
}
/// <summary>
/// 执行Sql语句方法没有返回值
/// </summary>
/// <param name="SqlStr">传入的查询参数</param>
public void RunSql(string SqlStr)
{
OpenDataBase();
cmd = new SqlCommand(SqlStr, con);
cmd.ExecuteNonQuery();
CloseDataBase();
}
/// <summary>
/// 返回查询结果的首行首列
/// </summary>
/// <param name="SqlStr">查询字符串</param>
/// <returns>返回结果</returns>
public string ReturnSql(string SqlStr)
{
OpenDataBase();
string ReturnSql = "";
try
{
cmd = new SqlCommand(SqlStr, con);
ReturnSql = cmd.ExecuteScalar().ToString();
}
catch { }
CloseDataBase();
return ReturnSql;
}
public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(connectionString))
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
}
public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connectionString);
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return rdr;
}
catch
{
conn.Close();
conn.Dispose();
throw;
}
}
public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection connection = new SqlConnection(connectionString))
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
}
}
public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
}
public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters)
{
parmCache[cacheKey] = commandParameters;
}
public static DataTable GetTable(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(connectionString))
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(dt);
}
return dt;
}
public static SqlParameter[] GetCachedParameters(string cacheKey)
{
SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey];
if (cachedParms == null)
return null;
SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length];
for (int i = 0, j = cachedParms.Length; i < j; i++)
clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone();
return clonedParms;
}
private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
{
if (conn.State != ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandText = cmdText;
if (trans != null)
cmd.Transaction = trans;
cmd.CommandType = cmdType;
if (cmdParms != null)
{
foreach (SqlParameter parm in cmdParms)
cmd.Parameters.Add(parm);
}
}
}
|
主页相关登录按钮:
[Visual Basic .NET] 纯文本查看 复制代码 using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Login : System.Web.UI.Page
{
SqlHelper data = new SqlHelper();
SqlDataReader dr;
Alert js = new Alert();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void btn_login_Click(object sender, EventArgs e)
{
if (username.Text == "" && password.Text == "")
{
Alert.AlertAndRedirect("没有输入账号和密码!", "Login.aspx");
}
else
{
if (level.SelectedValue == "管理员")
{
dr = data.GetDataReader("select * from [Admin] where Admin='" + username.Text + "'and pwd='" + password.Text.Trim() + "'");
if (dr.Read())
{
Session["User"] = dr["Admin"].ToString();
Session["Userid"] = dr["id"].ToString();
Session["Roule"] = "管理员";
Response.Redirect("Admin/Default.aspx");
}
else
{
Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Login.aspx");
}
}
if (level.SelectedValue == "指导老师")
{
dr = data.GetDataReader("select * from [Teachter] where xuexiao='" + username.Text + "'and Pwd='" + password.Text.Trim() + "'");
if (dr.Read())
{
Session["Userid"] = dr["id"].ToString();
Session["User"] = dr["Name"].ToString();
Session["xuexiao"] = dr["xuexiao"].ToString();
Session["Roule"] = "指导老师";
Response.Redirect("Teachter/Default.aspx");
}
else
{
Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Login.aspx");
}
}
if (level.SelectedValue == "学生")
{
dr = data.GetDataReader("select * from [Student] where xuexiao='" + username.Text + "'and Pwd='" + password.Text.Trim() + "'");
if (dr.Read())
{
Session["Userid"] = dr["id"].ToString();
Session["xuexiao"] = dr["xuexiao"].ToString();
Session["User"] = dr["Name"].ToString();
Session["Roule"] = "学生";
Response.Redirect("Default.aspx");
}
else
{
Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Login.aspx");
}
}
if (level.SelectedValue == "企业")
{
dr = data.GetDataReader("select * from [CompanyInfo] where LoginName='" + username.Text + "'and LoingPwd='" + password.Text.Trim() + "'");
if (dr.Read())
{
Session["Userid"] = dr["id"].ToString();
Session["User"] = dr["fuzeren"].ToString();
Session["Roule"] = "企业";
Response.Redirect("Commpany/Default.aspx");
}
else
{
Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Login.aspx");
}
}
}
}
protected void btn_register_Click(object sender, EventArgs e)
{
Response.Redirect("AddAdmin.aspx");
}
} |
web.config配置文件中修改数据库连接字符串方法演示:
|
|
|
免费评分
-
查看全部评分
|