private string uploadDirectory; // 文件保存路径 #endregion Fields #region Methods protected void btnUpload_Click(object sender, EventArgs e) { // 判断是否有文件提交. if (Quiz_Info.PostedFile.FileName == "") { } else { // 判断文件大小是否超过200KB. if (Quiz_Info.PostedFile.ContentLength > 204800) { } else { // 判断文件类型. string extension = Path.GetExtension(Quiz_Info.PostedFile.FileName); switch (extension.ToLower()) { case ".txt": break; default: return; } // 以下代码是保持文件到服务器uploadDirectory中。 //文件名维持原文件名不变。 string serverFileName = Path.GetFileName(Quiz_Info.PostedFile.FileName); string fullUploadPath = Path.Combine(uploadDirectory, serverFileName); Quiz_Info.PostedFile.SaveAs(fullUploadPath); // 上传文件 // lblInfo.Text += fullUploadPath; string qname = Quiz_Name.Text.ToString(); string qcontent = Quiz_Content.Text.ToString(); string qinfo = "/Quiz/" + serverFileName; string qtype = Quiz_Type.Text.ToString(); int qlevel = Convert.ToInt32(Quiz_Level.Text.ToString()); int qtime = Convert.ToInt32(Quiz_Time.Text.ToString()); string qinput = Quiz_Input.Text.ToString(); string qoutput = Quiz_Output.Text.ToString(); Model.QuizForDB db = new Model.QuizForDB(); db.Quiz_ID = Guid.NewGuid(); db.Quiz_Name = qname; db.Quiz_Output = qoutput; db.Quiz_Info = qinfo; db.Quiz_Content = qcontent; db.Quiz_Input = qinput; db.Quiz_Level = qlevel; db.Quiz_Time = qtime; db.Quiz_Type = qtype; OxcoderIBL.QuizInfoIBL User = new OxcoderBL.QuizInfoBL(); User.insertAQuiz(db); } } }
protected void btnUpload_Click(object sender, EventArgs e) { // 判断是否有文件提交. if (Quiz_Info.PostedFile.FileName == "") { } else { // 判断文件大小是否超过200KB. if (Quiz_Info.PostedFile.ContentLength > 204800) { } else { // 判断文件类型. string extension = Path.GetExtension(Quiz_Info.PostedFile.FileName); switch (extension.ToLower()) { case ".txt": break; default: return; } // 以下代码是保持文件到服务器uploadDirectory中。 //文件名维持原文件名不变。 string serverFileName = Path.GetFileName(Quiz_Info.PostedFile.FileName); string fullUploadPath = Path.Combine(uploadDirectory, serverFileName); Quiz_Info.PostedFile.SaveAs(fullUploadPath); // 上传文件 // lblInfo.Text += fullUploadPath; string qname = Quiz_Name.Text.ToString(); string qcontent = Quiz_Content.Text.ToString(); string qinfo = "/Quiz/" + serverFileName; string qtype = Quiz_Type.Text.ToString(); int qlevel = Convert.ToInt32(Quiz_Level.Text.ToString()); int qtime = Convert.ToInt32(Quiz_Time.Text.ToString()); string qinput = Quiz_Input.Text.ToString(); string qoutput = Quiz_Output.Text.ToString(); Model.QuizForDB db = new Model.QuizForDB(); db.Quiz_ID = Guid.NewGuid(); db.Quiz_Name = qname; db.Quiz_Output = qoutput; db.Quiz_Info = qinfo; db.Quiz_Content = qcontent; db.Quiz_Input = qinput; db.Quiz_Level = qlevel; db.Quiz_Time = qtime; db.Quiz_Type = qtype; OxcoderIBL.QuizInfoIBL User = new OxcoderBL.QuizInfoBL(); User.insertAQuiz(db); } } }
public Model.Quiz searchQuizInfo(string reid, int order) { OxcoderIBL.SearchChallengeIBL search = new OxcoderBL.SearchChallengeBL(); OxcoderIBL.QuizInfoIBL enter = new OxcoderBL.QuizInfoBL(); DataSet ds = search.SearchByChallengeID(reid); switch (order) { case 0: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_First"].ToString()); break; case 1: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_Sec"].ToString()); break; case 2: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_Third"].ToString()); break; default: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_First"].ToString()); break; } Model.Quiz p1 = new Model.Quiz(); p1.chineseName = ds.Tables[0].Rows[0]["Quiz_Name"].ToString(); p1.pid = ds.Tables[0].Rows[0]["Quiz_ID"].ToString(); p1.codepath = ds.Tables[0].Rows[0]["Quiz_Info"].ToString(); p1.countDown = ds.Tables[0].Rows[0]["Quiz_Time"].ToString(); p1.order = order; p1.pname = ds.Tables[0].Rows[0]["Quiz_Pname"].ToString(); p1.previewfileExist = false; p1.ptype = ds.Tables[0].Rows[0]["Quiz_TypeID"].ToString(); p1.ptypeName = ds.Tables[0].Rows[0]["Quiz_Type"].ToString(); p1.target = ds.Tables[0].Rows[0]["Quiz_Content"].ToString(); p1.totalTime = ds.Tables[0].Rows[0]["Quiz_Time"].ToString(); p1.input = ds.Tables[0].Rows[0]["Quiz_Input"].ToString(); p1.output = ds.Tables[0].Rows[0]["Quiz_Output"].ToString(); return(p1); }
public Model.Quiz searchQuizInfo(string reid, int order) { OxcoderIBL.SearchChallengeIBL search = new OxcoderBL.SearchChallengeBL(); OxcoderIBL.QuizInfoIBL enter = new OxcoderBL.QuizInfoBL(); DataSet ds = search.SearchByChallengeID(reid); switch (order) { case 0: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_First"].ToString()); break; case 1: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_Sec"].ToString()); break; case 2: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_Third"].ToString()); break; default: ds = enter.QuizInfo(ds.Tables[0].Rows[0]["Challenge_Quiz_First"].ToString()); break; } Model.Quiz p1 = new Model.Quiz(); p1.chineseName = ds.Tables[0].Rows[0]["Quiz_Name"].ToString(); p1.pid = ds.Tables[0].Rows[0]["Quiz_ID"].ToString(); p1.codepath = ds.Tables[0].Rows[0]["Quiz_Info"].ToString(); p1.countDown = ds.Tables[0].Rows[0]["Quiz_Time"].ToString(); p1.order = order; p1.pname = ds.Tables[0].Rows[0]["Quiz_Pname"].ToString(); p1.previewfileExist = false; p1.ptype = ds.Tables[0].Rows[0]["Quiz_TypeID"].ToString(); p1.ptypeName = ds.Tables[0].Rows[0]["Quiz_Type"].ToString(); p1.target = ds.Tables[0].Rows[0]["Quiz_Content"].ToString(); p1.totalTime = ds.Tables[0].Rows[0]["Quiz_Time"].ToString(); p1.input = ds.Tables[0].Rows[0]["Quiz_Input"].ToString(); p1.output = ds.Tables[0].Rows[0]["Quiz_Output"].ToString(); return p1; }