protected void SaveButton_Click(object sender, EventArgs e)
        {
            string strFullName = string.Empty;            //, strUrl, strContentType, strSize

            CoursewareBLL coursewareBLL = new CoursewareBLL();


            if (ViewState["AddFlag"].ToString() == "1")      //新增
            {
                strFullName = File1.FileName;                //直接取得文件名



                if (!string.IsNullOrEmpty(strFullName))
                {
                    FileInfo fi = new FileInfo(File1.FileName);

                    //判断只能上传.flv与.swf格式

                    //if (fi.Extension.ToLower() != ".flv" && fi.Extension.ToLower() != ".swf")
                    //{
                    //    SessionSet.PageMessage = "文件格式应为FLV或SWF视频! 现在格式为:" + fi.Extension.ToLower();
                    //    return;
                    //}

                    if (fi.Name.Replace(fi.Extension, "") != txtCoursewareName.Text)
                    {
                        SessionSet.PageMessage = "上传文件名与课件名不一致,请确认上传文件名!";
                        return;
                    }
                }
                RailExam.Model.Courseware courseware = new RailExam.Model.Courseware();

                courseware.CoursewareName   = txtCoursewareName.Text;
                courseware.CoursewareTypeID = int.Parse(hfCoursewareTypeID.Value);
                courseware.ProvideOrg       = SessionSet.OrganizationID;
                courseware.PublishDate      = DateTime.Parse(datePublishDate.DateValue.ToString());
                courseware.Authors          = txtAuthors.Text;
                courseware.Revisers         = txtRevisers.Text;
                courseware.KeyWord          = txtKeyWord.Text;
                courseware.Description      = txtDescription.Text;
                courseware.Memo             = txtMemo.Text;
                courseware.IsGroupLearder   = Convert.ToInt32(ddlIsGroup.SelectedValue);
                courseware.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue);

                ArrayList al = new ArrayList();
                courseware.OrgIDAL = GetOrg(tvOrg.Nodes, al);

                ArrayList al1 = new ArrayList();

                foreach (TreeViewNode tn in tvPost.Nodes)
                {
                    if (tn.Checked)
                    {
                        al1.Add(tn.ID);
                    }

                    if (tn.Nodes.Count > 0)
                    {
                        foreach (TreeViewNode tns in tn.Nodes)
                        {
                            if (tns.Checked)
                            {
                                al1.Add(tns.ID);
                            }

                            if (tns.Nodes.Count > 0)
                            {
                                foreach (TreeViewNode tnss in tns.Nodes)
                                {
                                    if (tnss.Checked)
                                    {
                                        al1.Add(tnss.ID);
                                    }
                                }
                            }
                        }
                    }
                }
                courseware.PostIDAL = al1;

                ArrayList trainTypeIDList = new ArrayList();
                string[]  strType         = hfTrainTypeID.Value.Split(',');
                for (int i = 0; i < strType.Length; i++)
                {
                    if (!string.IsNullOrEmpty(strType[i]))
                    {
                        trainTypeIDList.Add(strType[i]);
                    }
                }
                courseware.TrainTypeIDAL = trainTypeIDList;

                int nCoursewareID = coursewareBLL.AddCourseware(courseware);

                if (!string.IsNullOrEmpty(strFullName))
                {
                    //strUrl = File1.PostedFile.FileName;//先取得全部的上传文件路径个名字,然后再利用SubString方法来得到用户名,现在看来是没有必要了


                    //strContentType = File1.PostedFile.ContentType;//获取文件MIME内容类型
                    //strFileType = strFullName.Substring(strFullName.LastIndexOf(".") + 1);//获取文件名字 . 后面的字符作为文件类型


                    //strSize = File1.PostedFile.ContentLength.ToString();


                    Directory.CreateDirectory(Server.MapPath("../Online/Courseware/" + nCoursewareID));
                    File1.SaveAs(Server.MapPath("../Online/Courseware/" + nCoursewareID + "/") + strFullName);                    //将文件保存在跟目录的UP文件夹下

                    courseware.CoursewareID = nCoursewareID;
                    courseware.Url          = "/RailExamBao/Online/Courseware/" + nCoursewareID + "/" + strFullName;

                    coursewareBLL.UpdateCourseware(courseware);
                }
                Response.Write("<script>window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>");
            }
            else                //修改
            {
                string strCoursewareID = Request.QueryString.Get("id");

                RailExam.Model.Courseware courseware = coursewareBLL.GetCourseware(Convert.ToInt32(strCoursewareID));
                courseware.CoursewareID     = int.Parse(strCoursewareID);
                courseware.CoursewareName   = txtCoursewareName.Text;
                courseware.CoursewareTypeID = int.Parse(hfCoursewareTypeID.Value);
                courseware.ProvideOrg       = int.Parse(hfProvideOrgID.Value);
                courseware.PublishDate      = DateTime.Parse(datePublishDate.DateValue.ToString());
                courseware.Authors          = txtAuthors.Text;
                courseware.Revisers         = txtRevisers.Text;
                courseware.KeyWord          = txtKeyWord.Text;
                courseware.Description      = txtDescription.Text;
                courseware.IsGroupLearder   = Convert.ToInt32(ddlIsGroup.SelectedValue);
                courseware.TechnicianTypeID = Convert.ToInt32(ddlTech.SelectedValue);
                courseware.OrderIndex       = Convert.ToInt32(hfOrderIndex.Value);

                strFullName = File1.FileName;                //直接取得文件名



                //strUrl = File1.PostedFile.FileName;//先取得全部的上传文件路径个名字,然后再利用SubString方法来得到用户名,现在看来是没有必要了


                //strContentType = File1.PostedFile.ContentType;//获取文件MIME内容类型
                //strFileType = strFullName.Substring(strFullName.LastIndexOf(".") + 1);//获取文件名字 . 后面的字符作为文件类型


                //strSize = File1.PostedFile.ContentLength.ToString();

                if (!string.IsNullOrEmpty(strFullName))
                {
                    FileInfo fi = new FileInfo(File1.FileName);

                    //如果是武汉,就判断只能上传.flv与.swf格式

                    //if (fi.Extension.ToLower() != ".flv" && fi.Extension.ToLower() != ".swf")
                    //{
                    //    SessionSet.PageMessage = "文件格式应为FLV或SWF视频! 现在格式为:" + fi.Extension.ToLower();
                    //    return;
                    //}

                    if (fi.Name.Replace(fi.Extension, "") != txtCoursewareName.Text)
                    {
                        SessionSet.PageMessage = "上传文件名与课件名不一致,请确认上传文件名!";
                        return;
                    }

                    if (File.Exists(Server.MapPath(courseware.Url)))
                    {
                        //string[] filelist = Directory.GetFileSystemEntries(Server.MapPath("../Online/Courseware/" + courseware.CoursewareID + "/"));
                        //foreach (string file in filelist)
                        //{
                        //    if(!Directory.Exists(file))
                        //    {
                        //        File.Delete(file);
                        //    }
                        //}
                        File.Delete(Server.MapPath(courseware.Url));
                    }

                    if (!Directory.Exists(Server.MapPath("../Online/Courseware/" + strCoursewareID)))
                    {
                        Directory.CreateDirectory(Server.MapPath("../Online/Courseware/" + strCoursewareID));
                    }

                    File1.SaveAs(Server.MapPath("../Online/Courseware/" + strCoursewareID + "/") + strFullName);                    //将文件保存在跟目录的UP文件夹下

                    courseware.Url = "/RailExamBao/Online/Courseware/" + strCoursewareID + "/" + strFullName;
                }
                courseware.Memo = txtMemo.Text;

                ArrayList al = new ArrayList();
                courseware.OrgIDAL = GetOrg(tvOrg.Nodes, al);

                ArrayList al1 = new ArrayList();

                foreach (TreeViewNode tn in tvPost.Nodes)
                {
                    if (tn.Checked)
                    {
                        al1.Add(tn.ID);
                    }

                    if (tn.Nodes.Count > 0)
                    {
                        foreach (TreeViewNode tns in tn.Nodes)
                        {
                            if (tns.Checked)
                            {
                                al1.Add(tns.ID);
                            }

                            if (tns.Nodes.Count > 0)
                            {
                                foreach (TreeViewNode tnss in tns.Nodes)
                                {
                                    if (tnss.Checked)
                                    {
                                        al1.Add(tnss.ID);
                                    }
                                }
                            }
                        }
                    }
                }
                courseware.PostIDAL = al1;

                ArrayList trainTypeIDList = new ArrayList();
                string[]  strType         = hfTrainTypeID.Value.Split(',');
                for (int i = 0; i < strType.Length; i++)
                {
                    if (!string.IsNullOrEmpty(strType[i]))
                    {
                        trainTypeIDList.Add(strType[i]);
                    }
                }
                courseware.TrainTypeIDAL = trainTypeIDList;

                coursewareBLL.UpdateCourseware(courseware);

                Response.Write("<script>window.opener.form1.Refresh.value='true';window.opener.form1.submit();window.close();</script>");
            }
        }