⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acc_input.aspx.cs

📁 毕业设计关系b/s系统 毕业设计管理工作 毕业设计管理数据
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO ;
using System.Data.SqlClient  ;
using System.Configuration ;
using System.Data .OleDb ;

namespace graduate.stu
{
	/// <summary>
	/// acc_input 的摘要说明。
	/// </summary>
	public class acc_input : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label label_title;
		protected System.Web.UI.HtmlControls.HtmlTable tt;
		protected System.Web.UI.HtmlControls.HtmlTableRow tr_js;
		protected System.Web.UI.WebControls.Button bt_trans;
		protected System.Web.UI.WebControls.Button bt_thesis;
		protected System.Web.UI.WebControls.Button bt_code;
		protected System.Web.UI.HtmlControls.HtmlInputFile fp_trans;
		protected System.Web.UI.HtmlControls.HtmlInputFile fp_thesis;
		protected System.Web.UI.HtmlControls.HtmlInputFile fp_code;
		protected System.Web.UI.HtmlControls.HtmlTableRow Tr1;
		protected System.Web.UI.WebControls.Button btn_trans;
		protected System.Web.UI.WebControls.Button btn_thesis;
		protected System.Web.UI.WebControls.Button btn_code;
		protected System.Web.UI.HtmlControls.HtmlTableRow tr_xs;
		string myConnString=ConfigurationSettings.AppSettings ["SQLconnectionString"];
		string sql="",key="",url0="",ftype="",url="";
		string studentid="",trans="",thesis="",code="",classname="",suresubjectid="";
		protected System.Web.UI.HtmlControls.HtmlTableCell td_trans1;
		protected System.Web.UI.HtmlControls.HtmlTableCell td_trans2;
		protected System.Web.UI.HtmlControls.HtmlTableCell td_thesis1;
		protected System.Web.UI.HtmlControls.HtmlTableCell td_thesis2;
		protected System.Web.UI.HtmlControls.HtmlTableCell td_code1;
		protected System.Web.UI.WebControls.Button btn_dtrans;
		protected System.Web.UI.WebControls.Button btn_dthesis;
		protected System.Web.UI.WebControls.Button btn_dcode;
		protected System.Web.UI.WebControls.HyperLink hyp_trans;
		protected System.Web.UI.WebControls.HyperLink hyp_thesis;
		protected System.Web.UI.WebControls.HyperLink hyp_code;
		protected System.Web.UI.HtmlControls.HtmlTableCell td_code2;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			//string id=Request.QueryString.Get(0);
			studentid = Convert.ToString (Session["studentid"]);

			if(!IsPostBack)
			{
				SqlConnection conn = new SqlConnection(myConnString);
				sql="select translationurl,papercommiturl,codecommiturl  from BYSJ.accessory a,bysj.suresubject b where a.suresubjectid=b.suresubjectid and b.studentid='"+studentid+"'";
				try
				{
					conn.Open();
					SqlDataAdapter adapter1 = new  SqlDataAdapter(sql, conn);
					DataSet cla=new DataSet ();
					adapter1.Fill(cla);

					ViewState["key"]="0";//accessory表中无该生信息

					string sql1="select classname ,suresubjectid from bysj.classinfo a,bysj.studentbaseinfo b ,bysj.suresubject c where a.classid=b.classid and b.studentid='"+studentid+"' and b.studentid=c.studentid";
					SqlDataAdapter adapter2 = new  SqlDataAdapter(sql1, conn);
					DataSet cla1=new DataSet ();
					adapter2.Fill(cla1);
					if (cla1.Tables ["table"].Rows.Count !=0)
					{
						classname = Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [0]);
						ViewState["classname"] = classname;
						suresubjectid= Convert.ToString (cla1.Tables ["table"].Rows [0].ItemArray [1]);
						ViewState["suresubjectid"] = suresubjectid;
					}

					if(cla.Tables ["table"].Rows .Count !=0)
					{
						ViewState["key"]="1";//accessory表中已有该生信息 
						trans = Convert.ToString (cla.Tables ["table"].Rows[0].ItemArray [0]);
						ViewState["trans"] = trans;
						thesis = Convert.ToString (cla.Tables ["table"].Rows[0].ItemArray [1]);
						ViewState["thesis"] = thesis;
						code = Convert.ToString (cla.Tables ["table"].Rows[0].ItemArray [2]);
						ViewState["code"] = code;

						if(trans.Length ==0)
						{
							td_trans1.Visible=false;
							td_trans2.Visible =true;
						}
						else
						{
							td_trans1.Visible =true;
							td_trans2.Visible =false;
							hyp_trans.Text = "翻译文件名为:"+ trans;
							url0="data/"+classname+"/"+studentid+"/"+trans;   //带存储文件夹名字,url是纯文件名字  
							hyp_trans.NavigateUrl = "../"+url0;
						}

						if(thesis.Length ==0)
						{
							td_thesis1.Visible=false;
							td_thesis2.Visible =true;
						}
						else
						{
							td_thesis1.Visible =true;
							td_thesis2.Visible =false;
							hyp_thesis.Text = "翻译文件名为:"+ thesis;
							url0="data/"+classname+"/"+studentid+"/"+thesis;   //带存储文件夹名字,url是纯文件名字  
							hyp_thesis.NavigateUrl = "../"+url0;
						}

						if(code.Length ==0)
						{
							td_code1.Visible=false;
							td_code2.Visible =true;
						}
						else
						{
							td_code1.Visible =true;
							td_code2.Visible =false;
							hyp_code.Text = "翻译文件名为:"+ code;
							url0="data/"+classname+"/"+studentid+"/"+code;   //带存储文件夹名字,url是纯文件名字  
							hyp_code.NavigateUrl = "../"+url0;
						}

						
					}
					else
					{
						td_trans1.Visible =false;
						td_thesis1.Visible =false;
						td_code1.Visible=false;
					}
					

				
					
				}
				catch(SqlException ex)
				{
					Response.Write ("<script>");
					Response.Write ("alert('数据库连接出错!')");
					Response.Write ("</script>");
				}
				finally
				{
					conn.Close ();
				}

			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btn_trans.Click += new System.EventHandler(this.btn_trans_Click);
			this.btn_dtrans.Click += new System.EventHandler(this.btn_dtrans_Click);
			this.bt_trans.Click += new System.EventHandler(this.bt_trans_Click);
			this.btn_thesis.Click += new System.EventHandler(this.btn_thesis_Click);
			this.btn_dthesis.Click += new System.EventHandler(this.btn_dthesis_Click);
			this.bt_thesis.Click += new System.EventHandler(this.bt_thesis_Click);
			this.btn_code.Click += new System.EventHandler(this.btn_code_Click);
			this.btn_dcode.Click += new System.EventHandler(this.btn_dcode_Click);
			this.bt_code.Click += new System.EventHandler(this.bt_code_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		//获取上传文本的filename和type,type=doc返回true,否则返回false;
		private Boolean gain_name( )
		{
			ftype=url0.Substring (url0.Length -3,3);    //type
			string[] tt=url0.Split('\\');
			url0=tt[tt.Length-1];
			url=url0;	                                //纯filename(带type)
			if(ftype.ToLower() !="doc")
			{
				
				Response.Write ("<script>");
				Response.Write ("alert('请上传word文本!')");
				Response.Write ("</script>");
				return false;
			}
			else
				return true;
					
			
		}

		private void bt_trans_Click(object sender, System.EventArgs e)
		{
			if(fp_trans.PostedFile.ContentLength!=0)
			{
				url0=fp_trans.PostedFile.FileName.Trim ();
				if (gain_name()==true)                  //判断上传文本类型,记录文件名
				{
					//上传文件
					classname = Convert.ToString (ViewState["classname"]);
					url0="data/"+classname+"/"+studentid+"/"+studentid+"_trans_"+url0;   //带存储文件夹名字,url是纯文件名字  
					
					//将文件上传至服务器
					if (!Directory.Exists(Server.MapPath("../")+"/data/"+classname+"/"+studentid+"/")) 
					{
						Directory.CreateDirectory(Server.MapPath("../")+"/data/"+classname+"/"+studentid+"/");
					}
					try
					{
						fp_trans.PostedFile.SaveAs(Server.MapPath("../")+"/"+url0);
					}
					catch(Exception ex)
					{
						Response.Write(" <font color='Red' size='2'>'上传不成功 ' </font>;");
					}

					SqlConnection conn = new SqlConnection(myConnString);
					try
					{
						conn.Open();
						DateTime dt=new DateTime ();
						dt=DateTime.Now ;

						key=Convert.ToString (ViewState["key"]);
						trans = studentid+"_trans_"+url;
						ViewState["trans"] = trans;
						suresubjectid = Convert.ToString (ViewState["suresubjectid"]);

						if (key == "0")
							sql="insert into bysj.accessory (suresubjectid,translationurl) values('"+suresubjectid+"','"+trans+"')";
						else
							sql="update bysj.accessory set translationurl='"+trans+"' where suresubjectid='"+suresubjectid+"'";
						SqlCommand cmd = new  SqlCommand (sql,conn);
						cmd.CommandText =sql;
						cmd.ExecuteNonQuery ();

						sql="select  * from bysj.flowmonitor where suresubjectid='"+suresubjectid+"'";
						SqlDataAdapter adapter3 = new  SqlDataAdapter(sql, conn);
						DataSet cla2=new DataSet ();
						adapter3.Fill(cla2);
						if (cla2.Tables ["table"].Rows.Count ==0)
							sql="insert into bysj.flowmonitor (suresubjectid,translationflag,translationtime)values('"+suresubjectid+"','"+1+"','"+dt+"')";
						else
							sql="update bysj.flowmonitor set translationflag='1' ,translationtime='"+dt+"' where suresubjectid='"+suresubjectid+"'";
						cmd.CommandText =sql;
						cmd.ExecuteNonQuery ();
					
						Response.Write ("<script>");
						Response.Write ("alert('提交成功!');");
						Response.Write("</script>");

						td_trans1.Visible =true;
						td_trans2.Visible =false;
						hyp_trans.Text = "翻译文件名为:"+trans;
						url0="data/"+classname+"/"+studentid+"/"+trans;   //带存储文件夹名字,url是纯文件名字  
						hyp_trans.NavigateUrl = "../"+url0;
						ViewState["key"]="2";
					
					}
					catch(SqlException ex)
					{
						Response.Write ("<script>");
						Response.Write ("alert('数据库连接出错!')");
						Response.Write ("</script>");
					}
					finally
					{
						conn.Close ();
					}



					
				}
				
			}
			
			else
			{
				Response.Write ("<script>");
				Response.Write ("alert('请选择word文本!!')");
				Response.Write ("</script>");
			}
		}

		private void btn_trans_Click(object sender, System.EventArgs e)
		{
			td_trans2.Visible =true;
		}

		private void btn_dtrans_Click(object sender, System.EventArgs e)
		{
			classname = Convert.ToString (ViewState["classname"]);
			trans = Convert.ToString (ViewState["trans"]);
			suresubjectid = Convert.ToString (ViewState["suresubjectid"]);
			url0="data/"+classname+"/"+studentid+"/"+trans;   //带存储文件夹名字,url是纯文件名字  

			FileInfo file=new FileInfo(Server.MapPath("../")+url0);
			if(file.Exists )
			{
				file.Delete ( );

				SqlConnection conn = new SqlConnection(myConnString);
				try
				{
					conn.Open();
					DateTime dt=new DateTime ();
					dt=DateTime.Now ;

					sql="update bysj.accessory set translationurl='' where suresubjectid='"+suresubjectid+"'";
					SqlCommand cmd = new  SqlCommand (sql,conn);
					cmd.CommandText =sql;
					cmd.ExecuteNonQuery ();
					sql="update bysj.flowmonitor set translationflag='0' where suresubjectid='"+suresubjectid+"'";
					cmd.CommandText =sql;
					cmd.ExecuteNonQuery ();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -