Exemplo n.º 1
0
 public bool Create(Accessory accessory)
 {
     if (accessory.adress.Length == 0)
         return false;
     DataClassesDataContext da = new DataClassesDataContext();
     da.Accessory.InsertOnSubmit(accessory);
     da.SubmitChanges();
     return true;
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Student")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            //获取作业id
            id = Request.QueryString["AssignmentId"];
            header_text.Text = Request.QueryString["AssignmentTitle"];
            ProblemManager ProblemMan = new ProblemManager();

            stu = (Student)Session["student"];
            ProblemList = ProblemMan.GetProblem(System.Int32.Parse(id));

            if (ProblemList.Count != 0)
            {
                //动态创建问题及回答区域
                //加载上次答案
                AnswerList = AnswerMan.GetAnswerList(stu.username, System.Int32.Parse(id));
                accessory = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));

                for (int i = 0; i < ProblemList.Count; i++)
                {
                    string pro = "<p>" + ProblemList[i].title + "</p>";
                    Control ct = ParseControl(pro);
                    PlaceHolder1.Controls.Add(ct);

                    string an = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'></textarea></p>";

                    //加载已有答案
                    if (AnswerList != null)
                    {
                        an = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'>" + AnswerList[i].content + "</textarea></p>";
                        submitFlag = false;
                    }

                    Control ct2 = ParseControl(an);
                    PlaceHolder1.Controls.Add(ct2);
                }

                //加载已有附件
                if (accessory != null)
                {
                    fileTips.Text = "已有附件,无需再添加!";
                    FileUpload2.Enabled = false;
                }
            }
            else
            {
                header_text.Text = "   逗你玩呢,哈哈哈哈。";
                submit.Enabled = false;
                submit2.Enabled = false;
                export.Enabled = false;
                export2.Enabled = false;
                fileTips.Enabled = false;
                FileUpload2.Enabled = false;
            }
        }
Exemplo n.º 3
0
        protected void submit_Click(object sender, EventArgs e)
        {
            string[] content = Request.Form.GetValues("TA");
            for (int i = 0; i < ProblemList.Count; i++)
            {
                Answer answer = new Answer();
                answer.content = content[i];
                answer.student = stu.username;
                answer.problem = ProblemList[i].id;
                answer.score = (float)0.0;
                answer.comment = "no comment";
                answer.major = stu.major;
                answer.state = "2";
                if (AnswerList == null)
                {
                    AnswerList = new List<Answer>();
                }
                AnswerList.Add(answer);
            }

            if (submitFlag)
            {
                AnswerMan.AddAnswer(AnswerList);

                if (accessory == null)
                {
                    accessory = new Accessory();
                }

                try
                {
                    //获取上传文件的路径
                    string filepath = FileUpload2.PostedFile.FileName;
                    //获取后缀名
                    int filepos = filepath.LastIndexOf(".");
                    //截取后缀名
                    String strfilename = filepath.Substring(filepos);
                    //获取时间
                    string time1 = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    //保存到服务器的路径,这是我们网站固定网址
                    string serverpath = Server.MapPath("Accessory") + "\\" + stu.username + "_" + id + "_" + time1 + strfilename;
                    //确定上传文件
                    FileUpload2.PostedFile.SaveAs(serverpath);

                    string DBFilePath = "http://tasksystem.apphb.com/Accessory/" + stu.username + "_" + id + "_" + time1 + strfilename;
                    accessory.adress = DBFilePath;
                    accessory.assignment = System.Int32.Parse(id);
                    accessory.student = stu.username;
                    AccessoryMan.Create(accessory);
                }
                catch (System.Exception error)
                {
                    Response.Write(error.Message.ToString());
                }
            }
            else
            {
                AnswerMan.UpdateAnswer(AnswerList);
                //accessory = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));
            }

            //Response.Redirect("StudentMainForm.aspx");
            Response.Write("<script language=javascript>alert('提交成功!');location='StudentMainForm.aspx'</script>");
        }
Exemplo n.º 4
0
		private void detach_Accessory(Accessory entity)
		{
			this.SendPropertyChanging();
			entity.Assignment1 = null;
		}
Exemplo n.º 5
0
 partial void DeleteAccessory(Accessory instance);
Exemplo n.º 6
0
 partial void UpdateAccessory(Accessory instance);
Exemplo n.º 7
0
 partial void InsertAccessory(Accessory instance);
Exemplo n.º 8
0
		private void attach_Accessory(Accessory entity)
		{
			this.SendPropertyChanging();
			entity.Student1 = this;
		}