public void AddRow(params object[] row) { if (row.Length == Columns.Count) { var dr = new DataRow(this, _RowCount++); int colLength = Columns.Count; for (int x = 0; x < colLength; x++) { Columns[x].Cells.Add(row[x]); } Rows.Add(dr); } }
private void cb_dt_SelectedIndexChanged(object sender, System.EventArgs e) { ComboBoxEdit comboBoxEdit = sender as ComboBoxEdit; string text = comboBoxEdit.SelectedItem.ToString(); string type = this.gridView1.GetRowCellValue(this.gridView1.FocusedRowHandle, "ft").ToString(); if (text != null) { if (this.curtable != null) { this.curtable.Rows.Clear(); this.curtable.Columns.Clear(); } if (text == "值域型") { this.curtable.Columns.Add(this.fieldMin, this.GetColumnTypeByString(type)); this.curtable.Columns.Add(this.fieldMax, this.GetColumnTypeByString(type)); System.Data.DataRowCollection arg_C5_0 = this.curtable.Rows; object[] values = new object[2]; arg_C5_0.Add(values); } else { if (text == "枚举型") { this.curtable.Columns.Add(this.fieldCode, typeof(string)); this.curtable.Columns.Add(this.fieldValue, this.GetColumnTypeByString(type)); for (int i = 0; i < 200; i++) { System.Data.DataRowCollection arg_143_0 = this.curtable.Rows; object[] array = new object[2]; array[0] = ""; arg_143_0.Add(array); } } } this.gridView2.PopulateColumns(this.curtable); } }
private void btnImprimir_Click(object sender, EventArgs e) { DataTable tblArticulos = BL.GetDataBLL.Articulos(); bool imprimePrecios; if (MessageBox.Show("¿Imprime el precio en las etiquetas?", "Trend", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) imprimePrecios = true; else imprimePrecios = false; DataView viewStockMovDetalle = new DataView(tblStockMovDetalle); string pk = dgvStockMov.CurrentRow.Cells["IdMovMSTK"].Value.ToString(); viewStockMovDetalle.RowFilter = "IdMovMSTKD = '" + pk + "'"; viewStockMovDetalle.Sort = "ordenar"; Cursor.Current = Cursors.WaitCursor; DataTable tblEtiquetas = new DataTable(); tblEtiquetas.Columns.Add("IdArticuloMSTKD", typeof(string)); tblEtiquetas.Columns.Add("DescripcionART", typeof(string)); tblEtiquetas.Columns.Add("Precio", typeof(string)); tblEtiquetas.Columns.Add("IdArticuloMSTKD1", typeof(string)); tblEtiquetas.Columns.Add("DescripcionART1", typeof(string)); tblEtiquetas.Columns.Add("Precio1", typeof(string)); cfilas = tblEtiquetas.Rows; int i = 1; foreach (DataRowView row in viewStockMovDetalle) { string precio; DataRow[] foundRow = tblArticulos.Select("IdArticuloART = '" + row["IdArticuloMSTKD"].ToString() + "'"); DataRow filaActual = foundRow[0]; precio = filaActual["PrecioPublicoART"].ToString(); int x = Convert.ToInt32(row["CantidadMSTKD"].ToString()); if (x != 0) { if (i > 1 && (i %= 2) == 0) { nuevaFila[3] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[4] = row["DescripcionART"].ToString(); nuevaFila[5] = precio; cfilas.Add(nuevaFila); nuevaFila = null; x = x - 1; } for (i = 1; i <= x; i++) { int j; if ((j = i % 2) != 0) { nuevaFila = tblEtiquetas.NewRow(); nuevaFila[0] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[1] = row["DescripcionART"].ToString(); nuevaFila[2] = precio; } else { nuevaFila[3] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[4] = row["DescripcionART"].ToString(); nuevaFila[5] = precio; cfilas.Add(nuevaFila); nuevaFila = null; } } } } if (nuevaFila != null) { nuevaFila[3] = string.Empty; nuevaFila[4] = string.Empty; nuevaFila[5] = string.Empty; cfilas.Add(nuevaFila); } EtiquetasRpt frm = new EtiquetasRpt(tblEtiquetas, imprimePrecios); frm.Show(); Cursor.Current = Cursors.Arrow; }
private bool ImprimirEtiquetas() { bool imprimir = false; if (MessageBox.Show("¿Imprime etiquetas?", "Trend", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { imprimePrecios = false; tblEtiquetas = new DataTable(); tblEtiquetas.Columns.Add("IdArticuloMSTKD", typeof(string)); tblEtiquetas.Columns.Add("DescripcionART", typeof(string)); tblEtiquetas.Columns.Add("Precio", typeof(string)); tblEtiquetas.Columns.Add("IdArticuloMSTKD1", typeof(string)); tblEtiquetas.Columns.Add("DescripcionART1", typeof(string)); tblEtiquetas.Columns.Add("Precio1", typeof(string)); cfilas = tblEtiquetas.Rows; bool validar = true; foreach (DataGridViewRow row in dgvDatos.Rows) { if (!row.IsNewRow) { if (string.IsNullOrEmpty(row.Cells["IdArticuloMSTKD"].Value.ToString()) || string.IsNullOrEmpty(row.Cells["CantidadMSTKD"].Value.ToString())) { validar = false; } } } if (validar) tblEntradasDetalle.AcceptChanges(); // hago el foreach para borrar la fila extra que me genera tblEntradasDetalle.AcceptChanges() foreach (DataGridViewRow row in dgvDatos.Rows) { if (!row.IsNewRow) { if (string.IsNullOrEmpty(row.Cells["IdMSTKD"].Value.ToString()) && string.IsNullOrEmpty(row.Cells["IdArticuloMSTKD"].Value.ToString())) { dgvDatos.Rows.Remove(row); } } } int i = 1; foreach (DataRow row in tblEntradasDetalle.Rows) { int x = Convert.ToInt32(row["CantidadMSTKD"].ToString()); if (x != 0) { if (i > 1 && (i %= 2) == 0) { nuevaFila[3] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[4] = row["DescripcionART"].ToString(); nuevaFila[5] = row["Precio"].ToString(); cfilas.Add(nuevaFila); nuevaFila = null; x = x - 1; } for (i = 1; i <= x; i++) { int j; if ((j = i % 2) != 0) { nuevaFila = tblEtiquetas.NewRow(); nuevaFila[0] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[1] = row["DescripcionART"].ToString(); nuevaFila[2] = row["Precio"].ToString(); } else { nuevaFila[3] = "*" + row["IdArticuloMSTKD"].ToString() + "*"; nuevaFila[4] = row["DescripcionART"].ToString(); nuevaFila[5] = row["Precio"].ToString(); cfilas.Add(nuevaFila); nuevaFila = null; } } } } if (nuevaFila != null) { nuevaFila[3] = string.Empty; nuevaFila[4] = string.Empty; nuevaFila[5] = string.Empty; cfilas.Add(nuevaFila); } imprimir = true; } return imprimir; }