示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Student stu = (Student)Session["student"];
         if (stu == null)
         {
             Response.Redirect("~/Login.aspx");
         }
         else
         {
             Student student = (Student)Session["student"];
             Thesis  th      = thesisManage.GetThesisByStuID(student.SID);
             if (!string.IsNullOrEmpty(th.PublishDate))
             {
                 Thesis thesis = thesisManage.GetThesisByStuID(student.SID);
                 Title  title  = titleManage.GetTilteByTitleID(thesis.Title.TitleID);
                 lblTitle.Text      = thesis.Title.TitleName;
                 lblUploadTime.Text = thesis.PublishDate;
                 lblTeacher.Text    = title.Teacher.TeacherName;
             }
             else
             {
                 Panel1.Visible = false;
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('对不起!你还没有上传论文!');</script>");
                 lblMessage.Text = "你还没有上传论文!";
             }
         }
     }
 }
示例#2
0
    protected void btnUpLoad_Click(object sender, EventArgs e)
    {
        Student student = (Student)Session["student"];

        if (student.Title.TitleName != null && student.Title.TitleName != "")
        {
            string wordtype = FileUpload1.PostedFile.ContentType;
            string name     = this.FileUpload1.PostedFile.FileName;
            int    n        = FileUpload1.PostedFile.InputStream.Read(new byte[FileUpload1.PostedFile.ContentLength], 0, FileUpload1.PostedFile.ContentLength);
            Thesis thesis   = new Thesis();
            thesis.Student     = student;
            thesis.PublishDate = DateTime.Now.ToString();
            thesis.Content     = (new byte[FileUpload1.PostedFile.ContentLength]);
            thesis.Title       = titlemanage.GetTilteByTitleID(student.Title.TitleID);
            if (string.IsNullOrEmpty(thesisManage.GetThesisByStuID(student.SID).PublishDate))
            {
                int isUpLoadOk = thesisManage.InsertThesis(thesis);
                if (isUpLoadOk > 0)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('论上传成功!');</script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('论文上传失败!');</script>");
                }
            }
            else
            {
                btnUpLoad.Attributes.Add("onclick", "return confirm('你已上传论文,确定要重新上传吗?');");
                thesisManage.DeleteThesisByStudentID(student.SID);
                if (thesisManage.InsertThesis(thesis) > 0)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('论文重新上传成功!');</script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('论文重新上传失败!');</script>");
                }
            }
        }
        else
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('你还没有选题,请选题!');</script>");
        }
    }