private void btnPrint_Click(object sender, EventArgs e) { DataSet1.ProductDataTable dt = new DataSet1.ProductDataTable(); dt = (DataSet1.ProductDataTable)SetProductInfo(prod); ProductForm rf = new ProductForm(dt); rf.Show(); }
private void btnEditar_Click(object sender, EventArgs e) { int?id = GetId(); int valorcillo; // MessageBox.Show(id.ToString()); if (id != null) { DataSet1TableAdapters.ProductTableAdapter ta = new DataSet1TableAdapters.ProductTableAdapter(); DataSet1.ProductDataTable pt = ta.GetDataByIdProduct((int)id); DataSet1.ProductRow row = (DataSet1.ProductRow)pt.Rows[0]; txtNombre.Text = row.ProductName; udCantidad.Value = row.ProductQuantity; udUnidades.Value = row.ProductUnits; txtTipoUnidad.Text = row.ProductUnitType; clnFechaExp.SetDate(row.ProductExpDate); valorcillo = row.idSupplier; // MessageBox.Show(valorcillo.ToString()); //from here DataSet1TableAdapters.SupplierTableAdapter tas = new DataSet1TableAdapters.SupplierTableAdapter(); DataSet1.SupplierDataTable pts = tas.GetDataByIdSupplier((int)valorcillo); // DataSet1.SupplierRow rowsup = (DataSet1.SupplierRow)pts.Rows[0]; // txtProveedor.Text = rowsup.ToString(); dgvProveedor.DataSource = pts; // dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.Equals(valorcillo); //DataSet1TableAdapters.SupplierTableAdapter tas = new DataSet1TableAdapters.SupplierTableAdapter(); // DataSet1.SupplierDataTable pts = tas.GetDataByIdSupplier((int)iddSupplier); // txtProveedor.Text = pts.ToString(); //iddSupplier= row.idSupplier; // DataSet1.SupplierRow rowsup = (DataSet1.SupplierRow)pts.Rows[0]; // rowsup.id_Supplier = iddSupplier; // // int.Parse(dgvProveedor.Rows[dgvProveedor.CurrentRow.Index].Cells[0].Value.ToString()); //DataSet1.SupplierRow rowsup = (DataSet1.SupplierRow)pts.Rows[0]; //rowsup.id_Supplier = row.idSupplier; } else { MessageBox.Show("No hay registros"); } }
private void Refresh() { DataSet1TableAdapters.ProductTableAdapter ta = new DataSet1TableAdapters.ProductTableAdapter(); DataSet1.ProductDataTable dt = ta.GetDataProduct(); dataGridView1.DataSource = dt; dataGridView1.Columns[0].HeaderText = "Id"; dataGridView1.Columns[1].HeaderText = "Nombre"; dataGridView1.Columns[2].HeaderText = "Cantidad"; dataGridView1.Columns[3].HeaderText = "Presentacion"; dataGridView1.Columns[4].HeaderText = "Caducidad"; dataGridView1.Columns[5].HeaderText = "Unidades"; dataGridView1.Columns[6].HeaderText = "Tipo Unidad"; dataGridView1.Columns[7].HeaderText = "Proveedor"; }
private void txtBuscarProd_KeyPress(object sender, KeyPressEventArgs e) { try { DataSet1TableAdapters.ProductTableAdapter ta = new DataSet1TableAdapters.ProductTableAdapter(); DataSet1.ProductDataTable dt = ta.GetDataByProductFiltering(txtBuscarProd.Text//,//string , txtBuscarProd.Text , txtBuscarProd.Text , txtBuscarProd.Text , txtBuscarProd.Text, txtBuscarProd.Text, txtBuscarProd.Text // ,txtBuscarMat.Text,// clnFechaExp.SelectionRange.Start.ToShortDateString(), // , Convert.ToDecimal(txtBuscarMat.Text),//decimal // , Convert.ToInt32(txtBuscarMat.Text)//int //,Convert.ToInt32(txtBuscarMat.Text)//int // ,txtBuscarMat.Text,// clnFechaExp.SelectionRange.Start.ToShortDateString(), // , Convert.ToDecimal(txtBuscarMat.Text),//decimal // , Convert.ToInt32(txtBuscarMat.Text)//int ); // (txtNombre.Text.Trim(), (int)udCantidad.Value, // clnFechaExp.SelectionRange.Start.ToShortDateString(), (decimal)udUnidades.Value, // valorIdSupplier // , (int)idd); ta.FillByProductFiltering(dt, txtBuscarProd.Text//, , txtBuscarProd.Text , txtBuscarProd.Text , txtBuscarProd.Text , txtBuscarProd.Text, txtBuscarProd.Text, txtBuscarProd.Text ); dataGridView1.DataSource = dt; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public static DataTable SetProductInfo(List <Product> list) { DataSet1.ProductDataTable dt = new DataSet1.ProductDataTable(); try { foreach (var cust in list) { DataRow newRow = dt.NewRow(); foreach (PropertyInfo property in cust.GetType().GetProperties()) { newRow[property.Name] = cust.GetType().GetProperty(property.Name).GetValue(cust, null); } dt.Rows.Add(newRow); } return(dt); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }