Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Wgw_listEntity> DataTableToList(DataTable dt)
        {
            List<Wgw_listEntity> modelList = new List<Wgw_listEntity>();
            int rowsCount = dt.Rows.Count;
            int result;
            if (rowsCount > 0)
            {
                Wgw_listEntity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Wgw_listEntity();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.id = int.TryParse(dt.Rows[n]["id"].ToString(), out result) ? result : 0;
                    model.typeone = dt.Rows[n]["typeone"].ToString();
                    model.typetwo = dt.Rows[n]["typetwo"].ToString();
                    if (dt.Rows[n]["pid"].ToString() != "")
                    {
                        model.pid = int.Parse(dt.Rows[n]["pid"].ToString());
                    }
                    model.pid = int.TryParse(dt.Rows[n]["pid"].ToString(), out result) ? result : 0;
                    if (dt.Rows[n]["clientid"].ToString() != "")
                    {
                        model.clientid = int.Parse(dt.Rows[n]["clientid"].ToString());
                    }
                    model.clientid = int.TryParse(dt.Rows[n]["clientid"].ToString(), out result) ? result : 0;
                    model.listname = dt.Rows[n]["listname"].ToString();
                    model.listdesc = dt.Rows[n]["listdesc"].ToString();
                    if (dt.Rows[n]["listorder"].ToString() != "")
                    {
                        model.listorder = int.Parse(dt.Rows[n]["listorder"].ToString());
                    }
                    model.listorder = int.TryParse(dt.Rows[n]["listorder"].ToString(), out result) ? result : 0;
                    model.listcover = dt.Rows[n]["listcover"].ToString();
                    if (dt.Rows[n]["isshow"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isshow"].ToString() == "1") || (dt.Rows[n]["isshow"].ToString().ToLower() == "true"))
                        {
                            model.isshow = true;
                        }
                        else
                        {
                            model.isshow = false;
                        }
                    }
                    model.icon = dt.Rows[n]["icon"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Wgw_listEntity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Wgw_list(");
            strSql.Append("typeone,typetwo,pid,clientid,listname,listdesc,listorder,listcover,isshow,icon");
            strSql.Append(") values (");
            strSql.Append("@typeone,@typetwo,@pid,@clientid,@listname,@listdesc,@listorder,@listcover,@isshow,@icon");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters = {
                        new SqlParameter("@typeone", SqlDbType.NVarChar,150) ,
                        new SqlParameter("@typetwo", SqlDbType.NVarChar,150) ,
                        new SqlParameter("@pid", SqlDbType.Int,4) ,
                        new SqlParameter("@clientid", SqlDbType.Int,4) ,
                        new SqlParameter("@listname", SqlDbType.NVarChar,50) ,
                        new SqlParameter("@listdesc", SqlDbType.NVarChar,300) ,
                        new SqlParameter("@listorder", SqlDbType.Int,4) ,
                        new SqlParameter("@listcover", SqlDbType.VarChar,300) ,
                        new SqlParameter("@isshow", SqlDbType.Bit,1) ,
                        new SqlParameter("@icon", SqlDbType.VarChar,100)

            };

            parameters[0].Value = model.typeone;
            parameters[1].Value = model.typetwo;
            parameters[2].Value = model.pid;
            parameters[3].Value = model.clientid;
            parameters[4].Value = model.listname;
            parameters[5].Value = model.listdesc;
            parameters[6].Value = model.listorder;
            parameters[7].Value = model.listcover;
            parameters[8].Value = model.isshow;
            parameters[9].Value = model.icon;

            DataTable dt = DBExecuteUtil.querySqlTable(strSql.ToString(), parameters);
            if (dt.Rows.Count == 0)
            {

                return 0;

            }
            else
            {

                return Convert.ToInt32(dt.Rows[0][0].ToString());

            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Wgw_listEntity model)
        {
            StringBuilder strSql = new StringBuilder();
            List<SqlParameter> parameters = new List<SqlParameter>();
            strSql.Append("update Wgw_list set ");

            if (!string.IsNullOrEmpty(model.typeone))
            {
                strSql.Append(" typeone = @typeone , ");
                parameters.Add(new SqlParameter("@typeone", model.typeone));
            }
            if (!string.IsNullOrEmpty(model.typetwo))
            {
                strSql.Append(" typetwo = @typetwo , ");
                parameters.Add(new SqlParameter("@typetwo", model.typetwo));
            }
            if (true)
            {
                strSql.Append(" pid = @pid , ");
                parameters.Add(new SqlParameter("@pid", model.pid));
            }

            if (true)
            {
                strSql.Append(" clientid = @clientid , ");
                parameters.Add(new SqlParameter("@clientid", model.clientid));
            }

            if (!string.IsNullOrEmpty(model.listname))
            {
                strSql.Append(" listname = @listname , ");
                parameters.Add(new SqlParameter("@listname", model.listname));
            }
            if (!string.IsNullOrEmpty(model.listdesc))
            {
                strSql.Append(" listdesc = @listdesc , ");
                parameters.Add(new SqlParameter("@listdesc", model.listdesc));
            }
            if (true)
            {
                strSql.Append(" listorder = @listorder , ");
                parameters.Add(new SqlParameter("@listorder", model.listorder));
            }

            if (!string.IsNullOrEmpty(model.listcover))
            {
                strSql.Append(" listcover = @listcover , ");
                parameters.Add(new SqlParameter("@listcover", model.listcover));
            }
            strSql.Append(" isshow = @isshow , ");
            parameters.Add(new SqlParameter("@isshow", model.isshow));

            if (!string.IsNullOrEmpty(model.icon))
            {
                strSql.Append(" icon = @icon , ");
                parameters.Add(new SqlParameter("@icon", model.icon));
            } strSql = strSql.Remove(strSql.Length - 2, 2);
            strSql.Append(" where id=@id ");
            parameters.Add(new SqlParameter("@id", model.id));
            int rows = DBExecuteUtil.ExecuteSqlWithParams(strSql.ToString(), parameters.ToArray());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 获取分页数据
 /// </summary>
 /// <returns></returns>
 public DataTable GetPage(int pageIndex, int pageSize, Wgw_listEntity model, out int count)
 {
     count = 0;
     SqlParameter[] items = new SqlParameter[]{
         new SqlParameter("pageIndex",pageIndex),
         new SqlParameter("pageSize",pageSize),
         new SqlParameter("count",count)
     };
     items[2].Direction = ParameterDirection.Output;
     var dt = DBStoreProUtil.queryProTable4Params("proc_Wgw_list_Pagedata", items);
     count = int.Parse(items[2].Value.ToString());
     return dt;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Wgw_listEntity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id, typeone, typetwo, pid, clientid, listname, listdesc, listorder, listcover, isshow, icon  ");
            strSql.Append("  from Wgw_list ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            Wgw_listEntity model = new Wgw_listEntity();
            DataTable dt = DBExecuteUtil.querySqlTable(strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
                model.typeone = dt.Rows[0]["typeone"].ToString();
                model.typetwo = dt.Rows[0]["typetwo"].ToString();
                if (dt.Rows[0]["pid"].ToString() != "")
                {
                    model.pid = int.Parse(dt.Rows[0]["pid"].ToString());
                }
                if (dt.Rows[0]["clientid"].ToString() != "")
                {
                    model.clientid = int.Parse(dt.Rows[0]["clientid"].ToString());
                }
                model.listname = dt.Rows[0]["listname"].ToString();
                model.listdesc = dt.Rows[0]["listdesc"].ToString();
                if (dt.Rows[0]["listorder"].ToString() != "")
                {
                    model.listorder = int.Parse(dt.Rows[0]["listorder"].ToString());
                }
                model.listcover = dt.Rows[0]["listcover"].ToString();
                if (dt.Rows[0]["isshow"].ToString() != "")
                {
                    if ((dt.Rows[0]["isshow"].ToString() == "1") || (dt.Rows[0]["isshow"].ToString().ToLower() == "true"))
                    {
                        model.isshow = true;
                    }
                    else
                    {
                        model.isshow = false;
                    }
                }
                model.icon = dt.Rows[0]["icon"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Wgw_listEntity model)
 {
     return dal.Add(model);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Wgw_listEntity model)
 {
     return dal.Update(model);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 获得分页数据
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="model"></param>
 /// <returns></returns>
 public DataTable GetPage(int pageIndex, int pageSize, Wgw_listEntity model, out int count)
 {
     return dal.GetPage(pageIndex, pageSize, model, out count);
 }