Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.sys_model GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id,title,sort_id,inherit_index,inherit_list,inherit_detail,is_sys from dt_sys_model ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.sys_model model = new Model.sys_model();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  父表信息
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["inherit_index"] != null && ds.Tables[0].Rows[0]["inherit_index"].ToString() != "")
                {
                    model.inherit_index = ds.Tables[0].Rows[0]["inherit_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["inherit_list"] != null && ds.Tables[0].Rows[0]["inherit_list"].ToString() != "")
                {
                    model.inherit_list = ds.Tables[0].Rows[0]["inherit_list"].ToString();
                }
                if (ds.Tables[0].Rows[0]["inherit_detail"] != null && ds.Tables[0].Rows[0]["inherit_detail"].ToString() != "")
                {
                    model.inherit_detail = ds.Tables[0].Rows[0]["inherit_detail"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                #endregion  父表信息end

                #region  子表信息
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,model_id,title,nav_url,sort_id from dt_sys_model_nav ");
                strSql2.Append(" where model_id=@model_id ");
                SqlParameter[] parameters2 = {
					new SqlParameter("@model_id", SqlDbType.Int,4)};
                parameters2[0].Value = id;

                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    #region  子表字段信息
                    int i = ds2.Tables[0].Rows.Count;
                    List<Model.sys_model_nav> models = new List<Model.sys_model_nav>();
                    Model.sys_model_nav modelt;
                    for (int n = 0; n < i; n++)
                    {
                        modelt = new Model.sys_model_nav();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["model_id"] != null && ds2.Tables[0].Rows[n]["model_id"].ToString() != "")
                        {
                            modelt.model_id = int.Parse(ds2.Tables[0].Rows[n]["model_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["title"] != null && ds2.Tables[0].Rows[n]["title"].ToString() != "")
                        {
                            modelt.title = ds2.Tables[0].Rows[n]["title"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["nav_url"] != null && ds2.Tables[0].Rows[n]["nav_url"].ToString() != "")
                        {
                            modelt.nav_url = ds2.Tables[0].Rows[n]["nav_url"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["sort_id"] != null && ds2.Tables[0].Rows[n]["sort_id"].ToString() != "")
                        {
                            modelt.sort_id = int.Parse(ds2.Tables[0].Rows[n]["sort_id"].ToString());
                        }
                        models.Add(modelt);
                    }
                    model.sys_model_navs = models;
                    #endregion  子表字段信息end
                }
                #endregion  子表信息end

                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.sys_model GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,title,sort_id,inherit_index,inherit_list,inherit_detail,is_sys from dt_sys_model ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                #region  父表信息
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["inherit_index"] != null && ds.Tables[0].Rows[0]["inherit_index"].ToString() != "")
                {
                    model.inherit_index = ds.Tables[0].Rows[0]["inherit_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["inherit_list"] != null && ds.Tables[0].Rows[0]["inherit_list"].ToString() != "")
                {
                    model.inherit_list = ds.Tables[0].Rows[0]["inherit_list"].ToString();
                }
                if (ds.Tables[0].Rows[0]["inherit_detail"] != null && ds.Tables[0].Rows[0]["inherit_detail"].ToString() != "")
                {
                    model.inherit_detail = ds.Tables[0].Rows[0]["inherit_detail"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                #endregion  父表信息end

                #region  子表信息
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,model_id,title,nav_url,sort_id from dt_sys_model_nav ");
                strSql2.Append(" where model_id=@model_id ");
                SqlParameter[] parameters2 =
                {
                    new SqlParameter("@model_id", SqlDbType.Int, 4)
                };
                parameters2[0].Value = id;

                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    #region  子表字段信息
                    int i = ds2.Tables[0].Rows.Count;
                    List <Model.sys_model_nav> models = new List <Model.sys_model_nav>();
                    Model.sys_model_nav        modelt;
                    for (int n = 0; n < i; n++)
                    {
                        modelt = new Model.sys_model_nav();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["model_id"] != null && ds2.Tables[0].Rows[n]["model_id"].ToString() != "")
                        {
                            modelt.model_id = int.Parse(ds2.Tables[0].Rows[n]["model_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["title"] != null && ds2.Tables[0].Rows[n]["title"].ToString() != "")
                        {
                            modelt.title = ds2.Tables[0].Rows[n]["title"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["nav_url"] != null && ds2.Tables[0].Rows[n]["nav_url"].ToString() != "")
                        {
                            modelt.nav_url = ds2.Tables[0].Rows[n]["nav_url"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["sort_id"] != null && ds2.Tables[0].Rows[n]["sort_id"].ToString() != "")
                        {
                            modelt.sort_id = int.Parse(ds2.Tables[0].Rows[n]["sort_id"].ToString());
                        }
                        models.Add(modelt);
                    }
                    model.sys_model_navs = models;
                    #endregion  子表字段信息end
                }
                #endregion  子表信息end

                return(model);
            }
            else
            {
                return(null);
            }
        }