Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strCoursewareID = Request.QueryString.Get("id");

                CoursewareBLL             objBll = new CoursewareBLL();
                RailExam.Model.Courseware obj    = objBll.GetCourseware(Convert.ToInt32(strCoursewareID));

                hfUrl.Value = obj.Url;
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strCoursewareID = Request.QueryString.Get("id");

                CoursewareBLL             objBll = new CoursewareBLL();
                RailExam.Model.Courseware obj    = objBll.GetCourseware(Convert.ToInt32(strCoursewareID));

                string   strFileName = obj.Url.Replace("/RailExamBao/Online/Courseware/" + obj.CoursewareID + "/", "");
                FileInfo f           = new FileInfo(strFileName);

                //下载文件的路径
                string path = Server.MapPath(obj.Url);

                //下载文件的名称
                string filename = f.Name;

                System.IO.FileInfo toDownload = new System.IO.FileInfo(path);

                if (toDownload.Exists == true)
                {
                    const long ChunkSize = 10000;
                    byte[]     buffer    = new byte[ChunkSize];

                    Response.Clear();
                    System.IO.FileStream iStream = System.IO.File.OpenRead(path);
                    long dataLengthToRead        = iStream.Length;
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment; filename=new_" + HttpUtility.UrlEncode(toDownload.Name));
                    while (dataLengthToRead > 0 && Response.IsClientConnected)
                    {
                        int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize));
                        Response.OutputStream.Write(buffer, 0, lengthRead);
                        Response.Flush();
                        dataLengthToRead = dataLengthToRead - lengthRead;
                    }
                    iStream.Close();
                    Response.Close();
                }
            }
        }
Exemplo n.º 3
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Request.QueryString.Get("TrainTypeID") != null)
            {
                int bookID      = Convert.ToInt32(Request.QueryString.Get("CoursewareID"));
                int trainTypeID = Convert.ToInt32(Request.QueryString.Get("TrainTypeID"));
                CoursewareTrainTypeBLL objBll = new CoursewareTrainTypeBLL();
                CoursewareTrainType    obj    = objBll.GetCoursewareTrainType(bookID, trainTypeID);
                int order = Convert.ToInt32(txtOrderIndex.Text);
                int max   = Convert.ToInt32(Request.QueryString.Get("MaxOrder"));
                if (order > max)
                {
                    obj.OrderIndex = max;
                }
                else
                {
                    obj.OrderIndex = order;
                }
                objBll.UpdateCoursewareTrainType(obj);
            }
            else
            {
                CoursewareBLL             objBll = new CoursewareBLL();
                RailExam.Model.Courseware obj    = objBll.GetCourseware(Convert.ToInt32(Request.QueryString.Get("CoursewareID")));
                int order = Convert.ToInt32(txtOrderIndex.Text);
                int max   = Convert.ToInt32(Request.QueryString.Get("MaxOrder"));
                if (order > max)
                {
                    obj.OrderIndex = max;
                }
                else
                {
                    obj.OrderIndex = order;
                }
                objBll.UpdateCourseware(obj);
            }

            Response.Write("<script>top.returnValue='true';window.close();</script>");
        }