Example #1
0
        private void btnnoticeRemove_Click(object sender, EventArgs e)
        {
            if (dgvNotice.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请选择一行进行操作!");
                return;
            }
            NoticeId = Convert.ToInt16(dgvNotice.SelectedRows[0].Cells[0].Value);
            if (tboxNoticeContent.Text.Trim() == "")
            {
                MessageBox.Show("信息不能为空");
                return;
            }

            if (AdminManage.DelNotice(NoticeId))
            {
                MessageBox.Show("删除成功!");
                tboxNoticeContent.Text = "";
                //加载社团公告
                DataTable dt = AdminManage.GetNoticeList(id);
                dgvNotice.DataSource = dt;
                //失效设置红色
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (DateTime.Compare(Convert.ToDateTime(dt.Rows[i][3]), DateTime.Now) < 0)
                    {
                        dgvNotice.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                    }
                }
            }
            else
            {
                MessageBox.Show("公告删除失败!");
            }
        }