Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Dianda.Model.News_News model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update News_News set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("PARENTID=@PARENTID,");
            strSql.Append("DATETIME=@DATETIME,");
            strSql.Append("CONTENTS=@CONTENTS,");
            strSql.Append("TYPE=@TYPE,");
            strSql.Append("KEYWORD=@KEYWORD,");
            strSql.Append("WRITER=@WRITER,");
            strSql.Append("SOURCE=@SOURCE,");
            strSql.Append("MINIPIC=@MINIPIC,");
            strSql.Append("FILEUP=@FILEUP,");
            strSql.Append("UPTOP=@UPTOP,");
            strSql.Append("DELFLAG=@DELFLAG,");
            strSql.Append("ISPASS=@ISPASS,");
            strSql.Append("IsLimits=@IsLimits,");
            strSql.Append("LimitsChoose=@LimitsChoose");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,         4),
                new SqlParameter("@NAME",         SqlDbType.VarChar,   300),
                new SqlParameter("@PARENTID",     SqlDbType.Int,         4),
                new SqlParameter("@DATETIME",     SqlDbType.DateTime),
                new SqlParameter("@CONTENTS",     SqlDbType.Text),
                new SqlParameter("@TYPE",         SqlDbType.Int,         4),
                new SqlParameter("@KEYWORD",      SqlDbType.VarChar,   500),
                new SqlParameter("@WRITER",       SqlDbType.VarChar,    50),
                new SqlParameter("@SOURCE",       SqlDbType.VarChar,    50),
                new SqlParameter("@MINIPIC",      SqlDbType.VarChar,   100),
                new SqlParameter("@FILEUP",       SqlDbType.VarChar,   100),
                new SqlParameter("@UPTOP",        SqlDbType.Int,         4),
                new SqlParameter("@DELFLAG",      SqlDbType.Int,         4),
                new SqlParameter("@ISPASS",       SqlDbType.Int,         4),
                new SqlParameter("@IsLimits",     SqlDbType.Int,         4),
                new SqlParameter("@LimitsChoose", SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.NAME;
            parameters[2].Value  = model.PARENTID;
            parameters[3].Value  = model.DATETIME;
            parameters[4].Value  = model.CONTENTS;
            parameters[5].Value  = model.TYPE;
            parameters[6].Value  = model.KEYWORD;
            parameters[7].Value  = model.WRITER;
            parameters[8].Value  = model.SOURCE;
            parameters[9].Value  = model.MINIPIC;
            parameters[10].Value = model.FILEUP;
            parameters[11].Value = model.UPTOP;
            parameters[12].Value = model.DELFLAG;
            parameters[13].Value = model.ISPASS;
            parameters[14].Value = model.IsLimits;
            parameters[15].Value = model.LimitsChoose;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Dianda.Model.News_News model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into News_News(");
            strSql.Append("NAME,PARENTID,DATETIME,CONTENTS,TYPE,KEYWORD,WRITER,SOURCE,MINIPIC,FILEUP,UPTOP,DELFLAG,ISPASS,IsLimits,LimitsChoose)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@PARENTID,@DATETIME,@CONTENTS,@TYPE,@KEYWORD,@WRITER,@SOURCE,@MINIPIC,@FILEUP,@UPTOP,@DELFLAG,@ISPASS,@IsLimits,@LimitsChoose)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NAME",         SqlDbType.VarChar,   300),
                new SqlParameter("@PARENTID",     SqlDbType.Int,         4),
                new SqlParameter("@DATETIME",     SqlDbType.DateTime),
                new SqlParameter("@CONTENTS",     SqlDbType.Text),
                new SqlParameter("@TYPE",         SqlDbType.Int,         4),
                new SqlParameter("@KEYWORD",      SqlDbType.VarChar,   500),
                new SqlParameter("@WRITER",       SqlDbType.VarChar,    50),
                new SqlParameter("@SOURCE",       SqlDbType.VarChar,    50),
                new SqlParameter("@MINIPIC",      SqlDbType.VarChar,   100),
                new SqlParameter("@FILEUP",       SqlDbType.VarChar,   100),
                new SqlParameter("@UPTOP",        SqlDbType.Int,         4),
                new SqlParameter("@DELFLAG",      SqlDbType.Int,         4),
                new SqlParameter("@ISPASS",       SqlDbType.Int,         4),
                new SqlParameter("@IsLimits",     SqlDbType.Int,         4),
                new SqlParameter("@LimitsChoose", SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.NAME;
            parameters[1].Value  = model.PARENTID;
            parameters[2].Value  = model.DATETIME;
            parameters[3].Value  = model.CONTENTS;
            parameters[4].Value  = model.TYPE;
            parameters[5].Value  = model.KEYWORD;
            parameters[6].Value  = model.WRITER;
            parameters[7].Value  = model.SOURCE;
            parameters[8].Value  = model.MINIPIC;
            parameters[9].Value  = model.FILEUP;
            parameters[10].Value = model.UPTOP;
            parameters[11].Value = model.DELFLAG;
            parameters[12].Value = model.ISPASS;
            parameters[13].Value = model.IsLimits;
            parameters[14].Value = model.LimitsChoose;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.News_News GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,NAME,PARENTID,DATETIME,CONTENTS,TYPE,KEYWORD,WRITER,SOURCE,MINIPIC,FILEUP,UPTOP,DELFLAG,ISPASS,IsLimits,LimitsChoose from News_News ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Dianda.Model.News_News model = new Dianda.Model.News_News();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                if (ds.Tables[0].Rows[0]["PARENTID"].ToString() != "")
                {
                    model.PARENTID = int.Parse(ds.Tables[0].Rows[0]["PARENTID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DATETIME"].ToString() != "")
                {
                    model.DATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["DATETIME"].ToString());
                }
                model.CONTENTS = ds.Tables[0].Rows[0]["CONTENTS"].ToString();
                if (ds.Tables[0].Rows[0]["TYPE"].ToString() != "")
                {
                    model.TYPE = int.Parse(ds.Tables[0].Rows[0]["TYPE"].ToString());
                }
                model.KEYWORD = ds.Tables[0].Rows[0]["KEYWORD"].ToString();
                model.WRITER  = ds.Tables[0].Rows[0]["WRITER"].ToString();
                model.SOURCE  = ds.Tables[0].Rows[0]["SOURCE"].ToString();
                model.MINIPIC = ds.Tables[0].Rows[0]["MINIPIC"].ToString();
                model.FILEUP  = ds.Tables[0].Rows[0]["FILEUP"].ToString();
                if (ds.Tables[0].Rows[0]["UPTOP"].ToString() != "")
                {
                    model.UPTOP = int.Parse(ds.Tables[0].Rows[0]["UPTOP"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DELFLAG"].ToString() != "")
                {
                    model.DELFLAG = int.Parse(ds.Tables[0].Rows[0]["DELFLAG"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ISPASS"].ToString() != "")
                {
                    model.ISPASS = int.Parse(ds.Tables[0].Rows[0]["ISPASS"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsLimits"].ToString() != "")
                {
                    model.IsLimits = int.Parse(ds.Tables[0].Rows[0]["IsLimits"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LimitsChoose"].ToString() != "")
                {
                    model.LimitsChoose = int.Parse(ds.Tables[0].Rows[0]["LimitsChoose"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        ///点击确定按钮触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button_sumbit_Click(object sender, EventArgs e)
        {
            try
            {
                string NAME = this.txtNAME.Text;//获取到用户名

                //if (String.IsNullOrEmpty(NAME))
                //{
                //    tag.Text = "标题不能为空,请填写标题!";
                //    return;
                //}
                //if (this.ddlPARENTID.SelectedIndex == 0)
                //{
                //    tag.Text = "请选择栏目!";
                //    return;
                //}
                int intMaxID = bNews_News.GetMaxId();
                mNews_News      = new Dianda.Model.News_News();
                mNews_News.ID   = intMaxID;
                mNews_News.NAME = txtNAME.Text;

                if (!ddlPARENTID.SelectedValue.Equals(""))
                {
                    mNews_News.PARENTID = Int32.Parse(ddlPARENTID.SelectedValue);
                }

                mNews_News.DATETIME = DateTime.Now;
                mNews_News.CONTENTS = this.FCKeditor_neirong.Value;
                // mNews_News.TYPE = 0;
                mNews_News.KEYWORD = txtNAME.Text;
                mNews_News.WRITER  = ((Model.USER_Users)Session["USER_Users"]).USERNAME;
                //mNews_News.FILEUP = "";//上传附件/AllFileUp/admin/news/目录下
                mNews_News.UPTOP        = 0;
                mNews_News.DELFLAG      = 0;
                mNews_News.ISPASS       = 0;//是否通过审核(默认0,1表示通过审核,2表示审核不通过)添加新闻时,需要根据选择栏目的审核设定进行赋值
                mNews_News.LimitsChoose = Int32.Parse(this.rblLimitsChoose.SelectedValue);
                bNews_News.Add(mNews_News);
                Dianda.Model.News_News mNews_News2 = new Dianda.Model.News_News();
                DataTable Dt = new DataTable();
                Dt       = bNews_News.GetList(" [NAME]='" + mNews_News.NAME + "' and PARENTID=" + mNews_News.PARENTID + " and WRITER='" + mNews_News.WRITER + "' and KEYWORD='" + mNews_News.KEYWORD + "' order by id desc").Tables[0];
                intMaxID = int.Parse(Dt.Rows[0]["ID"].ToString());
                string NEWS = "";
                if (_parentid == "3")
                {
                    NEWS = "部门消息";
                }
                else if (_parentid == "4")
                {
                    NEWS = "个人消息";
                }
                else if (_parentid == "5")
                {
                    NEWS = "通知公告";
                }

                // 添加News_LimitUser
                ArrayList arrUserID = UserManage1.getSelectUser();

                if (arrUserID.Count > 0)
                {
                    for (int k = 0; k < arrUserID.Count; k++)
                    {
                        mNews_LimitUser        = new Dianda.Model.News_LimitUser();
                        mNews_LimitUser.ID     = bNews_LimitUser.GetMaxId();
                        mNews_LimitUser.UserID = arrUserID[k].ToString();
                        mNews_LimitUser.NewsID = intMaxID;
                        mNews_LimitUser.IsRead = 0;
                        bNews_LimitUser.Add(mNews_LimitUser);

                        /*给业务申请者发信息*/
                        Model.FaceShowMessage mFaceShowMessage = new Dianda.Model.FaceShowMessage();
                        BLL.FaceShowMessage   bFaceShowMessage = new Dianda.BLL.FaceShowMessage();

                        mFaceShowMessage.DATETIME  = DateTime.Now;
                        mFaceShowMessage.FromTable = NEWS;
                        mFaceShowMessage.IsRead    = 0;
                        mFaceShowMessage.NewsID    = null;
                        mFaceShowMessage.NewsType  = NEWS;
                        mFaceShowMessage.ReadTime  = null;
                        mFaceShowMessage.Receive   = arrUserID[k].ToString();
                        mFaceShowMessage.DELFLAG   = 0;

                        //mFaceShowMessage.URLS = ((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME.ToString() + ")给您发送了[" + NEWS + "]!<a href='/Admin/newsManage/OAnews/show.aspx?id=" + intMaxID + "' target='_self' rel='gb_page_center[726,400]' title='查看详细'>点击查看</a>";
                        mFaceShowMessage.URLS = "<a href=\"javascript:window.showModalDialog('/Admin/newsManage/OAnews/show.aspx?id=" + intMaxID + "','','dialogWidth=726px;dialogHeight=400px');\" target='_self' title='发布时间:" + DateTime.Now.ToString() + "'>" + NEWS + ":" + NAME + "</a>  (" + ((Model.USER_Users)Session["USER_Users"]).REALNAME.ToString() + ")";

                        bFaceShowMessage.Add(mFaceShowMessage);
                        /*给业务申请者发信息*/
                    }
                }
                // tag.Text = "操作成功!";
                string coutws = "<script language=\"javascript\" type=\"text/javascript\">alert(\"操作成功!现在进入列表页面\"); location.href = \"manage.aspx?pageindex=" + Request["pageindex"] + "&status=" + Request["status"] + "&PARENTID=" + Request["PARENTID"] + "\";</script>";
                Response.Write(coutws);

                //添加操作日志
                Dianda.BLL.SYS_LogsExt bsyslog    = new Dianda.BLL.SYS_LogsExt();
                Model.USER_Users       user_model = (Model.USER_Users)Session["USER_Users"];
                bsyslog.addlogs(((Model.USER_Users)Session["USER_Users"]).REALNAME + "(" + ((Model.USER_Users)Session["USER_Users"]).USERNAME + ")", "添加新闻", "添加成功");
                //添加操作日志
            }
            catch
            {
                tag.Text = "操作失败,请重试!";
            }
        }