private void LiveScrollingGrid_GetData(object sender, Nitobi.Components.Grid.GetEventArgs e) { OleDbDataAdapter dAdapter; string serverPath=""; serverPath=Server.MapPath(serverPath); dbConn=new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\contactsflatfile3k.mdb" ); dbConn.Open(); OleDbCommand cmd = new OleDbCommand("select count(*) from tblContacts3k", dbConn); int count = (int)cmd.ExecuteScalar(); if (count > e.NumRowsRequested + e.StartingRecordIndex) { count = e.NumRowsRequested + e.StartingRecordIndex; } int numRows = count - e.StartingRecordIndex; string query=""; if (LiveScrollingGrid.RowsPerPage ==0) LiveScrollingGrid.RowsPerPage=20; string sortField = "ContactID"; SortOrder sortOrder = SortOrder.Asc; if (e!=null && e.Sort != null && e.Sort.SortField != null) { sortField = e.Sort.SortField; sortOrder = e.Sort.SortOrder; } string ReverseDirection; if (sortOrder == SortOrder.Asc) ReverseDirection = SortOrder.Desc.ToString(); else ReverseDirection = SortOrder.Asc.ToString(); string tableName; //if (e.DataSourceId == DataSources.PrimaryDataSourceId) //{ // 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 tblContacts3k ORDER BY " + sortField + " " + sortOrder + ") ORDER BY " + sortField + " " + ReverseDirection + ") ORDER BY " + sortField + " " + sortOrder; tableName = "tblContacts3k"; /*} else { query = "SELECT * FROM tblProductCategories"; if (e.SearchString != "") { query += " WHERE ProductCategoryName LIKE '" + e.SearchString + "%'"; } tableName = "tblProductCategories"; }*/ // Fill the tables from the dataset with the data from the database. DataSet ds = new DataSet(); ds.Tables.Add(tableName); dAdapter=new OleDbDataAdapter(query,dbConn); dAdapter.Fill(ds.Tables[tableName]); dbConn.Close(); e.DataSource = ds; }
/// <summary> /// Gets the Province Combo a new page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbProvince_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { // When user changes the value of country, the old value of the province must be deleted. this.cmbProvince.ClearSelectedValues(); this.ds.Tables["tblProvinces"].DefaultView.RowFilter="CountryID="+e.SearchSubstring; e.NextPage=ds.Tables["tblProvinces"].DefaultView; }
private void DetailGrid_GetData(object sender, Nitobi.Components.Grid.GetEventArgs e) { OleDbDataAdapter dAdapter; string serverPath=""; serverPath=Server.MapPath(serverPath); dbConn=new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\masterdetaildb.mdb" ); dbConn.Open(); string customerID = System.Web.HttpContext.Current.Request["CustomerId"]; // Construct the WHERE clause of the query based on the parameter set in the ChooseCustomer() function // on the client side. string whereClause = " "; if (customerID != null) { whereClause = " WHERE CustomerID LIKE '" + customerID + "' "; } OleDbCommand cmd = new OleDbCommand("select count(*) from tblOrders" + whereClause, dbConn); int count = (int)cmd.ExecuteScalar(); if (count > e.NumRowsRequested + e.StartingRecordIndex) { count = e.NumRowsRequested + e.StartingRecordIndex; } int numRows = count - e.StartingRecordIndex; string query=""; if (DetailGrid.RowsPerPage ==0) DetailGrid.RowsPerPage=20; string sortField = "OrderDate"; SortOrder sortOrder = SortOrder.Asc; if (e!=null && e.Sort != null && e.Sort.SortField != null) { sortField = e.Sort.SortField; sortOrder = e.Sort.SortOrder; } string ReverseDirection; if (sortOrder == SortOrder.Asc) ReverseDirection = SortOrder.Desc.ToString(); else ReverseDirection = 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 (SELECT TOP " + numRows + " * FROM (SELECT TOP " + count + " * FROM tblOrders" + whereClause + "ORDER BY " + sortField + " " + sortOrder + ") ORDER BY " + sortField + " " + ReverseDirection + ") ORDER BY " + sortField + " " + sortOrder; tableName = "tblOrders"; // Fill the tables from the dataset with the data from the database. DataSet ds = new DataSet(); ds.Tables.Add(tableName); dAdapter=new OleDbDataAdapter(query,dbConn); dAdapter.Fill(ds.Tables[tableName]); dbConn.Close(); e.DataSource = ds; }
private void ShowAllGrid_GetData(object sender, Nitobi.Components.Grid.GetEventArgs e) { OleDbDataAdapter dAdapter; string serverPath=""; serverPath=Server.MapPath(serverPath); dbConn=new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\contactsflatfile3k.mdb" ); dbConn.Open(); /*OleDbCommand cmd = new OleDbCommand("select count(*) from tblContacts3k", dbConn); int count = (int)cmd.ExecuteScalar(); if (count > e.NumRowsRequested + e.StartingRecordIndex) { count = e.NumRowsRequested + e.StartingRecordIndex; } int numRows = count - e.StartingRecordIndex; */ string query=""; //if (ShowAllGrid.RowsPerPage ==0) ShowAllGrid.RowsPerPage=20; string sortField = "ContactID"; SortOrder sortOrder = SortOrder.Asc; if (e!=null && e.Sort != null && e.Sort.SortField != null) { sortField = e.Sort.SortField; sortOrder = e.Sort.SortOrder; } string ReverseDirection; if (sortOrder == SortOrder.Asc) ReverseDirection = SortOrder.Desc.ToString(); else ReverseDirection = SortOrder.Asc.ToString(); string tableName; query = "SELECT TOP 50 * FROM tblContacts3k ORDER BY " + sortField + " " + sortOrder; tableName = "tblContacts3k"; // Fill the tables from the dataset with the data from the database. DataSet ds = new DataSet(); ds.Tables.Add(tableName); dAdapter=new OleDbDataAdapter(query,dbConn); dAdapter.Fill(ds.Tables[tableName]); dbConn.Close(); e.DataSource = ds; }
public static void customers_SaveData(HttpRequest request, Nitobi.AjaxSaveDataHandlerEventArgs args) { ArrayList l = (ArrayList)System.Web.HttpContext.Current.Session["customers"]; for (int p = 0; p < args.Count; p++) { IRow r = args[p]; switch (r.UpdateAction) { case UpdateAction.Update: Customer c = (Customer)l[Convert.ToInt32(r["Id"])]; c.FirstName = (string)r["FirstName"]; c.LastName = (string)r["LastName"]; break; case UpdateAction.Insert: l.Add(new Customer(l.Count.ToString(), (string)r["FirstName"], (string)r["LastName"])); break; case UpdateAction.Delete: l.RemoveAt(Convert.ToInt32(r["Id"])); break; } } }
object SimpleCombo_GetData(HttpRequest request, Nitobi.AjaxGetDataHandlerEventArgs args) { return Enum.GetNames(typeof(Nitobi.ComboThemeName)); }
/// <summary> /// This is called when the combo wants a page. /// </summary> /// <param name="sender"></param> /// <param name="e">Stores information about the request.</param> private void cmbContacts_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { e.NextPage=GetPage(e.PageSize,e.SearchSubstring,e.StartingRecordIndex); }
/// <summary> /// This is called when the combo wants a page. /// </summary> /// <param name="sender"></param> /// <param name="e">Stores information about the request.</param> private void myCombo_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { e.NextPage=GetPage(e.PageSize,e.SearchSubstring,e.StartingRecordIndex,e.LastString); }
private void EditorsGrid_Save(object sender, Nitobi.Components.Grid.GridSaveEventArgs e) { OleDbDataAdapter dAdapter = new OleDbDataAdapter(); string serverPath=""; serverPath=Server.MapPath(serverPath); dbConn=new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + serverPath + @"\data\generalproducts.mdb" ); dAdapter.SelectCommand = new OleDbCommand("SELECT * FROM tblProducts", dbConn); // The following line required for updates and inserts. new OleDbCommandBuilder(dAdapter); DataSet ds = new DataSet(); ds.Tables.Add("tblProducts"); dAdapter.TableMappings.Add("Table","tblProducts"); dbConn.Open(); dAdapter.Fill(ds.Tables["tblProducts"]); ds.Tables["tblProducts"].PrimaryKey = new DataColumn[] {ds.Tables["tblProducts"].Columns["ProductID"]}; // Ensure that we capture the key assigned by the db in order to send it back to the grid. dAdapter.RowUpdated += new OleDbRowUpdatedEventHandler(RowUpdated); Hashtable ht = new Hashtable(); int MDB_WORKAROUND=0, i=0; foreach (Row row in EditorsGrid.DataSources.PrimaryData.Rows) { UpdateAction xac = row.EditAction; switch(xac) { case(UpdateAction.INSERT): { DataRow r = ds.Tables["tblProducts"].NewRow(); // The first field is an auto-increment field. r[0]=MDB_WORKAROUND--; // Keep the row so that we can update the key later. ht[i] = r; for (int j=1;j<row.Count;j++) { if (!ds.Tables["tblProducts"].Columns[j].AutoIncrement) { r[j] = row[j]; } } ds.Tables["tblProducts"].Rows.Add(r); break; } case(UpdateAction.DELETE): { DataRow r = ds.Tables["tblProducts"].Rows.Find(row[0]); r.Delete(); break; } case(UpdateAction.UPDATE): { DataRow r = ds.Tables["tblProducts"].Rows.Find(row[0]); for (int j=0;j<row.Count;j++) { r[j] = row[j]; } break; } } i++; } dAdapter.Update(ds.Tables["tblProducts"]); // Update the rows that were inserted with the keys that were returned // by the db. Rows rs = EditorsGrid.DataSources.PrimaryData.Rows; foreach (int key in ht.Keys) { string s = ((DataRow)ht[key])[0].ToString(); rs[key][0] = s; } dbConn.Close(); }
public static void xmlCustomers_SaveData(HttpRequest request, Nitobi.AjaxSaveDataHandlerEventArgs args) { XmlDocument doc = (XmlDocument)System.Web.HttpContext.Current.Session["xmlCustomers"]; XmlElement el = null; for (int p = 0; p < args.Count; p++) { IRow r = args[p]; switch (r.UpdateAction) { case UpdateAction.Update: if ((el = findElementWithId(doc, r["Id"])) != null) { updateValue(el, "FirstName", r["FirstName"]); updateValue(el, "LastName", r["LastName"]); } break; case UpdateAction.Insert: break; case UpdateAction.Delete: break; } } }
private void cmbCustomers2_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { e.NextPage = this.GetPage(e.PageSize,e.SearchSubstring,e.StartingRecordIndex,e.LastString); }
object GridBoundToListOfObjects_GetData(HttpRequest request, Nitobi.AjaxGetDataHandlerEventArgs args) { return Session["customers"]; }
object SimpleDataGrid_GetData(HttpRequest request, Nitobi.AjaxGetDataHandlerEventArgs args) { return Session["customers"]; }
private void cmbName_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { // Getpage event handler. This will send a new page of data to combobox. e.NextPage = GetComboDs(e.PageSize,e.SearchSubstring,e.StartingRecordIndex,e.LastString); }
public static void roomAvailability_SaveData(HttpRequest request, Nitobi.AjaxSaveDataHandlerEventArgs args) { ArrayList l = (ArrayList)System.Web.HttpContext.Current.Session["roomAvailability"]; int c = args.Count; for (int pos = 0; pos < c; pos++) { IRow r = args[pos]; if (r.UpdateAction == UpdateAction.Update || r.UpdateAction == UpdateAction.Insert) { BaseCalendarEvent e = null; if (r.UpdateAction == UpdateAction.Update) { int index = int.Parse(r.RowKey.ToString()) - 1; e = (BaseCalendarEvent)l[index]; } else { l.Add(e = new BaseCalendarEvent()); r.RowKey = l.Count; e.StartDate = DateTime.Today; e.EventType = "event"; } if(!Cmn.IsEmpty(r["StartDate"])) e.StartDate = DateTime.Parse(r["StartDate"].ToString()); if(r["Tooltip"] != null) e.Tooltip = r["Tooltip"].ToString(); if (r["Location"] != null) e.Location = r["Location"].ToString(); if (r["Description"] != null) e.Description = r["Description"].ToString(); if (r["CssStyle"] != null) e.CssStyle = r["CssStyle"].ToString(); if (r["CssClass"] != null) e.CssClass = r["CssClass"].ToString(); } } }
// Unbound still calls the server, just like the other modes. private void myCombo_GetPage(object sender, Nitobi.ComboGetPageEventArgs e) { e.NextPage=data; }
object SimpleCombLocalHandler_GetData(HttpRequest request, Nitobi.AjaxGetDataHandlerEventArgs args) { //Rather than hard coding the same test data processing, use the standard one in our TestDataProvider return TestDataProvider.dropDown_GetData(request, args); }