//private void ExportarDatos(List<InfoFieldBook> datos) //{ // string nombreArchivo = ""; // var book = FuncionesExcel.ExportaDetalleEntryList(datos); // SaveFileDialog saveFileDialog1 = new SaveFileDialog(); // saveFileDialog1.InitialDirectory = @"C:\"; // saveFileDialog1.Title = "Save Excel Files"; // saveFileDialog1.DefaultExt = "xlsx"; // saveFileDialog1.Filter = "Excel files (*.xlsx)|*.xlsx"; // saveFileDialog1.FilterIndex = 2; // saveFileDialog1.RestoreDirectory = true; // if (saveFileDialog1.ShowDialog() == DialogResult.OK) // { // nombreArchivo = saveFileDialog1.FileName; // try // { // book.SaveAs(nombreArchivo); // MessageBox.Show("Archivo Creado!", "Módulo Carga", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); // } // catch (Exception ex) // { // MessageBox.Show("Error: ", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); // } // } //} #endregion #region -------Rutina Barra de Progreso------- private void bg_DoWork(object sender, DoWorkEventArgs e) { totalEmpleadosProcesar = datos.Count; foreach (var item in datos) { infoF = InfoFieldBookBusiness.GetIndEuid(item.indEuid, item.euid); if (infoF != null) { //infoF.Id = infoF.Id; //infoF.cc = item.cc; //infoF.client = item.client; //infoF.codInternacion = item.codInternacion; //infoF.CodPermanencia = item.CodPermanencia; //infoF.codReception = item.codReception; //infoF.country = item.country; //infoF.crop = item.crop; //infoF.ent = item.ent; //infoF.EntName = item.EntName; //infoF.EntRole = item.EntRole; //infoF.gmoEvent = item.gmoEvent; //infoF.GranosHilera = item.GranosHilera; //infoF.instructions = item.instructions; //infoF.location = item.location; //infoF.LotId = item.LotId; //infoF.opExpName = item.opExpName; //infoF.order = item.order; //infoF.Owner = item.Owner; //infoF.plt = item.plt; //infoF.ResImportation = item.ResImportation; //infoF.rng = item.rng; //infoF.sag = item.sag; //infoF.year = item.year; infoF.breedersCode1 = item.breedersCode1; infoF.breedersCode2 = item.breedersCode2; infoF.breedersCode3 = item.breedersCode3; infoF.breedersCode4 = item.breedersCode4; infoF.BreedersInstructions1 = item.BreedersInstructions1; infoF.BreedersInstructions2 = item.BreedersInstructions2; infoF.BreedersInstructions3 = item.BreedersInstructions3; infoF.BreedersInstructions4 = item.BreedersInstructions4; infoF.fechaModificacion = (DateTime?)DateTime.Now; infoF.projecLead = item.projecLead; infoF.projectCode = item.projectCode; infoF.shelling = item.shelling; infoF.shipTo = item.shipTo; infoF.targears = item.targears; infoF.targetKern = item.targetKern; infoF.targetWg = item.targetWg; infoF.obs = item.obs; modificados++; } else { infoF = new InfoFieldBook(); infoF = item; infoF.fechaCarga = DateTime.Now; insertados++; } InfoFieldBookBusiness.GrabaInformacion(infoF); progreso++; //Aumentando el progreso porciento = Convert.ToInt16((((double)progreso / (double)totalEmpleadosProcesar) * 100.00)); //Calculo del porcentaje bg.ReportProgress(porciento); } }
public static ResultadoCarga SaveExcelData(List <InfoFieldBook> data) { int rowUpdated = 0; int rowInserted = 0; ResultadoCarga status = new ResultadoCarga(); InfoFieldBook ultimoProcesado = new InfoFieldBook(); try { foreach (var result in data) { var row = InfoFieldBookBusiness.GetIndEuid(result.indEuid, result.euid); if (row != null) { rowUpdated++; row.fechaModificacion = DateTime.Now; } else { row = new InfoFieldBook(); rowInserted++; row.fechaCarga = DateTime.Now; } row.breedersCode1 = result.breedersCode1; row.breedersCode2 = result.breedersCode2; row.breedersCode3 = result.breedersCode3; row.breedersCode4 = result.breedersCode4; row.cc = result.cc; row.client = result.client; row.codInternacion = result.codInternacion; row.codReception = result.codReception; row.country = result.country; row.crop = result.crop; row.ent = result.ent; row.euid = result.euid; row.gmoEvent = result.gmoEvent; row.indEuid = result.indEuid; row.instructions = result.instructions; row.location = result.location; row.obs = result.obs; row.opExpName = result.opExpName; row.order = result.order; row.plt = result.plt; row.projecLead = result.projecLead; row.projectCode = result.projectCode; row.rng = result.rng; row.sag = result.sag; row.shelling = result.shelling; row.shipTo = result.shipTo; row.targears = result.targears; row.targetKern = result.targetKern; row.targetWg = result.targetWg; row.year = result.year; ultimoProcesado = row; var obj = InfoFieldBookBusiness.GrabaInformacion(row); } } catch (Exception ex) { status.Error = "Error: " + ex.Message; } status.TotalRows = data.Count(); status.NumeroActualizados = rowUpdated; status.NumeroInsertados = rowInserted; status.UltimoProcesado = ultimoProcesado; return(status); }