高校学报信息管理系统 源代码
高校学报信息管理系统 源代码
用户登录代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{ string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd;
protected void LoginButton_Click(object sender, EventArgs e)
{
//创建数据库连接
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToS
tring());
//打开数据库
conn.Open();
string username = this.Login1.UserName;
Session["AName"] = username;
string userpwd = this.Login1.Password;
DropDownList d1 = (DropDownList)Login1.FindControl("DropDownList1");
switch (d1.Text)
{
case "管理员":
strSQL = "select AdminID from AdminUser where AdminName='" +
username + "' and AdminPass='" + userpwd + "'";
SqlCommand cmd = new SqlCommand(strSQL, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["AID"] = dr["AdminID"].ToString();
Page.Response.Redirect("~/Manage/Main.aspx");
}
else
{
Response.Write("");
}
break;
case "普通用户":
strSQL = "select Author_ID from Author where Author_Name='" + username + "' and
Author_Pass='" + userpwd + "'";
cmd = new SqlCommand(strSQL, conn);
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.Read())
{
Session["CID"] = dr2["Author_ID"].ToString();
Page.Response.Redirect("~/Customer/Main.aspx");
}
else
{
Response.Write("");
}
break;
case "审稿人":
strSQL = "select Judge_ID from Judge where Judge_Name='" + username + "' and
PassWord='" + userpwd + "'";
cmd = new SqlCommand(strSQL, conn);
SqlDataReader dr3 = cmd.ExecuteReader();
if (dr3.Read())
{
Session["JID"] = dr3["Judge_ID"].ToString();
Page.Response.Redirect("~/Judge/Main.aspx");
}
else
{
Response.Write("");
}
break;
}
conn.Close();
}
}
注册新用户
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Reg : System.Web.UI.Page
{
string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnReg_Click(object sender, EventArgs e)
{
string Ssex;
if (sexRadio1.Checked == true)
Ssex = "男";
else
Ssex = "女";
strSQL = "insert into Author
(Author_ID,Author_Name,Sex,Age,Phone,Address,Email,Author_Pass) Values('";
strSQL += txtNum.Text.ToString() + "','";
strSQL += UserName.Text.ToString() + "','";
strSQL += Ssex+"','";
strSQL += txtAge.Text.ToString() +"','";
.....
//创建数据库连接
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToS
tring());
conn.Open();
cmd = new SqlCommand(strSQL, conn);
try
{
cmd.ExecuteNonQuery(); //执行保存命令
}
catch (Exception err)
{
}
conn.Close();
Session["sName"] = UserName.Text.ToString();
string strSQL1 = "select Author_ID from Author where Author_Name='" +
Session["sName"].ToString() + "'";
cmd = new SqlCommand(strSQL1, conn);
conn.Open();
SqlDataReader dr2 = cmd.ExecuteReader();
if (dr2.Read())
{
Session["CID"] = dr2["Author_ID"].ToString();
}
conn.Close();
Response.Write(Session["CID"].ToString());
Response.Write("");
Server.Transfer("~/account/T01.aspx");
}
}
管理员模块:
稿件信息管理
using UniversityMIS;
public partial class Manage_Draft : System.Web.UI.Page
{
SQLHelper sqlhp = new UniversityMIS.SQLHelper();
protected void btnSearch_Click(object sender, EventArgs e)
{
string strsql = "select * from Draft where ";
string field = this.DropField.SelectedValue;
string DraftName = this.txtSearch.Text.Trim();
if (DraftName != "")
{
if (field.ToString() == "Draft_Name")
{
strsql += "(" + field + " like '%" + DraftName + "%')";
sqlhp.BindGV(GridView1, strsql);
}
else
{
string fiel = "Draft_ID";
int DNum = int.Parse(DraftName);
strsql += "(" + fiel + " like '%" + DNum + "%')";
sqlhp.BindGV(GridView1, strsql);
}
}
else
{
Response.Write("");
}
}
protected void GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
sqlhp.BindGV(GridView1, "select * from Draft");
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs
e)
{
GridView1.EditIndex = -1;
sqlhp.BindGV(GridView1, "select * from Draft");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
this.GridView1.EditRowStyle.BackColor = Color.FromName("#e7ce90");
sqlhp.BindGV(GridView1, "select * from Draft");
}
}
审稿人信息管理
string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd;
SQLHelper sqlhp = new SQLHelper();
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "insert")
{
GridView1.DataSourceID = "";
GridView1.DataBind();
}
}
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
}
protected void DetailsView1_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
{
GridView1.DataSourceID = "SqlDataSource1";
GridView1.DataBind();
}
稿件评审
string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd1;
protected SqlCommand cmd2;
protected SqlCommand cmd3;
SQLHelper sqlhp = new UniversityMIS.SQLHelper();
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//取得索引行
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow=GridView1.Rows[index];
//取得稿件编括号
TableCell D_num=selectedRow.Cells[0];
if (e.CommandName == "btnSave")
{
//获得审稿人
string J_name =
((DropDownList)GridView1.Rows[index].FindControl("DropDownList1")).SelectedItem.Text; string str2=" select Judge_id from Judge where Judge_name="+ "'"+ J_name+"'";
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToS
tring());
conn.Open();
cmd2 = new SqlCommand(str2, conn);
string fiel = null;
try
{
SqlDataReader reader = cmd2.ExecuteReader();
while(reader.Read())
{
fiel = reader[0].ToString();
}
}
catch (Exception err)
{
}
conn.Close();
string strsql = "insert into dbo.T_Draft_Reviewer (Draft_ID,Judge_id) values('";
strsql += D_num.Text + "','" + fiel + "')";
conn.Open();
cmd3 = new SqlCommand(strsql, conn);
try
{
cmd3.ExecuteNonQuery();
Page.Response.Redirect("~/Manage/Dist.aspx");
}
catch (Exception err)
{
}
conn.Close();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id=this.GridView1.DataKeys[e.Row.RowIndex]["Draft_ID"].ToString();
string str2 = " select typename from draft where draft_id=" + "'" + id+ "'";
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToString());
conn.Open();
cmd2 = new SqlCommand(str2, conn);
string fiel = null;
try
{
SqlDataReader reader = cmd2.ExecuteReader();
while (reader.Read())
{
fiel = reader[0].ToString();
}
}
catch (Exception err)
{
Response.Write(err.Message.ToString());
Response.Write("保存失败!");
}
conn.Close();
DropDownList ddl =
(DropDownList)e.Row.Cells[6].FindControl("DropDownList1");
using (SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=UniversityMIS;User ID=sa;Password=123456"))
{
con.Open();
strSQL = "select judge_id,judge_name from judge where typer='"+fiel+"'"; SqlCommand cmd = new SqlCommand(strSQL, con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
adapter.Fill(ds1);
DataTable dt = ds1.Tables[0];
ddl.Items.Clear();
ddl.DataSource = dt;
ddl.DataTextField = "Judge_Name";
ddl.DataValueField = "Judge_id";
ddl.DataBind();
}
}
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
//取得dropdownlist 控件
DropDownList J_name =
(DropDownList)GridView1.Rows[0].Cells[6].FindControl("DropDownList1");
Label ty=(Label)GridView1.Rows[0].Cells[2].FindControl("TypeName");
GridView1.PageIndex = GridView1.SelectedIndex;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) {
GridView1.PageIndex = e.NewPageIndex;
string strsql = "select * from dbo.Draft where Draft_ID not in ( select Draft_ID from dbo.T_Draft_Reviewer )";
sqlhp.BindGV(GridView1, strsql);
}
}
数据库备份
SQLHelper sqlhp = new SQLHelper();
protected void Button1_Click(object sender, EventArgs e)
{
string path = Server.MapPath("~/backup/");
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
string targetUrl = path+txtFileName.Text.Trim()
+DateTime.Now.Hour.ToString("yyyyMMddHHmmss") + ".bak";
string sql = "backup database UniversityMIS to disk='" +targetUrl +"'";
try
{
sqlhp.ExecuteSQL(sql);
Response.Write(""); }
catch (SqlException err)
{
throw new System.Exception(err.Message);
}
}
}
出版日期查询
public string strsql = " ";
public int bindType;
SQLHelper sqlhp = new SQLHelper();
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
GridView1.PageIndex = e.NewSelectedIndex;
sqlhp.BindGV(GridView1, "select * from Draft");
}
void Bind(string str, int bindType)
{
string str1 = "select * from Draft ";
string str2 = "select * from Draft ";
switch (bindType)
{
case 1:
str = str1 + str;
Panel1.Visible = true;
Panel2.Visible = false;
sqlhp.BindGV(GridView1, str);
break;
case 2:
str = str2 + str;
Panel1.Visible = false;
Panel2.Visible = true;
sqlhp.BindGV(GridView2, str);
break;
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
strsql = " ";
DateTime st = DateTime.Parse(this.sTime.Text.ToString());
DateTime et = DateTime.Parse(this.eTime.Text.ToString());
string field = this.DropDownList1.SelectedValue;
string fiel2 = "";
if (field == "PublishDate")
{
fiel2 = "PublishDate";
bindType = 1;
}
if (field == "DraftComeDate")
{
fiel2 = "DraftComeDate";
bindType = 2;
}
strsql += " where (" + fiel2 + " between'" + st + "'" + " and '" + et + "')";
Session["sql"] = strsql;
Bind(strsql, bindType);
}
protected void btnWord_Click(object sender, EventArgs e)
{
string fileName = DateTime.Today.ToShortDateString() + ".doc";
Response.Clear();
Response.BufferOutput = true;
//输出字符集
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename="+fileName); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //
Response.ContentType = "application/ms-word";
//
EnableViewState=false;
System.Globalization.CultureInfo cultureInfo=new
System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter stringWriter=new System.IO.StringWriter(cultureInfo); System.Web.UI.HtmlTextWriter textWriter = new
System.Web.UI.HtmlTextWriter(stringWriter);
if (Panel2.Visible == true)
{
this.GridView2.RenderControl(textWriter);
}
if (Panel1.Visible == true)
{
this.GridView1.RenderControl(textWriter);
}
//把HTML 写′回到浏览器
Response.Write(stringWriter.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) {
GridView1.PageIndex = e.NewPageIndex;
sqlhp.BindGV(GridView1, "select * from Draft");
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e) {
GridView1.PageIndex = e.NewPageIndex;
sqlhp.BindGV(GridView1, "select * from Draft");}
普通用户模块:
我想投稿
string strSQL; // 插入稿件
string strSQL2; // 插入稿件和投稿人关联标括志
protected SqlConnection conn;
protected SqlCommand cmd1;
protected SqlCommand cmd2;
SQLHelper sqlhp = new SQLHelper();
// file upload
protected void add1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
if (FileUpload1.HasFile)
{
//获取文件的扩展名
inputTitle.Text = FileUpload1.FileName;
string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); string[] allowedExt = { ".doc", ".docx",".pdf",".txt",".ppt"}; for (int i = 0; i
{
if (fileExt == allowedExt[i])
{
string name = FileUpload1.PostedFile.FileName;
FileInfo file = new FileInfo(name);
//文件名称
string fileName = file.Name;
//服务器端文件路径
string webFilePath = Server.MapPath("~/resource/" + fileName); //判断相同文件是否存在
if (!File.Exists(webFilePath))
{
try
{
FileUpload1.SaveAs(webFilePath);
Response.Write("");
Panel1.Visible = false;
Panel3.Visible = true;
}
catch (Exception ex)
{
}
}
else
{
Response.Write("提示:文件已经存在,请重命名后上传!"); }
}
}
protected void Button1_OnClick(object sender, EventArgs e)
{
string D_id = DateTime.Now.Ticks.ToString(); // 生成稿件ID string title = inputTitle.Text;
string type = DropDownList1.SelectedItem.Text;
string DraftStatus = "未′审核";
strSQL = "insert into Draft
(Draft_ID,Draft_Name,TypeName,DraftComeDate,Draft_status,Draft_abstract,Draft_keywords)values('";
strSQL += D_id + "','";
strSQL += title + "','";
strSQL += type + "','";
strSQL += DateTime.Now.ToString() + "','" + DraftStatus + "','";
strSQL += inputAbstract.Text + "','";
strSQL+= keyWords.Text+" ' )";
strSQL2 = "insert into dbo.T_Author_Draft (Draft_ID,Author_ID) values('";
strSQL2 += D_id + "','";
strSQL2 += Session["CID"].ToString() + "')";
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToString());
conn.Open();
cmd2 = new SqlCommand(strSQL2, conn);
cmd1 = new SqlCommand(strSQL, conn);
try
{
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
}
catch (Exception err)
{
}
finally
{
conn.Close();
}
}
已投稿件查询
string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd;
SQLHelper sqlhp = new SQLHelper();
protected void Page_Load(object sender, EventArgs e)
{
string strsql = "select
dbo.Draft.Draft_ID,Draft_Name,Author_ID,TypeName,PublishDate,DraftComeDate,Draft_Status,draft_remarks from Draft,dbo.T_Author_Draft where
dbo.T_Author_Draft.Draft_ID=dbo.Draft.Draft_ID and dbo.T_Author_Draft.Author_ID="; if (Session["CID"] != null)
{
string adName = Session["CID"].ToString();
int C_num = int.Parse(adName);
strsql += "'" + C_num + "'";
sqlhp.BindGV(GridView1, strsql);
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) {
GridView1.PageIndex = e.NewPageIndex;
string strsql = "select
dbo.Draft.Draft_ID,Draft_Name,Author_ID,TypeName,PublishDate,DraftComeDate,Draft_Status,draft_remarks from Draft,dbo.T_Author_Draft where
dbo.T_Author_Draft.Draft_ID=dbo.Draft.Draft_ID and dbo.T_Author_Draft.Author_ID="; if (Session["CID"] != null)
{
string adName = Session["CID"].ToString();
int C_num = int.Parse(adName);
strsql += "'" + C_num + "'";
sqlhp.BindGV(GridView1, strsql);
}
}
}
文件下载
string root;
Table tableDirInfo = new Table();
protected void Page_Load(object sender, EventArgs e)
{
root = Server.MapPath("~/resource"); //指定下载的根目录
GetFileList(root);
Panel1.Controls.Add(tableDirInfo);
if (!IsPostBack)
{
if (Request.QueryString["dFile"] != null && Request.QueryString["dFile"] != "") {
//要下载文件的名称
string downFile = Request.QueryString["dFile"].ToString();
//调用DownLoadFile()下载该文件
DownLoadFile(downFile);
}
}
}
private void DownLoadFile(string fileName)
{
string filePath = Server.MapPath("~/resource/")+fileName;
if (File.Exists(filePath))
{
FileInfo file = new FileInfo(filePath);
//解决中文乱码
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); Response.AddHeader("Content-Disposition","attachment; filename="
+Server.UrlEncode(file.Name));
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
审稿人模块:
待审稿件
string strSQL;
protected SqlConnection conn;
protected SqlCommand cmd1;
protected SqlCommand cmd2;
protected SqlCommand cmd3;
SQLHelper sqlhp = new SQLHelper();
string strsql = "select
dbo.Draft.Draft_ID,Draft_Name,TypeName,PublishDate,DraftComeDate,Draft_Status from Draft,dbo.T_Draft_Reviewer where (dbo.T_Draft_Reviewer.Draft_ID=dbo.Draft.Draft_ID and dbo.Draft.Draft_Status='未′审核' and dbo.T_Draft_Reviewer.Judge_id=";
if (Session["JID"] != null)
{
string adName = Session["JID"].ToString();
int C_num = int.Parse(adName);
strsql += "'" + C_num + "')";
sqlhp.BindGV(GridView1, strsql);
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
DropDownList dd1 = (DropDownList)e.Row.FindControl("DropDownList1"); }
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
//取得dropdownlist 控件
DropDownList stu =
(DropDownList)GridView1.Rows[0].Cells[4].FindControl("DropDownList1");
TextBox tb=(TextBox)GridView1.Rows[0].Cells[5].FindControl("txtRemarks"); GridView1.PageIndex = GridView1.SelectedIndex;
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) {
int i = Convert.ToInt32(e.RowIndex);
string ID = GridView1.Rows[i].Cells[4].Text.ToString();
string stu =
((DropDownList)GridView1.Rows[i].FindControl("DropDownList1")).SelectedItem.ToString(); //获得审稿人评论
TextBox tb = (TextBox)GridView1.Rows[i].FindControl("txtRemarks");
string str2 = "update Draft set Draft_Status=" + "'" + stu + "',Draft_remarks= '" + tb.Text + "'";
str2 += " where draft_id ='" + ID+ "'";
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToString());
conn.Open();
cmd2 = new SqlCommand(str2, conn);
try
{
cmd2.ExecuteNonQuery();
}
catch (Exception err)
{
}
conn.Close();
sqlhp.BindGV(GridView1,str2);
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
//取得索引行
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = GridView1.Rows[index];
//取得稿件编括号
TableCell D_num = selectedRow.Cells[0];
if (e.CommandName == "btnSave")
{
//获得稿件状态
string stu =
((DropDownList)GridView1.Rows[index].FindControl("DropDownList1")).SelectedItem.Text; //获得审稿人评论
TextBox tb = (TextBox)GridView1.Rows[index].FindControl("txtRemarks"); string str2 = "update Draft set Draft_Status="+"'" + stu + "',Draft_remarks= '"+tb.Text+"'";
str2+=" where draft_id ='"+D_num.Text+"'";
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["UniversityMISConnectionString"].ToString());
conn.Open();
cmd2 = new SqlCommand(str2, conn);
try
{
cmd2.ExecuteNonQuery();
Page.Response.Redirect("~/Judge/draft_per.aspx");
}
catch (Exception err)
{
}
conn.Close();
sqlhp.BindGV(GridView1,str2);
}
}
已审稿件
strSQL += "select
dbo.Draft.Draft_ID,Draft_Name,TypeName,DraftComeDate,Draft_Status,draft_remarks from Draft,dbo.T_Draft_Reviewer where (dbo.T_Draft_Reviewer.Draft_ID=dbo.Draft.Draft_ID and dbo.Draft.Draft_Status!='未′审核' and dbo.T_Draft_Reviewer.Judge_id=";
if (Session["JID"] != null)
{
string adName = Session["JID"].ToString();
int C_num = int.Parse(adName);
strSQL += "'" + C_num + "')";
sqlhp.BindGV(GridView1, strSQL);
}