private void bg_DoWork(object sender, DoWorkEventArgs e) { totalEmpleadosProcesar = datos.Count; //Se debe crear lista de InfoFieldBook para cargarlas foreach (var item in datos) { itemInfoField.BreedersInstructions1 = item.Bi1; itemInfoField.BreedersInstructions2 = item.Bi2; itemInfoField.BreedersInstructions3 = item.Bi3; itemInfoField.BreedersInstructions4 = item.Bi4; itemInfoField.cc = item.Cc; itemInfoField.client = item.Client; itemInfoField.codInternacion = item.CodInternacion; itemInfoField.CodPermanencia = item.CodPermanencia; itemInfoField.codReception = item.CodReception; itemInfoField.country = item.Country; itemInfoField.crop = item.Crop; itemInfoField.ent = item.Ent; itemInfoField.EntName = item.EntName; itemInfoField.EntRole = item.EntRole; itemInfoField.euid = item.Euid; itemInfoField.fechaCarga = DateTime.Now; itemInfoField.gmoEvent = item.GmoEvent; itemInfoField.GranosHilera = int.Parse(item.GranosHilera); itemInfoField.indEuid = ""; itemInfoField.instructions = ""; itemInfoField.location = item.Location; itemInfoField.LotId = item.LotId; itemInfoField.obs = item.Obs; itemInfoField.opExpName = item.ExpName; itemInfoField.Owner = item.Owner; itemInfoField.plt = item.Plt; itemInfoField.projecLead = item.ProjectLead; itemInfoField.projectCode = item.ProjectCode; itemInfoField.ResImportation = item.ResImportacion; itemInfoField.rng = item.Rng; itemInfoField.sag = item.Sag; itemInfoField.year = item.Year; listaSplit.Add(itemInfoField); itemInfoField = new InfoFieldBook(); progreso++; //Aumentando el progreso porciento = Convert.ToInt16((((double)progreso / (double)totalEmpleadosProcesar) * 100.00)); //Calculo del porcentaje bg.ReportProgress(porciento); } EntryListBusiness.InsertBulk(datos); InfoFieldBookBusiness.InsertBulk(listaSplit); }
public static InfoFieldBook GrabaInformacion(InfoFieldBook movimiento) { try { if (movimiento.Id == 0) { repository.Insert(movimiento); } else { repository.Update(movimiento); } } catch (Exception ex) { movimiento = null; } return(movimiento); }
//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); }
/// <summary> /// Función que obtiene información de MovimientoCaja. /// </summary> /// <param name="shipmentCode"></param> /// <returns>DetailPackingListDto</returns> /// public List <DetailPackingListDto> GetDetailsByshipmentCode(string shipmentCode) { InfoFieldBook info = new InfoFieldBook(); repository = unitOfWork.Repository <MovimientoCaja>(); repositoryS = unitOfWork.Repository <MovimientoShipping>(); repositoryP = unitOfWork.Repository <MovimientoPacking>(); repositoryI = unitOfWork.Repository <InfoFieldBook>(); var data = (from i in (from mc in repository.Table from ms in repositoryS.Table from mp in repositoryP.Table from inf in repositoryI.Table //join ms in repositoryS.Table on mc.cajaEnvio equals ms.cajaEnvio //join mp in repositoryP.Table on ms.euid equals mp.euid //join inf in repositoryI.Table on new { mp.euid,mp.indEuid } equals new { inf.euid,inf.indEuid } where mc.cajaEnvio == ms.cajaEnvio && ms.euid == mp.euid && mp.euid == inf.euid && (mp.indEuid == inf.indEuid || inf.indEuid == null || mp.indEuid == "" || mp.indEuid == null) && mc.shipmentCode == shipmentCode orderby mc.correlativo select new { mc.cajaEnvio, euid = mp.euid.ToString(), mp.indEuid, mp.fechaPacking, totalWeight = mp.totalWeight.ToString(), totalKernels = mp.totalKernels.ToString(), totalEar = mp.totalEars.ToString(), inf.country, bc1 = inf.breedersCode1, bc2 = inf.breedersCode2, bc3 = inf.breedersCode3, bc4 = inf.breedersCode4, projectLead = inf.projecLead, inf.cc, inf.shipTo, inf.crop, inf.location, inf.opExpName, inf.client, inf.gmoEvent, inf.sag, inf.codReception, inf.codInternacion, inf.obs }) group i by new { i.cajaEnvio, i.euid, i.indEuid, i.fechaPacking, i.totalWeight, i.totalKernels, i.totalEar, i.country, i.bc1, i.bc2, i.bc3, i.bc4, i.projectLead, i.cc, i.shipTo, i.crop, i.location, i.opExpName, i.client, i.gmoEvent, i.sag, i.codReception, i.codInternacion, i.obs } into g select new DetailPackingListDto { shipmentCode = shipmentCode, cajaEnvio = g.Key.cajaEnvio, euid = g.Key.euid, indEuid = g.Key.indEuid, fechaPacking = g.Key.fechaPacking, totalWeight = g.Key.totalWeight, totalKernels = g.Key.totalKernels, totalEar = g.Key.totalEar, country = g.Key.country, bc1 = g.Key.bc1, bc2 = g.Key.bc2, bc3 = g.Key.bc3, bc4 = g.Key.bc4, projectLead = g.Key.projectLead, cc = g.Key.cc, shipTo = g.Key.shipTo, crop = g.Key.crop, location = g.Key.location, expName = g.Key.opExpName, client = g.Key.client, gmoEvent = g.Key.gmoEvent, sag = g.Key.sag, codReception = g.Key.codReception, codInternation = g.Key.codInternacion, obs = g.Key.obs }).ToList(); return(data); }