📄 tougao.aspx.cs
字号:
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 Tougao : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["uname"] != null)
{
//this.TextBox1.Text = Session["uname"].ToString();
}
else
{
Response.Write("<script language='javascript'>alert('没有登录请登录');location.href='UserLogin.aspx'</script>");
}
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
addgaojian();//调用过程
}
private void addgaojian()//发表稿件过程
{
string Fullname = this.FileUpload1.FileName;
string Type = Fullname.Substring(Fullname.LastIndexOf(".") + 1);
string Wpath = "稿件\\" + Fullname;
this.FileUpload1.SaveAs(Server.MapPath("稿件") + "\\" + Fullname);
SqlConnection con = db.ceratcon();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = (SqlConnection)con;
cmd.CommandText = "insert into Efile (Author,Title,Author_email,Description,File_path,File_class)values(@Author,@Title,@Author_email,@Description,@File_path,@File_class)";
cmd.Parameters.Add("@Author", SqlDbType.VarChar);
cmd.Parameters.Add("@Title", SqlDbType.VarChar);
cmd.Parameters.Add("@Author_email", SqlDbType.VarChar);
cmd.Parameters.Add("@Description", SqlDbType.VarChar);
cmd.Parameters.Add("@File_path", SqlDbType.VarChar);
cmd.Parameters.Add("@File_class", SqlDbType.VarChar);
cmd.Parameters["@Author"].Value = Session["uname"].ToString();
cmd.Parameters["@Title"].Value =this.txttittle.Text;
cmd.Parameters["@Author_email"].Value = this.txtemal.Text;
cmd.Parameters["@Description"].Value = this.txtmiaoshu.Text;
cmd.Parameters["@File_path"].Value = Wpath.ToString();
cmd.Parameters["@File_class"].Value =this.DropDownList1.SelectedItem.Text;
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script language='javascript'>alert('发表成功等待审核继续发表稿件!')</script>");
this.txttittle.Text="";
this.txtemal.Text="";
this.txtmiaoshu.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -