public SqlServerTest()
        {
            SqlServerExpress.Configuration.TraceService = traceService = new TestTraceService();
            db = SqlServerExpress.Connect("TestDatabase");


            db.T("IF OBJECT_ID(N'[dbo].[Test1]') IS NOT NULL DROP TABLE [dbo].[Test1]").ExecuteNonQuery();
            db.T(@"
CREATE TABLE [dbo].[Test1]
(
    [ID] INT NOT NULL IDENTITY,
    [Name] NVARCHAR(50) NOT NULL , 
    [Content] NTEXT NULL, 
    [XmlContent] XML NULL,
    [Index] INT NOT NULL, 
    CONSTRAINT [PK_Test1] PRIMARY KEY ([ID]) 
)").ExecuteNonQuery();
        }
Exemple #2
0
    public SqlServerTest()
    {
      SqlServerExpress.Configuration.TraceService = traceService = new TestTraceService();
      db = SqlServerExpress.Connect( "TestDatabase" );


      db.T( "IF OBJECT_ID(N'[dbo].[Test1]') IS NOT NULL DROP TABLE [dbo].[Test1]" ).ExecuteNonQuery();
      db.T( @"
CREATE TABLE [dbo].[Test1]
(
    [ID] INT NOT NULL IDENTITY,
    [Name] NVARCHAR(50) NOT NULL , 
    [Content] NTEXT NULL, 
    [XmlContent] XML NULL,
    [Index] INT NOT NULL, 
    CONSTRAINT [PK_Test1] PRIMARY KEY ([ID]) 
)" ).ExecuteNonQuery();
    }
Exemple #3
0
        private void InitRepeater1(SqlDbExecutor db, int currentPageIndex = 1, string customerId = "0", string startDate = "", string endDate = "")
        {
            //using (var context = new ReportContext())
            //{
            //    var items = context.Articles.ToList();
            //    if(customerId != "0")
            //    {
            //        int _customerId = int.Parse(customerId);
            //        items = items.Where(a => a.CustomerID == _customerId).ToList();
            //    }
            //    if(startDate != "" && endDate != "")
            //    {
            //        DateTime _startDate = DateTime.Parse(startDate);
            //        DateTime _endDate = DateTime.Parse(endDate);
            //        items = items.Where(a => a.AddDate >= _startDate && a.AddDate <= _endDate).ToList();
            //    }
            //    DataTable tempTable = (DataTable)ViewState["tempTable"];
            //    IEnumerable<DataRow> rows = new List<DataRow>();
            //    items.ForEach(item =>
            //    {
            //        DataRow row = tempTable.NewRow();
            //        row["ID"] = item.ID.ToString();
            //        row["Title"] = item.Title;
            //        row["ChannelType"] = item.ChannelType.ToString();
            //        row["ReplyCount"] = item.ReplyCount.ToString();
            //        row["Rating"] = item.Rating.ToString();
            //        row["AddDate"] = item.AddDate.ToString();
            //        row["Url"] = item.Url;
            //        row["CustomerID"] = item.CustomerID.ToString();
            //        row["RelateQuestion"] = item.RelateQuestion;
            //        tempTable.Rows.Add(row);
            //    });
            //    this.AspNetPager1.RecordCount = tempTable.Rows.Count;
            //    this.AspNetPager1.CurrentPageIndex = currentPageIndex;
            //    PagedDataSource dataSource = new PagedDataSource();

            //    //this.Repeater1.DataSource = tempTable.Rows.
            //    //this.Repeater1.DataBind();
            //}
            string con = "WHERE 1=1";

            if (customerId != "0")
            {
                con += " AND CustomerID = " + customerId;
            }
            if (startDate != "" && endDate != "")
            {
                con += String.Format(" AND AddDate >= '{0}' AND AddDate <= '{1}'", startDate + " 00:00:00", endDate + " 00:00:00");
            }
            string         sql      = String.Format("SELECT TOP {0} ID,Title,ChannelType,ReplyCount,Rating,AddDate,Url,CustomerID,RelateQuestion FROM ARTICLE WHERE ID NOT IN(SELECT TOP {1} ID FROM Article {2}  ORDER BY  ID DESC) {3} ORDER BY ID DESC", this.AspNetPager1.PageSize, (((currentPageIndex - 1) * this.AspNetPager1.PageSize)), con, con.Replace("WHERE", "AND"));
            string         countSql = String.Format("SELECT COUNT(ID) FROM Article {0}", con);
            var            count    = db.T(countSql).ExecuteScalar <int>();
            DataTable      table    = db.T(sql).ExecuteDataTable();
            List <DataRow> rows     = new List <DataRow>();

            foreach (DataRow row in table.Rows)
            {
                rows.Add(row);
            }
            this.AspNetPager1.RecordCount      = count;
            this.AspNetPager1.CurrentPageIndex = currentPageIndex;
            this.Repeater1.DataSource          = table;
            this.Repeater1.DataBind();
        }
        protected static bool IsUserExist(string userName)
        {
            var userInfo = db.T("select * from Users where userName = {0}", userName).ExecuteFirstRow();

            return(userInfo != null);
        }
Exemple #5
0
 public void Initialize()
 {
     db.T("TRUNCATE TABLE Test1").ExecuteNonQuery();
 }