예제 #1
0
        public List<LabMS.Model.Announcement> GetLatest(int counts)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select  top ");
            sb.Append(counts);
            sb.Append(" [key],AnnouncementTitle,AnnouncementContent,PublishTime,ExpireTime,Importance,AttachmentPath,LabID,PublisherID from Announcement ");
            sb.Append(" where ExpireTime > getdate() ");
            sb.Append(" order by [key] desc");

            LabMS.Model.Announcement model;
            List<LabMS.Model.Announcement> notices = new List<LabMS.Model.Announcement>();

            System.Data.DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sb.ToString());

            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                model = new LabMS.Model.Announcement();

                if (row["key"].ToString() != "")
                {
                    model.key = int.Parse(row["key"].ToString());
                }
                model.AnnouncementTitle = row["AnnouncementTitle"].ToString();
                model.AnnouncementContent = row["AnnouncementContent"].ToString();
                if (row["PublishTime"].ToString() != "")
                {
                    model.PublishTime = DateTime.Parse(row["PublishTime"].ToString());
                }
                if (row["ExpireTime"].ToString() != "")
                {
                    model.ExpireTime = DateTime.Parse(row["ExpireTime"].ToString());
                }
                if (row["Importance"].ToString() != "")
                {
                    model.Importance = int.Parse(row["Importance"].ToString());
                }
                model.AttachmentPath = row["AttachmentPath"].ToString();
                if (row["LabID"].ToString() != "")
                {
                    model.LabID = int.Parse(row["LabID"].ToString());
                }
                if (row["PublisherID"].ToString() != "")
                {
                    model.PublisherID = int.Parse(row["PublisherID"].ToString());
                }

                notices.Add(model);
            }

            return notices;
        }
예제 #2
0
        protected void BtnSubmn_Click(object sender, EventArgs e)
        {
            DateTime dateExpire = DateTime.Now;

            #region validation

            if (string.IsNullOrEmpty(NoticeTitle.Text.Trim())) { WriteBackScript("alert('֪ͨ���ⲻ��Ϊ��!')"); return; }
            else if (NoticeTitle.Text.Length > 200) { WriteBackScript("alert('֪ͨ�������!')"); return; }

            if (string.IsNullOrEmpty(NoticeExpireTime.Text.Trim())) { WriteBackScript("alert('֪ͨʧЧʱ�䲻��Ϊ��!')"); return; }
            try
            {
                dateExpire = DateTime.Parse(NoticeExpireTime.Text);
                if (dateExpire <= DateTime.Now) { WriteBackScript("alert('֪ͨʧЧʱ������ڵ�ǰʱ��֮��!')"); return; }
            }
            catch { WriteBackScript("'֪ͨʧЧʱ��Ϊ�Ƿ���ʱ���ʽ!'"); return; }

            #endregion

            LabMS.BLL.Announcement notice = new LabMS.BLL.Announcement();
            LabMS.Model.Announcement noticeInfo = new LabMS.Model.Announcement();

            noticeInfo.AnnouncementTitle = NoticeTitle.Text;
            noticeInfo.ExpireTime = dateExpire;
            noticeInfo.Importance = (ImportanceValue.Value == "0") ? 0 : 1;
            noticeInfo.PublishTime = DateTime.Now;
            noticeInfo.AnnouncementContent = Server.HtmlEncode(NoticeContent.Text);

            noticeInfo.LabID = int.Parse(LabList.SelectedValue);
            noticeInfo.PublisherID = int.Parse(UserID);
            // TBD ����Ķ�֪ͨ�Ľ�ɫ��Ӧ

            #region Upload file

            if (NoticeAttachment.HasFile)
            {
                noticeInfo.AttachmentPath = "Attachment/" + Guid.NewGuid().ToString() + "." + ExtendBLL.FileUtility.GetFileExtension(NoticeAttachment.FileName);
                NoticeAttachment.SaveAs(Server.MapPath(noticeInfo.AttachmentPath));
            }

            #endregion

            noticeInfo.key = notice.Add(noticeInfo);

            WriteBackScript("alert('���֪ͨ�ɹ�!');window.location.href='list.aspx';");
        }
예제 #3
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Announcement GetModel(int key)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 [key],AnnouncementTitle,AnnouncementContent,PublishTime,ExpireTime,Importance,AttachmentPath,LabID,PublisherID from Announcement ");
            strSql.Append(" where [key]=@key ");
            SqlParameter[] parameters = {
                    new SqlParameter("@key", SqlDbType.Int,4)};
            parameters[0].Value = key;

            LabMS.Model.Announcement model = new LabMS.Model.Announcement();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["key"].ToString() != "")
                {
                    model.key = int.Parse(ds.Tables[0].Rows[0]["key"].ToString());
                }
                model.AnnouncementTitle = ds.Tables[0].Rows[0]["AnnouncementTitle"].ToString();
                model.AnnouncementContent = ds.Tables[0].Rows[0]["AnnouncementContent"].ToString();
                if (ds.Tables[0].Rows[0]["PublishTime"].ToString() != "")
                {
                    model.PublishTime = DateTime.Parse(ds.Tables[0].Rows[0]["PublishTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExpireTime"].ToString() != "")
                {
                    model.ExpireTime = DateTime.Parse(ds.Tables[0].Rows[0]["ExpireTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Importance"].ToString() != "")
                {
                    model.Importance = int.Parse(ds.Tables[0].Rows[0]["Importance"].ToString());
                }
                model.AttachmentPath = ds.Tables[0].Rows[0]["AttachmentPath"].ToString();
                if (ds.Tables[0].Rows[0]["LabID"].ToString() != "")
                {
                    model.LabID = int.Parse(ds.Tables[0].Rows[0]["LabID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PublisherID"].ToString() != "")
                {
                    model.PublisherID = int.Parse(ds.Tables[0].Rows[0]["PublisherID"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }