예제 #1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Title = "Карточка публикации - LeadForce";

            var fsp = new FileSystemProvider();

            if (Page.RouteData.Values["id"] != null)
            {
                _publicationID = Guid.Parse(Page.RouteData.Values["id"] as string);
            }


            hlCancel.NavigateUrl = UrlsData.AP_Publications();


            if (!Page.IsPostBack)
            {
                BindData();
            }

            radAjaxManager = RadAjaxManager.GetCurrent(Page);
            radAjaxManager.AjaxSettings.AddAjaxSetting(RadUpload1, rbiImage);

            radAjaxManager.AjaxSettings.AddAjaxSetting(rcbPublicationType, rcbPublicationStatus, null, UpdatePanelRenderMode.Inline);
            radAjaxManager.AjaxSettings.AddAjaxSetting(rcbPublicationType, ddlAccessRecord, null, UpdatePanelRenderMode.Inline);
            radAjaxManager.AjaxSettings.AddAjaxSetting(rcbPublicationType, ddlAccessComment, null, UpdatePanelRenderMode.Inline);
            radAjaxManager.AjaxSettings.AddAjaxSetting(ddlAccessRecord, plCompany, null, UpdatePanelRenderMode.Inline);

            tagsPublication.ObjectID = _publicationID;
        }
예제 #2
0
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            tbl_Publication publicationData = DataManager.Publication.SelectById(SiteId, _publicationID) ?? new tbl_Publication();

            publicationData.Title                 = txtTitle.Text;
            publicationData.Code                  = txtCode.Text;
            publicationData.Date                  = rdpDate.SelectedDate;
            publicationData.AuthorID              = (Guid)ucAuthor.SelectedValue;
            publicationData.PublicationStatusID   = Guid.Parse(rcbPublicationStatus.SelectedValue);
            publicationData.PublicationCategoryID = sccPublicationCategory.SelectedCategoryId;
            publicationData.PublicationTypeID     = Guid.Parse(rcbPublicationType.SelectedValue);
            publicationData.Noun                  = txtNoun.Text;
            publicationData.Text                  = ucHtmlEditor.Content;
            publicationData.SiteID                = SiteId;
            publicationData.AccessRecord          = int.Parse(ddlAccessRecord.SelectedValue);
            publicationData.AccessComment         = int.Parse(ddlAccessComment.SelectedValue);

            if (publicationData.AccessRecord == (int)PublicationAccessRecord.Company)
            {
                publicationData.AccessCompanyID = ucCompany.SelectedValue;
            }
            else
            {
                publicationData.AccessCompanyID = null;
            }

            if (RadUpload1.UploadedFiles.Count > 0)
            {
                byte[] imageData = new byte[RadUpload1.UploadedFiles[0].InputStream.Length];
                RadUpload1.UploadedFiles[0].InputStream.Read(imageData, 0, (int)RadUpload1.UploadedFiles[0].InputStream.Length);
                publicationData.Img = imageData;
            }

            var fsp = new FileSystemProvider();

            if (!string.IsNullOrEmpty(publicationData.FileName))
            {
                fsp.Delete(CurrentUser.Instance.SiteID, "Publications", publicationData.FileName, FileType.Attachment);
            }

            string fileName = null;

            if (RadUpload2.UploadedFiles.Count > 0)
            {
                fileName = fsp.Upload(CurrentUser.Instance.SiteID, "Publications", RadUpload2.UploadedFiles[0].FileName, RadUpload2.UploadedFiles[0].InputStream, FileType.Attachment);
            }

            publicationData.FileName = fileName;

            if (publicationData.ID == Guid.Empty)
            {
                DataManager.Publication.Add(publicationData);
            }
            else
            {
                DataManager.Publication.Update(publicationData);
            }

            RelatedPublication.Save(publicationData.ID);
            PublicationTerms.Save(publicationData.ID);
            PublicationComment.Save(publicationData.ID);
            PublicationMark.Save(publicationData.ID);

            Response.Redirect(UrlsData.AP_Publications());
        }