Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)                 //判断是否是DataRow,以防止鼠标经过Header也有效果
                {
                    e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#BCE2F9'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");

                    //HiddenField hid = (HiddenField)e.Row.FindControl("Hid_ID");
                    //部门或岗位的ID
                    string ID = DataBinder.Eval(e.Row.DataItem, "ID").ToString();
                    //hid.Value = ID;
                    string PARENTID = DataBinder.Eval(e.Row.DataItem, "PARENTID").ToString();
                    string ForItems = DataBinder.Eval(e.Row.DataItem, "ForItems").ToString();
                    string ItemsID  = DataBinder.Eval(e.Row.DataItem, "ItemsID").ToString();

                    mNews_Columns = new Dianda.Model.News_Columns();
                    mNews_Columns = bNews_Columns.GetModel(Int32.Parse(PARENTID));
                    if (mNews_Columns != null)
                    {
                        e.Row.Cells[1].Text = mNews_Columns.NAME;
                    }
                    else
                    {
                        e.Row.Cells[1].Text = "";
                    }

                    if (ForItems == "DEPARTMENT")
                    {
                        e.Row.Cells[2].Text = "部门信息栏目";
                        mUSER_Groups        = new Dianda.Model.USER_Groups();
                        mUSER_Groups        = bUSER_Groups.GetModel(ItemsID);
                        if (mUSER_Groups != null)
                        {
                            e.Row.Cells[3].Text = mUSER_Groups.NAME;
                        }
                    }
                    if (ForItems == "PROJECT")
                    {
                        e.Row.Cells[2].Text = "项目信息栏目";
                        mProject_Projects   = new Dianda.Model.Project_Projects();
                        mProject_Projects   = bProject_Projects.GetModel(Int32.Parse(ItemsID));
                        if (mProject_Projects != null)
                        {
                            e.Row.Cells[3].Text = mProject_Projects.NAMES;
                        }
                    }
                    if (ForItems == "NEWS")
                    {
                        e.Row.Cells[2].Text = "普通信息栏目";
                    }
                }
            }
            catch
            {
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Dianda.Model.News_Columns model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update News_Columns set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("PARENTID=@PARENTID,");
            strSql.Append("ForItems=@ForItems,");
            strSql.Append("ItemsID=@ItemsID,");
            strSql.Append("DATETIME=@DATETIME,");
            strSql.Append("ISMENU=@ISMENU,");
            strSql.Append("ISSHENHE=@ISSHENHE,");
            strSql.Append("ONLYONE=@ONLYONE,");
            strSql.Append("DELFLAG=@DELFLAG,");
            strSql.Append("COLUMNSPATH=@COLUMNSPATH,");
            strSql.Append("SHUNXU=@SHUNXU,");
            strSql.Append("IMAGEURL=@IMAGEURL,");
            strSql.Append("PNAMES=@PNAMES");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",          SqlDbType.Int,          4),
                new SqlParameter("@NAME",        SqlDbType.VarChar,    100),
                new SqlParameter("@PARENTID",    SqlDbType.Int,          4),
                new SqlParameter("@ForItems",    SqlDbType.VarChar,     50),
                new SqlParameter("@ItemsID",     SqlDbType.VarChar,     50),
                new SqlParameter("@DATETIME",    SqlDbType.DateTime),
                new SqlParameter("@ISMENU",      SqlDbType.Int,          4),
                new SqlParameter("@ISSHENHE",    SqlDbType.Int,          4),
                new SqlParameter("@ONLYONE",     SqlDbType.Int,          4),
                new SqlParameter("@DELFLAG",     SqlDbType.Int,          4),
                new SqlParameter("@COLUMNSPATH", SqlDbType.VarChar,   1000),
                new SqlParameter("@SHUNXU",      SqlDbType.Int,          4),
                new SqlParameter("@IMAGEURL",    SqlDbType.VarChar,    100),
                new SqlParameter("@PNAMES",      SqlDbType.VarChar, 1000)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.NAME;
            parameters[2].Value  = model.PARENTID;
            parameters[3].Value  = model.ForItems;
            parameters[4].Value  = model.ItemsID;
            parameters[5].Value  = model.DATETIME;
            parameters[6].Value  = model.ISMENU;
            parameters[7].Value  = model.ISSHENHE;
            parameters[8].Value  = model.ONLYONE;
            parameters[9].Value  = model.DELFLAG;
            parameters[10].Value = model.COLUMNSPATH;
            parameters[11].Value = model.SHUNXU;
            parameters[12].Value = model.IMAGEURL;
            parameters[13].Value = model.PNAMES;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Dianda.Model.News_Columns model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into News_Columns(");
            strSql.Append("NAME,PARENTID,ForItems,ItemsID,DATETIME,ISMENU,ISSHENHE,ONLYONE,DELFLAG,COLUMNSPATH,SHUNXU,IMAGEURL,PNAMES)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@PARENTID,@ForItems,@ItemsID,@DATETIME,@ISMENU,@ISSHENHE,@ONLYONE,@DELFLAG,@COLUMNSPATH,@SHUNXU,@IMAGEURL,@PNAMES)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NAME",        SqlDbType.VarChar,    100),
                new SqlParameter("@PARENTID",    SqlDbType.Int,          4),
                new SqlParameter("@ForItems",    SqlDbType.VarChar,     50),
                new SqlParameter("@ItemsID",     SqlDbType.VarChar,     50),
                new SqlParameter("@DATETIME",    SqlDbType.DateTime),
                new SqlParameter("@ISMENU",      SqlDbType.Int,          4),
                new SqlParameter("@ISSHENHE",    SqlDbType.Int,          4),
                new SqlParameter("@ONLYONE",     SqlDbType.Int,          4),
                new SqlParameter("@DELFLAG",     SqlDbType.Int,          4),
                new SqlParameter("@COLUMNSPATH", SqlDbType.VarChar,   1000),
                new SqlParameter("@SHUNXU",      SqlDbType.Int,          4),
                new SqlParameter("@IMAGEURL",    SqlDbType.VarChar,    100),
                new SqlParameter("@PNAMES",      SqlDbType.VarChar, 1000)
            };
            parameters[0].Value  = model.NAME;
            parameters[1].Value  = model.PARENTID;
            parameters[2].Value  = model.ForItems;
            parameters[3].Value  = model.ItemsID;
            parameters[4].Value  = model.DATETIME;
            parameters[5].Value  = model.ISMENU;
            parameters[6].Value  = model.ISSHENHE;
            parameters[7].Value  = model.ONLYONE;
            parameters[8].Value  = model.DELFLAG;
            parameters[9].Value  = model.COLUMNSPATH;
            parameters[10].Value = model.SHUNXU;
            parameters[11].Value = model.IMAGEURL;
            parameters[12].Value = model.PNAMES;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Dianda.Model.News_Columns GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,NAME,PARENTID,ForItems,ItemsID,DATETIME,ISMENU,ISSHENHE,ONLYONE,DELFLAG,COLUMNSPATH,SHUNXU,IMAGEURL,PNAMES from News_Columns ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Dianda.Model.News_Columns model = new Dianda.Model.News_Columns();
            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());
                }
                model.ForItems = ds.Tables[0].Rows[0]["ForItems"].ToString();
                model.ItemsID  = ds.Tables[0].Rows[0]["ItemsID"].ToString();
                if (ds.Tables[0].Rows[0]["DATETIME"].ToString() != "")
                {
                    model.DATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["DATETIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ISMENU"].ToString() != "")
                {
                    model.ISMENU = int.Parse(ds.Tables[0].Rows[0]["ISMENU"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ISSHENHE"].ToString() != "")
                {
                    model.ISSHENHE = int.Parse(ds.Tables[0].Rows[0]["ISSHENHE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ONLYONE"].ToString() != "")
                {
                    model.ONLYONE = int.Parse(ds.Tables[0].Rows[0]["ONLYONE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DELFLAG"].ToString() != "")
                {
                    model.DELFLAG = int.Parse(ds.Tables[0].Rows[0]["DELFLAG"].ToString());
                }
                model.COLUMNSPATH = ds.Tables[0].Rows[0]["COLUMNSPATH"].ToString();
                if (ds.Tables[0].Rows[0]["SHUNXU"].ToString() != "")
                {
                    model.SHUNXU = int.Parse(ds.Tables[0].Rows[0]["SHUNXU"].ToString());
                }
                model.IMAGEURL = ds.Tables[0].Rows[0]["IMAGEURL"].ToString();
                model.PNAMES   = ds.Tables[0].Rows[0]["PNAMES"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }