public static object combo_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { SqlDataAdapter dAdapter; SqlConnection dbConn = new SqlConnection(localConnectionString); dbConn.Open(); DataSet ds = null; try { string tableName = "people", query = ""; SqlCommand cmd = new SqlCommand("select count(*) from " + tableName, dbConn); int count = (int)cmd.ExecuteScalar(); int pageSize = args.PageSize; if (pageSize <= 0) pageSize = count > 250 ? 250 : count; if (count > pageSize + args.StartRecordIndex) count = pageSize + args.StartRecordIndex; int numRows = count - args.StartRecordIndex; if (numRows > 0) { string sortField = "ContactName"; Nitobi.SortOrder sortOrder = Nitobi.SortOrder.Asc; if (!Cmn.IsEmpty(args.SortColumn)) { sortField = args.SortColumn; sortOrder = args.SortDirection; } string ReverseDirection; if (sortOrder == Nitobi.SortOrder.Asc) ReverseDirection = Nitobi.SortOrder.Desc.ToString(); else ReverseDirection = Nitobi.SortOrder.Asc.ToString(); // The reason for this overly complicated SQL query is due to the fact that MDB does not support proper paging. // Using a server such as Oracle or MySql would eliminate the complexity of this query, and most of the // preceeding code. // SELECT TOP 25 * FROM tblCustomers WHERE ContactName LIKe 'search%' string sort = " ORDER BY ContactID ASC"; query = "SELECT TOP " + numRows + " * FROM ("; query += "SELECT ROW_NUMBER() OVER (" + sort + ") AS Row, * FROM " + tableName; query += " WHERE " + sortField + " LIKE '" + args.SearchString + "%'"; query += ") AS X WHERE Row > " + args.StartRecordIndex.ToString(); } // Fill the tables from the dataset with the data from the database. ds = new DataSet(); ds.Tables.Add(tableName); if (numRows > 0) { dAdapter = new SqlDataAdapter(query, dbConn); dAdapter.Fill(ds.Tables[tableName]); addImageCol(ds.Tables[0]); } } finally { dbConn.Close(); } return ds; }
//------------------------------------------------------------------------------------------------------------ public static object customers_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["customers"] == null) { ArrayList l = new ArrayList(); l.Add(new Customer("0", "John", "Smith")); l.Add(new Customer("1", "Mark", "Aldrin")); l.Add(new Customer("2", "Matthew", "Jones")); l.Add(new Customer("3", "Luke", "Kettle")); System.Web.HttpContext.Current.Session["customers"] = l; } return System.Web.HttpContext.Current.Session["customers"]; }
//------------------------------------------------------------------------------------------------------------ public static object productIds_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { OleDbDataAdapter dAdapter; string serverPath = System.Web.HttpContext.Current.Server.MapPath("~"); OleDbConnection dbConn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\generalproducts.mdb"); dbConn.Open(); OleDbCommand cmd = new OleDbCommand("select count(*) from tblProducts", dbConn); int count = (int)cmd.ExecuteScalar(); if (count > args.PageSize + args.StartRecordIndex) count = args.PageSize + args.StartRecordIndex; int numRows = count - args.StartRecordIndex; string query = ""; string sortField = "ProductID"; Nitobi.SortOrder sortOrder = Nitobi.SortOrder.Asc; if (!Cmn.IsEmpty(args.SortColumn)) { sortField = args.SortColumn; sortOrder = args.SortDirection; } string ReverseDirection; if (sortOrder == Nitobi.SortOrder.Asc) ReverseDirection = Nitobi.SortOrder.Desc.ToString(); else ReverseDirection = Nitobi.SortOrder.Asc.ToString(); string tableName; // The reason for this overly complicated SQL query is due to the fact that MDB does not support proper paging. // Using a server such as Oracle or MySql would eliminate the complexity of this query, and most of the // preceeding code. query = "SELECT * FROM tblProductCategories"; if (!Cmn.IsEmpty(args.SearchString)) query += " WHERE ProductCategoryName LIKE '" + args.SearchString + "%'"; tableName = "tblProductCategories"; DataSet ds = new DataSet(); ds.Tables.Add(tableName); dAdapter = new OleDbDataAdapter(query, dbConn); dAdapter.Fill(ds.Tables[tableName]); addImageCol(ds.Tables[0]); return ds; }
public static object indentedProductNames_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { DataSet ds = default_GetData(request, args) as DataSet; if (ds != null) { DataTable products = ds.Tables[0]; int indent = 0; foreach (DataRow row in products.Rows) { row["ProductName"] = string.Format("#<#span style='padding-left: {0}px'#>#{1}#<#/span#>#", indent++ * 25, row["ProductName"]); if (indent > 3) indent = 0; } } return ds; }
public static object fileSys_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { ArrayList files = new ArrayList(); try { string serverPath = System.Web.HttpContext.Current.Server.MapPath("~"); string parentPath = args.ParentRow == null?"":(string)args.ParentRow["ParentPath"]; string curPath = args.ParentRow == null ? "" : (string)args.ParentRow["label"]; DirectoryInfo di = new DirectoryInfo(Cmn.pathCombine(serverPath, parentPath, curPath)); if (di.Exists) { string parentName = di.FullName; parentName = di.FullName.Substring(serverPath.Length); foreach (DirectoryInfo cdi in di.GetDirectories()) { FileSysInfo fs = new FileSysInfo(parentName, cdi.Name, true); if (string.Compare(cdi.Name, "App_Themes", true) == 0 || string.Compare(curPath, "App_Themes", true) == 0) fs.Icon = "images/theme.png"; files.Add(fs); } foreach (FileInfo cfi in di.GetFiles()) { FileSysInfo fs = new FileSysInfo(parentName, cfi.Name, false); if (File.Exists(Cmn.pathCombine(serverPath, "images", cfi.Extension.Substring(1) + ".png"))) fs.Icon = "images/" + cfi.Extension.Substring(1) + ".png"; files.Add(fs); } } } catch (Exception e) { FileSysInfo fs = new FileSysInfo("", e.ToString(), false); files.Add(fs); } return files; }
public static object eventTypes_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["CalEventTypes"] == null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(@" <EventTypes> <EventType Display='Holiday' Value='CalEvent_Holiday' /> <EventType Display='Birthday' Value='CalEvent_Birthday' /> <EventType Display='Flight' Value='CalEvent_Flight' /> <EventType Display='Car In Shop' Value='CalEvent_CarInShop' /> </EventTypes> "); System.Web.HttpContext.Current.Session["CalEventTypes"] = doc; } return ((XmlDocument)System.Web.HttpContext.Current.Session["CalEventTypes"]).SelectNodes("//EventType"); }
public virtual int getTotalDataSize(HttpRequest request, AjaxGetDataHandlerEventArgs info) { if (GetTotalRowCount != null) return (int)GetTotalRowCount(request, info); else if (m_dataSource != null && m_dataSource is IList) return ((IList)m_dataSource).Count; return -1; }
public static object customers_GetTotalRowCount(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["customers"] == null) customers_GetData(request, args); return ((ArrayList)System.Web.HttpContext.Current.Session["customers"]).Count; }
public static object xmlCustomers_GetTotalRowCount(HttpRequest request, AjaxGetDataHandlerEventArgs args) { return ((XmlNodeList)xmlCustomers_GetData(request, args)).Count; }
public static object worldTree_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { SqlDataAdapter dAdapter; SqlConnection dbConn = new SqlConnection(localConnectionString); dbConn.Open(); DataSet ds = null; ds = new DataSet(); ArrayList regions = new ArrayList(); string tableName = "tblRegions"; string sortColumn = "RegionName"; string regionOwner = args.ParentRow["RegionID"] == "0" ? "0" : (string)args.ParentRow["RegionID"]; string query = "SELECT * FROM " + tableName + " WHERE RegionOwner = '" + regionOwner + "' ORDER BY " + sortColumn + " ASC"; try { ds.Tables.Add(tableName); dAdapter = new SqlDataAdapter(query, dbConn); dAdapter.Fill(ds.Tables[tableName]); foreach (DataRow dr in ds.Tables[tableName].Rows) { WorldNode wn = new WorldNode((string)dr["RegionName"], dr["RegionOwner"].ToString(), (int)dr["RegionID"]); regions.Add(wn); } } finally { dbConn.Close(); } return regions; }
public static object unicode_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { StreamReader sr = new StreamReader(request.PhysicalApplicationPath + "combo\\CountryNamesAndFlags.xml"); string countries_xml = "", line; line = sr.ReadLine(); while (line != null) { countries_xml += line; line = sr.ReadLine(); } sr.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(@countries_xml); System.Web.HttpContext.Current.Session["unicode_countries"] = doc; return ((XmlDocument)System.Web.HttpContext.Current.Session["unicode_countries"]).SelectNodes("//memberNation"); }
public static object unbound_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["xmlCities"] == null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(@" <Cities> <City Id=""0"" CityName=""Vancouver"" Population=""3,000,000"" /> <City Id=""1"" CityName=""Toronto"" Population=""4,500,000"" /> <City Id=""2"" CityName=""Ottawa"" Population=""1,000,000"" /> <City Id=""3"" CityName=""California"" Population=""4,500,000"" /> <City Id=""4"" CityName=""Halifax"" Population=""900,000"" /> <City Id=""5"" CityName=""Calgary"" Population=""1,500,000"" /> <City Id=""6"" CityName=""Red Deer"" Population=""100,000"" /> <City Id=""7"" CityName=""Prince George"" Population=""200,000"" /> <City Id=""8"" CityName=""Portland"" Population=""1,500,000"" /> <City Id=""9"" CityName=""Atlanta"" Population=""4,500,000"" /> </Cities> "); System.Web.HttpContext.Current.Session["xmlCities"] = doc; } return ((XmlDocument)System.Web.HttpContext.Current.Session["xmlCities"]).SelectNodes("//City"); }
public static object smartsearch_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { string tableName = "tblFolderInfo"; string searchField = "FolderAbsolute"; string sortField = "FolderAbsolute"; Nitobi.SortOrder sortOrder = Nitobi.SortOrder.Asc; string query = ""; int numRows = 0; SqlDataAdapter dAdapter; SqlConnection dbConn = new SqlConnection(localConnectionString); dbConn.Open(); try { SqlCommand cmd = new SqlCommand("select count(*) from " + tableName, dbConn); int count = (int)cmd.ExecuteScalar(); int pageSize = args.PageSize; if (pageSize <= 0) pageSize = count > 250 ? 250 : count; if (count > pageSize + args.StartRecordIndex) count = pageSize + args.StartRecordIndex; numRows = count - args.StartRecordIndex; if (numRows > 0) { if (!Cmn.IsEmpty(args.SortColumn)) { sortField = args.SortColumn; sortOrder = args.SortDirection; } string ReverseDirection; if (sortOrder == Nitobi.SortOrder.Asc) ReverseDirection = Nitobi.SortOrder.Desc.ToString(); else ReverseDirection = Nitobi.SortOrder.Asc.ToString(); // The reason for this overly complicated SQL query is due to the fact that MDB does not support proper paging. // Using a server such as Oracle or MySql would eliminate the complexity of this query, and most of the // preceeding code. string sort = " ORDER BY " + sortField + " " + sortOrder; query = "SELECT TOP " + numRows + " * FROM ("; query += "SELECT ROW_NUMBER() OVER (" + sort + ") AS Row, * FROM " + tableName + ") AS X WHERE Row > " + args.StartRecordIndex.ToString(); if (!Cmn.IsEmpty(args.SearchString)) query += " AND " + searchField + " LIKE '%" + args.SearchString + "%'"; } } finally { dbConn.Close(); } return generic_GetData(tableName, query, numRows); }
public static object roomavailability_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { ArrayList l = new ArrayList(); l.Add(new BaseCalendarEvent(DateTime.Now, "Nitobi Office", "We test CUI.NET today!", "event", null, null, null)); return l; }
protected override void writeClientInnerContents(HtmlTextWriter writer) { base.writeClientInnerContents(writer); if ((GetDataUrl == null || LocalDataDepth > 0) && m_dataHandler != null) { AjaxGetDataHandlerEventArgs info = new AjaxGetDataHandlerEventArgs(AjaxRequestTypes.TreeGetDataRequest, DataSourceId == null ? s_defaultDataSourceId : DataSourceId, 0, -1); info.MaxTreeDepth = LocalDataDepth - 1; m_dataHandler.generateFullCompressedXml(System.Web.HttpContext.Current.Request, writer, Columns, info); } }
//------------------------------------------------------------------------------------------------------------ public static object roomAvailability_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["roomAvailability"] == null) { ArrayList l = new ArrayList(); l.Add(new BaseCalendarEvent(DateTime.Today + new TimeSpan(7, 0, 0, 0, 0), "Cebu City", "Scuba diving at Ocean Safari", "event", null, null, "border-top:solid red 2px;border-left:solid red 2px;")); l.Add(new BaseCalendarEvent(DateTime.Today + new TimeSpan(12, 0, 0, 0, 0), "Moal-Boal", "Photo shoot for Living magazine", "event", null, "CalEvent_Flight", null)); l.Add(new BaseCalendarEvent(DateTime.Today + new TimeSpan(18, 0, 0, 0, 0), "Cebu City", "Scuba diving at Ocean Safari", "event", null, "CalEvent_Flight", null)); l.Add(new BaseCalendarEvent(DateTime.Today - new TimeSpan(2, 0, 0, 0, 0), "Cebu City", "Wife birthday", "event", null, "CalEvent_Birthday", null)); System.Web.HttpContext.Current.Session["roomAvailability"] = l; } return System.Web.HttpContext.Current.Session["roomAvailability"]; }
public static object xmlCustomers_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { if (System.Web.HttpContext.Current.Session["xmlCustomers"] == null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(@" <Customers> <Customer Id= '0' FirstName='John'> <LastName>Smith</LastName> </Customer> <Customer Id= '1' FirstName='Mark' LastName='Aldrin' /> <Customer Id= '2' FirstName='Matthew' LastName='Jones' /> <Customer Id= '3' FirstName='Luke' LastName='Kettle' /> </Customers> "); System.Web.HttpContext.Current.Session["xmlCustomers"] = doc; } return ((XmlDocument)System.Web.HttpContext.Current.Session["xmlCustomers"]).SelectNodes("//Customer"); }
public static object default_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { SqlDataAdapter dAdapter; /* string serverPath = ""; serverPath = System.Web.HttpContext.Current.Server.MapPath(serverPath); OleDbConnection dbConn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\generalproducts.mdb"); */ SqlConnection dbConn = new SqlConnection(localConnectionString); dbConn.Open(); // Create a DataSet object - we will populate it full of data from our server and return that to the Grid. DataSet ds = null; try { string tableName = "people", query = ""; SqlCommand cmd = new SqlCommand("select count(*) from " + tableName, dbConn); int count = (int)cmd.ExecuteScalar(); int pageSize = args.PageSize; if (pageSize <= 0) pageSize = 10; if (count > 0) { string sortField = "ContactID"; Nitobi.SortOrder sortOrder = Nitobi.SortOrder.Asc; if (!Cmn.IsEmpty(args.SortColumn)) { sortField = args.SortColumn; sortOrder = args.SortDirection; } string ReverseDirection; if (sortOrder == Nitobi.SortOrder.Asc) ReverseDirection = Nitobi.SortOrder.Desc.ToString(); else ReverseDirection = Nitobi.SortOrder.Asc.ToString(); // The reason for this overly complicated SQL query is due to the fact that MDB does not support proper paging. // Using a server such as Oracle or MySql would eliminate the complexity of this query, and most of the // preceeding code. string sort = " ORDER BY " + sortField + " " + sortOrder; query = "SELECT TOP " + pageSize + " * FROM ("; query += "SELECT ROW_NUMBER() OVER (" + sort + ") AS Row, * FROM "+tableName+") AS X WHERE Row > " + args.StartRecordIndex.ToString(); if (!Cmn.IsEmpty(args.SearchString)) query += " AND JobTitle LIKE '%" + args.SearchString + "%'"; } // Fill the tables from the dataset with the data from the database. ds = new DataSet(); ds.Tables.Add(tableName); if (count > 0) { dAdapter = new SqlDataAdapter(query, dbConn); dAdapter.Fill(ds.Tables[tableName]); addImageCol(ds.Tables[0]); } } finally { dbConn.Close(); } return ds; }
public static object default_GetTotalRecordCount(HttpRequest request, AjaxGetDataHandlerEventArgs args) { string serverPath = ""; serverPath = System.Web.HttpContext.Current.Server.MapPath(serverPath); OleDbConnection dbConn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\generalproducts.mdb"); dbConn.Open(); int count = -1; try { OleDbCommand cmd = new OleDbCommand("select count(*) from tblProducts", dbConn); count = (int)cmd.ExecuteScalar(); if (args.PageSize <= 0) count = 300; } finally { dbConn.Close(); } return count; }
public static object dropDown_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { return default_GetData(request, args); }
public static object default_GetData(HttpRequest request, AjaxGetDataHandlerEventArgs args) { OleDbDataAdapter dAdapter; string serverPath = ""; serverPath = System.Web.HttpContext.Current.Server.MapPath(serverPath); OleDbConnection dbConn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\generalproducts.mdb"); dbConn.Open(); DataSet ds = null; try { OleDbCommand cmd = new OleDbCommand("select count(*) from tblProducts", dbConn); int count = (int)cmd.ExecuteScalar(); int pageSize = args.PageSize; if (pageSize <= 0) pageSize = count > 250 ? 250 : count; if (count > pageSize + args.StartRecordIndex) count = pageSize + args.StartRecordIndex; int numRows = count - args.StartRecordIndex; string tableName = "tblProducts", query = ""; if (numRows > 0) { string sortField = "ProductID"; Nitobi.SortOrder sortOrder = Nitobi.SortOrder.Asc; if (!Cmn.IsEmpty(args.SortColumn)) { sortField = args.SortColumn; sortOrder = args.SortDirection; } string ReverseDirection; if (sortOrder == Nitobi.SortOrder.Asc) ReverseDirection = Nitobi.SortOrder.Desc.ToString(); else ReverseDirection = Nitobi.SortOrder.Asc.ToString(); // The reason for this overly complicated SQL query is due to the fact that MDB does not support proper paging. // Using a server such as Oracle or MySql would eliminate the complexity of this query, and most of the // preceeding code. query = "SELECT * FROM (SELECT TOP " + numRows + " * FROM (SELECT TOP " + count + " * FROM tblProducts "; if (!Cmn.IsEmpty(args.SearchString)) query += " WHERE ProductName LIKE '%" + args.SearchString + "%'"; query += " ORDER BY " + sortField + " " + sortOrder + ") ORDER BY " + sortField + " " + ReverseDirection + ") ORDER BY " + sortField + " " + sortOrder; } // Fill the tables from the dataset with the data from the database. ds = new DataSet(); ds.Tables.Add(tableName); if (numRows > 0) { dAdapter = new OleDbDataAdapter(query, dbConn); dAdapter.Fill(ds.Tables[tableName]); addImageCol(ds.Tables[0]); } } finally { dbConn.Close(); } return ds; }
public object getDataSource(HttpRequest request, AjaxGetDataHandlerEventArgs info) { if (m_dataSource != null) return m_dataSource; if (GetData != null) return GetData(request, info); return null; }