// - przeciążona metoda public int itemAdd(String aSelectCommand, String aTableName, ItemOleDbManager aOwner) { if (this._Connection != null) { try { int index = this.itemAdd(aSelectCommand, aTableName); ItemOleDbManager o = cItems[index - 1]; o.Owner = aOwner; // - dodaj parametry do zapytania foreach (ItemTableColumn Item in o.Owner.PrimaryKeyColumns) { o._Command_ParameterAdd(o.Adapter.SelectCommand, Item.ColumnName, Item.DataType, 0); } return(index); } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.ToString(), "exception class" + this.ToString()); } } else { MessageBox.Show("Error: no connected"); } return(0); }
// - usuń element public bool itemDel(int index) { if (index > 0) { try { ItemOleDbManager o = cItems[index - 1]; // zwolnij połączenia o.RemoveBindings(); // wyczyść zapytanie o.Query.Clear(); o.RemoveBindings(); o.BindSource.DataSource = null; // zwolnij obiekty o.Adapter.Dispose(); o.BindSource.Dispose(); o.Table = null; // usuń element cItems.Remove(o); o = null; return(true); } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.ToString(), "exception class" + this.ToString()); } } return(false); }
// - dodaj element public int itemAdd(String aSelectCommand, String aTableName) { if (this._Connection != null) { try { ItemOleDbManager o = new ItemOleDbManager(this); o.SQLCommandOryginal = aSelectCommand; o.Adapter = new OleDbDataAdapter("", this.Connection); o.Adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; o.Query = new DataSet(); o.BindSource = new BindingSource(); o.TableName = aTableName; // pobierz strukturę o.GetStructure(o.TableName); // - insert, update, delete o.Adapter.InsertCommand = o.BuildSQLInsert(); o.Adapter.UpdateCommand = o.BuildSQLUpdate(); o.Adapter.DeleteCommand = o.BuildSQLDelete(); cItems.Add(o); return(cItems.Count); } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.ToString(), "exception class" + this.ToString()); } } else { MessageBox.Show("Error: no connected"); } return(0); }
// - pobierz element public ItemOleDbManager itemGet(int index) { try { ItemOleDbManager c = cItems[index - 1]; return(c); } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + ex.ToString(), "exception class" + this.ToString()); } return(null); }
// - kontruktor przeciążony (wskazanie na rodzica) public ItemOleDbManager(OleDbManager aManager, ItemOleDbManager aOwner) { this.ParentMenager = aManager; this.Owner = aOwner; }