public bool insertAQuiz(Model.QuizForDB quiz) { String sql = "insert into [Quiz] (Quiz_ID,Quiz_Name,Quiz_Content,Quiz_Info,Quiz_Type,Quiz_Level,Quiz_Time,Quiz_TypeID,Quiz_Input,Quiz_Output) values(@id,@name,@content,@info,@type,@level,@time,@typeid,@input,@output)"; SqlParameter[] par = { new SqlParameter("@id", SqlDbType.UniqueIdentifier, 50), new SqlParameter("@name", SqlDbType.Text), new SqlParameter("@content", SqlDbType.Text), new SqlParameter("@info", SqlDbType.Text), new SqlParameter("@type", SqlDbType.Text), new SqlParameter("@level", SqlDbType.SmallInt), new SqlParameter("@time", SqlDbType.Int), new SqlParameter("@typeid", SqlDbType.Int), new SqlParameter("@input", SqlDbType.Text), new SqlParameter("@output", SqlDbType.Text) }; par[0].Value = quiz.Quiz_ID; par[1].Value = quiz.Quiz_Name; par[2].Value = quiz.Quiz_Content; par[3].Value = quiz.Quiz_Info; par[4].Value = quiz.Quiz_Type; par[5].Value = quiz.Quiz_Level; par[6].Value = quiz.Quiz_Time; par[7].Value = quiz.Quiz_TypeID; par[8].Value = quiz.Quiz_Input; //publish time par[9].Value = quiz.Quiz_Output; Common.DbHelperSQL.ExecuteSql(sql.ToString(), par); return(true); }
public bool insertAQuiz(Model.QuizForDB quiz) { OxcoderIFactory.IFactory factory = new OxcoderFactory.SqlSeverFactory(); OxcoderIDAL.QuizInfoIDAL en = factory.getQuizInstance(); if (quiz.Quiz_Type.Equals("php")) { quiz.Quiz_TypeID = 29; } else if (quiz.Quiz_Type.Equals("cpp")) { quiz.Quiz_TypeID = 1; } else if (quiz.Quiz_Type.Equals("python")) { quiz.Quiz_TypeID = 4; } else if (quiz.Quiz_Type.Equals("c")) { quiz.Quiz_TypeID = 34; } else if (quiz.Quiz_Type.Equals("java")) { quiz.Quiz_TypeID = 10; } return(en.insertAQuiz(quiz)); }
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); } } }