コード例 #1
0
ファイル: FrmUploadEntryList.cs プロジェクト: hcarra90/SgpApp
        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);
        }
コード例 #2
0
        private void CargaArchivo()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "xlsx files (*.xlsx)|*.xlsx";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                pathFile = openFileDialog.FileName;
                //lblFile.Text = pathFile;
            }

            if (pathFile != "")
            {
                try
                {
                    datos = FuncionesExcel.GetData(pathFile);
                    var val = InfoFieldBookBusiness.ValidateIndEuids(datos);
                    if (!val)
                    {
                        insertados = datos.Count;
                        InfoFieldBookBusiness.InsertBulk(datos);
                    }
                    //Validación Inicial
                    //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;
                    //        existentes.Add(infoF);

                    //        modificados++;
                    //    }
                    //    else
                    //    {
                    //        infoF = new InfoFieldBook();
                    //        infoF = item;
                    //        infoF.fechaCarga = DateTime.Now;
                    //        nuevos.Add(infoF);

                    //        insertados++;
                    //    }
                    //}

                    grdDetalle.AutoGenerateColumns = false;
                    grdDetalle.DataSource          = datos;
                    grdDetalle.ClearSelection();

                    lblEuids.Text       = "N° Filas : " + grdDetalle.RowCount.ToString();
                    btnProcesar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "Módulo Carga Field Book", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            }
        }