public static Result GetInfo()
    {
        var        result     = new Result <List <Style> >();
        DbHelperV2 dbhelperv2 = new DbHelperV2();
        //此处需优化,参数化处理
        var sqltextFomat = "select * from [clothes].[dbo].[style]";
        var dt           = dbhelperv2.ExecuteDataTable(sqltextFomat);

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 403;
            result.Message = "查无此人!";
            //result.Message = "查无此人!";
            result.IsTrue = false;
            result.Data   = new List <Style>();
            return(result);
        }
        var dts = dt.ToStyles();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = dts;
        result.IsTrue  = true;
        return(result);
    }
    public static Result GetInfoById(string userId)
    {
        DbHelperV2 dbhelperv2 = new DbHelperV2();
        var        result     = new Result <Figure>();
        //此处需优化,参数化处理
        var sqltextFomat = "select * from [clothes].[dbo].[figure] where userId={0}";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, userId));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code = 403;
            //result.Message = "查无此人!";
            result.IsTrue = false;
            result.Data   = new Figure();
            return(result);
        }
        var figures = dt.ToFigures();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = figures[0];
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 3
0
    public static Result getClothByIds(string ids)
    {
        var result = new Result <List <Cloth> >();
        //此处需优化,参数化处理
        var        sqltextFomat = "SELECT a.*, b.type from [clothes].[dbo].[cloth] as a, [clothes].[dbo].[clothType] as b where a.id in ({0}) and a.clothTypeId = b.id";
        DbHelperV2 dbhelperv2   = new DbHelperV2();
        var        dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, ids));
        var        dts          = dt.ToCloths();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = dts;
        result.IsTrue  = true;
        return(result);
    }
    public Result share_all_get()
    {
        var result = new Result <List <Share> >();
        //此处需优化,参数化处理
        var sqltextFomat = "select a.id, clothId, a.userId, date, belong, describe, b.clothName, b.imgUrl from [clothes].[dbo].[share] as a, [clothes].[dbo].[cloth] as b where a.clothId=b.id";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 200;
            result.Message = "暂无数据!";
            result.IsTrue  = false;
            result.Data    = new List <Share>();
            return(result);
        }
        var shares = dt.ToShares();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = shares;
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 5
0
    public Result collection_get(int userId)
    {
        var result = new Result <List <Collection> >();
        //此处需优化,参数化处理
        var sqltextFomat = "select a.id, a.userId, clothId, startTime, a.endTime, b.clothName, b.imgUrl from [clothes].[dbo].[collection] as a, [clothes].[dbo].[cloth] as b where a.clothId=b.id";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, userId));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 200;
            result.Message = "没有收藏记录!";
            result.IsTrue  = false;
            result.Data    = new List <Collection>();
            return(result);
        }
        var collections = dt.ToCollections();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = collections;
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 6
0
    public static Result GetInfoByTypeOrName(string typeid, string name, string userId, string id)
    {
        var result   = new Result <List <Cloth> >();
        var whereexp = "a.clothTypeId = b.id";

        if (!string.IsNullOrEmpty(userId))
        {
            whereexp = whereexp + " and a.userId=" + userId;
        }

        if (!string.IsNullOrEmpty(id))
        {
            whereexp = whereexp + " and a.id=" + id;
        }

        if (typeid != "")
        {
            whereexp = whereexp + " and clothTypeId=" + typeid;
        }
        if (!string.IsNullOrEmpty(name))
        {
            whereexp = whereexp + " and clothName LIKE '%" + name + "%'";
        }

        //此处需优化,参数化处理
        var        sqltextFomat = "select a.*, b.type from [clothes].[dbo].[cloth] as a, [clothes].[dbo].[clothType] as b where {0}";
        DbHelperV2 dbhelperv2   = new DbHelperV2();
        var        dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, whereexp));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 200;
            result.Message = "查无此人!";
            result.IsTrue  = false;
            result.Data    = new List <Cloth>();
            return(result);
        }
        var dts = dt.ToCloths();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = dts;
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 7
0
    public Result Thumb_up_delete(int id)
    {
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        DbHelperV2 dbhelperv2 = new DbHelperV2();
        var        result     = new Result <List <Link> >();
        //此处需优化,参数化处理
        var sqltextFomat = "delete from [clothes].[dbo].[link] where id='{0}'";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, id));

        result.Code    = 200;
        result.Message = "成功!";
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 8
0
    public Result Thumb_insert(int userId, int clothId)
    {
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        DbHelperV2 dbhelperv2 = new DbHelperV2();
        var        result     = new Result <List <Link> >();
        //此处需优化,参数化处理
        var sqltextFomat = "insert into [clothes].[dbo].[link] (userId, clothId) values ('{0}', '{1}') ";

        dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, userId, clothId));

        result.Code    = 200;
        result.Message = "成功!";
        result.IsTrue  = true;
        return(result);
    }
    public static Result GetInfoByTypeOrName(string styeid, string name, string userId)
    {
        DbHelperV2 dbhelperv2 = new DbHelperV2();
        var        result     = new Result <List <Chuanda> >();
        var        whereexp   = " userId=" + userId;

        if (!string.IsNullOrEmpty(styeid))
        {
            whereexp = whereexp + " and styleId=" + styeid;
        }
        if (!string.IsNullOrEmpty(name))
        {
            whereexp = whereexp + " and name LIKE '%" + name + "%'";
        }

        //此处需优化,参数化处理
        var sqltextFomat = @"SELECT TOP 1000 cd.[id]
                                ,[styleId]
                                ,[clothIds]
                                ,cd.[describe]
                                ,[userId]
                                ,[createTime]
                                ,[endTime]
                                ,cd.[name]
	                            ,sl.sName
	                            ,sl.describe as styledescribe
                    FROM [clothes].[dbo].[chuanda] cd inner join [clothes].[dbo].[style] sl  on {0} and cd.styleId= sl.id";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, whereexp));

        var dts = dt.ToChuanDa();

        //result.Code = 200;
        //result.Message = "成功!";
        //result.Data = dts;
        //result.IsTrue = true;
        //return result;
        return(new Result <List <Chuanda> > {
            Code = 200, IsTrue = true, Message = "成功", Data = dts
        });
    }
    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="loginName"></param>
    /// <param name="loginPsw"></param>
    /// <returns></returns>
    private Result LoginClothes(string loginName, string loginPsw)
    {
        var result = new Result <List <User> >();
        //此处需优化,参数化处理
        var sqltextFomat = "select * from [clothes].[dbo].[user] where userName='******' and password='******'";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, loginName, loginPsw));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 403;
            result.Message = "查无此人!";
            result.IsTrue  = false;
            result.Data    = new List <User>();
            return(result);
        }
        var users = dt.ToUsers();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = users;
        result.IsTrue  = true;
        return(result);
    }
Esempio n. 11
0
    private Result getUser(string id)
    {
        var result = new Result <List <User> >();
        //此处需优化,参数化处理
        var sqltextFomat = "select * from [clothes].[dbo].[user] where id={0}";
        var dt           = dbhelperv2.ExecuteDataTable(string.Format(sqltextFomat, id));

        if (dt == null || dt.Rows.Count == 0)
        {
            //Error todo
            result.Code    = 403;
            result.Message = "查无此人!";
            result.IsTrue  = false;
            result.Data    = new List <User>();
            return(result);
        }
        var users = dt.ToUsers();

        result.Code    = 200;
        result.Message = "成功!";
        result.Data    = users;
        result.IsTrue  = true;
        return(result);
    }