/// <summary> /// Constructor that initializes and sets all the variables in the class /// </summary> /// <param name="value">The data stored in the cell</param> /// <param name="collumn">The column that this cell is in</param> /// <param name="row">The row that this cell is in</param> public SqlCell(IComparable value, SqlColumn collumn, SqlRow row, bool isNull) { Value = value; Collumn = collumn; Row = row; Null = isNull; }
public SqlRow AddRow(List <SqlCell> cells) { SqlRow newRow; //currentId makes sure each row in unique Tree.AddNode(newRow = new SqlRow(currentId, this, cells)); currentId++; return(newRow); }
/// <summary> /// Initializes and adds a row into the table by adding it to the binary tree /// </summary> /// <param name="values">The values of the cells in the row</param> /// <returns>Returns the new row</returns> public SqlRow AddRow(params IComparable[] values) { SqlRow newRow; //currentId makes sure each row in unique Tree.AddNode(newRow = new SqlRow(currentId, this, values)); currentId++; return(newRow); }
///// <summary> ///// Updates all the rows inthe table where they pass the where clause ///// </summary> ///// <param name="hasWhereClause">If the update command included a where clause or if it schould update all the rows</param> ///// <param name="columnValuePairs">A list of the columns to set to values</param> ///// <param name="whereColumn">The column in the where clause</param> ///// <param name="whereOpperation">The logical opperation in the where clause</param> ///// <param name="whereValue">The value in the where clause</param> ///// <param name="errors">Any errors that occure while updateing the rows</param> ///// <returns>The amount of rows updated</returns> //public int Update(bool hasWhereClause, List<ColumnValuePair> columnValuePairs, SqlColumn whereColumn, Opperations whereOpperation, IComparable whereValue, out string errors) //{ // int returnInt = 0; // errors = ""; // //Selects all the rows that pass the where clause // List<SqlRow> itemsToUpdate = Select(hasWhereClause, whereColumn, whereOpperation, whereValue); // //foreach columnValuePair loop through the rows and set the cell of the columnValuePair.Column to columnValuePair.Value // foreach (ColumnValuePair columnValuePair in columnValuePairs) // { // returnInt++; // if (columnValuePair.Column.VarType == columnValuePair.Value.GetType()) // { // foreach (SqlRow row in itemsToUpdate) // { // row[columnValuePair.Column.Name].Value = columnValuePair.Value; // } // } // else // { // errors += "Values Don't Match Collumn Types, "; // break; // } // } // return returnInt; //} /// <summary> /// Recursively fills the binary tree from the XML data /// </summary> /// <param name="lastNode">The last node added to the binary tree</param> /// <param name="currentElement">The current XML element to get its data inputed into the tree</param> /// <returns>A node to be added to the tree</returns> BSTNode <SqlRow> FillBinaryTreeFromXML(BSTNode <SqlRow> lastNode, XElement currentElement) { //Gets all the values of the cells in the row and initializes the row node List <IComparable> values = new List <IComparable>(); foreach (XElement cellElement in currentElement.Element("Cells").Elements()) { values.Add(cellElement.Attribute("Value").Value); } SqlRow row = new SqlRow(int.Parse(currentElement.Attribute("id").Value), this, values.ToArray()); BSTNode <SqlRow> currentNode = new BSTNode <SqlRow>(row, lastNode); //Recursively gets this currentNode's children from the XML if (currentElement.Element("Left").HasElements) { currentNode.Left = FillBinaryTreeFromXML(currentNode, currentElement.Element("Left").Element("Node")); } if (currentElement.Element("Right").HasElements) { currentNode.Right = FillBinaryTreeFromXML(currentNode, currentElement.Element("Right").Element("Node")); } return(currentNode); }
/// <summary> /// Deletes a row /// </summary> /// <param name="rowToDelete">Row to delete</param> public void Delete(SqlRow rowToDelete) { Tree.DeleteNode(rowToDelete); }
/// <summary> /// Adds a row into the table by adding it to the binary tree /// </summary> /// <param name="newRow">The row being added</param> public void AddRow(SqlRow newRow) { Tree.AddNode(newRow); }