Ejemplo n.º 1
0
 public List<TemplateInfo> GetTemplateInfoListByUserId(string userId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(TemplateInfo));
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return TransferList<TemplateInfo>(dt);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 登录,并返回登录用户。如果登录失败,则返回null。
 /// </summary>
 /// <param name="loginName">登录名</param>
 /// <param name="password">加密后的密码</param>
 /// <returns></returns>
 public UserInfo Login(string loginName, string password)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(UserInfo));
     sqlSelect += string.Format("WHERE [LoginName] = N'{0}' AND [Password] = N'{1}'", loginName, password);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<UserInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
 public ItemCategoryInfo GetItemCategoryById(string categoryId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ItemCategoryInfo));
     sqlSelect += string.Format("WHERE [CategoryId] = N'{0}'", categoryId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<ItemCategoryInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
Ejemplo n.º 4
0
 public TemplateContentInfo GetTemplateContentById(string templateId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(TemplateContentInfo));
     sqlSelect += string.Format(" WHERE [Id] = '{0}'", templateId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<TemplateContentInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
        public void TestAddItemCategory_正确添加()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";

            #region 验证前置条件

            MSSql2005Query query = new MSSql2005Query();
            string sqlQuery = query.GenerateSelectViewSql(typeof(ItemCategoryInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            string idNew = facade.AddItemCategory(id, "50011665", "0", "网游装备/游戏币/帐号/代练", false, "normal", 0);

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("50011665", dt.Rows[0]["CategoryId"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("网游装备/游戏币/帐号/代练", dt.Rows[0]["Name"].ToString(), true);
                Assert.AreEqual("false", dt.Rows[0]["IsParent"].ToString(), true);
                Assert.AreEqual("normal", dt.Rows[0]["Status"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["SortOrder"].ToString(), true);
            }

            #endregion
        }
Ejemplo n.º 6
0
        public void TestAddArea_正确添加区域()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-037453d53919";

            #region 验证前置条件

            MSSql2005Query query = new MSSql2005Query();
            string sqlQuery = query.GenerateSelectViewSql(typeof(AreaInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            AreaFacade facade = new AreaFacade();
            string idNew = facade.AddArea(id, "401331", AreaType.Province, "重庆市", "", "401331");

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-037453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-037453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("401331", dt.Rows[0]["AreaId"].ToString(), true);
                Assert.AreEqual("2", dt.Rows[0]["AreaType"].ToString(), true);
                Assert.AreEqual("重庆市", dt.Rows[0]["AreaName"].ToString(), true);
                Assert.AreEqual("", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("401331", dt.Rows[0]["Zip"].ToString(), true);
            }

            #endregion
        }
 public List<ItemCategoryInfo> GetItemCategoryListByParent(string parentId)
 {
     if (string.IsNullOrEmpty(parentId))
     {
         parentId = "0";
     }
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ItemCategoryInfo));
     sqlSelect += string.Format("WHERE [ParentId] = N'{0}' ", parentId);
     sqlSelect += "ORDER BY [SortOrder] ASC";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         List<ItemCategoryInfo> list = new List<ItemCategoryInfo>();
         DataTable dt = dbOperator.GetTable(sqlSelect);
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<ItemCategoryInfo>(row));
         }
         return list;
     }
 }
 public bool IsItemCategoryExist(string categoryId)
 {
     string sqlCheck = sqlHelper.GenerateCountViewSql(typeof(ItemCategoryInfo));
     sqlCheck += string.Format("WHERE [CategoryId] = N'{0}'", categoryId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlCheck);
         int i = (int)dt.Rows[0][0];
         return i > 0;
     }
 }
Ejemplo n.º 9
0
 public List<AreaInfo> GetAllProvinceAreaList()
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(AreaInfo));
     sqlSelect += string.Format("WHERE [AreaType] = N'{0}'", (int)AreaType.Province);
     sqlSelect += " ORDER BY [AreaId]";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         List<AreaInfo> list = new List<AreaInfo>();
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<AreaInfo>(row));
         }
         return list;
     }
 }
Ejemplo n.º 10
0
 public bool IsHasChildren(string parentId)
 {
     string sqlSelect = sqlHelper.GenerateCountViewSql(typeof(AreaInfo));
     sqlSelect += string.Format("WHERE [ParentId] = N'{0}'", parentId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return (int)dt.Rows[0]["RowCount"] > 0;
     }
 }
Ejemplo n.º 11
0
 public bool IsAreaExist(string areaId)
 {
     string sqlCheck = sqlHelper.GenerateCountViewSql(typeof(AreaInfo));
     sqlCheck += string.Format("WHERE [AreaId] = N'{0}'", areaId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlCheck);
         return (int)dt.Rows[0]["RowCount"] > 0;
     }
 }
Ejemplo n.º 12
0
 public List<AreaInfo> GetAllRootAreaList()
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(AreaInfo));
     sqlSelect += "WHERE [ParentId] = N'0'";
     sqlSelect += " ORDER BY [AreaId]";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         List<AreaInfo> list = new List<AreaInfo>();
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<AreaInfo>(row));
         }
         return list;
     }
 }
Ejemplo n.º 13
0
        public List<ImportItemInfo> GetImportItemList(string groupId, int pageIndex, int pageSize)
        {
            int start = pageIndex * pageSize + 1;
            int end = start + pageSize - 1;
            string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ImportItemInfo));
            sqlSelect += string.Format("WHERE [ItsImportGroupId] = N'{0}'", groupId);
            sqlSelect = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY [LastUpdateDate] DESC) AS [RowNum] FROM ("
                + sqlSelect
                + string.Format(") AS [MyTable]) AS [T1] WHERE [T1].[RowNum] BETWEEN {0} AND {1}", start, end);

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                DataTable dt = dbOperator.GetTable(sqlSelect);
                return TransferList<ImportItemInfo>(dt);
            }
        }
Ejemplo n.º 14
0
 public List<ImportItemInfo> GetImportItemList(string groupId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ImportItemInfo));
     sqlSelect += string.Format("WHERE [ItsImportGroupId] = N'{0}'", groupId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return TransferList<ImportItemInfo>(dt);
     }
 }