Пример #1
0
 private void LoadProductListView(GridView girdView, string orderByColumnName, OrderType orderWay)
 {
     try
     {
         string    _sql      = @"select ProductID,ProductName,QuantityPerUnit,UnitPrice,UnitsOnOrder,Discontinued from dbo.Products";
         DataTable _table    = sqlHelper.ExecuteDataTable(_sql, null);
         DataView  _dataView = new DataView(_table);
         _dataView.Sort = string.Format("{0} {1}", orderByColumnName, orderWay);
         girdView.SetDataSource(_dataView);
     }
     catch (System.Exception ex)
     {
         ClientScriptHelper.Alert(ex.Message.Trim());
     }
 }
Пример #2
0
        public void ToExcelTest()
        {
            string    _xlsPath     = string.Format(@"D:\Employees_{0}.xls", DateTime.Now.FormatDate(12));
            DataTable _queryResult = sqlHelper.ExecuteDataTable(@"SELECT * FROM [Employees]", null);

            NPOIExcel.ToExcel(_queryResult, "Hello", "Employees", _xlsPath);
            bool _actual = File.Exists(_xlsPath);

            Assert.IsTrue(_actual);
        }
Пример #3
0
        public void ExecuteDataTableTest()
        {
            ExecuteNonQueryTest();
            string    _sql   = "select * from dbo.Person where PName=@pname";
            DataTable _table = SqlHelper.ExecuteDataTable(_sql, new DbParameter[1] {
                new SqlParameter("@pname", "YanZhiwei")
            });

            Assert.IsTrue(_table.Rows.Count > 0);
        }
Пример #4
0
        public void ToListTest()
        {
            SqlServerDataOperator _sqlHelper = new SqlServerDataOperator(@"server=YANZHIWEI-PC\SQLEXPRESS;database=AdventureWorks2014;uid=sa;pwd=sasa;");
            string                _sql       = @"SELECT [AddressID]
                                  ,[AddressLine1]
                                  ,[AddressLine2]
                                  ,[City]
                                  ,[StateProvinceID]
                                  ,[PostalCode]
                                  ,[rowguid]
                                  ,[ModifiedDate]
                                  FROM [Person].[Address]";
            DataTable             _result    = _sqlHelper.ExecuteDataTable(_sql, null);
            IEnumerable <Address> _actual    = GeneralMapper.ToList <Address>(_result);

            Assert.IsTrue(_actual.Count() > 0);
        }