Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TFXK.Model.TourCategory GetModelByTitle(string title, string where)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,title,codeNo,parentID,description,orderId,imgPath,stateID,typeID,outLink,simpleDes,otherdes1,otherdes2,gtLink,ylLink from tb_TourCategory ");
            strSql.Append(" where title=@title ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = title;
            if (!string.IsNullOrEmpty(where))
            {
                strSql.Append(" and " + where);
            }
            TFXK.Model.TourCategory model = new TFXK.Model.TourCategory();
            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.title  = ds.Tables[0].Rows[0]["title"].ToString();
                model.codeNo = ds.Tables[0].Rows[0]["codeNo"].ToString();
                if (ds.Tables[0].Rows[0]["parentID"].ToString() != "")
                {
                    model.parentID = int.Parse(ds.Tables[0].Rows[0]["parentID"].ToString());
                }
                model.description = ds.Tables[0].Rows[0]["description"].ToString();
                if (ds.Tables[0].Rows[0]["orderId"].ToString() != "")
                {
                    model.orderId = int.Parse(ds.Tables[0].Rows[0]["orderId"].ToString());
                }
                model.imgPath = ds.Tables[0].Rows[0]["imgPath"].ToString();
                if (ds.Tables[0].Rows[0]["stateID"].ToString() != "")
                {
                    model.stateID = int.Parse(ds.Tables[0].Rows[0]["stateID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["typeID"].ToString() != "")
                {
                    model.stateID = int.Parse(ds.Tables[0].Rows[0]["typeID"].ToString());
                }
                model.outLink   = ds.Tables[0].Rows[0]["outLink"].ToString();
                model.simpleDes = ds.Tables[0].Rows[0]["simpleDes"].ToString();
                model.otherDes1 = ds.Tables[0].Rows[0]["otherDes1"].ToString();
                model.otherDes2 = ds.Tables[0].Rows[0]["otherDes2"].ToString();
                model.gtLink    = ds.Tables[0].Rows[0]["gtLink"].ToString();
                model.ylLink    = ds.Tables[0].Rows[0]["ylLink"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TFXK.Model.TourCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_TourCategory set ");
            strSql.Append("title=@title,");
            strSql.Append("codeNo=@codeNo,");
            strSql.Append("parentID=@parentID,");
            strSql.Append("description=@description,");
            strSql.Append("orderId=@orderId,");
            strSql.Append("imgPath=@imgPath,");
            strSql.Append("stateID=@stateID,");
            strSql.Append("typeID=@typeID,");
            strSql.Append("outLink=@outLink,");
            strSql.Append("simpleDes=@simpleDes,");
            strSql.Append("otherDes1=@otherDes1,");
            strSql.Append("otherDes2=@otherDes2,");
            strSql.Append("gtLink=@gtLink,");
            strSql.Append("ylLink=@ylLink");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.Int,       4),
                new SqlParameter("@title",       SqlDbType.VarChar,  50),
                new SqlParameter("@codeNo",      SqlDbType.VarChar,  50),
                new SqlParameter("@parentID",    SqlDbType.Int,       4),
                new SqlParameter("@description", SqlDbType.Text),
                new SqlParameter("@orderId",     SqlDbType.Int,       4),
                new SqlParameter("@imgPath",     SqlDbType.VarChar,  50),
                new SqlParameter("@stateID",     SqlDbType.Int,       4),
                new SqlParameter("@typeID",      SqlDbType.Int,       4),
                new SqlParameter("@outLink",     SqlDbType.VarChar, 100),
                new SqlParameter("@simpleDes",   SqlDbType.Text),
                new SqlParameter("@otherDes1",   SqlDbType.Text),
                new SqlParameter("@otherDes2",   SqlDbType.Text),
                new SqlParameter("@gtLink",      SqlDbType.VarChar, 100),
                new SqlParameter("@ylLink",      SqlDbType.VarChar, 100)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.codeNo;
            parameters[3].Value  = model.parentID;
            parameters[4].Value  = model.description;
            parameters[5].Value  = model.orderId;
            parameters[6].Value  = model.imgPath;
            parameters[7].Value  = model.stateID;
            parameters[8].Value  = model.typeID;
            parameters[9].Value  = model.outLink;
            parameters[10].Value = model.simpleDes;
            parameters[11].Value = model.otherDes1;
            parameters[12].Value = model.otherDes2;
            parameters[13].Value = model.gtLink;
            parameters[14].Value = model.ylLink;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TFXK.Model.TourCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_TourCategory(");
            strSql.Append("title,codeNo,parentID,description,orderId,imgPath,stateID,typeID,outLink,simpleDes,otherDes1,otherDes2,gtLink,ylLink)");
            strSql.Append(" values (");
            strSql.Append("@title,@codeNo,@parentID,@description,@orderId,@imgPath,@stateID,@typeID,@outLink,@simpleDes,@otherDes1,@otherDes2,@gtLink,@ylLink)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",       SqlDbType.VarChar,  50),
                new SqlParameter("@codeNo",      SqlDbType.VarChar,  50),
                new SqlParameter("@parentID",    SqlDbType.Int,       4),
                new SqlParameter("@description", SqlDbType.Text),
                new SqlParameter("@orderId",     SqlDbType.Int,       4),
                new SqlParameter("@imgPath",     SqlDbType.VarChar,  50),
                new SqlParameter("@stateID",     SqlDbType.Int,       4),
                new SqlParameter("@typeID",      SqlDbType.Int,       4),
                new SqlParameter("@outLink",     SqlDbType.VarChar, 100),
                new SqlParameter("@simpleDes",   SqlDbType.Text),
                new SqlParameter("@otherDes1",   SqlDbType.Text),
                new SqlParameter("@otherDes2",   SqlDbType.Text),
                new SqlParameter("@gtLink",      SqlDbType.VarChar, 100),
                new SqlParameter("@ylLink",      SqlDbType.VarChar, 100)
            };
            parameters[0].Value  = model.title;
            parameters[1].Value  = model.codeNo;
            parameters[2].Value  = model.parentID;
            parameters[3].Value  = model.description;
            parameters[4].Value  = model.orderId;
            parameters[5].Value  = model.imgPath;
            parameters[6].Value  = model.stateID;
            parameters[7].Value  = model.typeID;
            parameters[8].Value  = model.outLink;
            parameters[9].Value  = model.simpleDes;
            parameters[10].Value = model.otherDes1;
            parameters[11].Value = model.otherDes2;
            parameters[12].Value = model.gtLink;
            parameters[13].Value = model.ylLink;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <TFXK.Model.TourCategory> DataTableToList(DataTable dt)
        {
            List <TFXK.Model.TourCategory> modelList = new List <TFXK.Model.TourCategory>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                TFXK.Model.TourCategory model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TFXK.Model.TourCategory();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.title  = dt.Rows[n]["title"].ToString();
                    model.codeNo = dt.Rows[n]["codeNo"].ToString();
                    if (dt.Rows[n]["parentID"].ToString() != "")
                    {
                        model.parentID = int.Parse(dt.Rows[n]["parentID"].ToString());
                    }
                    model.description = dt.Rows[n]["description"].ToString();
                    if (dt.Rows[n]["orderId"].ToString() != "")
                    {
                        model.orderId = int.Parse(dt.Rows[n]["orderId"].ToString());
                    }
                    model.imgPath = dt.Rows[n]["imgPath"].ToString();
                    if (dt.Rows[n]["stateID"].ToString() != "")
                    {
                        model.stateID = int.Parse(dt.Rows[n]["stateID"].ToString());
                    }
                    if (dt.Rows[n]["typeID"].ToString() != "")
                    {
                        model.typeID = int.Parse(dt.Rows[n]["typeID"].ToString());
                    }
                    model.outLink   = dt.Rows[n]["outLink"].ToString();
                    model.simpleDes = dt.Rows[n]["simpleDes"].ToString();
                    model.otherDes1 = dt.Rows[n]["otherDes1"].ToString();
                    model.otherDes2 = dt.Rows[n]["otherDes2"].ToString();
                    model.gtLink    = dt.Rows[n]["gtLink"].ToString();
                    model.ylLink    = dt.Rows[n]["ylLink"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Beispiel #5
0
        /// <summary>
        /// 更具编号获取父分类的编号
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>dataset pid</returns>
        public DataSet GetParentIdsByID(int id)
        {
            Model.TourCategory model = new TFXK.Model.TourCategory();
            model.parentID = id;
            DataTable dt = new DataTable();

            dt.Columns.Add("pid");
            while (model != null && model.parentID != 0)
            {
                model = GetParentID(model.parentID);
                DataRow dr = dt.NewRow();
                dr["pid"] = model.parentID;
                dt.Rows.Add(dr);
            }
            DataSet ds = new DataSet();

            ds.Tables.Add(dt);
            return(ds);
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(TFXK.Model.TourCategory model)
 {
     dal.Update(model);
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TFXK.Model.TourCategory model)
 {
     return(dal.Add(model));
 }