private void ShowIpWorkDone()
    {
        if (Request.Cookies["StudentCookies"] != null)
        {
            if (Request.QueryString["Mid"] != null)
            {
                string Sgrade = Request.Cookies["StudentCookies"].Values["Sgrade"].ToString();
                string Sclass = Request.Cookies["StudentCookies"].Values["Sclass"].ToString();
                string Snum = Request.Cookies["StudentCookies"].Values["Snum"].ToString();
                string Wip = Request.Cookies["StudentCookies"].Values["LoginIp"].ToString();
                if (Request.QueryString["Mcid"] != null)
                {
                    string Wcid = Request.QueryString["Mcid"].ToString();
                    string Wmid = Request.QueryString["Mid"].ToString();
                    if (LearnSite.Common.WordProcess.IsNum(Wcid) && LearnSite.Common.WordProcess.IsNum(Wmid))
                    {
                        LearnSite.BLL.Works ws = new LearnSite.BLL.Works();
                        string SnumDone = ws.IpWorkDoneSnum(Int32.Parse(Sgrade), Int32.Parse(Sclass), Int32.Parse(Wcid), Int32.Parse(Wmid), Wip);
                        if (SnumDone == "")
                        {
                            if (LabelMfiletype.Text != "html")
                            {
                                Labelmsg.Text = DateTime.Now.ToShortDateString();
                            }
                        }
                        else
                        {
                            if (Snum != SnumDone)
                            {
                                if (LearnSite.Common.XmlHelp.GetWorkIpLimit())
                                {
                                    AttachFile.Enabled = false;
                                    Btnupload.Enabled = false;//如果作品提交设定为IP限制的话,提交按钮灰色失效
                                    Labelmsg.Text = SnumDone + "学号<br/>已经在该IP提交本任务作品!";
                                }
                                Labelmsg.Text = SnumDone + "学号<br/>已经在该IP提交本任务作品!";
                            }
                            else
                            {
                                if (Session[Snum] != null)
                                {
                                    AttachFile.Enabled = false;
                                    Btnupload.Enabled = false;
                                    Labelmsg.Text = "你已经参加投票活动!<br/>你不可以重新提交了!";
                                }
                                else
                                {
                                    Labelmsg.Text = "你可以修改作品";

                                }
                            }
                        }
                        string Wid = ws.WorkDone(Snum, Int32.Parse(Wcid), Int32.Parse(Wmid));//返回空字符表示不存在该记录
                        if (Wid != "")
                        {
                            //如果作品已经评分,提交按钮灰色失效
                            if (ws.IsChecked(Int32.Parse(Wid)))
                            {
                                Labelmsg.Text = "该作品已经评分!";
                                Btnupload.Enabled = false;
                                AttachFile.Enabled = false;
                                CheckBoxCan.Enabled = false;
                            }
                        }
                        else
                        {
                            if (CheckBoxMupload.Checked)
                            {
                                Labelmsg.Text =Labelmsg.Text+ "<br/>你未提交该作品?";
                            }
                        }
                    }
                    else
                    {
                        Panelworks.Visible = false;
                        Labelmsg.Text = "网页超时过期!";
                    }
                }
            }
        }
    }
    protected void Btnupload_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            string Wmid = Request.QueryString["Mid"].ToString();
            if (LearnSite.Common.WordProcess.IsNum(Wmid))
            {
                string Sname = Request.Cookies["StudentCookies"].Values["Sname"].ToString();
                string Syear = Request.Cookies["StudentCookies"].Values["Syear"].ToString();
                string Sgrade = Request.Cookies["StudentCookies"].Values["Sgrade"].ToString();
                string Sclass = Request.Cookies["StudentCookies"].Values["Sclass"].ToString();
                string Wnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString();
                string Wip = Request.Cookies["StudentCookies"].Values["LoginIp"].ToString();
                string LoginTime = Request.Cookies["StudentCookies"].Values["LoginTime"].ToString();
                string Wcid = LabelMcid.Text;
                string Mfiletype = LabelMfiletype.Text;
                string Wmsort = LabelMsort.Text;
                DateTime Wdate = DateTime.Now;
                string iplast = Wip.Substring(Wip.LastIndexOf(".") + 1);

                if (CheckBoxMupload.Checked)//是否可上传
                {
                    string postfilename = this.AttachFile.FileName;
                    int Wlength = Convert.ToInt32(this.AttachFile.ContentLength);
                    if (postfilename != "" && postfilename != null)
                    {
                        if (LearnSite.Common.WorkUpload.CheckType(postfilename, Mfiletype))  //上传类型是否正确
                        {
                            LearnSite.BLL.Works ws = new LearnSite.BLL.Works();
                            string Wid = ws.WorkDone(Wnum, Int32.Parse(Wcid), Int32.Parse(Wmid));//返回空字符表示不存在该记录
                            if (Wid != "")
                            {
                                //重新提交修改作品
                                string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建)
                                string RndTime = (DateTime.Parse(LoginTime)).Minute.ToString();
                                string NewFileName = Server.UrlDecode(Sname) + Wcid + "_" + Wmid + "_" + RndTime + iplast + "." + Mfiletype;
                                string Wurl = MySavePath + "/" + NewFileName;
                                string saveFilename = Server.MapPath(Wurl);
                                try
                                {
                                    this.AttachFile.MoveTo(saveFilename, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);//保存提交作品

                                    ws.UpdateWorkUp(Int32.Parse(Wid), Wurl, NewFileName, Wlength, Wdate,CheckBoxCan.Checked);//更新Wfilename, Wurl,Wlength, Wdate
                                    string ch = "课程活动" + Wmsort + "重新提交作品成功!";
                                    Labelmsg.Text = ch;
                                    LearnSite.Common.WordProcess.Alert(ch, this.Page);
                                }
                                catch (Exception ex)
                                {
                                    throw ex;

                                }
                            }
                            else
                            {
                                //如果作品未提交,提交作品(Wnum, Wcid,Wmid,Wmsort, Wfilename, Wurl,Wlength, Wdate, Wip, Wtime)
                                string MySavePath = LearnSite.Common.WorkUpload.GetWurl(Syear, Sgrade, Sclass, Wcid, Wmid);//获得作品保存路径(如果不存在,自动创建)
                                string RndTime = (DateTime.Parse(LoginTime)).Minute.ToString();
                                string NewFileName = Server.UrlDecode(Sname) + Wcid + "_" + Wmid + "_" + RndTime + iplast + "." + Mfiletype;
                                string Wurl = MySavePath + "/" + NewFileName;
                                string Wtime = LearnSite.Common.Computer.TimePassed().ToString();

                                LearnSite.Model.Works wmodel = new LearnSite.Model.Works();
                                wmodel.Wnum = Wnum;
                                wmodel.Wcid = Int32.Parse(Wcid);
                                wmodel.Wmid = Int32.Parse(Wmid);
                                wmodel.Wmsort = Int32.Parse(Wmsort);
                                wmodel.Wfilename = NewFileName;
                                wmodel.Wurl = Wurl;
                                wmodel.Wlength = Wlength;
                                wmodel.Wdate = Wdate;
                                wmodel.Wip = Wip;
                                wmodel.Wtime = Wtime;
                                wmodel.Wcan = CheckBoxCan.Checked;
                                string saveFilename = Server.MapPath(Wurl);
                                try
                                {
                                    this.AttachFile.MoveTo(saveFilename, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);//保存提交作品

                                    ws.AddWorkUp(wmodel);//添加作品提交记录
                                    string worknums = ws.HowCidWorks(Int32.Parse(Wcid), Wnum);
                                    if (worknums != "")
                                    {
                                        LearnSite.BLL.Signin sn = new LearnSite.BLL.Signin();
                                        sn.UpdateQwork(Wnum, Int32.Parse(worknums));//更新今天签到表中的作品数量
                                    }
                                    string ch = "课程活动"+Wmsort+"提交作品成功!";
                                    Labelmsg.Text = ch;
                                    LearnSite.Common.WordProcess.Alert(ch, this.Page);
                                    ShowWorked();
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }
                            }
                        }
                        else
                        {
                            Labelmsg.Text = "提交类型错误!";
                            string ch = "提交作品类型错误!";
                            LearnSite.Common.WordProcess.Alert(ch, this.Page);
                        }

                    }

                    else
                    {
                        Labelmsg.Text = "你没有选择提交作品!";
                        string ch = "你没有浏览选择你的作品,请再选择一遍!";
                        LearnSite.Common.WordProcess.Alert(ch, this.Page);
                    }
                }
                else
                {
                    Labelmsg.Text = "本任务无作品!";
                }
            }
        }
    }