private void button4_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Benja\\Desktop\\liquidacion.xlsx;Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\";"; OleDbConnection con = new OleDbConnection(Connection); System.Data.DataTable tblPrecioNuevos = new System.Data.DataTable(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Hoja1$]", con); myCommand.Fill(tblPrecioNuevos); DataTable tblArticulos = BL.GetDataBLL.Articulos(); foreach (DataRow rowPreciosNuevos in tblPrecioNuevos.Rows) { string articulo = rowPreciosNuevos["Articulo"].ToString(); if (!string.IsNullOrEmpty(articulo)) { if (articulo.Length == 8) { articulo = "00" + articulo; } if (articulo.Length == 9) { articulo = "0" + articulo; } // articulo = rowPreciosNuevos["Articulo"].ToString().Substring(0, rowPreciosNuevos["Articulo"].ToString().Length - 4); articulo = articulo.Substring(0, articulo.Length - 4); DataRow[] foundRow = tblArticulos.Select("IdArticuloART LIKE '" + articulo + "*'"); foreach (DataRow rowArticulos in foundRow) { rowArticulos["PrecioPublicoART"] = rowPreciosNuevos["Liquidacion"]; rowArticulos["PrecioMayorART"] = rowPreciosNuevos["Liquidacion"]; } /* foreach (DataRow rowArticulos in foundRow) * { * if (!string.IsNullOrEmpty(rowPreciosNuevos["Makro"].ToString()) && !string.IsNullOrEmpty(rowPreciosNuevos["Jesus"].ToString())) * { * rowArticulos["PrecioPublicoART"] = rowPreciosNuevos["Makro"]; * rowArticulos["PrecioMayorART"] = rowPreciosNuevos["Jesus"]; * } * }*/ } } if (tblArticulos.GetChanges() != null) { StockVentas.frmProgress progreso = new StockVentas.frmProgress(tblArticulos, "frmArticulosGenerar", "grabar"); progreso.ShowDialog(); } Cursor.Current = Cursors.Arrow; }
private void button4_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Benja\\Desktop\\liquidacion.xlsx;Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\";"; OleDbConnection con = new OleDbConnection(Connection); System.Data.DataTable tblPrecioNuevos = new System.Data.DataTable(); OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Hoja1$]", con); myCommand.Fill(tblPrecioNuevos); DataTable tblArticulos = BL.GetDataBLL.Articulos(); foreach (DataRow rowPreciosNuevos in tblPrecioNuevos.Rows) { string articulo = rowPreciosNuevos["Articulo"].ToString(); if (!string.IsNullOrEmpty(articulo)) { if (articulo.Length == 8) articulo = "00" + articulo; if (articulo.Length == 9) articulo = "0" + articulo; // articulo = rowPreciosNuevos["Articulo"].ToString().Substring(0, rowPreciosNuevos["Articulo"].ToString().Length - 4); articulo = articulo.Substring(0, articulo.Length - 4); DataRow[] foundRow = tblArticulos.Select("IdArticuloART LIKE '" + articulo + "*'"); foreach (DataRow rowArticulos in foundRow) { if (!string.IsNullOrEmpty(rowPreciosNuevos["Makro"].ToString()) && !string.IsNullOrEmpty(rowPreciosNuevos["Jesus"].ToString())) { rowArticulos["PrecioPublicoART"] = rowPreciosNuevos["Makro"]; rowArticulos["PrecioMayorART"] = rowPreciosNuevos["Jesus"]; } } } } if (tblArticulos.GetChanges() != null) { StockVentas.frmProgress progreso = new StockVentas.frmProgress(tblArticulos, "frmArticulosGenerar", "grabar"); progreso.ShowDialog(); } Cursor.Current = Cursors.Arrow; }