Ejemplo n.º 1
0
        public async Task <IActionResult> Putnotices([FromRoute] int id, [FromBody] notices notices)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != notices.id)
            {
                return(BadRequest());
            }

            _context.Entry(notices).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!noticesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     //避免js失效,后端验证
     string title = txtTitle.Text;
     if (txtTitle.Text == null || txtTitle.Text.Trim() == "")
     {
         LblStatus.Text = "请填写标题";
         LblStatus.Visible = true;
         return;
     }
     string content = ueditor.Value;
     if (content == null || content.Trim() == "")
     {
         LblStatus.Text = "请填写内容";
         LblStatus.Visible = true;
         return;
     }
     using (var db = new ITStudioEntities())
     {
         var not = new notices();
         not.time = DateTime.Now;
         not.title = txtTitle.Text;
         not.content = ueditor.Value;
         db.notices.Add(not);
         db.SaveChanges();
     }
     ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功');</script>");
     txtTitle.Text = "";
     ueditor.Value = "";
 }
Ejemplo n.º 3
0
        public noticedetail notice(int studentcode)
        {
            noticedetail   Detail      = new noticedetail();
            List <notices> noticeslist = new List <notices>();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("usp_api_notices_LinkHeading", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@studentcode", SqlDbType.Int).Value = studentcode;
                    SqlDataAdapter sda = new SqlDataAdapter(cmd);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dtrow in dt.Rows)
                        {
                            var slist = new notices();
                            slist.linkheading = Convert.ToString(dtrow["LinkHeading"]);
                            noticeslist.Add(slist);
                        }
                        Detail.noticeheading = noticeslist;
                    }
                    else
                    {
                        throw new HttpResponseException(HttpStatusCode.NoContent);
                    }
                }
            }
            return(Detail);
        }
        protected void btnAddNotices_Click(object sender, EventArgs e)
        {
            using (EnshineUnionDataContext db = new EnshineUnionDataContext())
            {
                notices addNot = new notices();
                addNot.title   = SearchDataClass.CheckStr(txtTitle.Value.Trim());;
                addNot.content = txtFckContent.Value;                // SearchDataClass.CheckStr(txtFckContent.Value);

                //addNot.validate = Convert.ToChar(drpValidate.SelectedValue);
                //addNot.setindex = Convert.ToChar(drpSetIndex.SelectedValue);

                addNot.newssort   = int.Parse(drpNewsSort.SelectedValue);
                addNot.img        = HFurl.Value.Trim();
                addNot.img1       = HFurl1.Value.Trim();
                addNot.img2       = HFurl2.Value.Trim();
                addNot.newssource = txtSource.Value.Trim();
                addNot.likenum    = 0;
                addNot.discussnum = 0;
                addNot.browses    = 0;
                addNot.addtime    = DateTime.Now;
                db.notices.InsertOnSubmit(addNot);
                db.SubmitChanges();
            }
            Response.Redirect("NewsNoticesManager.aspx?mid=" + Request["mid"]);
        }
Ejemplo n.º 5
0
        public ActionResult releaseNews(NewsReleaseViewModel model)  //发布通知公告
        {
            notices newnotices = new notices();

            newnotices.userID  = Convert.ToInt32(Request.Cookies["userID"].Value);
            newnotices.vital   = model.vital;
            newnotices.title   = model.title;
            newnotices.time    = DateTime.Now;
            newnotices.content = model.content;

            //Word.Document doc = null; //一会要记录word打开的文档
            if (Request.Files["upload-doc"] != null)
            {
                Stream fileStream = Request.Files[0].InputStream;


                string fileName   = DateTime.Now.ToString().Replace("/", ".").Replace(":", ".") + Path.GetFileName(Request.Files["upload-doc"].FileName);
                int    fileLength = Request.Files["upload-doc"].ContentLength;
                //本地存放路径
                string path = AppDomain.CurrentDomain.BaseDirectory + "schoolUploads/";
                //将文件以文件名filename存放在path路径中
                Request.Files["upload-doc"].SaveAs(Path.Combine(path, fileName));
                newnotices.attachmentAddr = path + fileName;
                newnotices.attachmentName = Request.Files["upload-doc"].FileName;
            }
            else
            {
                newnotices.attachmentAddr = "";
                newnotices.attachmentName = "";
            }
            db.notice_table.Add(newnotices);
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 查看单一公告详细信息
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 /// <returns></returns>
 public DataTable Select(notices n)
 {
     SqlParameter[] paras = new SqlParameter[]
     {
         new SqlParameter("@noticeId", n.NoticeId),
     };
     return(sqlhelper.ExecuteQuery("SELECT noticeId, noticeName, [content], CONVERT(varchar(100), issueTime, 23) as issueTime, issuer FROM notices WHERE noticeId=@noticeId", paras, CommandType.Text));
 }
Ejemplo n.º 7
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        notices     n   = new notices();
        GridViewRow gvr = GridView1.Rows[e.RowIndex];

        n.NoticeId = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);          //获取当前行主键id
        nm.Delete(n);
        gridviewBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        notices n = new notices();

        n.NoticeId = Convert.ToInt32(Request.QueryString["noticeId"]);
        DataTable m = nm.Select(n);

        lbl1.Text = m.Rows[0]["noticeName"].ToString();
        txt2.Text = m.Rows[0]["content"].ToString();
        lbl2.Text = m.Rows[0]["issuer"].ToString();
        lbl3.Text = m.Rows[0]["issueTime"].ToString();
    }
        public void BindShowUpInfo(string strUpid)
        {
            if (!string.IsNullOrEmpty(strUpid))
            {
                if (EnshineUnionManager.model.SearchDataClass.IsNumber(strUpid) == true)
                {
                    using (EnshineUnionDataContext db = new EnshineUnionDataContext())
                    {
                        notices getNot = db.notices.Single(x => x.Id == int.Parse(strUpid));
                        txtTitle.Value      = SearchDataClass.CheckStr(getNot.title);;
                        txtFckContent.Value = getNot.content;
                        //SearchDataClass.CheckStr(getNot.content);
                        //drpValidate.SelectedValue = getNot.validate.ToString();
                        //drpSetIndex.SelectedValue = getNot.setindex.ToString();
                        this.drpNewsSort.SelectedValue = getNot.newssort.ToString();

                        this.hfDel.Value = getNot.img;
                        this.HFurl.Value = getNot.img;
                        if (!string.IsNullOrEmpty(getNot.img))
                        {
                            this.iShowPhoto.Src = getNot.img;
                        }
                        else
                        {
                            this.iShowPhoto.Src = "assets/images/nophoto.gif";
                        }

                        this.hfDel1.Value = getNot.img1;
                        this.HFurl1.Value = getNot.img1;
                        if (!string.IsNullOrEmpty(getNot.img1))
                        {
                            this.iShowPhoto1.Src = getNot.img1;
                        }
                        else
                        {
                            this.iShowPhoto1.Src = "assets/images/nophoto.gif";
                        }

                        this.hfDel2.Value = getNot.img2;
                        this.HFurl2.Value = getNot.img2;
                        if (!string.IsNullOrEmpty(getNot.img2))
                        {
                            this.iShowPhoto2.Src = getNot.img2;
                        }
                        else
                        {
                            this.iShowPhoto2.Src = "assets/images/nophoto.gif";
                        }
                        txtSource.Value = getNot.newssource;
                    }
                }
            }
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        notices n = new notices();

        n.NoticeName = txt1.Text.Trim();
        n.Content    = txt2.Text;
        n.Creater    = Session["adminId"].ToString();
        n.Issuer     = txt3.Text.Trim();
        n.IssueTime  = Convert.ToDateTime(txt4.Text);
        nm.Insert(n);
        ScriptManager.RegisterStartupScript(this, this.GetType(), "updateScript", "alert(\"新增成功\");", true);
    }
Ejemplo n.º 11
0
        public async Task <IActionResult> Postnotices([FromBody] notices notices)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.notices.Add(notices);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getnotices", new { id = notices.id }, notices));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 更新公告信息
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 public void Update(notices n)
 {
     SqlParameter[] paras = new SqlParameter[]
     {
         new SqlParameter("@content", n.Content),
         new SqlParameter("@issuer", n.Issuer),
         new SqlParameter("@issueTime", n.IssueTime),
         new SqlParameter("@noticeId", n.NoticeId),
         new SqlParameter("@noticeName", n.NoticeName),
         new SqlParameter("@modifier", n.Modifier),
     };
     sqlhelper.ExecuteQuery("UPDATE notices SET noticeName=@noticeName, modifier=@modifier,[content] = @content,issuer=@issuer, issueTime=@issueTime ,lastmodify = getdate() where noticeId=@noticeId ", paras, CommandType.Text);
 }
Ejemplo n.º 13
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        NoticesManage nm = new NoticesManage();
        notices       n  = new notices();

        n.NoticeId   = Convert.ToInt32(Request.QueryString["noticeId"].ToString());
        n.NoticeName = txt1.Text.Trim();
        n.Content    = txt2.Text;
        n.Issuer     = txt3.Text.Trim();
        n.IssueTime  = Convert.ToDateTime(txt4.Text.Trim());
        n.Modifier   = Session["adminId"].ToString();
        nm.Update(n);
        Response.Redirect("viewnotice.aspx?noticeId=" + Convert.ToInt32(Request.QueryString["noticeId"].ToString()));
    }
Ejemplo n.º 14
0
        /// <summary>
        /// 删除公告
        /// </summary>
        /// <param name="n">公告信息实体类</param>
        /// <returns></returns>
        public bool Delete(notices n)
        {
            bool flag = false;

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@noticeId", n.NoticeId),
            };
            int res = sqlhelper.ExecuteNonQuery("DELETE FROM notices where noticeId=@noticeId", paras, CommandType.Text);

            if (res > 0)
            {
                flag = true;
            }
            return(flag);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["studentId"] != null)
     {
         notices n = new notices();
         n.NoticeId = Convert.ToInt32(Request.QueryString["noticeId"]);
         DataTable m = nm.Select(n);
         lbl1.Text = m.Rows[0]["noticeName"].ToString();
         txt2.Text = m.Rows[0]["content"].ToString();
         lbl2.Text = m.Rows[0]["issuer"].ToString();
         lbl3.Text = m.Rows[0]["issueTime"].ToString();
     }
     else
     {
         Response.Redirect("../login.aspx");
     }
 }
Ejemplo n.º 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["adminId"] != null)
     {
         if (!IsPostBack)
         {
             notices n = new notices();
             n.NoticeId = Convert.ToInt32(Request.QueryString["noticeId"]);
             txt1.Text  = Request.QueryString["noticeName"].ToString();
             txt2.Text  = nm.Select(n).Rows[0]["content"].ToString();
             txt3.Text  = Request.QueryString["issuer"].ToString();
             txt4.Text  = Request.QueryString["issueTime"].ToString();
         }
     }
     else
     {
         Response.Redirect("../login.aspx");
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 新增公告
        /// </summary>
        /// <param name="n">公告信息实体类</param>
        /// <returns></returns>
        public bool Insert(notices n)
        {
            bool flag = false;

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@content", n.Content),
                new SqlParameter("@issuer", n.Issuer),
                new SqlParameter("@issueTime", n.IssueTime),
                new SqlParameter("@noticeName", n.NoticeName),
                new SqlParameter("@creater", n.Creater),
                new SqlParameter("@modifier", n.Creater),
            };
            int res = sqlhelper.ExecuteNonQuery("INSERT INTO notices ([content],issuer,issueTime,noticeName, creater, modifier) VALUES (@content,@issuer,@issueTime,@noticeName,@creater,@modifier)", paras, CommandType.Text);

            if (res > 0)
            {
                flag = true;
            }
            return(flag);
        }
        protected void btnUpdateNotices_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["upid"]))
            {
                if (EnshineUnionManager.model.SearchDataClass.IsNumber(Request["upid"]) == true)
                {
                    using (EnshineUnionDataContext db = new EnshineUnionDataContext())
                    {
                        notices upNot = db.notices.Single(x => x.Id == int.Parse(Request["upid"]));
                        upNot.title   = SearchDataClass.CheckStr(txtTitle.Value.Trim());;
                        upNot.content = txtFckContent.Value;                        //SearchDataClass.CheckStr(txtFckContent.Value);

                        //upNot.validate = Convert.ToChar(drpValidate.SelectedValue);
                        //upNot.setindex = Convert.ToChar(drpSetIndex.SelectedValue);


                        upNot.newssort = int.Parse(drpNewsSort.SelectedValue);
                        if (!string.IsNullOrEmpty(HFurl.Value))
                        {
                            upNot.img = HFurl.Value.Trim();
                        }

                        if (!string.IsNullOrEmpty(HFurl.Value))
                        {
                            upNot.img1 = HFurl1.Value.Trim();
                        }

                        if (!string.IsNullOrEmpty(HFurl.Value))
                        {
                            upNot.img2 = HFurl2.Value.Trim();
                        }

                        upNot.newssource = txtSource.Value.Trim();
                        upNot.addtime    = DateTime.Now;
                        db.SubmitChanges();
                    }
                }
                Response.Redirect("NewsNoticesManager.aspx?mid=" + Request["mid"]);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 新增公告
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 /// <returns></returns>
 public bool Insert(notices n)
 {
     return(ndao.Insert(n));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 更新公告信息
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 /// <returns></returns>
 public void Update(notices n)
 {
     ndao.Update(n);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 删除公告
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 /// <returns></returns>
 public bool Delete(notices n)
 {
     return(ndao.Delete(n));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 查看单一公告详细信息
 /// </summary>
 /// <param name="n">公告信息实体类</param>
 /// <returns></returns>
 public DataTable Select(notices n)
 {
     return(ndao.Select(n));
 }