Ejemplo n.º 1
0
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="notify">文章的一个对象</param>
        public void AddNotifyInfo(AdminNotifyInfo notify)
        {
            try
            {
                string sql = "INSERT INTO usta_AdminNotifyInfo(notifyTitle,notifyContent,notifyTypeId,attachmentIds) VALUES(@notifyTitle,@notifyContent,@notifyTypeId,@attachmentIds)";
                SqlParameter[] parameters = {
                    new SqlParameter("@notifyTitle", SqlDbType.NChar,50),
                    new SqlParameter("@notifyContent", SqlDbType.NText),
                    new SqlParameter("@notifyTypeId", SqlDbType.Int,4),
                    new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200)
                    };
                parameters[0].Value = notify.notifyTitle;
                parameters[1].Value = notify.notifyContent;
                parameters[2].Value = notify.notifyTypeId;
                parameters[3].Value = notify.attachmentIds;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);
            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 2
0
    //第1个标签:结束
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ddlNotifyTypeChild.Items.Count == 0)
        {
            Javascript.GoHistory(-1, "请选择“" + ddlNotifyType.SelectedItem.Text + "”下的二级分类\n若无二级分类,请在文章类别管理页面添加相应地的二级分类", Page);
            return;
        }

        if (txtTitle.Text.Trim().Length == 0 || Textarea1.Value.Trim().Length == 0)
        {
            Javascript.GoHistory(-1, "标题和内容不能为空,请输入!", Page);
        }
        else
        {
            DalOperationAboutAdminNotify doan = new DalOperationAboutAdminNotify();
            AdminNotifyInfo notify = new AdminNotifyInfo();
            notify.notifyTitle = txtTitle.Text.Trim();
            notify.notifyContent = Textarea1.Value.Trim();
            notify.notifyTypeId = int.Parse(ddlNotifyTypeChild.SelectedValue);

            //以下提交附件的判断与相关操作
            if (hidAttachmentId.Value.CompareTo(string.Empty) != 0)
            {
                notify.attachmentIds = hidAttachmentId.Value;//保存了附件并且返回了attachmentId(自增长类型主键)
            }

            try
            {
                doan.AddNotifyInfo(notify);//保存通知
                //Javascript.ExcuteJavascriptCode("delBeforeUnloadEvent();", Page);
                Javascript.AlertAndRedirect("添加成功!", "/Common/NotifyList.aspx", Page);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                //Javascript.ExcuteJavascriptCode("delBeforeUnloadEvent();", Page);
                Javascript.GoHistory(-1, "添加失败,请检查格式是否有误!", Page);
            }
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 查询文章
        /// </summary>
        /// <param name="notityId"> 文章主键</param>
        /// <returns>一个文章对象</returns>
        public AdminNotifyInfo FindNotifyByNo(int notityId)
        {
            AdminNotifyInfo notify = null;
            string sql = "SELECT [adminNotifyInfoId],[notifyTitle] ,[notifyContent] ,[notifyTypeId],[updateTime] ,[attachmentIds] ,[isTop],[scanCount]  FROM [USTA].[dbo].[usta_AdminNotifyInfo] WHERE adminNotifyInfoId=@adminNotifyInfoId";
            SqlParameter[] parameters = new SqlParameter[1]{
                 new SqlParameter("@adminNotifyInfoId",notityId)
             };
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql,parameters);

            while (dr.Read())
            {
                notify = new AdminNotifyInfo();
                notify.adminNotifyInfoIds = dr["adminNotifyInfoId"].ToString();
                notify.notifyTitle = dr["notifyTitle"].ToString().Trim();
                notify.notifyContent = dr["notifyContent"].ToString().Trim();
                notify.notifyTypeId = int.Parse(dr["notifyTypeId"].ToString());
                notify.updateTime = DateTime.Parse(dr["updateTime"].ToString());
                notify.attachmentIds = dr["attachmentIds"].ToString();
                notify.isTop = int.Parse(dr["isTop"].ToString());
                notify.scanCount = int.Parse(dr["scanCount"].ToString());
            }

            dr.Close();
            conn.Close();
            return notify;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 修改文章
        /// </summary>
        /// <param name="notify">文章实体</param>
        public void UpdateNotifyInfo(AdminNotifyInfo notify)
        {
            try
            {
                string sql = "UPDATE usta_AdminNotifyInfo SET notifyTypeId=@notifyTypeId, notifyTitle=@notifyTitle, notifyContent=@notifyContent, attachmentIds=@attachmentIds, updateTime=@updateTime WHERE adminNotifyInfoId=@adminNotifyInfoId";
                SqlParameter[] parameters = {
                    new SqlParameter("@adminNotifyInfoId", SqlDbType.Int,4),
                    new SqlParameter("@notifyTitle", SqlDbType.NChar,50),
                    new SqlParameter("@notifyContent", SqlDbType.NText),
                    new SqlParameter("@notifyTypeId", SqlDbType.Int,4),
                    new SqlParameter("@updateTime", SqlDbType.DateTime),
                    new SqlParameter("@attachmentIds", SqlDbType.NVarChar,200)};
                parameters[0].Value = notify.adminNotifyInfoIds;
                parameters[1].Value = notify.notifyTitle;
                parameters[2].Value = notify.notifyContent;
                parameters[3].Value = notify.notifyTypeId;
                parameters[4].Value = notify.updateTime;
                parameters[5].Value = notify.attachmentIds;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);
            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 5
0
    //修改
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (ddlNotifyTypeChild.Items.Count == 0)
        {
            Javascript.GoHistory(-1, "请选择“" + ddlNotifyType.SelectedItem.Text + "”下的二级分类\n若无二级分类,请在文章类别管理页面添加相应地的二级分类", Page);
            return;
        }

        if (txtTitle.Text.Trim().Length == 0 || this.Textarea1.Value.Trim().Length == 0)
        {
            Javascript.GoHistory(-1, "标题和内容不能为空,请输入!", Page);
        }
        else
        {
            DalOperationAboutAdminNotify doan = new DalOperationAboutAdminNotify();
            AdminNotifyInfo notify = new AdminNotifyInfo();
            notify.adminNotifyInfoIds = notifyId.ToString();

            notify.notifyTitle = txtTitle.Text.Trim();
            notify.notifyContent = this.Textarea1.Value.Trim();
            notify.notifyTypeId = int.Parse(ddlNotifyTypeChild.SelectedValue.ToString().Trim());
            notify.attachmentIds = hidAttachmentId.Value;
            notify.updateTime = DateTime.Now;

            try
            {

                doan.UpdateNotifyInfo(notify);//修改
                Javascript.RefreshParentWindow("修改成功!", "/Administrator/NotifyInfoManage.aspx", Page);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                Javascript.GoHistory(-1, "修改失败,请检查格式是否有误!", Page);
            }

        }
    }