Beispiel #1
0
        protected void imbEdit_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                var notice = NoticeBiz.GetNotice(((ImageButton)sender).CommandArgument);
                txtNoticeIdEdit.Text       = notice.NoticeId.ToString();
                txtTopicEdit.Text          = notice.Topic;
                rbActiveEdit.Checked       = notice.ActiveStatus == "Y" ? true : false;
                rbInactiveEdit.Checked     = notice.ActiveStatus == "Y" ? false : true;
                txtEditAttachFileFlag.Text = "";

                if (!string.IsNullOrEmpty(notice.ImageName))
                {
                    lbAttachImageEdit.Text              = notice.ImageName;
                    lbAttachImageEdit.OnClientClick     = AppUtil.GetNoticeDownloadScript(Page, notice.ImageVirtualPath, "preview");
                    lbAttachImageEdit.CommandArgument   = notice.ImagePhysicalPath; //เก็บไว้ใช้ตอนลบไฟล์
                    divImageInfoEdit.Style["display"]   = "block";
                    divImageUploadEdit.Style["display"] = "none";
                }
                else
                {
                    divImageInfoEdit.Style["display"]   = "none";
                    divImageUploadEdit.Style["display"] = "block";
                }

                if (!string.IsNullOrEmpty(notice.FileName))
                {
                    lbAttachFileEdit.Text              = notice.FileName;
                    lbAttachFileEdit.OnClientClick     = AppUtil.GetNoticeDownloadScript(Page, notice.FileVirtualPath, "downlaodfile");
                    lbAttachFileEdit.CommandArgument   = notice.FilePhysicalPath;   //เก็บไว้ใช้ตอนลบไฟล์
                    divFileInfoEdit.Style["display"]   = "block";
                    divFileUploadEdit.Style["display"] = "none";
                }
                else
                {
                    divFileInfoEdit.Style["display"]   = "none";
                    divFileUploadEdit.Style["display"] = "block";
                    txtEditAttachFileFlag.Text         = "edit";
                }

                mpePopupEdit.Show();
            }
            catch (Exception ex)
            {
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                _log.Debug(message);
                AppUtil.ClientAlert(Page, message);
            }
        }
        private void DisplayNotice()
        {
            try
            {
                Random rnd  = new Random();
                var    list = NoticeBiz.GetNoticeIdList();
                if (list.Count > 0)
                {
                    int index  = rnd.Next(0, list.Count);       //creates a number between 0 and list.Count - 1
                    var notice = NoticeBiz.GetNotice(list[index].ToString());

                    lblNoticeTopic.Text = notice.Topic;
                    imgNotice.ImageUrl  = Page.ResolveUrl("~" + notice.ImageVirtualPath);

                    if (!string.IsNullOrEmpty(notice.FileName))
                    {
                        imbNoticeDownload.Visible       = true;
                        imbNoticeDownload.OnClientClick = AppUtil.GetNoticeDownloadScript(Page, notice.FileVirtualPath, "downloadfile");

                        //lbNoticeDownload.Text = notice.FileName;
                        //lbNoticeDownload.OnClientClick = AppUtil.GetNoticeDownloadScript(Page, notice.FileVirtualPath, "downloadfile");
                    }
                    else
                    {
                        imbNoticeDownload.Visible = false;
                        //lbNoticeDownload.Text = "ไม่พบไฟล์เอกสาร";
                        //lbNoticeDownload.Enabled = false;
                    }
                }
                else
                {
                    trNoticeDownload.Visible    = false;
                    trNoticeDownloadAll.Visible = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }