public static void AddInlineNote(TableRowCollection tableRowCollection, OutlinerNote note, bool fromWordFriendly = false) { TableRow tableRow = new TableRow(); Section section = XamlReader.Load(TransformFlowDocumentToSection(note.InlineNoteDocument)) as Section; if (section == null) { return; } TableCell cell = new TableCell(); if (fromWordFriendly) { section.Margin = new Thickness(note.Level * 20 + (note.Document.CheckboxesVisble ? 10 : 0), 0, 0, 2); } else { section.Margin = new Thickness(note.Level * 20 + 20 + (note.Document.CheckboxesVisble ? 20 : 0), 0, 0, 2); } cell.Blocks.Add(section); tableRow.Cells.Add(cell); for (int c = 0; c < note.Columns.Count - 1; c++) { tableRow.Cells.Add(new TableCell()); } tableRowCollection.Add(tableRow); }
public static TableRow Add(this TableRowCollection collection) // TODO check why it doesn't work { var row = new TableRow(); collection.Add(row); return(row); }
public void GetDataFromTableIntoPurchaseItem(Table table) { int rowNumber = 0; int columnNumber = 0; SalesStart salesStart = new SalesStart(); TableRowCollection salesTableRows = table.Rows; for (int i = 1; i < salesTableRows.Count; i++) { TableRow tableRow = salesTableRows[i]; rowNumber += 1; PurchaseItem purchaseItem = new PurchaseItem(); ArrayList arrayList = new ArrayList(); TableCellCollection tableCellCollection = tableRow.Cells; foreach (TableCell tableCell in tableCellCollection) { columnNumber += 1; System.Web.UI.WebControls.TextBox textBox = (System.Web.UI.WebControls.TextBox)tableCell.FindControl("TextBox0" + rowNumber + columnNumber); arrayList.Add(textBox.Text); } purchaseItem.ItemQuantity = Int32.Parse((string)arrayList[3]); purchaseItem.ItemSubtotal = Int32.Parse((string)arrayList[5]); PurchaseCart.PurchaseCartList.Add(purchaseItem); } }
private void WalkDocumentTree(Action <TextElement> action, TableRowCollection trc) { foreach (TableRow tr in trc) { WalkDocumentTree(action, tr); } }
public static TableRow Add(this TableRowCollection table, params TableCell[] cells) { var row = new TableRow(); table.Add(row); row.Cells.AddRange(cells.ToArray()); return(row); }
} // end method public static string GetColumnName(this Table table, int index) { TableRowCollection rows = table.Rows; string columnName = null; if (rows.Count > 0) { TableCellCollection cells = rows[0].Cells; if (index > -1 && index < cells.Count) columnName = cells[index].Text; } // end if return columnName; } // end method
private void AppendTableRows(TableRowCollection renderRows) { if (renderRows != null) { int count = renderRows.DetailRowDefinitions.Count; for (int i = 0; i < count; i++) { this.m_rows.Add(new ShimTableRow(base.m_owner, this.m_rows.Count, renderRows[i])); } } }
} // end method public static int GetColumnIndex(this Table table, string columnName) { TableRowCollection rows = table.Rows; int index = -1; if (rows.Count > 0) { TableCellCollection cells = rows[0].Cells; for (int c = 0; c < cells.Count && index == -1; c++) if (cells[c].Text == columnName) index = c; } // end if return index; } // end method
/// <summary> /// Runs a query that checks the event log table for recent exceptions (within the last day). /// Writes any exceptions to a file. /// </summary> /// <param name="filePath">The path of the file that the exceptions will be recorded in.</param> public void CheckForRecentExceptionsWriteToFile(string filePath) { DateTime currentDate = DateTime.Now; int year = currentDate.Year; int month = currentDate.Month; int day = currentDate.Day; if (day < 2) { month = month - 1; if (month == 01 || month == 03 || month == 05 || month == 07 || month == 08 || month == 10 || month == 12) { day = 31; } else if (month == 04 || month == 06 || month == 09 || month == 11) { day = 30; } else { if (DateTime.IsLeapYear(currentDate.Year)) { day = 29; } else { day = 28; } } } else { day = day - 1; } SQLQueryTextField.Value = "SELECT LogTypeKey, LogCreateDate, LogProperties FROM EventLog WHERE LogTypeKey LIKE '%EXCEPTION' AND LogCreateDate>'" + year + "-" + month + "-" + day + " 23:59:59.996'"; ExecuteSQLLink.Click(); System.Threading.Thread.Sleep(2000); if (!QueryResultsTable.InnerHtml.Contains("The query did not return any data")) { TableRowCollection resultsRows = QueryResultsTable.TableRows.Filter(Find.ByClass("Normal")); if (File.Exists(filePath)) { File.Delete(filePath); } StreamWriter sWriter = File.CreateText(filePath); foreach (TableRow row in resultsRows) { sWriter.WriteLine(row.OwnTableCells[0].Text + " on " + row.OwnTableCells[1] + ":"); sWriter.WriteLine(row.OwnTableCells[2].Text); } sWriter.Close(); } }
private TextElement FindTextElement(TreeNode node, TableRowCollection trc) { foreach (TableRow tr in trc) { TextElement te = FindTextElement(node, tr); if (te != null) { return(te); } } return(null); }
/// <summary> /// asp:TableRow의 ID는 바로 읽을 수 없으므로 모든 TableRow에 대해 루핑해서 /// 해당 ID를 가진 TableRow를 리턴함. /// </summary> /// <param name="trows">TableRowCollection</param> /// <param name="ID">찾을 TableRow의 ID</param> /// <returns><paramref name="ID"/> 값을 가진 TableRow</returns> public static TableRow GetTableRowByID(TableRowCollection trows, string ID) { foreach (TableRow r in trows) { if (r.ID == ID) { return(r); } } return(null); }
private void InitializeRow(GridViewRow row, DataControlField[] fields, TableRowCollection newRows) { GridViewRowEventArgs e = new GridViewRowEventArgs(row); InitializeRow(row, fields); OnRowCreated(e); newRows.Add(row); row.DataBind(); OnRowDataBound(e); row.DataItem = null; }
// updates table private void RefreshCartTable() { // get cart ShoppingCart_S1 _cart = (ShoppingCart_S1)((ShopMaster)Master).GetCart(); // cycle through each row, except the first one // find items w/ quantity of zero, remove row TableRowCollection _rows = tableCart.Rows; int i = 1; while (i < _rows.Count) { TableRow _row = _rows[i]; // get ID for row HyperLink _link = (HyperLink)_row.Cells[0].Controls[0]; int _id = Int32.Parse(_link.Text); int _actualQuantity = _cart.Quantity(_id); // check quantity if (_actualQuantity <= 0) { _row.Cells.Clear(); _rows.Remove(_row); Trace.Warn("cart", string.Format("removed row id: {0}", _id)); } else { // check if quantity changed int _quantity = Int32.Parse((_row.Cells[3].Text)); if (_actualQuantity != _quantity) { _row.Cells[3].Text = _actualQuantity.ToString(); } ++i; } } // check row count if (tableCart.Rows.Count <= 1) { // empty table tableCart.Rows.Clear(); labelCart.Text = "Cart is empty"; labelCart.ForeColor = System.Drawing.Color.OrangeRed; tableCartContainer.Visible = false; } }
public override string GetDesignTimeHtml() { Table viewControl = (Table)base.ViewControl; TableRowCollection rows = viewControl.Rows; bool flag = rows.Count == 0; bool flag2 = false; if (flag) { TableRow row = new TableRow(); rows.Add(row); TableCell cell = new TableCell { Text = "###" }; rows[0].Cells.Add(cell); } else { flag2 = true; for (int i = 0; i < rows.Count; i++) { if (rows[i].Cells.Count != 0) { flag2 = false; break; } } if (flag2) { TableCell cell2 = new TableCell { Text = "###" }; rows[0].Cells.Add(cell2); } } if (!flag) { foreach (TableRow row2 in rows) { foreach (TableCell cell3 in row2.Cells) { if ((cell3.Text.Length == 0) && !cell3.HasControls()) { cell3.Text = "###"; } } } } return(base.GetDesignTimeHtml()); }
// update button click private void CommandUpdate(object _sender, CommandEventArgs _e) { Trace.Warn("cart", string.Format("CommandUpdate(\"{0}\":{1})", _e.CommandName, _e.CommandArgument)); if (_e.CommandName.Equals("ItemID", StringComparison.OrdinalIgnoreCase)) { int _id = Int32.Parse((string)_e.CommandArgument); Trace.Write("Shop", string.Format("Updating id {0}", _id)); // find row w/ item TableRowCollection _rows = tableCart.Rows; TableRow _row = null; int i = 1; while (i < _rows.Count) { _row = _rows[i]; // get ID for row HyperLink _link = (HyperLink)_row.Cells[0].Controls[0]; int _rowID = Int32.Parse(_link.Text); if (_id == _rowID) { break; } ++i; } if (i == _rows.Count) { Trace.Warn("Shop Update", string.Format("Failed to find row w/ ID: {0}", _id)); return; } // pull value from textbox int _quantity = Int32.Parse((((TextBox)(_row.Cells[4].Controls[0])).Text)); Trace.Write("Cart", string.Format("Quantity read: {0}", _quantity)); ShoppingCart_S2 _cart = (ShoppingCart_S2)((ShopMaster)Master).GetCart(); if (_cart.Update(_id, _quantity)) { Trace.Write("cart", string.Format("updated id:{0}", _id)); } else { Trace.Warn("cart", string.Format("failed to update id:{0}", _id)); } } }
/// <summary> /// Checks the role checkbox on the newsletters page for the role specified. /// </summary> /// <param name="roleName">The name of the role.</param> public void CheckRoleCheckBoxByName(string roleName) { //Returns the Edit Button for the user specified CheckBox roleCheckBox = null; TableRowCollection roleRows = IEInstance.Div(Find.ByClass("dnnRolesGrid")).Table(Find.Any).TableRows; foreach (TableRow row in roleRows) { if (row.TableCells[0].InnerHtml.Contains(roleName)) { roleCheckBox = row.TableCells[1].CheckBox(Find.Any); } continue; } roleCheckBox.Checked = true; }
/// <summary> /// Finds the table cell containing the message status. /// </summary> /// <param name="subject">The subject of the message.</param> /// <returns>The table cell containing the Status of the message.</returns> public TableCell GetMsgStatusBySubject(string subject) { //Returns the user Row specified from the user table TableCell result = null; TableRowCollection rows = InboxTable.TableRows.Filter(Find.ById(s => s.Contains("MessageList_messagesGrid"))); foreach (TableRow row in rows) { if (row.TableCells[2].InnerHtml.Contains(subject)) { result = row.TableCells[4]; break; } continue; } return(result); }
/// <summary> /// Finds the message link in the users messages table. /// </summary> /// <param name="subject">The subject for the message.</param> /// <returns>The link to the message.</returns> public Link GetMsgLinkBySubject(string subject) { //Returns the message link specified from the my messages table Link result = null; TableRowCollection rows = InboxTable.TableRows.Filter(Find.ById(s => s.Contains("MessageList_messagesGrid"))); foreach (TableRow row in rows) { if (row.TableCells[2].Link(Find.Any).Text.Contains(subject)) { result = row.TableCells[2].Link(Find.Any); break; } continue; } return(result); }
protected void btnDelete_Click(object sender, EventArgs e) { string strDSN = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source =|DataDirectory|CaseList.accdb;" + "Persist Security Info = False"; OleDbConnection newConn = new OleDbConnection(strDSN); Table TableCase = (Table)FindControl("TableCase"); TableRowCollection Rows = TableCase.Rows; DialogResult dr = MessageBox.Show("¿Estás seguro de querer eliminar/las?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { for (int i = 1; i < Rows.Count; i++) { System.Web.UI.WebControls.CheckBox CheckBox = (System.Web.UI.WebControls.CheckBox)FindControl("row_" + i.ToString()); if (CheckBox.Checked) { try { newConn.Open(); OleDbCommand newCmd = newConn.CreateCommand(); newCmd.CommandText = "delete from [Case] where ID='" + Rows[i].Cells[1].Text + "'"; newCmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("Error interno, por favor vuelve a probar más tarde"); Debug.WriteLine(ex.Message); } finally { newConn.Close(); } } } } Response.Redirect(Request.RawUrl); }
// Token: 0x06006AD2 RID: 27346 RVA: 0x001E92E0 File Offset: 0x001E74E0 internal void GetNextRow(IntPtr nmRow, out int fFound, out IntPtr pnmNextRow) { BaseParagraph baseParagraph = (RowParagraph)base.PtsContext.HandleToObject(nmRow); BaseParagraph baseParagraph2 = baseParagraph.Next; if (baseParagraph2 == null) { TableRow row = ((RowParagraph)baseParagraph).Row; TableRowGroup rowGroup = row.RowGroup; TableRow tableRow = null; int num = row.Index + 1; int num2 = rowGroup.Index + 1; if (num < rowGroup.Rows.Count) { tableRow = rowGroup.Rows[num]; } while (tableRow == null && num2 != this.Table.RowGroups.Count) { TableRowCollection rows = this.Table.RowGroups[num2].Rows; if (rows.Count > 0) { tableRow = rows[0]; } num2++; } if (tableRow != null) { baseParagraph2 = new RowParagraph(tableRow, base.StructuralCache); baseParagraph.Next = baseParagraph2; baseParagraph2.Previous = baseParagraph; ((RowParagraph)baseParagraph2).CalculateRowSpans(); } } if (baseParagraph2 != null) { fFound = 1; pnmNextRow = baseParagraph2.Handle; return; } fFound = 0; pnmNextRow = IntPtr.Zero; }
void autoresizeColumns(Table table) { TableColumnCollection columns = table.Columns; TableRowCollection rows = table.RowGroups[0].Rows; TableCellCollection cells; TableRow row; TableCell cell; int columnCount = columns.Count; int rowCount = rows.Count; int cellCount = 0; double[] columnWidths = new double[columnCount]; double columnWidth; // loop through all rows for (int r = 0; r < rowCount; r++) { row = rows[r]; cells = row.Cells; cellCount = cells.Count; // loop through all cells in the row for (int c = 0; c < columnCount && c < cellCount; c++) { cell = cells[c]; columnWidth = getDesiredWidth(new TextRange(cell.ContentStart, cell.ContentEnd)) + 19; if (columnWidth > columnWidths[c]) { columnWidths[c] = columnWidth; } } } // set the columns width to the widest cell for (int c = 0; c < columnCount; c++) { columns[c].Width = new GridLength(columnWidths[c]); } }
protected void btnAssign_Click(object sender, EventArgs e) { string strDSN = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source =|DataDirectory|CaseList.accdb;" + "Persist Security Info = False"; OleDbConnection newConn = new OleDbConnection(strDSN); Table TableCase = (Table)FindControl("TableCase"); TableRowCollection Rows = TableCase.Rows; for (int i = 1; i < Rows.Count; i++) { System.Web.UI.WebControls.CheckBox CheckBox = (System.Web.UI.WebControls.CheckBox)FindControl("row_" + i.ToString()); if (CheckBox.Checked) { try { newConn.Open(); OleDbCommand newCmd = newConn.CreateCommand(); newCmd.CommandText = "update [Case] set Responsable='" + Context.User.Identity.Name + "' where ID='" + Rows[i].Cells[1].Text + "'"; newCmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("Error interno, por favor vuelve a probar más tarde"); Debug.WriteLine(ex.Message); } finally { newConn.Close(); } } } Response.Redirect(Request.RawUrl); }
//public void dropdownList() //{ // const string dbConnectionString = @"Data Source=DATABAIST;Database=ksingh31;Integrated Security=true"; // SqlConnection dbConnection = new SqlConnection(); // dbConnection.ConnectionString = dbConnectionString; // dbConnection.Open(); // SqlCommand getItemCmd = new SqlCommand(); // getItemCmd.Connection = dbConnection; // getItemCmd.CommandType = CommandType.StoredProcedure; // getItemCmd.CommandText = "GetCustomers"; // SqlDataAdapter da = new SqlDataAdapter(getItemCmd); // DataSet custC = new DataSet(); // da.Fill(custC); // CustomerIDList.DataSource = custC; // CustomerIDList.DataTextField = "CustomerName"; // CustomerIDList.DataValueField = "CustomerID"; // CustomerIDList.DataBind(); // CustomerIDList.Items.Insert(0, new ListItem("-- Select Customer --", "0")); // dbConnection.Close(); //} protected void GoToSalePage_Click(object sender, EventArgs e) { int saleNumber = int.Parse(SaleNumberTextBox.Text); string sName = SalepersonTextBox.Text; double sSubTotal = Convert.ToDouble(subTotalTextBox.Text); double sgst = Convert.ToDouble(gstTextBox.Text); double sTotal = Convert.ToDouble(totalTextBox.Text); var list = new List <ItemsSold>(); TableRowCollection t = CartTable.Rows; foreach (TableRow r in t) { ItemsSold item1 = new ItemsSold(); item1.ItemCode = (r.Cells[0].Text).ToString(); item1.SaleNumber = saleNumber; item1.Quantity = int.Parse(r.Cells[1].Text); item1.ItemTotal = Convert.ToDouble(r.Cells[2].Text); list.Add(item1); } BAIS3150CodeSampleHandler RequestDirector = new BAIS3150CodeSampleHandler(); try { bool Confirmation = RequestDirector.AddSale(saleNumber, sName, sSubTotal, sgst, sTotal, list); if (Confirmation) { MessageLabel.Text = "<i>Sale Created successfully</i>"; } else { MessageLabel.Text = "<i style='color: red;'>Sale was NOT successful</i>"; } } catch (Exception ex) { MessageLabel.Text = "<i style='color: red;'>Create Sale was NOT successful</i>"; Console.WriteLine(ex.Message); } }
public static void AddInlineNote(TableRowCollection tableRowCollection, OutlinerNote note, bool fromWordFriendly = false) { TableRow tableRow = new TableRow(); Section section = XamlReader.Load(TransformFlowDocumentToSection(note.InlineNoteDocument)) as Section; if (section == null) return; TableCell cell = new TableCell(); if (fromWordFriendly) section.Margin = new Thickness(note.Level * 20 + (note.Document.CheckboxesVisble ? 10 : 0), 0, 0, 2); else section.Margin = new Thickness(note.Level * 20 + 20 + (note.Document.CheckboxesVisble ? 20 : 0), 0, 0, 2); cell.Blocks.Add(section); tableRow.Cells.Add(cell); for (int c = 0; c < note.Columns.Count - 1; c++) tableRow.Cells.Add(new TableCell()); tableRowCollection.Add(tableRow); }
/// <summary> /// GetNextRow /// </summary> /// <param name="nmRow">Previous body row name</param> /// <param name="fFound">Indication that body row is found</param> /// <param name="pnmNextRow">Body row name</param> internal void GetNextRow( IntPtr nmRow, out int fFound, out IntPtr pnmNextRow) { Debug.Assert(Table.RowGroups.Count > 0); BaseParagraph prevParagraph = ((RowParagraph)PtsContext.HandleToObject(nmRow)); BaseParagraph nextParagraph = prevParagraph.Next; if (nextParagraph == null) { TableRow currentRow = ((RowParagraph)prevParagraph).Row; TableRowGroup currentRowGroup = currentRow.RowGroup; TableRow tableRow = null; int nextRowIndex = currentRow.Index + 1; int nextRowGroupIndex = currentRowGroup.Index + 1; if (nextRowIndex < currentRowGroup.Rows.Count) { Debug.Assert(currentRowGroup.Rows[nextRowIndex].Index != -1, "Row is not in a table"); tableRow = currentRowGroup.Rows[nextRowIndex]; } while (tableRow == null) { if (nextRowGroupIndex == Table.RowGroups.Count) { break; } TableRowCollection Rows = Table.RowGroups[nextRowGroupIndex].Rows; if (Rows.Count > 0) { Debug.Assert(Rows[0].Index != -1, "Row is not in a table"); tableRow = Rows[0]; } nextRowGroupIndex++; } if (tableRow != null) { nextParagraph = new RowParagraph(tableRow, StructuralCache); prevParagraph.Next = nextParagraph; nextParagraph.Previous = prevParagraph; ((RowParagraph)nextParagraph).CalculateRowSpans(); } } if (nextParagraph != null) { fFound = PTS.True; pnmNextRow = nextParagraph.Handle; } else { fFound = PTS.False; pnmNextRow = IntPtr.Zero; } }
protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding) { int rows = base.CreateChildControls(dataSource, dataBinding); // no data rows created, create empty table if enabled if (rows == 0 && (ShowFooterWhenEmpty || ShowHeaderWhenEmpty)) { // create the table Table table = CreateChildTable(); Controls.Clear(); Controls.Add(table); DataControlField[] fields; if (AutoGenerateColumns) { var source = new PagedDataSource { DataSource = dataSource }; ICollection autoGeneratedColumns = CreateColumns(source, true); fields = new DataControlField[autoGeneratedColumns.Count]; autoGeneratedColumns.CopyTo(fields, 0); } else { fields = new DataControlField[Columns.Count]; Columns.CopyTo(fields, 0); } TableRowCollection newRows = table.Rows; if (ShowHeaderWhenEmpty) { // create a new header row _headerRow = CreateRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal); InitializeRow(_headerRow, fields, newRows); } // create the empty row GridViewRow emptyRow = new GridViewRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal); TableCell cell = new TableCell(); List <DataControlField> f = fields.Where(dataControlField => dataControlField.Visible).ToList(); cell.ColumnSpan = f.Count; //cell.Width = Unit.Percentage(100); // respect the precedence order if both EmptyDataTemplate // and EmptyDataText are both supplied ... if (EmptyDataTemplate != null) { EmptyDataTemplate.InstantiateIn(cell); } else if (!string.IsNullOrEmpty(EmptyDataText)) { cell.Controls.Add(new LiteralControl(EmptyDataText)); } emptyRow.Cells.Add(cell); GridViewRowEventArgs e = new GridViewRowEventArgs(emptyRow); OnRowCreated(e); newRows.Add(emptyRow); emptyRow.DataBind(); OnRowDataBound(e); emptyRow.DataItem = null; if (ShowFooterWhenEmpty && ShowFooter) { // create footer row _footerRow = CreateRow(-1, -1, DataControlRowType.Footer, DataControlRowState.Normal); InitializeRow(_footerRow, fields, newRows); newRows.Remove(emptyRow); } } return(rows); }
/// <include file='doc\TableDesigner.uex' path='docs/doc[@for="TableDesigner.GetDesignTimeHtml"]/*' /> /// <devdoc> /// <para> /// Gets the design time HTML of the <see cref='System.Web.UI.WebControls.Table'/> /// control. /// </para> /// </devdoc> public override string GetDesignTimeHtml() { Table table = (Table)Component; TableRowCollection rows = table.Rows; ArrayList cellsWithDummyContents = null; bool emptyTable = (rows.Count == 0); bool emptyRows = false; if (emptyTable) { TableRow row = new TableRow(); rows.Add(row); TableCell cell = new TableCell(); cell.Text = "###"; rows[0].Cells.Add(cell); } else { emptyRows = true; for (int i = 0; i < rows.Count; i++) { if (rows[i].Cells.Count != 0) { emptyRows = false; break; } } if (emptyRows == true) { TableCell cell = new TableCell(); cell.Text = "###"; rows[0].Cells.Add(cell); } } if (emptyTable == false) { // rows and cells were defined by the user, but if the cells are empty // then something needs to be done about that, so they are visible foreach (TableRow row in rows) { foreach (TableCell cell in row.Cells) { if ((cell.Text.Length == 0) && (cell.HasControls() == false)) { if (cellsWithDummyContents == null) { cellsWithDummyContents = new ArrayList(); } cellsWithDummyContents.Add(cell); cell.Text = "###"; } } } } // now get the design-time HTML string designTimeHTML = base.GetDesignTimeHtml(); // and restore the table back to the way it was if (emptyTable) { // restore the table back to its empty state rows.Clear(); } else { // restore the cells that were empty if (cellsWithDummyContents != null) { foreach (TableCell cell in cellsWithDummyContents) { cell.Text = String.Empty; } } if (emptyRows) { // we added a cell into row 0, so remove it rows[0].Cells.Clear(); } } return(designTimeHTML); }
// INSERT INTO MyTable (PriKey, Description) // VALUES (123, 'A description of part 123.') public static string BuildInsertLine(TableRowCollection rowCollection, TableMeta tableObj, Version lowVersion, Version highVersion) { string strTableName = tableObj.FullName; StringBuilder strInsertBatch = new StringBuilder(1024); // at least 1K string strInsertSQL = string.Empty; strInsertSQL += "INSERT INTO "; strInsertSQL += strTableName; foreach (TableRow tblRow in rowCollection) { DDLActionEnum action = Anonymous.ValidateVersion(tblRow, lowVersion, highVersion); if (action == DDLActionEnum.NONE) // not in range! { continue; } StringBuilder strInsertLineTmp = new StringBuilder(strInsertSQL); StringBuilder strColumnData = new StringBuilder(); strInsertLineTmp.Append(" ( "); TableFieldValueCollection fields = tblRow.FieldValues; for (int nInd = 0; nInd < fields.Count; nInd++) { TableFieldValue field = fields[nInd]; //if ( field.IsNull == false ) // continue; ColumnMeta colMetaTmp = tableObj.GetColMeta(field.Name); if (colMetaTmp == null) { Debug.Assert(false, "Column " + field.Name + " not found!"); continue; } if (strColumnData.Length > 0) { strInsertLineTmp.Append(","); strColumnData.Append(","); } strInsertLineTmp.Append(field.Name); if (IsNumeric(colMetaTmp.DataType.TypeEnum)) { strColumnData.Append(field.FieldValue); } else // Quote the value { strColumnData.Append(CHAR.SINGLEQUOTE); strColumnData.Append(field.FieldValue); strColumnData.Append(CHAR.SINGLEQUOTE); } } strInsertLineTmp.Append(" ) \n"); strInsertLineTmp.Append("VALUES ("); strInsertLineTmp.Append(strColumnData); strInsertLineTmp.Append(")"); strInsertBatch.Append(strInsertLineTmp); strInsertBatch.Append(KWD.SQLSVR_BD); } return(strInsertBatch.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.TableLayout"/> class with the specified rows. /// </summary> /// <param name="yscale">Scale all rows</param> /// <param name="rows">Rows to populate the table.</param> public TableLayout(bool yscale, params TableRow[] rows) { if (yscale) foreach (TableRow row in rows) if(row != null) row.ScaleHeight = true; Rows = new TableRowCollection(this, rows); Create(); Initialize(); }
public static void GenerateTestCases(Page testSuitePage, TableRowCollection rows, string testPage, string testPrefix) { TestSuiteGenerator testSuiteGenerator = new TestSuiteGenerator(testSuitePage, testPage); rows.AddRange(testSuiteGenerator.CreateTestCases(testPrefix)); }
// updates table private void RefreshCartTable() { // get cart ShoppingCart_S2 _cart = (ShoppingCart_S2)((ShopMaster)Master).GetCart(); // cycle through each row, except the first one // find items w/ quantity of zero, remove row TableRowCollection _rows = tableCart.Rows; TableRow _row = null; int i = 1; while (i < _rows.Count) { _row = _rows[i]; // get ID for row HyperLink _link = (HyperLink)_row.Cells[0].Controls[0]; int _id = Int32.Parse(_link.Text); Trace.Write("Cart", string.Format("Refreshing row id: {0}", _id)); int _actualQuantity = _cart.Quantity(_id); // check quantity if (_actualQuantity <= 0) { _row.Cells.Clear(); _rows.Remove(_row); Trace.Warn("cart", string.Format("removed row id: {0}", _id)); } else { // always refresh int _quantity = Int32.Parse((((TextBox)(_row.Cells[4].Controls[0])).Text)); Trace.Write("Cart", string.Format("Quantity read: {0}", _quantity)); // get item info Item_S2 _item = (Item_S2)((ShopMaster)Master).GetItem(_id); // update quantity and ext price/weight //_row.Cells[4].Text = _actualQuantity.ToString(); _row.Cells[5].Text = (_item.Price * _actualQuantity).ToString("C2"); _row.Cells[6].Text = (_item.Weight * _actualQuantity).ToString("f2"); ++i; } } // check row count if (tableCart.Rows.Count <= 1) { DisplayEmptyCart(); return; } // calculate totals double _totalPrice = 0, _totalWeight = 0; foreach (ShoppingCart_S2.ShoppingCartItem_S2 _cartItem in _cart.Items) { // get item Item_S2 _item = (Item_S2)((ShopMaster)Master).GetItem(_cartItem.ItemID); _totalPrice += _item.Price * _cartItem.Quantity; _totalWeight += _item.Weight * _cartItem.Quantity; } // add totals row _row = new TableRow(); _row.CssClass = "TotalRow"; // populate empty cells TableCell _cell = null; for (i = 0; i < 5; ++i) { _cell = new TableCell(); _cell.CssClass = "EmptyCell"; _cell.Text = " "; _row.Cells.Add(_cell); } // total ext price _cell = new TableCell(); _cell.CssClass = "EmptyCell"; _cell.Text = _totalPrice.ToString("C2"); _row.Cells.Add(_cell); // total ext weight _cell = new TableCell(); _cell.CssClass = "EmptyCell"; _cell.Text = _totalWeight.ToString("f2"); _row.Cells.Add(_cell); tableCart.Rows.Add(_row); }
protected virtual void PrepareControlHierarchyForRendering() { ControlCollection controls = Controls; if (controls.Count != 1) { return; } Table outerTable = (Table)controls[0]; outerTable.CopyBaseAttributes(this); if (ControlStyleCreated) { outerTable.ApplyStyle(ControlStyle); } else { // Because we didn't create a ControlStyle yet, the settings // for the default style of the control need to be applied // to the child table control directly. outerTable.CellSpacing = 0; } TableRowCollection rows = outerTable.Rows; TableCell bodyCell = null; if (_headerTemplate != null) { TableRow headerRow = rows[0]; if (ShowHeader) { if (_headerStyle != null) { headerRow.Cells[0].MergeStyle(_headerStyle); } } else { headerRow.Visible = false; } bodyCell = rows[1].Cells[0]; } if (_footerTemplate != null) { TableRow footerRow = rows[rows.Count - 1]; if (ShowFooter) { if (_footerStyle != null) { footerRow.Cells[0].MergeStyle(_footerStyle); } } else { footerRow.Visible = false; } } if (bodyCell == null) { bodyCell = rows[0].Cells[0]; } ListViewPanel viewPanel = (ListViewPanel)bodyCell.Controls[0]; if (_viewStyle != null) { viewPanel.ApplyStyle(_viewStyle); if (ShowScrollBars) { viewPanel.Style["overflow"] = "scroll"; viewPanel.Style["overflow-x"] = "auto"; viewPanel.Style["overflow-y"] = "auto"; } } ListViewTable bodyTable = (ListViewTable)viewPanel.Controls[0]; bodyTable.Columns = Columns; foreach (ListViewItem item in _items) { TableItemStyle style = _itemStyle; TableItemStyle compositeStyle = null; ListViewItemType itemType = item.ItemType; if (((itemType & ListViewItemType.EditItem) != 0) && (_editItemStyle != null)) { if (style != null) { compositeStyle = new TableItemStyle(); compositeStyle.CopyFrom(style); compositeStyle.CopyFrom(_editItemStyle); } else { style = _editItemStyle; } } if (((itemType & ListViewItemType.SelectedItem) != 0) && (_selectedItemStyle != null)) { if (compositeStyle != null) { compositeStyle.CopyFrom(_selectedItemStyle); } else if (style != null) { compositeStyle = new TableItemStyle(); compositeStyle.CopyFrom(style); compositeStyle.CopyFrom(_selectedItemStyle); } else { style = _selectedItemStyle; } } if (compositeStyle != null) { item.MergeStyle(compositeStyle); } else if (style != null) { item.MergeStyle(style); } if (_renderClickSelectScript) { if ((itemType & ListViewItemType.SelectedItem) == 0) { item.Attributes["onclick"] = Page.GetPostBackEventReference(this, "S" + item.ItemIndex); item.Style["cursor"] = "hand"; } } } }
// Corrects borders on cells to avoid double-sizing. private static void CorrectBorders(TableRowCollection rows) { Table table = rows[0].Table; if (table.CellSpacing > 0) { // We only apply "smart borders" algorithm when the table has CellSpacing==0 return; } int columnCount = table.ColumnCount; int rowCount = rows.Count; for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { TableRow row = rows[rowIndex]; TableCellCollection cells = row.Cells; for (int cellIndex = 0; cellIndex < cells.Count; cellIndex++) { TableCell cell = cells[cellIndex]; Thickness border = cell.BorderThickness; double borderRight = cell.ColumnIndex + cell.ColumnSpan < columnCount ? 0.0 : border.Left; double borderBottom = rowIndex + cell.RowSpan < rowCount ? 0.0 : border.Top; if (border.Right != borderRight || border.Bottom != borderBottom) { border.Right = borderRight; border.Bottom = borderBottom; cell.BorderThickness = border; } } } }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.TableLayout"/> class with the specified rows. /// </summary> /// <param name="rows">Rows to populate the table.</param> public TableLayout(params TableRow[] rows) { Rows = new TableRowCollection(rows); Create(); Initialize(); }
private List<TableRow> TableRowCollectionToList(TableRowCollection tRC) { List<TableRow> tableRowList = new List<TableRow>(); for (int i = 0; i < tRC.Count; i++) { tableRowList.Add(tRC[i]); } return tableRowList; }
void SetCellSize(Size value, bool createRows) { if (created) throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Can only set the cell size of a table once")); dimensions = value; Handler.CreateControl(dimensions.Width, dimensions.Height); if (!dimensions.IsEmpty) { if (createRows) { var rows = Enumerable.Range(0, value.Height).Select(r => new TableRow(Enumerable.Range(0, value.Width).Select(c => new TableCell()))); Rows = new TableRowCollection(rows); created = true; } } }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.TableLayout"/> class with the specified rows. /// </summary> /// <param name="rows">Rows to populate the table.</param> public TableLayout(IEnumerable<TableRow> rows) { Rows = new TableRowCollection(rows); Create(); Initialize(); }