Exemple #1
0
        private void btnCorRes_Click(object sender, EventArgs e)
        {
            if (Imgbytes.Length == 1)
            {
                MessageBox.Show("请选择一张图片");
                return;
            }
            if (tboxCorName.Text.Trim() == "" || tboxPropri.Text.Trim() == "" || tboxIntro.Text.Trim() == "" || tboxNotice.Text.Trim() == "")
            {
                MessageBox.Show("信息为空!");
            }
            else
            {
                //根据类别名称获取社团类别ID
                int CorTypeId = 1;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    cboxCorType.Items.Add(dt.Rows[i][0].ToString());
                    if (dt.Rows[i][0].ToString() == cboxCorType.Text)
                    {
                        CorTypeId = (int)dt.Rows[i][1];
                    }
                }
                //获取当前时间
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //获取公告有效期
                string noticeDate = dtpNoticeDate.Value.ToString();

                Cor c = new Cor(CorTypeId, tboxCorName.Text.Trim(), time, int.Parse(tboxPropri.Text), tboxIntro.Text.Trim(), Imgbytes);
                if (AdminManage.CorAdd(c))
                {
                    //添加社长成为该社团的成员
                    //社团id
                    int CorId = AdminManage.FindCorId();
                    if (AdminManage.UserCorIdUpdate(int.Parse(tboxPropri.Text), CorId))
                    {
                        Notice n = new Notice(CorId, tboxNotice.Text, time, noticeDate);
                        //添加公告到公告表
                        if (AdminManage.AddNotice(n))
                        {
                            MessageBox.Show("添加成功!");
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("公告添加失败!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("添加失败!");
                }
            }
        }
Exemple #2
0
        private void btnNoticeAdd_Click(object sender, EventArgs e)
        {
            if (tboxNoticeContent.Text.Trim() == "")
            {
                MessageBox.Show("信息不能为空");
                return;
            }
            //获取日期
            string noticeBeginDate = dtpBeginTime.Value.ToString();
            string noticeEndDate   = dtpTimeEnd.Value.ToString();

            //判断失效日期不能小于当前时间
            if (DateTime.Compare(dtpTimeEnd.Value, DateTime.Now) < 0)
            {
                MessageBox.Show("失效时间不能小于当前日期");
                return;
            }
            //获取内容
            string NoticeContent = tboxNoticeContent.Text;

            Notice n = new Notice(id, NoticeContent, noticeBeginDate, noticeEndDate);

            //添加公告到公告表
            if (AdminManage.AddNotice(n))
            {
                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("公告添加失败!");
            }
        }