Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxTitle.Text))
            {
                ShowNotify("请输入公告主题");
                return;
            }
            int announceID = Change.ToInt(tbxAnnounceID.Text);

            Infobasis.Data.DataEntity.Announcement announcement = null;
            if (announceID > 0)
            {
                announcement = DB.Announcements.Find(announceID);
            }
            else
            {
                announcement      = new Infobasis.Data.DataEntity.Announcement();
                announcement.Code = GenerateNum("Ann");
            }

            announcement.Title       = tbxTitle.Text;
            announcement.PublisherID = UserInfo.Current.ID;
            announcement.PublishDate = Change.ToDateTime(tbxPublishDate.Text);
            if (Change.ToDateTime(tbxEndDate.Text) != DateTime.MinValue)
            {
                announcement.EndDate = Change.ToDateTime(tbxEndDate.Text);
            }
            announcement.Publisher        = UserInfo.Current.ChineseName;
            announcement.Note             = tbxContentHtml.Text;
            announcement.CreateByID       = UserInfo.Current.ID;
            announcement.CreateByName     = UserInfo.Current.ChineseName;
            announcement.AnnounceTypeID   = DropDownAnnounceType.SelectedValue;
            announcement.AnnounceTypeName = DropDownAnnounceType.SelectedText;

            if (announceID == 0)
            {
                DB.Announcements.Add(announcement);
            }

            if (SaveChanges())
            {
                ShowNotify("保存成功");
                tbxAnnounceID.Text = Change.ToString(announcement.ID);
            }
            else
            {
                ShowNotify("保存失败");
            }
        }
Exemplo n.º 2
0
        private void LoadData()
        {
            btnClose.OnClientClick = ActiveWindow.GetHideReference();

            int id = GetQueryIntValue("id");

            Infobasis.Data.DataEntity.Announcement current = DB.Announcements
                                                             .Where(u => u.ID == id).FirstOrDefault();
            if (current == null)
            {
                // 参数错误,首先弹出Alert对话框然后关闭弹出窗口
                Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference());
                return;
            }

            labTitle.Text       = current.Title;
            labNote.Text        = current.Note;
            labPublisher.Text   = current.Publisher;
            labPublishDate.Text = current.PublishDate.ToString("yyyy-MM-dd hh:mm:ss");
        }