示例#1
0
    void btnSave_Click(object sender, EventArgs e)
    {
        bool isValid = true;

        try
        {
            MyComponent.Entities.Content content = BLL.GetContentById(Convert.ToInt32(ddlAllContents.SelectedValue));
            if (content != null)
            {
                content.CourseId     = Convert.ToInt32(ddlCourses.SelectedValue);
                content.LevelId      = Convert.ToInt32(ddlLevel.SelectedValue);
                content.AcademicYear = ddlAcademicYear.SelectedValue;
                content.Semester     = Convert.ToInt32(ddlSemester.SelectedValue);
            }
            BLL.UpdateContent(content);
            FillContent();
            SetAlert(operationMessage);
        }
        catch (Exception ex)
        {
            isValid = false;
            Response.Write(ex.ToString());
        }
        finally
        {
            if (!isValid)
            {
                SetAlert("حدث خطأ لا يمكن المتابعة");
            }
        }
    }
示例#2
0
    void lbtnDownload_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["Cid"]))
        {
            int contentId = 0;

            if (int.TryParse(Request.QueryString["Cid"], out contentId))
            {
                if (contentId > 0)
                {
                    MyComponent.Entities.Content content = BLL.GetContentById(contentId);

                    if (content != null)
                    {
                        string filePath = Server.MapPath("~/Questions/" + content.FileNamePath);
                        // string strURL = txtFileName.Text;
                        WebClient    req      = new WebClient();
                        HttpResponse response = HttpContext.Current.Response;
                        response.Clear();
                        response.ClearContent();
                        response.ClearHeaders();
                        response.Buffer = true;
                        response.AddHeader("Content-Disposition", "attachment;filename=\"" + content.FileName +
                                           Path.GetExtension(content.FileNamePath) + "\"");
                        byte[] data = req.DownloadData(Server.MapPath("../../Questions/" + content.FileNamePath));
                        response.BinaryWrite(data);
                        BLL.IncreaseContentDownLoadCount(contentId);
                        response.End();
                    }
                }
            }
        }
    }
示例#3
0
    void btnSave_Click(object sender, EventArgs e)
    {
        MyComponent.Entities.Content content = new MyComponent.Entities.Content();
        content.FileName     = TextFileName.Text;
        content.Semester     = Convert.ToInt32(ddlSemester.SelectedValue);
        content.SpecialtyId  = Convert.ToInt32(ddlSpecialty.SelectedValue);
        content.PublishDate  = DateTime.Now;
        content.AcademicYear = ddlAcademicYear.SelectedValue;
        content.WriterId     = Convert.ToInt32(Session["SecureAdminSite"]);
        content.Type         = (int)MyComponent.Enums.ContentType.PreviousTests;

        bool fileSizePassed = true;

        if (FUpTest.PostedFile != null)
        {
            if (FUpTest.PostedFile != null)
            {
                int    maxFileSize = Convert.ToInt32(ConfigurationManager.AppSettings["MaxFileSize"].ToString());
                string extension   = Path.GetExtension(FUpTest.PostedFile.FileName);
                string fileName    = Guid.NewGuid().ToString() + extension;
                string path        = Server.MapPath("~/Questions/");
                FUpTest.SaveAs(path + fileName);
                content.FileNamePath = fileName;
                content.LevelId      = Convert.ToInt32(ddlCourseLevelsAdd.SelectedValue);
                content.CourseId     = Convert.ToInt32(ddlCoursesAdd.SelectedValue);
            }
            else
            {
                fileSizePassed = false;
            }
        }

        if (fileSizePassed)
        {
            BLL.AddContent(content);
            SetAlert(operationMessage);
        }
        else
        {
            SetAlert(maxFileSizeExceeds);
        }
    }