📄 submitnewpaper.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;
public partial class ViewPage_SubmitPaper : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submitbtn_Click(object sender, EventArgs e)
{
HttpFileCollection files = HttpContext.Current.Request.Files;
for (int i = 0; i < files.Count; i++)
{
if (files[i].FileName != "" || files[i] != null)
{
int FileSize = 6 * 1024 * 1024;
HttpPostedFile myFile = files[i];
string strFilePath = myFile.FileName.ToString().Trim();
this.lblAttachmentError.Text = "<" + strFilePath + ">"; // Show file name
int nFindSlashPos = strFilePath.Trim().LastIndexOf("\\") + 1;
string UploadFileName = strFilePath.Substring(nFindSlashPos);
string FileName = "YeeWen" + "_" + Session["Email"].ToString() + "_" + UploadFileName;
if (myFile.FileName.Trim() == "") // Empty value in Browse Box
{
this.lblAttachmentError.Text = "No file selected.";
return;
}
if (myFile.ContentLength != 0)
{
if (myFile.ContentLength > FileSize)
{
this.lblAttachmentError.Text = "File Size is limited to 6 MB only.";
return;
}
//this.lblAttachment.Text += "<BR>" + FileName;
this.lblAttachmentError.Text = "";
// string s=this.Request.PhysicalApplicationPath.ToString().Trim();
// string s1=this.Request.ApplicationPath.ToString().Trim();
// string s3=this.Server.MapPath("");
myFile.SaveAs(this.Request.PhysicalApplicationPath.ToString().Trim() + @"\uploads\" + FileName);
//myFile.SaveAs(Server.MapPath("uploads" + FileName));
///ArrayFileName[i] = FileName;
// // return;
string ArticleUrl = this.Request.PhysicalApplicationPath.ToString().Trim() + @"\uploads\" + FileName;
Int32 ModNumber;
String ArticleName, Subject, Writer, Abstract, Discipline, Statics, Keywords;
DateTime SubmitDate;
ArticleName = FileName;
Subject = Subjecttb.Text.Trim();
Writer = Writertb.Text.Trim();
Keywords = Keywordstb1.Text.Trim() + "," + Keywordstb2.Text.Trim() + "," + Keywordstb3.Text.Trim();
Abstract = Abstracttb.Text.Trim();
Discipline = Dd1.SelectedValue;
ModNumber = 0;
Statics = "New";
//ReturnMessage = "";
SubmitDate = DateTime.Now;
PaperOp insert_papers = new PaperOp();
if (
insert_papers.insert_articles_envoyers(ArticleName, Subject, Writer, Abstract, Discipline, Keywords, ArticleUrl, Statics,
ModNumber, SubmitDate) == 1)
{
GetArticleId get_max_articleid = new GetArticleId();
GetArticleId getnum = new GetArticleId();
String Email = Session["Email"].ToString();
GetUserId get_userid = new GetUserId();
int UserId = get_userid.GetUserId_basicinformation(Email);
int ArticleId = get_max_articleid.GetArticleId_Articles();
UserLogin update_envoyers = new UserLogin();
int Number = getnum.GetArticleId_number_admin(UserId);
if (Number == 1)
update_envoyers.update_envoyers_articleid(ArticleId, UserId);
else
{
int RoleId = 3;
update_envoyers.insert_Envoyers_SubmitPapers(RoleId, UserId, ArticleId);
}
}
else
Server.Transfer("~/ViewPage/LoginError.aspx");
}
else
{
this.lblAttachmentError.Text = "File not found.";
return;
}
}
else
this.lblAttachmentError.Text = "Uploaded File exceed limits.";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -