Exemple #1
0
        void AddNotice(object parameter)
        {
            SelectedNotice = null; // Unselects last selection. Essential, as assignment below won't clear other control's SelectedItems
            var notice = new Model.Notice();

            SelectedNotice = notice;
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //判断标题是否为空
            if (txtTitle.Text == "")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('标题内容为空,请输入标题内容!');</script>");
            }
            //判断内容是否为空
            else if (ftbContent.Text == "")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('公告内容为空,请输入公告内容!');</script>");
            }
            else
            {
                string       title   = txtTitle.Text.Trim();
                string       content = ftbContent.Text.Trim();
                int          aid     = Convert.ToInt32(Session["admin"].ToString());
                Model.Notice n       = new Model.Notice(title, content, aid);

                BLL.NoticeManager nm = new BLL.NoticeManager();
                bool b = nm.Insert(n);
                if (b)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('公告添加成功!');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('公告添加失败,请联系管理员!');</script>");
                }
                //清空标题和内容
                txtTitle.Text   = "";
                ftbContent.Text = "";
            }
        }
        private static string AddNotice()
        {
            string strreturn;
            string strTitle   = NetSchool.Common.Library.GetPostBack.GetPostBackStr("title");
            string strContent = Microsoft.JScript.GlobalObject.unescape(NetSchool.Common.Library.GetPostBack.GetPostBackStr("content"));

            NetSchool.Model.Notice noticeInfo = new Model.Notice();
            noticeInfo.NoticeID   = Guid.NewGuid();
            noticeInfo.Title      = strTitle;
            noticeInfo.Content    = strContent;
            noticeInfo.ViewNum    = 0;
            noticeInfo.Author     = NetSchool.Common.Info.CurUserInfo.Username;
            noticeInfo.CreateTime = DateTime.Now;
            noticeInfo.EditTime   = DateTime.Now;

            if (NetSchool.BLL.Notice.Add(noticeInfo))
            {
                strreturn = JsonConvert.SerializeObject(new { state = "success", msg = "OK" }, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                });
            }
            else
            {
                strreturn = JsonConvert.SerializeObject(new { state = "error", msg = "插入失败" }, new Newtonsoft.Json.Converters.IsoDateTimeConverter()
                {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                });
            }
            return(strreturn);
        }
Exemple #4
0
        /// <summary>
        /// 更新某条公告的内容。
        /// </summary>
        /// <param name="noti">公告对象</param>
        /// <returns>通过布尔类型判断操作是否成功.</returns>
        public bool updateNotice(Model.Notice noti)
        {
            string sqltext               = "update notice set subject=@subject,title=@title,body=@body,userId=@userId,createTime=@createTime,publishTime=@publishTime where noticeId=@noticeId";
            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara1 = new SqlParameter("@noticeId", noti.NoticeId);
            SqlParameter        sqlpara2 = new SqlParameter("@subject", noti.Subject);
            SqlParameter        sqlpara3 = new SqlParameter("@title", noti.Title);
            SqlParameter        sqlpara4 = new SqlParameter("@body", noti.Body);
            SqlParameter        sqlpara5 = new SqlParameter("@userId", noti.SysUser.UserId);
            SqlParameter        sqlpara6 = new SqlParameter("@createTime", noti.CreateTime.ToString());
            SqlParameter        sqlpara7 = new SqlParameter("@publishTime", noti.UpdateTime.ToString());

            para.Add(sqlpara2);
            para.Add(sqlpara3);
            para.Add(sqlpara4);
            para.Add(sqlpara5);
            para.Add(sqlpara6);
            para.Add(sqlpara7);
            para.Add(sqlpara1);
            int i = DBTools.exenonquerySQL(sqltext, para);

            if (i == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        private static Model.Notice TranEntity(DataRow dr)
        {
            Model.Notice model = new Model.Notice();

            if (dr["ID"] != null)
            {
                model.ID = int.Parse(dr["ID"].ToString());
            }
            if (dr["NTitle"] != null)
            {
                model.NTitle = dr["NTitle"].ToString();
            }
            if (dr["NContent"] != null)
            {
                model.NContent = dr["NContent"].ToString();
            }
            if (dr["NClicks"].ToString() != "")
            {
                model.NClicks = int.Parse(dr["NClicks"].ToString());
            }
            if (dr["NState"].ToString() != "")
            {
                model.NState = bool.Parse(dr["NState"].ToString());
            }
            if (dr["NCreateTime"].ToString() != "")
            {
                model.NCreateTime = DateTime.Parse(dr["NCreateTime"].ToString());
            }
            if (dr["IsFixed"].ToString() != "")
            {
                model.IsFixed = bool.Parse(dr["IsFixed"].ToString());
            }
            return(model);
        }
Exemple #6
0
        /// <summary>
        /// 添加一条公告。
        /// </summary>
        public bool addNotice(Model.Notice notice)
        {
            string sqltext = "insert notice(noticeId,subject,title,body,userId,createTime,publishTime) values(@noticeId,@subject,@title,@body,@userId,@createTime,@publishTime)";
            string maxid   = DBTools.searchID("notice", "noticeId");
            int    id      = maxid != null?int.Parse(maxid) : 0;

            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara1 = new SqlParameter("@noticeId", (id + 1).ToString());
            SqlParameter        sqlpara2 = new SqlParameter("@subject", notice.Subject);
            SqlParameter        sqlpara3 = new SqlParameter("@title", notice.Title);
            SqlParameter        sqlpara4 = new SqlParameter("@body", notice.Body);
            SqlParameter        sqlpara5 = new SqlParameter("@userId", notice.SysUser.UserId);
            SqlParameter        sqlpara6 = new SqlParameter("@createTime", notice.CreateTime.ToString());
            SqlParameter        sqlpara7 = new SqlParameter("@publishTime", notice.UpdateTime.ToString());

            para.Add(sqlpara1);
            para.Add(sqlpara2);
            para.Add(sqlpara3);
            para.Add(sqlpara4);
            para.Add(sqlpara5);
            para.Add(sqlpara6);
            para.Add(sqlpara7);

            int i = DBTools.exenonquerySQL(sqltext, para);

            if (i == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
        public static bool Add(Model.Notice model)
        {
            string sb = " Update Notice set IsFixed=0; ";

            if (!model.IsFixed)
            {
                sb = "";
            }
            sb = "insert into Notice(NTitle,NContent,IsFixed) values (@NTitle,@NContent,@IsFixed)";
            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@NTitle", SqlDbType.NVarChar, 200),
                new SqlParameter("@NContent", SqlDbType.Text),
                new SqlParameter("@IsFixed", SqlDbType.Bit, 1)
            };

            para[0].Value = model.NTitle;
            para[1].Value = model.NContent;
            para[2].Value = model.IsFixed;
            if (DbHelperSQL.ExecuteSql(sb, para) > 0)
            {
                return(true);
            }
            return(false);
        }
Exemple #8
0
        /// <summary>
        /// 根据ID获取某条公告。
        /// </summary>
        /// <param name="iid">公告id</param>
        public Model.Notice getNoticeById(string iid)
        {
            Model.Notice        notice   = null;
            string              sqltext  = "select * from notice where noticeId=@noticeId";
            List <SqlParameter> para     = new List <SqlParameter>();
            SqlParameter        sqlpara1 = new SqlParameter("@noticeId", iid);

            para.Add(sqlpara1);
            SqlDataReader sdr = DBTools.exereaderSQL(sqltext, para);

            while (sdr.Read())
            {
                notice            = new Model.Notice();
                notice.NoticeId   = sdr["noticeId"].ToString();
                notice.Subject    = sdr["subject"].ToString();
                notice.Title      = sdr["title"].ToString();
                notice.Body       = sdr["body"].ToString();
                notice.SysUser    = new DAL.SysUserDAO().getUserById(sdr["userId"].ToString());
                notice.CreateTime = DateTime.Parse(sdr["createTime"].ToString());
                notice.UpdateTime = DateTime.Parse(sdr["publishTime"].ToString());
            }
            sdr.Close();
            DBTools.DBClose();
            return(notice);
        }
Exemple #9
0
        public static bool Update(Model.Notice model)
        {
            string sb = " Update Notice set IsFixed=0; ";

            if (!model.IsFixed)
            {
                sb = "";
            }
            sb += "Update Notice set NTitle=@NTitle,NContent=@NContent,NState=@NState,IsFixed=@IsFixed where ID=@ID";
            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@NTitle", SqlDbType.NVarChar, 200),
                new SqlParameter("@NContent", SqlDbType.Text),
                new SqlParameter("@NState", SqlDbType.Bit),
                new SqlParameter("@ID", SqlDbType.Int, 4),
                new SqlParameter("@IsFixed", SqlDbType.Bit, 4)
            };

            para[0].Value = model.NTitle;
            para[1].Value = model.NContent;
            para[2].Value = model.NState;
            para[3].Value = model.ID;
            para[4].Value = model.IsFixed;

            if (DbHelperSQL.ExecuteSql(sb, para) > 0)
            {
                return(true);
            }
            return(false);
        }
Exemple #10
0
        protected override void SetPowerZone()
        {
            List <Model.Notice> listnotice = BLL.Notice.GetNoticeList(" IsFixed = 1 ");

            if (listnotice.Count > 0)
            {
                Model.Notice notice = listnotice[0];
                noticecontent = GetKeyName(notice.NContent);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         BLL.NoticeManager m = new BLL.NoticeManager();
         Model.Notice      n = m.SelectNotice();
         lblTitle.Text      = n.Title;
         lblContent.Text    = n.Content;
         lblCreateTime.Text = n.CreateTime;
     }
 }
Exemple #12
0
        /// <summary>
        /// 选择一条最新公告
        /// </summary>
        /// <returns></returns>
        public Model.Notice SelectNotice()
        {
            Model.Notice n       = new Model.Notice();
            DataTable    dt      = new DataTable();
            string       cmdText = "SelectNewNotice";

            dt           = sqlhelper.ExecuteQuery(cmdText, CommandType.StoredProcedure);
            n.Title      = dt.Rows[0]["title"].ToString();
            n.Content    = dt.Rows[0]["content"].ToString();
            n.CreateTime = dt.Rows[0]["createTime"].ToString();
            return(n);
        }
Exemple #13
0
 protected override void SetPowerZone()
 {
     notice = BLL.Notice.GetTopNotice();
     if (Convert.ToDateTime(TModel.ValidTime).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd") && notice != null)            //当天第一次登陆
     {
         isnotice2.Value = "1";
         BLL.CommonBase.GetSingle(string.Format("update member set validtime='{0}' where mid='{1}'", DateTime.Now, TModel.MID));
         noticeid3.Value = notice.ID.ToString();
     }
     else
     {
         isnotice2.Value = "0";
     }
 }
Exemple #14
0
        public int Add(Model.Notice[] Allmodel)
        {
            int n = 0;

            for (int i = 0; i < Allmodel.Length; i++)
            {
                Model.Notice model = new Model.Notice();
                model = Allmodel[i];
                if (Exist(model.Link) == false)
                {
                    n += Add(model);
                }
            }
            return(n);
        }
Exemple #15
0
        public int Update(string Department, string Type)
        {
            Dictionary <string, string> dict = RegEx(Department, Type);
            string       MoreLink            = dict["MoreLink"].ToString();
            string       pattern             = dict["RuleStr"].ToString();
            string       Encode  = dict["Encode"].ToString();
            string       UrlMain = dict["PublicLink"].ToString();
            string       Parse   = dict["Parse"].ToString();
            SpiderNotice spider  = new SpiderNotice(MoreLink, pattern, UrlMain, Department, Type);

            spider.encode = Encode;
            spider.parse  = Parse;
            spider.Get();
            Model.Notice[] AllNotice = new Model.Notice[spider.Count()];
            AllNotice = spider.GetAll();
            return(dal.Add(AllNotice));
        }
Exemple #16
0
        public static Model.Notice GetNewNotice(int days)
        {
            string sb = "select top 1 * from Notice where NState='1' and IsFixed='1' order by ID desc";

            DataSet ds = DbHelperSQL.Query(sb);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Model.Notice model = TranEntity(ds.Tables[0].Rows[0]);
                model.NContent = CheckStr(model.NContent);
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #17
0
        public static Model.Notice GetTopNotice()
        {
            string sb = "select top 1 * from Notice where NState='1' order by IsFixed desc,NCreateTime desc";

            DataSet ds = DbHelperSQL.Query(sb);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Model.Notice model = TranEntity(ds.Tables[0].Rows[0]);
                model.NContent = CheckStr(model.NContent) + "[" + model.NCreateTime.ToShortDateString() + "]";
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #18
0
        public static Model.Notice GetNewNotice(int days)
        {
            string sb = "select top 1 * from Notice where NState='1' and IsFixed = 1 and NCreateTime > CONVERT(varchar(10),DATEADD(DD," + -days + ",GETDATE()),120) order by ID desc";

            DataSet ds = DbHelperSQL.Query(sb);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Model.Notice model = TranEntity(ds.Tables[0].Rows[0]);
                model.NContent = CheckStr(model.NContent);
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #19
0
        /// <summary>
        /// 添加公告
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public bool Insert(Model.Notice n)
        {
            bool   flag    = false;
            string cmdText = "addNotice";

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@title", n.Title),
                new SqlParameter("@content", n.Content),
                new SqlParameter("@aid", n.Aid)
            };
            int res = sqlhelper.ExecuteNonQuery(cmdText, paras, CommandType.StoredProcedure);

            if (res > 0)
            {
                flag = true;
            }
            return(flag);
        }
Exemple #20
0
        protected DataTable dtjjlist  = null;//
        protected override void SetPowerZone()
        {
            dtjjlist = BLL.CommonBase.GetTable("select tomid,sum(case when changetype='R_LD' then money else 0 end) as 'R_LD',sum(case when changetype='R_TJ' then money else 0 end) as 'R_TJ',sum(case when changetype='R_RFH' then money else 0 end) as 'R_RFH',sum(money) as 'HeJi',CONVERT(varchar(7), changedate, 23) as 'Date' from changemoney a WHERE  changetype in ('R_TJ','R_LD','R_RFH') and a.ToMID='" + TModel.MID + "'  group by CONVERT(varchar(7), changedate, 23),tomid order by CONVERT(varchar(7), changedate, 23) DESC;");

            List <Model.Notice> listnotice = BLL.Notice.GetNoticeList(" IsFixed = 1 ");

            if (listnotice.Count > 0)
            {
                notice = listnotice[0];
            }

            fhtotal = Convert.ToDecimal(BLL.CommonBase.GetSingle("select ISNULL(SUM(Money),0) from ChangeMoney where ToMID='" + TModel.MID + "' and ChangeType in('R_RFH') and CState=1;"));

            listPowers = TModel.Role.PowersList.Where(emp => emp.Content.VState).ToList();
            //txtTuiGuang.Value = HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/Regedit/Index.aspx");
            //txtTuiGuang.Value += "?mid=" + TModel.MID;
            //tuiguang = txtTuiGuang.Value;

            roleName = TModel.Role.RName;

            if (TModel.Role.IsAdmin)
            {
                yjMoney = BLL.Member.GetSum("YJMoney", string.Format(" MTJ = '{0}' and MID <> '{0}' ", TModel.MID));
            }
            else
            {
                yjMoney = TModel.MConfig.YJMoney;
            }

            Model.Notice obj = BLL.Notice.GetNewNotice(9999);
            if (obj != null)
            {
                notcie = obj.NContent;
            }

            //repNoticeList.DataSource = BLL.Notice.GetNoticeList(" IsFixed = 0 ");
            //repNoticeList.DataBind();
            //mTJ = BllModel.GetModel(TModel.MTJ);
            //if (mTJ == null || mTJ.MID == TModel.MID)
            //{
            //    mTJ = new Model.Member();
            //}
        }
Exemple #21
0
        /// <summary>
        /// 获取所有的公告对象。
        /// </summary>
        public List <Model.Notice> getAllNotices()
        {
            List <Model.Notice> notice = new List <Model.Notice>();
            string        sqltext      = "select * from notice";
            SqlDataReader sdr          = DBTools.exereaderSQL(sqltext, new List <SqlParameter> ());

            while (sdr.Read())
            {
                Model.Notice n = new Model.Notice();
                n.NoticeId   = sdr["noticeId"].ToString();
                n.Subject    = sdr["subject"].ToString();
                n.Title      = sdr["title"].ToString();
                n.Body       = sdr["body"].ToString();
                n.SysUser    = new DAL.SysUserDAO().getUserById(sdr["userId"].ToString());
                n.CreateTime = DateTime.Parse(sdr["createTime"].ToString());
                n.UpdateTime = DateTime.Parse(sdr["publishTime"].ToString());
                notice.Add(n);
            }
            sdr.Close();
            DBTools.DBClose();
            return(notice);
        }
Exemple #22
0
        //插入一条记录
        public int Add(Model.Notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [Notice](");
            strSql.Append("[Type],[Link],[Title],[Department],[Date])");
            strSql.Append(" values (");
            strSql.Append("@Type,@Link,@Title,@Department,@Date)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@Type",       OleDbType.VarChar, 255),
                new OleDbParameter("@Link",       OleDbType.VarChar, 255),
                new OleDbParameter("@Title",      OleDbType.VarChar, 255),
                new OleDbParameter("@Department", OleDbType.VarChar, 255),
                new OleDbParameter("@Date",       OleDbType.VarChar, 255)
            };
            parameters[0].Value = model.Type;
            parameters[1].Value = model.Link;
            parameters[2].Value = model.Title;
            parameters[3].Value = model.Department;
            parameters[4].Value = model.Date.ToString("yyyy-MM-dd");
            return(SqlHelper.ExecuteNonQuery(strSql.ToString(), parameters));
        }
Exemple #23
0
 public bool Add(Model.Notice model)
 {
     return(SqlHelper.SqlHelper.ExecuteNonQuery(insertsql, GetModelPare(model)) > 0);
 }
Exemple #24
0
 protected override void SetValue(string id)
 {
     model = BLL.Notice.Select(int.Parse(id), true);
 }
 public bool Insert(Model.Notice n)
 {
     return(ndao.Insert(n));
 }
Exemple #26
0
 public static bool Add(Model.Notice model)
 {
     return(dal.Add(model));
 }
        protected override void SetPowerZone()
        {
            string id = Request.QueryString["id"];

            notice = BLL.Notice.Select(Convert.ToInt32(id), false);
        }
Exemple #28
0
 public static bool Add(Model.Notice model)
 {
     return(DAL.Notice.Add(model));
 }
Exemple #29
0
 public static bool Update(Model.Notice model)
 {
     return(DAL.Notice.Update(model));
 }
Exemple #30
0
 public bool Update(Model.Notice model)
 {
     return(SqlHelper.SqlHelper.ExecuteNonQuery(updatesql, GetModelPare(model)) > 0);
 }